21SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
22ENGINE_ROOT = os.path.abspath(os.path.join(SCRIPT_DIR,
"..",
".."))
24LOCAL_DIR = os.path.join(ENGINE_ROOT,
"Local")
25REGISTRY_FILE = os.path.join(LOCAL_DIR,
"registered_projects.cmake")
30 @brief Convert a path to an absolute CMake-friendly path.
32 @param path Path to normalize.
34 @return Absolute normalized path using forward slashes.
36 return os.path.abspath(path).replace(
"\\",
"/")
41 @brief Read external UserApplication paths from the local registry.
43 @return List of registered project paths.
45 if not os.path.exists(REGISTRY_FILE):
50 with open(REGISTRY_FILE,
"r")
as registry_file:
51 for line
in registry_file:
54 if line.startswith(
'"')
and line.endswith(
'"'):
55 projects.append(line[1:-1])
62 @brief Write external UserApplication paths to the local registry.
64 @param projects List of registered project paths.
66 os.makedirs(LOCAL_DIR, exist_ok=
True)
68 with open(REGISTRY_FILE,
"w")
as registry_file:
70 "# This file is generated by register_project.py.\n"
71 "# Machine-local Rendering Engine application registrations.\n"
73 "set(RE_EXTERNAL_APPLICATIONS\n"
76 for project
in projects:
77 registry_file.write(f
' "{project}"\n')
79 registry_file.write(
")\n")
84 @brief Write the machine-local Rendering Engine configuration
85 for a UserApplication.
87 @param project_path Path to the UserApplication.
89 local_dir = os.path.join(project_path,
"Local")
90 config_file = os.path.join(local_dir,
"rendering_engine.cmake")
92 os.makedirs(local_dir, exist_ok=
True)
96 with open(config_file,
"w")
as config:
98 "# This file is generated by register_project.py.\n"
99 "# Machine-local Rendering Engine configuration.\n"
101 "set(RENDERING_ENGINE_ROOT\n"
102 f
' "{engine_root}"\n'
111 @brief Register an external UserApplication with this Rendering Engine.
113 @param project_path Path to the UserApplication.
117 if not os.path.isdir(project_path):
118 print(f
"Error: Project directory does not exist: '{project_path}'.")
121 cmake_file = os.path.join(project_path,
"CMakeLists.txt")
123 if not os.path.isfile(cmake_file):
125 f
"Error: Project '{project_path}' does not contain "
126 "a CMakeLists.txt file."
132 if project_path
not in projects:
133 projects.append(project_path)
135 print(f
"Registered project: {project_path}")
137 print(f
"Project is already registered: {project_path}")
141 print(f
"Project configuration: {project_config}")
142 print(f
"Registration file: {REGISTRY_FILE}")
147if __name__ ==
"__main__":
148 if len(sys.argv) != 2:
149 print(
"Usage: register_project.py <ProjectPath>")
write_registered_projects(projects)
write_project_engine_config(project_path)
read_registered_projects()