Add pre-compile function in configuration

This commit is contained in:
Corentin 2021-07-02 01:03:55 +09:00
commit 1ed601c52c
2 changed files with 7 additions and 0 deletions

View file

@ -23,6 +23,8 @@ class Config:
COMPILE_FLAGS = f'-Wall -I{INCLUDE_DIR}' # Flags added for compiling (recommandation : `pkg-config --cflags`)
LINK_FLAGS = '' # Flags added for linking (recommandation : `pkg-config --libs`)
PRE_COMPILE_FUNCTION = None # Function to run before compile (not call in --clean situation)
CPP_SOURCES = [filepath for filepath in SOURCE_DIR.rglob('*.cpp') if not filepath.name.startswith('.')]

View file

@ -26,6 +26,8 @@ class Config:
COMPILE_FLAGS = f'-Wall -I{INCLUDE_DIR}' # Flags added for compiling (recommandation : `pkg-config --cflags`)
LINK_FLAGS = '' # Flags added for linking (recommandation : `pkg-config --libs`)
PRE_COMPILE_FUNCTION = None # Function to run before compile (not call in --clean situation)
CPP_SOURCES = SOURCE_DIR.rglob('*.cpp')
@ -61,6 +63,9 @@ def make(config: Config):
shutil.rmtree(config.BIN_DIR, ignore_errors=True)
return
if config.PRE_COMPILE_FUNCTION is not None:
config.PRE_COMPILE_FUNCTION()
# Update flags and directories for mode debug/release
if arguments.type == 'debug':
config.COMMON_FLAGS += ' ' + config.COMMON_DEBUG_FLAGS