Save and reuse UUIDs between project generations.
This commit is contained in:
parent
329278c5f5
commit
e3b3fd8f7c
30
SConscript
30
SConscript
@ -483,8 +483,26 @@ 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.')
|
||||||
def _generate_uuid() -> str:
|
|
||||||
return str(uuid.uuid4())
|
uuid_cache_file = pathlib.Path(env['SHARED_CACHE_DIR'], 'uuids.json')
|
||||||
|
uuid_cache = {}
|
||||||
|
save_uuid_cache = False
|
||||||
|
if uuid_cache_file.exists():
|
||||||
|
try:
|
||||||
|
with uuid_cache_file.open('r') as f:
|
||||||
|
uuid_cache = json.load(f)
|
||||||
|
except Exception as e:
|
||||||
|
print(f'Error loading UUID cache: {e}')
|
||||||
|
|
||||||
|
def _generate_uuid(name: str = '') -> str:
|
||||||
|
nonlocal save_uuid_cache
|
||||||
|
if name and name in uuid_cache:
|
||||||
|
return uuid_cache[name]
|
||||||
|
new_uuid = str(uuid.uuid4())
|
||||||
|
if name:
|
||||||
|
uuid_cache[name] = new_uuid
|
||||||
|
save_uuid_cache = True
|
||||||
|
return new_uuid
|
||||||
|
|
||||||
root_path = pathlib.Path(env.Dir('#').abspath)
|
root_path = pathlib.Path(env.Dir('#').abspath)
|
||||||
def _get_executables() -> list:
|
def _get_executables() -> list:
|
||||||
@ -526,6 +544,14 @@ def _generate_project(project_type: str) -> None:
|
|||||||
with target_file.open('w') as f:
|
with target_file.open('w') as f:
|
||||||
f.write(templ.render())
|
f.write(templ.render())
|
||||||
|
|
||||||
|
if save_uuid_cache:
|
||||||
|
try:
|
||||||
|
with uuid_cache_file.open('w') as f:
|
||||||
|
json.dump(uuid_cache, f)
|
||||||
|
except Exception as e:
|
||||||
|
print(f'Error writing uuid cache: {e}')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Import('config')
|
Import('config')
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
{% 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 -%}
|
||||||
<target id="{{ generate_uuid() }}" name="{{ executable.name }} {{ build_type_name }}" defaultType="TOOL">
|
<target id="{{ generate_uuid('target_' + executable.name + '_' + build_type) }}" name="{{ executable.name }} {{ build_type_name }}" defaultType="TOOL">
|
||||||
<configuration id="{{ generate_uuid() }}" name="{{ executable.name }} {{ build_type_name }}">
|
<configuration id="{{ generate_uuid('configuration_' + executable.name + '_' + build_type) }}" name="{{ executable.name }} {{ build_type_name }}">
|
||||||
<build type="TOOL">
|
<build type="TOOL">
|
||||||
<tool actionId="Tool_External Tools_{{ executable.name }} {{ build_type_name }}" />
|
<tool actionId="Tool_External Tools_{{ executable.name }} {{ build_type_name }}" />
|
||||||
</build>
|
</build>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user