162
164 logging.basicConfig(
165 filename=os.path.join(LOGS_ROOT, "packaging.log"),
166 level=logging.INFO,
167 format="%(asctime)s %(levelname)s: %(message)s",
168 )
169 logging.info("=== SDK Packaging Started ===")
170
171 try:
174
175 sdk_name = f"RenderingEngine-v{version}-SDK-{platform}"
176 sdk_root = os.path.join(SDK_TEMP_ROOT, sdk_name)
177
178
179 if os.path.exists(sdk_root):
180 shutil.rmtree(sdk_root)
182
183 logging.info(f"Version : {version}")
184 logging.info(f"Platform: {platform}")
185 logging.info(f"SDK root: {sdk_root}")
186
187
188 sdk_rendering_engine_root =
ensure_dir(os.path.join(sdk_root,
"RenderingEngine"))
189 sdk_render_lib_root =
ensure_dir(os.path.join(sdk_rendering_engine_root,
"RenderingLibrary"))
190 sdk_material_compiler_root =
ensure_dir(os.path.join(sdk_rendering_engine_root,
"MaterialCompiler"))
191 sdk_scripts_root =
ensure_dir(os.path.join(sdk_rendering_engine_root,
"Scripts"))
192
193
194
195
196 installed_engine_root = os.path.join(INSTALL_ROOT, "RenderingEngine")
197
198
199 installed_render_lib = os.path.join(installed_engine_root, "RenderingLibrary")
200
202 os.path.join(installed_render_lib, "Include"),
203 os.path.join(sdk_render_lib_root, "Include"),
204 )
205
207 os.path.join(installed_render_lib, "Library"),
208 os.path.join(sdk_render_lib_root, "Library"),
209 )
210
211
212
213
214 installed_mc_root = os.path.join(installed_engine_root, "MaterialCompiler")
215 copy_tree(installed_mc_root, sdk_material_compiler_root)
216
217
218
219
220 installed_external_root = os.path.join(installed_engine_root, "External")
221 copy_tree(installed_external_root, os.path.join(sdk_rendering_engine_root,
"External"))
222
223
224
225
227 os.path.join(REPO_ROOT, "RenderingEngine", "Scripts", "Templates"),
228 os.path.join(sdk_scripts_root, "Templates"),
229 )
230
231
232
233
234 cmake_template_path = os.path.join(sdk_scripts_root, "Templates", "CMakeLists.txt.in")
235
236
238 os.path.join(REPO_ROOT, "RenderingEngine", "Scripts", "Templates"),
239 os.path.join(sdk_scripts_root, "Templates"),
240 )
241
242
243 create_project_src = os.path.join(REPO_ROOT, "RenderingEngine", "Scripts", "create_project.py")
244 if os.path.isfile(create_project_src):
245 shutil.copy2(create_project_src, os.path.join(sdk_scripts_root, "create_project.py"))
246 logging.info("Copied script: create_project.py")
247 else:
248 logging.warning(f"create_project.py not found at {create_project_src}")
249
250
251 cmake_template_path = os.path.join(sdk_scripts_root, "Templates", "CMakeLists.txt.in")
252
253 with open(cmake_template_path, "r", encoding="utf-8") as f:
254 text = f.read()
255
256 text = re.sub(
257 r'option\(RE_DEV_MODE\s+"[^"]+"\s+ON\)',
258 'option(RE_DEV_MODE "Build using RenderingEngine directly from source tree (Windows only)" OFF)',
259 text
260 )
261
262 with open(cmake_template_path, "w", encoding="utf-8") as f:
263 f.write(text)
264
265 logging.info("Updated CMakeLists.txt.in to set RE_DEV_MODE=OFF")
266
267
268
269
270
271 doc_dst =
ensure_dir(os.path.join(sdk_root,
"Doc"))
272 for doc in DOC_FILES:
273 src = os.path.join(REPO_ROOT, doc)
274 if os.path.isfile(src):
275 shutil.copy2(src, doc_dst)
276 logging.info(f"Copied documentation: {src}")
277 else:
278 logging.warning(f"Documentation file missing, skipped: {src}")
279
280
281
282
283 examples_src_root = os.path.join(REPO_ROOT, "ContentExamples")
284 examples_dst_root =
ensure_dir(os.path.join(sdk_root,
"ContentExamples"))
285
286 def ignore_example(dirpath, names):
287 ignore = []
288 for n in names:
289 if n in ("Build", "Intermediate", ".vs", ".vscode", "x64"):
290 ignore.append(n)
291 elif n.endswith(".user") or n.endswith(".vcxproj") or n.endswith(".vcxproj.filters"):
292 ignore.append(n)
293 return ignore
294
295 if os.path.isdir(examples_src_root):
296 copy_tree(examples_src_root, examples_dst_root, ignore=ignore_example)
297 logging.info("Copied ContentExamples folder.")
298
299
300 for proj in os.listdir(examples_dst_root):
301 proj_path = os.path.join(examples_dst_root, proj)
302 if os.path.isdir(proj_path):
303 build_script = os.path.join(proj_path, "build_project.sh")
305 else:
306 logging.warning("No ContentExamples folder found.")
307
308
309
310
311 ensure_dir(os.path.join(sdk_root,
"UserApplications"))
312
313
314
315
316 write_manifest(os.path.join(sdk_root,
"Manifest.txt"), version, platform)
317
318
319
320
322 archive_path = os.path.join(PACKAGE_ROOT, sdk_name)
323
324
325 for ext in (".tar.gz", ".zip", ".tgz"):
326 old = archive_path + ext
327 if os.path.exists(old):
328 os.remove(old)
329
330 shutil.make_archive(archive_path, "gztar", root_dir=SDK_TEMP_ROOT)
331 logging.info(f"Archive created: {archive_path}.tar.gz")
332 logging.info("=== SDK Packaging Complete ===")
333
334 except Exception as e:
335 logging.error(f"SDK packaging failed: {e}", exc_info=True)
336 print(f"SDK packaging failed: {e}")
337
338
def patch_build_script_for_sdk(build_script_path)
def write_manifest(path, version, platform)