From 3a3c79d240eb3aee182b9333ccbf0cc117a6778c Mon Sep 17 00:00:00 2001 From: Patrick Wuttke Date: Fri, 14 Mar 2025 09:48:30 +0100 Subject: [PATCH] Revert "Updated to include build type and variant in binary names, so they don't need to be rebuilt everytime the configuration is changed." Modifying the suffix variables broke the library file detection, at least on Windows. This reverts commit e6e7dbe6425e1b60cf6383242453d8fc8db8da1e. --- SConscript | 40 ++++++------------- .../tools/External Tools.xml.jinja | 8 ++-- .../workspace.xml.jinja | 2 +- .../vscode_project_template/launch.json.jinja | 2 +- util/vscode_project_template/tasks.json.jinja | 8 ++-- 5 files changed, 22 insertions(+), 38 deletions(-) diff --git a/SConscript b/SConscript index ee4bec6..08a3c30 100644 --- a/SConscript +++ b/SConscript @@ -570,13 +570,11 @@ 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']) - 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) + exe_path = pathlib.Path(trgt.abspath).relative_to(root_path) + exe_path = exe_path.parent / f'{env["PROGPREFIX"]}{exe_path.name}{env["PROGSUFFIX"]}' result.append({ 'name': target.name, - 'filename': _exe_path + 'filename': str(exe_path) }) return result def _get_libraries() -> list: @@ -584,23 +582,19 @@ 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']) - 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) + 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")}' result.append({ 'name': target.name, - 'filename': _lib_path + 'filename': str(lib_path) }) elif target.target_type == TargetType.SHARED_LIBRARY: trgt = _target_entry(target.kwargs['target']) - 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) + 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")}' result.append({ 'name': target.name, - 'filename': _lib_path + 'filename': str(lib_path) }) return result def _escape_path(input: str) -> str: @@ -843,19 +837,9 @@ env['SPP_TARGET_DEPENDENCIES'] = [] env['SPP_DEPENDENCIES'] = {} env['SPP_RECIPES'] = {} -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) +env['OBJSUFFIX'] = f".{env['BUILD_TYPE']}{env['OBJSUFFIX']}" +if variant: + env['OBJSUFFIX'] = f".{variant}{env['OBJSUFFIX']}" # create the cache dir os.makedirs(env['CACHE_DIR'], exist_ok=True) diff --git a/util/clion_project_template/tools/External Tools.xml.jinja b/util/clion_project_template/tools/External Tools.xml.jinja index 55893d5..a392e3d 100644 --- a/util/clion_project_template/tools/External Tools.xml.jinja +++ b/util/clion_project_template/tools/External Tools.xml.jinja @@ -5,14 +5,14 @@ @@ -24,14 +24,14 @@ diff --git a/util/clion_project_template/workspace.xml.jinja b/util/clion_project_template/workspace.xml.jinja index 3e603a3..e30f906 100644 --- a/util/clion_project_template/workspace.xml.jinja +++ b/util/clion_project_template/workspace.xml.jinja @@ -84,7 +84,7 @@ {% for executable in project.executables -%} {% for build_type in project.build_types -%} {% set build_type_name = build_type | capitalize -%} - + diff --git a/util/vscode_project_template/launch.json.jinja b/util/vscode_project_template/launch.json.jinja index ae8ced0..fd623b0 100644 --- a/util/vscode_project_template/launch.json.jinja +++ b/util/vscode_project_template/launch.json.jinja @@ -6,7 +6,7 @@ "name": "Debug {{ executable.name }}", "type": "cppvsdbg", "request": "launch", - "program": "{{ executable.filename(build_type) | escape_path }}", + "program": "{{ executable.filename | escape_path }}", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", diff --git a/util/vscode_project_template/tasks.json.jinja b/util/vscode_project_template/tasks.json.jinja index db85d6a..f753166 100644 --- a/util/vscode_project_template/tasks.json.jinja +++ b/util/vscode_project_template/tasks.json.jinja @@ -9,7 +9,7 @@ { "label": "{{ executable.name }} {{ build_type_name }}", "type": "shell", - "command": "{{ scons_exe | escape_path }} -j{{ nproc }} --build_type={{ build_type }} --unity=disable {{ executable.filename(build_type) | escape_path }} compile_commands.json", + "command": "{{ scons_exe | escape_path }} -j{{ nproc }} --build_type={{ build_type }} --unity=disable {{ executable.filename | escape_path }} compile_commands.json", "options": { "cwd": "${workspaceFolder}" }, @@ -22,7 +22,7 @@ { "label": "{{ executable.name }} {{ build_type_name }} Clean", "type": "shell", - "command": "{{ scons_exe | escape_path }} --build_type={{ build_type }} --unity=disable {{ executable.filename(build_type) | escape_path }} -c", + "command": "{{ scons_exe | escape_path }} --build_type={{ build_type }} --unity=disable {{ executable.filename | escape_path }} -c", "options": { "cwd": "${workspaceFolder}" }, @@ -40,7 +40,7 @@ { "label": "{{ library.name }} {{ build_type_name }}", "type": "shell", - "command": "{{ scons_exe | escape_path }} -j{{ nproc }} --build_type={{ build_type }} --unity=disable {{ library.filename(build_type) | escape_path }} compile_commands.json", + "command": "{{ scons_exe | escape_path }} -j{{ nproc }} --build_type={{ build_type }} --unity=disable {{ library.filename | escape_path }} compile_commands.json", "options": { "cwd": "${workspaceFolder}" }, @@ -53,7 +53,7 @@ { "label": "{{ library.name }} {{ build_type_name }} Clean", "type": "shell", - "command": "{{ scons_exe | escape_path }} --build_type={{ build_type }} --unity=disable {{ library.filename(build_type) | escape_path }} -c", + "command": "{{ scons_exe | escape_path }} --build_type={{ build_type }} --unity=disable {{ library.filename | escape_path }} -c", "options": { "cwd": "${workspaceFolder}" },