uui/make.py
2021-07-13 01:02:17 +09:00

46 lines
1.3 KiB
Python

#! python3
import os
from pathlib import Path
from umake import 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'
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():
# Compiling fragment shaders
for frag_path in Config.SOURCE_DIR.rglob('*.frag'):
out_path = (Config.BIN_DIR / frag_path.relative_to(Config.SOURCE_DIR))
if not out_path.parent.exists():
out_path.parent.mkdir(parents=True)
if subprocess.run(['glslc', str(frag_path), '-o', str(out_path) + '.spv']).returncode != 0:
print(f'Error while compiling fragment shader {frag_path}')
return
Config.PRE_COMPILE_FUNCTION = pre_compile
make(Config)
if __name__ == '__main__':
main()