51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
#! 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++17 -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('.')]
|
|
|
|
|
|
def main():
|
|
def pre_compile():
|
|
# Copying 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)
|
|
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)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|