Updated to include build type and variant in binary names, so they don't need to be rebuilt everytime the configuration is changed.

This commit is contained in:
2025-03-13 23:42:58 +01:00
parent 1edf745b39
commit e6e7dbe642
5 changed files with 38 additions and 22 deletions

View File

@@ -570,11 +570,13 @@ def _generate_project(project_type: str) -> None:
for target in env['SPP_TARGETS']:
if target.target_type == TargetType.PROGRAM:
trgt = _target_entry(target.kwargs['target'])
exe_path = pathlib.Path(trgt.abspath).relative_to(root_path)
exe_path = exe_path.parent / f'{env["PROGPREFIX"]}{exe_path.name}{env["PROGSUFFIX"]}'
def _exe_path(build_type) -> str:
exe_path = pathlib.Path(trgt.abspath).relative_to(root_path)
exe_path = exe_path.parent / f'{env.subst("$PROGPREFIX")}{exe_path.name}{_make_suffix(env.subst("$ORIG_PROGSUFFIX"), build_type, variant)}'
return str(exe_path)
result.append({
'name': target.name,
'filename': str(exe_path)
'filename': _exe_path
})
return result
def _get_libraries() -> list:
@@ -582,19 +584,23 @@ def _generate_project(project_type: str) -> None:
for target in env['SPP_TARGETS']:
if target.target_type == TargetType.STATIC_LIBRARY:
trgt = _target_entry(target.kwargs['target'])
lib_path = pathlib.Path(trgt.abspath).relative_to(root_path)
lib_path = lib_path.parent / f'{env.subst("$LIBPREFIX")}{lib_path.name}{env.subst("$LIBSUFFIX")}'
def _lib_path(build_type) -> str:
lib_path = pathlib.Path(trgt.abspath).relative_to(root_path)
lib_path = lib_path.parent / f'{env.subst("$LIBPREFIX")}{lib_path.name}{_make_suffix(env.subst("ORIG_$LIBSUFFIX"), build_type, variant)}'
return str(lib_path)
result.append({
'name': target.name,
'filename': str(lib_path)
'filename': _lib_path
})
elif target.target_type == TargetType.SHARED_LIBRARY:
trgt = _target_entry(target.kwargs['target'])
lib_path = pathlib.Path(trgt.abspath).relative_to(root_path)
lib_path = lib_path.parent / f'{env.subst("$SHLIBPREFIX")}{lib_path.name}{env.subst("$SHLIBSUFFIX")}'
def _lib_path(build_type) -> str:
lib_path = pathlib.Path(trgt.abspath).relative_to(root_path)
lib_path = lib_path.parent / f'{env.subst("$SHLIBPREFIX")}{lib_path.name}{_make_suffix(env.subst("ORIG_$SHLIBSUFFIX"), build_type, variant)}'
return str(lib_path)
result.append({
'name': target.name,
'filename': str(lib_path)
'filename': _lib_path
})
return result
def _escape_path(input: str) -> str:
@@ -837,9 +843,19 @@ env['SPP_TARGET_DEPENDENCIES'] = []
env['SPP_DEPENDENCIES'] = {}
env['SPP_RECIPES'] = {}
env['OBJSUFFIX'] = f".{env['BUILD_TYPE']}{env['OBJSUFFIX']}"
if variant:
env['OBJSUFFIX'] = f".{variant}{env['OBJSUFFIX']}"
def _make_suffix(orig: str, build_type: str, variant: str|None = None) -> str:
add_to_suffix = f".{build_type}"
if variant:
add_to_suffix = f".{variant}{add_to_suffix}"
return add_to_suffix + orig
env['ORIG_LIBSUFFIX'] = env['LIBSUFFIX']
env['ORIG_OBJSUFFIX'] = env['OBJSUFFIX']
env['ORIG_PROGSUFFIX'] = env['PROGSUFFIX']
env['ORIG_SHLIBSUFFIX'] = env['SHLIBSUFFIX']
env['LIBSUFFIX'] = _make_suffix(env['LIBSUFFIX'], env['BUILD_TYPE'], variant)
env['OBJSUFFIX'] = _make_suffix(env['OBJSUFFIX'], env['BUILD_TYPE'], variant)
env['PROGSUFFIX'] = _make_suffix(env['PROGSUFFIX'], env['BUILD_TYPE'], variant)
env['SHLIBSUFFIX'] = _make_suffix(env['SHLIBSUFFIX'], env['BUILD_TYPE'], variant)
# create the cache dir
os.makedirs(env['CACHE_DIR'], exist_ok=True)