Added libraries to automatic CLion project generation.
This commit is contained in:
parent
7c4e403747
commit
b546931c09
38
SConscript
38
SConscript
@ -17,7 +17,8 @@ import uuid
|
||||
|
||||
class TargetType(enum.Enum):
|
||||
PROGRAM = 0
|
||||
LIBRARY = 1
|
||||
STATIC_LIBRARY = 1
|
||||
SHARED_LIBRARY = 2
|
||||
|
||||
class _VersionSpec:
|
||||
minimum_version = None
|
||||
@ -342,7 +343,7 @@ def _wrap_builder(builder, target_type: TargetType):
|
||||
for name, version_spec in dependencies.items():
|
||||
if version_spec == {}:
|
||||
dep_target = _find_target(env, name)
|
||||
if dep_target is not None and dep_target.target_type == TargetType.LIBRARY:
|
||||
if dep_target is not None and dep_target.target_type != TargetType.PROGRAM:
|
||||
#if 'LIBS' in kwargs:
|
||||
# kwargs['LIBS'].append(dep_target)
|
||||
#else:
|
||||
@ -540,12 +541,33 @@ def _generate_project(project_type: str) -> None:
|
||||
'filename': str(exe_path)
|
||||
})
|
||||
return result
|
||||
def _get_libraries() -> list:
|
||||
result = []
|
||||
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")}'
|
||||
result.append({
|
||||
'name': target.name,
|
||||
'filename': str(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")}'
|
||||
result.append({
|
||||
'name': target.name,
|
||||
'filename': str(lib_path)
|
||||
})
|
||||
return result
|
||||
|
||||
jinja_env = jinja2.Environment()
|
||||
jinja_env.globals['generate_uuid'] = _generate_uuid
|
||||
jinja_env.globals['project'] = {
|
||||
'name': env.Dir('#').name,
|
||||
'executables': _get_executables(),
|
||||
'libraries': _get_libraries(),
|
||||
'build_types': ['debug', 'release_debug', 'release', 'profile']
|
||||
}
|
||||
jinja_env.globals['scons_exe'] = shutil.which('scons')
|
||||
@ -914,17 +936,17 @@ env.AddMethod(_make_interface, 'MakeInterface')
|
||||
env.AddMethod(_lib_filename, 'LibFilename')
|
||||
env.AddMethod(_find_lib, 'FindLib')
|
||||
env.AddMethod(_error, 'Error')
|
||||
env.AddMethod(_wrap_builder(env.Library, TargetType.LIBRARY), 'Library')
|
||||
env.AddMethod(_wrap_builder(env.StaticLibrary, TargetType.LIBRARY), 'StaticLibrary')
|
||||
env.AddMethod(_wrap_builder(env.SharedLibrary, TargetType.LIBRARY), 'SharedLibrary')
|
||||
env.AddMethod(_wrap_builder(env.Library, TargetType.STATIC_LIBRARY), 'Library')
|
||||
env.AddMethod(_wrap_builder(env.StaticLibrary, TargetType.STATIC_LIBRARY), 'StaticLibrary')
|
||||
env.AddMethod(_wrap_builder(env.SharedLibrary, TargetType.SHARED_LIBRARY), 'SharedLibrary')
|
||||
env.AddMethod(_wrap_builder(env.Program, TargetType.PROGRAM), 'Program')
|
||||
env.AddMethod(_wrap_default(env.Default), 'Default')
|
||||
env.AddMethod(_wrap_depends(env.Depends), 'Depends')
|
||||
|
||||
env.AddMethod(_wrap_builder(env.UnityProgram, TargetType.PROGRAM), 'UnityProgram')
|
||||
env.AddMethod(_wrap_builder(env.UnityLibrary, TargetType.LIBRARY), 'UnityLibrary')
|
||||
env.AddMethod(_wrap_builder(env.UnityStaticLibrary, TargetType.LIBRARY), 'UnityStaticLibrary')
|
||||
env.AddMethod(_wrap_builder(env.UnitySharedLibrary, TargetType.LIBRARY), 'UnitySharedLibrary')
|
||||
env.AddMethod(_wrap_builder(env.UnityLibrary, TargetType.STATIC_LIBRARY), 'UnityLibrary')
|
||||
env.AddMethod(_wrap_builder(env.UnityStaticLibrary, TargetType.STATIC_LIBRARY), 'UnityStaticLibrary')
|
||||
env.AddMethod(_wrap_builder(env.UnitySharedLibrary, TargetType.SHARED_LIBRARY), 'UnitySharedLibrary')
|
||||
env.AddMethod(_module, 'Module')
|
||||
env.AddMethod(_finalize, 'Finalize')
|
||||
env.AddMethod(_find_target, 'FindTarget')
|
||||
|
@ -16,5 +16,20 @@
|
||||
</target>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% for library in project.libraries %}
|
||||
{% for build_type in project.build_types %}
|
||||
{% set build_type_name = build_type | capitalize -%}
|
||||
<target id="{{ generate_uuid('target_' + library.name + '_' + build_type) }}" name="{{ library.name }} {{ build_type_name }}" defaultType="TOOL">
|
||||
<configuration id="{{ generate_uuid('configuration_' + library.name + '_' + build_type) }}" name="{{ library.name }} {{ build_type_name }}">
|
||||
<build type="TOOL">
|
||||
<tool actionId="Tool_External Tools_{{ library.name }} {{ build_type_name }}" />
|
||||
</build>
|
||||
<clean type="TOOL">
|
||||
<tool actionId="Tool_External Tools_{{ library.name }} {{ build_type_name }} Clean" />
|
||||
</clean>
|
||||
</configuration>
|
||||
</target>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</component>
|
||||
</project>
|
||||
|
@ -18,4 +18,23 @@
|
||||
</tool>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% for library in project.libraries %}
|
||||
{% for build_type in project.build_types %}
|
||||
{% set build_type_name = build_type | capitalize -%}
|
||||
<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>
|
||||
<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="WORKING_DIRECTORY" value="$ProjectFileDir$" />
|
||||
</exec>
|
||||
</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">
|
||||
<exec>
|
||||
<option name="COMMAND" value="{{ scons_exe }}" />
|
||||
<option name="PARAMETERS" value="--build_type={{ build_type }} --unity=disable {{ library.filename }} -c" />
|
||||
<option name="WORKING_DIRECTORY" value="$ProjectFileDir$" />
|
||||
</exec>
|
||||
</tool>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</toolSet>
|
||||
|
@ -91,6 +91,16 @@
|
||||
</configuration>
|
||||
{% endfor -%}
|
||||
{% endfor -%}
|
||||
{% for library in project.libraries -%}
|
||||
{% for build_type in project.build_types -%}
|
||||
{% set build_type_name = build_type | capitalize -%}
|
||||
<configuration name="{{ library.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="{{ library.name }} {{ build_type_name }}" CONFIG_NAME="{{ library.name }} {{ build_type_name }}">
|
||||
<method v="2">
|
||||
<option name="CLION.EXTERNAL.BUILD" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
{% endfor -%}
|
||||
{% endfor -%}
|
||||
</component>
|
||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
|
Loading…
x
Reference in New Issue
Block a user