diff --git a/SConscript b/SConscript index 7eea4f0..621c4ad 100644 --- a/SConscript +++ b/SConscript @@ -483,8 +483,26 @@ def _generate_project(project_type: str) -> None: }.get(project_type, (None, None)) if not source_folder: _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) def _get_executables() -> list: @@ -526,6 +544,14 @@ def _generate_project(project_type: str) -> None: with target_file.open('w') as f: 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') diff --git a/util/clion_project_template/customTargets.xml.jinja b/util/clion_project_template/customTargets.xml.jinja index 598afbc..0dfd4d1 100644 --- a/util/clion_project_template/customTargets.xml.jinja +++ b/util/clion_project_template/customTargets.xml.jinja @@ -4,8 +4,8 @@ {% for executable in project.executables %} {% for build_type in project.build_types %} {% set build_type_name = build_type | capitalize -%} - - + +