diff --git a/SConscript b/SConscript index 08a3c30..f525a97 100644 --- a/SConscript +++ b/SConscript @@ -464,7 +464,10 @@ def _build_target(target: _Target): _build_target(lib) target.kwargs['LIBS'].remove(lib) target.kwargs['LIBS'].append(lib.target) - target.target = target.builder(*target.args, **target.kwargs) + new_kwargs = target.kwargs.copy() + if 'target' in new_kwargs: # there should always be a target, right? + new_kwargs['target'] = f"{new_kwargs['target']}-{build_type}" + target.target = target.builder(*target.args, **new_kwargs) def _version_to_string(version) -> str: return '.'.join([str(v) for v in version]) @@ -570,11 +573,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}-{build_type}{env.subst("$PROGSUFFIX")}' + return str(exe_path) result.append({ 'name': target.name, - 'filename': str(exe_path) + 'filename': _exe_path }) return result def _get_libraries() -> list: @@ -582,19 +587,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}-{build_type}{env.subst("$LIBSUFFIX")}' + 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}-{build_type}{env.subst("$SHLIBSUFFIX")}' + return str(lib_path) result.append({ 'name': target.name, - 'filename': str(lib_path) + 'filename': _lib_path }) return result def _escape_path(input: str) -> str: diff --git a/util/clion_project_template/tools/External Tools.xml.jinja b/util/clion_project_template/tools/External Tools.xml.jinja index a392e3d..55893d5 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 e30f906..68dc72e 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 fd623b0..ae8ced0 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 | escape_path }}", + "program": "{{ executable.filename(build_type) | 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 f753166..db85d6a 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 | escape_path }} compile_commands.json", + "command": "{{ scons_exe | escape_path }} -j{{ nproc }} --build_type={{ build_type }} --unity=disable {{ executable.filename(build_type) | 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 | escape_path }} -c", + "command": "{{ scons_exe | escape_path }} --build_type={{ build_type }} --unity=disable {{ executable.filename(build_type) | 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 | escape_path }} compile_commands.json", + "command": "{{ scons_exe | escape_path }} -j{{ nproc }} --build_type={{ build_type }} --unity=disable {{ library.filename(build_type) | 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 | escape_path }} -c", + "command": "{{ scons_exe | escape_path }} --build_type={{ build_type }} --unity=disable {{ library.filename(build_type) | escape_path }} -c", "options": { "cwd": "${workspaceFolder}" },