Rendering Engine 0.2.17
Modular Graphics Rendering Engine | v0.2.17
Loading...
Searching...
No Matches
register_project Namespace Reference

Functions

 normalize_path (path)
 
 read_registered_projects ()
 
 write_registered_projects (projects)
 
 write_project_engine_config (project_path)
 
 register_project (project_path)
 

Variables

 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
 
 ENGINE_ROOT = os.path.abspath(os.path.join(SCRIPT_DIR, "..", ".."))
 
 LOCAL_DIR = os.path.join(ENGINE_ROOT, "Local")
 
 REGISTRY_FILE = os.path.join(LOCAL_DIR, "registered_projects.cmake")
 

Function Documentation

◆ normalize_path()

register_project.normalize_path (   path)
@brief Convert a path to an absolute CMake-friendly path.

@param path  Path to normalize.

@return Absolute normalized path using forward slashes.

Definition at line 28 of file register_project.py.

28def normalize_path(path):
29 """
30 @brief Convert a path to an absolute CMake-friendly path.
31
32 @param path Path to normalize.
33
34 @return Absolute normalized path using forward slashes.
35 """
36 return os.path.abspath(path).replace("\\", "/")
37
38

◆ read_registered_projects()

register_project.read_registered_projects ( )
@brief Read external UserApplication paths from the local registry.

@return List of registered project paths.

Definition at line 39 of file register_project.py.

39def read_registered_projects():
40 """
41 @brief Read external UserApplication paths from the local registry.
42
43 @return List of registered project paths.
44 """
45 if not os.path.exists(REGISTRY_FILE):
46 return []
47
48 projects = []
49
50 with open(REGISTRY_FILE, "r") as registry_file:
51 for line in registry_file:
52 line = line.strip()
53
54 if line.startswith('"') and line.endswith('"'):
55 projects.append(line[1:-1])
56
57 return projects
58
59

◆ register_project()

register_project.register_project (   project_path)
@brief Register an external UserApplication with this Rendering Engine.

@param project_path  Path to the UserApplication.

Definition at line 109 of file register_project.py.

109def register_project(project_path):
110 """
111 @brief Register an external UserApplication with this Rendering Engine.
112
113 @param project_path Path to the UserApplication.
114 """
115 project_path = normalize_path(project_path)
116
117 if not os.path.isdir(project_path):
118 print(f"Error: Project directory does not exist: '{project_path}'.")
119 return False
120
121 cmake_file = os.path.join(project_path, "CMakeLists.txt")
122
123 if not os.path.isfile(cmake_file):
124 print(
125 f"Error: Project '{project_path}' does not contain "
126 "a CMakeLists.txt file."
127 )
128 return False
129
130 projects = read_registered_projects()
131
132 if project_path not in projects:
133 projects.append(project_path)
134 write_registered_projects(projects)
135 print(f"Registered project: {project_path}")
136 else:
137 print(f"Project is already registered: {project_path}")
138
139 project_config = write_project_engine_config(project_path)
140
141 print(f"Project configuration: {project_config}")
142 print(f"Registration file: {REGISTRY_FILE}")
143
144 return True
145
146

◆ write_project_engine_config()

register_project.write_project_engine_config (   project_path)
@brief Write the machine-local Rendering Engine configuration
       for a UserApplication.

@param project_path  Path to the UserApplication.

Definition at line 82 of file register_project.py.

82def write_project_engine_config(project_path):
83 """
84 @brief Write the machine-local Rendering Engine configuration
85 for a UserApplication.
86
87 @param project_path Path to the UserApplication.
88 """
89 local_dir = os.path.join(project_path, "Local")
90 config_file = os.path.join(local_dir, "rendering_engine.cmake")
91
92 os.makedirs(local_dir, exist_ok=True)
93
94 engine_root = normalize_path(ENGINE_ROOT)
95
96 with open(config_file, "w") as config:
97 config.write(
98 "# This file is generated by register_project.py.\n"
99 "# Machine-local Rendering Engine configuration.\n"
100 "\n"
101 "set(RENDERING_ENGINE_ROOT\n"
102 f' "{engine_root}"\n'
103 ")\n"
104 )
105
106 return config_file
107
108

◆ write_registered_projects()

register_project.write_registered_projects (   projects)
@brief Write external UserApplication paths to the local registry.

@param projects  List of registered project paths.

Definition at line 60 of file register_project.py.

60def write_registered_projects(projects):
61 """
62 @brief Write external UserApplication paths to the local registry.
63
64 @param projects List of registered project paths.
65 """
66 os.makedirs(LOCAL_DIR, exist_ok=True)
67
68 with open(REGISTRY_FILE, "w") as registry_file:
69 registry_file.write(
70 "# This file is generated by register_project.py.\n"
71 "# Machine-local Rendering Engine application registrations.\n"
72 "\n"
73 "set(RE_EXTERNAL_APPLICATIONS\n"
74 )
75
76 for project in projects:
77 registry_file.write(f' "{project}"\n')
78
79 registry_file.write(")\n")
80
81

Variable Documentation

◆ ENGINE_ROOT

register_project.ENGINE_ROOT = os.path.abspath(os.path.join(SCRIPT_DIR, "..", ".."))

Definition at line 22 of file register_project.py.

◆ LOCAL_DIR

register_project.LOCAL_DIR = os.path.join(ENGINE_ROOT, "Local")

Definition at line 24 of file register_project.py.

◆ REGISTRY_FILE

register_project.REGISTRY_FILE = os.path.join(LOCAL_DIR, "registered_projects.cmake")

Definition at line 25 of file register_project.py.

◆ SCRIPT_DIR

register_project.SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))

Definition at line 21 of file register_project.py.