Cleaned up/updated CLion project generation code and templates.

This commit is contained in:
Patrick 2024-10-10 23:23:29 +02:00
parent c6bba0e440
commit a0bbb46e51
3 changed files with 20 additions and 14 deletions

View File

@ -3,11 +3,16 @@ import copy
import enum import enum
import glob import glob
import inspect import inspect
import jinja2
import json import json
import multiprocessing
import os import os
import pathlib
import psutil import psutil
import shutil
import sys import sys
import time import time
import uuid
class TargetType(enum.Enum): class TargetType(enum.Enum):
@ -478,15 +483,9 @@ def _generate_project(project_type: str) -> None:
}.get(project_type, (None, None)) }.get(project_type, (None, None))
if not source_folder: if not source_folder:
_error(None, 'Invalid project type option.') _error(None, 'Invalid project type option.')
import uuid
def _generate_uuid() -> str: def _generate_uuid() -> str:
return str(uuid.uuid4()) return str(uuid.uuid4())
import pathlib
import shutil
import multiprocessing
root_path = pathlib.Path(env.Dir('#').abspath) root_path = pathlib.Path(env.Dir('#').abspath)
def _get_executables() -> list: def _get_executables() -> list:
result = [] result = []
@ -500,7 +499,6 @@ def _generate_project(project_type: str) -> None:
}) })
return result return result
import jinja2
jinja_env = jinja2.Environment() jinja_env = jinja2.Environment()
jinja_env.globals['generate_uuid'] = _generate_uuid jinja_env.globals['generate_uuid'] = _generate_uuid
jinja_env.globals['project'] = { jinja_env.globals['project'] = {
@ -508,7 +506,7 @@ def _generate_project(project_type: str) -> None:
'executables': _get_executables(), 'executables': _get_executables(),
'build_types': ['debug', 'release_debug', 'release', 'profile'] 'build_types': ['debug', 'release_debug', 'release', 'profile']
} }
jinja_env.globals['scons_exe'] = env['ENV']['_'] jinja_env.globals['scons_exe'] = shutil.which('scons')
jinja_env.globals['nproc'] = multiprocessing.cpu_count() jinja_env.globals['nproc'] = multiprocessing.cpu_count()
source_path = pathlib.Path(source_folder) source_path = pathlib.Path(source_folder)

View File

@ -18,4 +18,11 @@
</tool> </tool>
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
<tool name="Regenerate Project" showInMainMenu="true" showInEditor="true" showInProject="true" showInSearchPopup="true" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true">
<exec>
<option name="COMMAND" value="{{ scons_exe }}" />
<option name="PARAMETERS" value="--generate_project=clion" />
<option name="WORKING_DIRECTORY" value="$ProjectFileDir$" />
</exec>
</tool>
</toolSet> </toolSet>

View File

@ -58,11 +58,12 @@
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent"><![CDATA[{
"keyToString": { "keyToString": {
{% 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 -%}
"Custom Build Application.{{ executable.name }} {{ build_type_name }}.executor": "Debug", "Custom Build Application.{{ executable.name }} {{ build_type_name }}.executor": "Debug",
{% endfor %} {% endfor -%}
{% endfor %} {% endfor -%}
"RunOnceActivity.RadMigrateCodeStyle": "true", "RunOnceActivity.RadMigrateCodeStyle": "true",
"RunOnceActivity.ShowReadmeOnStart": "true", "RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.cidr.known.project.marker": "true", "RunOnceActivity.cidr.known.project.marker": "true",
@ -88,8 +89,8 @@
<option name="CLION.EXTERNAL.BUILD" enabled="true" /> <option name="CLION.EXTERNAL.BUILD" enabled="true" />
</method> </method>
</configuration> </configuration>
{% endfor %} {% endfor -%}
{% endfor %} {% endfor -%}
</component> </component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" /> <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">