Code refactor and make update
This commit is contained in:
parent
3ad40381e5
commit
2a2044c632
10 changed files with 35 additions and 44 deletions
44
make.py
44
make.py
|
|
@ -1,50 +1,38 @@
|
|||
#! python3
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
|
||||
from umake import get_hash, make
|
||||
|
||||
|
||||
class Config:
|
||||
CC = 'g++'
|
||||
APPS = ['test/example_gl', 'test/benchmark_text', 'test/sample']
|
||||
IGNORE_APPS = []
|
||||
JOB_COUNT = int(os.cpu_count() * 0.8)
|
||||
|
||||
BIN_DIR = Path('bin')
|
||||
INCLUDE_DIR = Path('include')
|
||||
OBJECT_DIR = Path('obj')
|
||||
SOURCE_DIR = Path('src')
|
||||
|
||||
COMMON_FLAGS = '-std=c++20 -fno-semantic-interposition'
|
||||
COMMON_DEBUG_FLAGS = '-g -Og -DDEBUG'
|
||||
COMMON_RELEASE_FLAGS = '-O2 -flto=auto'
|
||||
COMPILE_FLAGS = f'-Wall -Wextra -Wpedantic -Wconversion -I{INCLUDE_DIR} `pkg-config --cflags glfw3 vulkan gl x11 freetype2`'
|
||||
LINK_FLAGS = '-lpthread -ldl `pkg-config --libs glfw3 vulkan gl x11 freetype2`'
|
||||
|
||||
PRE_COMPILE_FUNCTION = None
|
||||
|
||||
CPP_SOURCES = [filepath for filepath in SOURCE_DIR.rglob('*.cpp') if not filepath.name.startswith('.')]
|
||||
from umake.umake import get_hash, make, Config
|
||||
|
||||
|
||||
def main():
|
||||
config = Config()
|
||||
|
||||
def pre_compile():
|
||||
# Copying OpenGL shaders
|
||||
src_opengl_shader_path = Config.SOURCE_DIR / 'uui' / 'opengl' / 'shaders'
|
||||
src_opengl_shader_path = config.source_dir / 'uui' / 'opengl' / 'shaders'
|
||||
for shader_path in (
|
||||
list(src_opengl_shader_path.rglob('*.vert'))
|
||||
+ list(src_opengl_shader_path.rglob('*.frag'))):
|
||||
out_path = Config.BIN_DIR / shader_path.relative_to(Config.SOURCE_DIR)
|
||||
out_path = config.bin_dir / shader_path.relative_to(config.source_dir)
|
||||
if out_path.exists() and get_hash(shader_path) == get_hash(out_path):
|
||||
continue
|
||||
if not out_path.parent.exists():
|
||||
out_path.parent.mkdir(parents=True)
|
||||
shutil.copy(shader_path, out_path)
|
||||
|
||||
Config.PRE_COMPILE_FUNCTION = pre_compile
|
||||
make(Config)
|
||||
|
||||
config.apps = [str(p.relative_to(Path('src')))[:-4] for p in (config.source_dir / 'test').rglob('*.cpp')]
|
||||
config.watch = True
|
||||
|
||||
config.common_flags = '-std=c++20 -fno-semantic-interposition'
|
||||
config.common_debug_flags = '-g -Og -DDEBUG'
|
||||
config.common_release_flags = '-O2 -flto=auto'
|
||||
config.compile_flags = f'-Wall -Wextra -Wpedantic -Wconversion -I{config.include_dir} `pkg-config --cflags glfw3 gl x11 freetype2`'
|
||||
config.link_flags = '-lpthread -ldl `pkg-config --libs glfw3 gl freetype2`'
|
||||
config.pre_compile_function = pre_compile
|
||||
make(config)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue