Next attempt of adding build type to executable and library names.

This commit is contained in:
Patrick 2025-03-14 22:02:40 +01:00
parent 3a3c79d240
commit 1401fdea90
5 changed files with 29 additions and 20 deletions

View File

@ -464,7 +464,10 @@ def _build_target(target: _Target):
_build_target(lib) _build_target(lib)
target.kwargs['LIBS'].remove(lib) target.kwargs['LIBS'].remove(lib)
target.kwargs['LIBS'].append(lib.target) 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: def _version_to_string(version) -> str:
return '.'.join([str(v) for v in version]) 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']: for target in env['SPP_TARGETS']:
if target.target_type == TargetType.PROGRAM: if target.target_type == TargetType.PROGRAM:
trgt = _target_entry(target.kwargs['target']) trgt = _target_entry(target.kwargs['target'])
exe_path = pathlib.Path(trgt.abspath).relative_to(root_path) def _exe_path(build_type) -> str:
exe_path = exe_path.parent / f'{env["PROGPREFIX"]}{exe_path.name}{env["PROGSUFFIX"]}' 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({ result.append({
'name': target.name, 'name': target.name,
'filename': str(exe_path) 'filename': _exe_path
}) })
return result return result
def _get_libraries() -> list: def _get_libraries() -> list:
@ -582,19 +587,23 @@ def _generate_project(project_type: str) -> None:
for target in env['SPP_TARGETS']: for target in env['SPP_TARGETS']:
if target.target_type == TargetType.STATIC_LIBRARY: if target.target_type == TargetType.STATIC_LIBRARY:
trgt = _target_entry(target.kwargs['target']) trgt = _target_entry(target.kwargs['target'])
lib_path = pathlib.Path(trgt.abspath).relative_to(root_path) def _lib_path(build_type) -> str:
lib_path = lib_path.parent / f'{env.subst("$LIBPREFIX")}{lib_path.name}{env.subst("$LIBSUFFIX")}' 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({ result.append({
'name': target.name, 'name': target.name,
'filename': str(lib_path) 'filename': _lib_path
}) })
elif target.target_type == TargetType.SHARED_LIBRARY: elif target.target_type == TargetType.SHARED_LIBRARY:
trgt = _target_entry(target.kwargs['target']) trgt = _target_entry(target.kwargs['target'])
lib_path = pathlib.Path(trgt.abspath).relative_to(root_path) def _lib_path(build_type) -> str:
lib_path = lib_path.parent / f'{env.subst("$SHLIBPREFIX")}{lib_path.name}{env.subst("$SHLIBSUFFIX")}' 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({ result.append({
'name': target.name, 'name': target.name,
'filename': str(lib_path) 'filename': _lib_path
}) })
return result return result
def _escape_path(input: str) -> str: def _escape_path(input: str) -> str:

View File

@ -5,14 +5,14 @@
<tool name="{{ executable.name }} {{ build_type_name }}" showInMainMenu="false" showInEditor="false" showInProject="false" showInSearchPopup="false" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true"> <tool name="{{ executable.name }} {{ build_type_name }}" showInMainMenu="false" showInEditor="false" showInProject="false" showInSearchPopup="false" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true">
<exec> <exec>
<option name="COMMAND" value="{{ scons_exe }}" /> <option name="COMMAND" value="{{ scons_exe }}" />
<option name="PARAMETERS" value="-j{{ nproc }} --build_type={{ build_type }} --unity=disable {{ executable.filename }} compile_commands.json" /> <option name="PARAMETERS" value="-j{{ nproc }} --build_type={{ build_type }} --unity=disable {{ executable.filename(build_type) }} compile_commands.json" />
<option name="WORKING_DIRECTORY" value="$ProjectFileDir$" /> <option name="WORKING_DIRECTORY" value="$ProjectFileDir$" />
</exec> </exec>
</tool> </tool>
<tool name="{{ executable.name }} {{ build_type_name }} Clean" showInMainMenu="false" showInEditor="false" showInProject="false" showInSearchPopup="false" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true"> <tool name="{{ executable.name }} {{ build_type_name }} Clean" showInMainMenu="false" showInEditor="false" showInProject="false" showInSearchPopup="false" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true">
<exec> <exec>
<option name="COMMAND" value="{{ scons_exe }}" /> <option name="COMMAND" value="{{ scons_exe }}" />
<option name="PARAMETERS" value="--build_type={{ build_type }} --unity=disable {{ executable.filename }} -c" /> <option name="PARAMETERS" value="--build_type={{ build_type }} --unity=disable {{ executable.filename(build_type) }} -c" />
<option name="WORKING_DIRECTORY" value="$ProjectFileDir$" /> <option name="WORKING_DIRECTORY" value="$ProjectFileDir$" />
</exec> </exec>
</tool> </tool>
@ -24,14 +24,14 @@
<tool name="{{ library.name }} {{ build_type_name }}" showInMainMenu="false" showInEditor="false" showInProject="false" showInSearchPopup="false" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true"> <tool name="{{ library.name }} {{ build_type_name }}" showInMainMenu="false" showInEditor="false" showInProject="false" showInSearchPopup="false" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true">
<exec> <exec>
<option name="COMMAND" value="{{ scons_exe }}" /> <option name="COMMAND" value="{{ scons_exe }}" />
<option name="PARAMETERS" value="-j{{ nproc }} --build_type={{ build_type }} --unity=disable {{ library.filename }} compile_commands.json" /> <option name="PARAMETERS" value="-j{{ nproc }} --build_type={{ build_type }} --unity=disable {{ library.filename(build_type) }} compile_commands.json" />
<option name="WORKING_DIRECTORY" value="$ProjectFileDir$" /> <option name="WORKING_DIRECTORY" value="$ProjectFileDir$" />
</exec> </exec>
</tool> </tool>
<tool name="{{ library.name }} {{ build_type_name }} Clean" showInMainMenu="false" showInEditor="false" showInProject="false" showInSearchPopup="false" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true"> <tool name="{{ library.name }} {{ build_type_name }} Clean" showInMainMenu="false" showInEditor="false" showInProject="false" showInSearchPopup="false" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true">
<exec> <exec>
<option name="COMMAND" value="{{ scons_exe }}" /> <option name="COMMAND" value="{{ scons_exe }}" />
<option name="PARAMETERS" value="--build_type={{ build_type }} --unity=disable {{ library.filename }} -c" /> <option name="PARAMETERS" value="--build_type={{ build_type }} --unity=disable {{ library.filename(build_type) }} -c" />
<option name="WORKING_DIRECTORY" value="$ProjectFileDir$" /> <option name="WORKING_DIRECTORY" value="$ProjectFileDir$" />
</exec> </exec>
</tool> </tool>

