uui/make.py
2021-07-13 01:30:37 +09:00

64 lines
2.2 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']
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 -DDEBUG'
COMMON_RELEASE_FLAGS = '-O2' # -flto'
COMPILE_FLAGS = f'-Wall -I{INCLUDE_DIR} `pkg-config --cflags glfw3 vulkan gl x11`'
LINK_FLAGS = '-lpthread -ldl `pkg-config --libs glfw3 vulkan gl x11`'
PRE_COMPILE_FUNCTION = None
CPP_SOURCES = [filepath for filepath in SOURCE_DIR.rglob('*.cpp') if not filepath.name.startswith('.')]
def main():
def pre_compile():
<<<<<<< HEAD
=======
# Compiling vulkan shaders
# for shader_path in (
# list((Config.SOURCE_DIR / 'uui' / 'vulkan').rglob('*.vert'))
# + list((Config.SOURCE_DIR / 'uui' / 'vulkan').rglob('*.frag'))):
# out_path = Config.BIN_DIR / shader_path.relative_to(Config.SOURCE_DIR)
# if not out_path.parent.exists():
# out_path.parent.mkdir(parents=True)
# if subprocess.run(['glslc', str(shader_path), '-o', str(out_path) + '.spv']).returncode != 0:
# print(f'Error while compiling shader {shader_path}')
# return
>>>>>>> 675cbbf (Correct resize and safer pointers)
# 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()