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 glob
import inspect
import jinja2
import json
import multiprocessing
import os
import pathlib
import psutil
import shutil
import sys
import time
import uuid
class TargetType(enum.Enum):
@ -478,15 +483,9 @@ def _generate_project(project_type: str) -> None:
}.get(project_type, (None, None))
if not source_folder:
_error(None, 'Invalid project type option.')
import uuid
def _generate_uuid() -> str:
return str(uuid.uuid4())
import pathlib
import shutil
import multiprocessing
root_path = pathlib.Path(env.Dir('#').abspath)
def _get_executables() -> list:
result = []
@ -500,7 +499,6 @@ def _generate_project(project_type: str) -> None:
})
return result
import jinja2
jinja_env = jinja2.Environment()
jinja_env.globals['generate_uuid'] = _generate_uuid
jinja_env.globals['project'] = {
@ -508,7 +506,7 @@ def _generate_project(project_type: str) -> None:
'executables': _get_executables(),
'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()
source_path = pathlib.Path(source_folder)

View File

@ -18,4 +18,11 @@
</tool>
{% 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>

View File

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