View File

@ -84,7 +84,7 @@
{% for executable in project.executables -%} {% for executable in project.executables -%}
{% for build_type in project.build_types -%} {% for build_type in project.build_types -%}
{% set build_type_name = build_type | capitalize -%} {% set build_type_name = build_type | capitalize -%}
<configuration name="{{ executable.name }} {{ build_type_name }}" type="CLionExternalRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="{{ project.name }}" TARGET_NAME="{{ executable.name }} {{ build_type_name }}" CONFIG_NAME="{{ executable.name }} {{ build_type_name }}" RUN_PATH="$PROJECT_DIR$/{{ executable.filename }}"> <configuration name="{{ executable.name }} {{ build_type_name }}" type="CLionExternalRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" WORKING_DIR="file://$ProjectFileDir$" PASS_PARENT_ENVS_2="true" PROJECT_NAME="{{ project.name }}" TARGET_NAME="{{ executable.name }} {{ build_type_name }}" CONFIG_NAME="{{ executable.name }} {{ build_type_name }}" RUN_PATH="$PROJECT_DIR$/{{ executable.filename(build_type) }}">
<method v="2"> <method v="2">
<option name="CLION.EXTERNAL.BUILD" enabled="true" /> <option name="CLION.EXTERNAL.BUILD" enabled="true" />
</method> </method>

View File

@ -6,7 +6,7 @@
"name": "Debug {{ executable.name }}", "name": "Debug {{ executable.name }}",
"type": "cppvsdbg", "type": "cppvsdbg",
"request": "launch", "request": "launch",
"program": "{{ executable.filename | escape_path }}", "program": "{{ executable.filename(build_type) | escape_path }}",
"args": [], "args": [],
"stopAtEntry": false, "stopAtEntry": false,
"cwd": "${workspaceFolder}", "cwd": "${workspaceFolder}",

View File

@ -9,7 +9,7 @@
{ {
"label": "{{ executable.name }} {{ build_type_name }}", "label": "{{ executable.name }} {{ build_type_name }}",
"type": "shell", "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": { "options": {
"cwd": "${workspaceFolder}" "cwd": "${workspaceFolder}"
}, },
@ -22,7 +22,7 @@
{ {
"label": "{{ executable.name }} {{ build_type_name }} Clean", "label": "{{ executable.name }} {{ build_type_name }} Clean",
"type": "shell", "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": { "options": {
"cwd": "${workspaceFolder}" "cwd": "${workspaceFolder}"
}, },
@ -40,7 +40,7 @@
{ {
"label": "{{ library.name }} {{ build_type_name }}", "label": "{{ library.name }} {{ build_type_name }}",
"type": "shell", "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": { "options": {
"cwd": "${workspaceFolder}" "cwd": "${workspaceFolder}"
}, },
@ -53,7 +53,7 @@
{ {
"label": "{{ library.name }} {{ build_type_name }} Clean", "label": "{{ library.name }} {{ build_type_name }} Clean",
"type": "shell", "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": { "options": {
"cwd": "${workspaceFolder}" "cwd": "${workspaceFolder}"
}, },