161 filename=os.path.join(LOGS_ROOT,
"packaging.log"),
163 format=
"%(asctime)s %(levelname)s: %(message)s",
165 logging.info(
"=== SDK Packaging Started ===")
171 sdk_name = f
"RenderingEngine-v{version}-SDK-{platform}"
172 sdk_root = os.path.join(SDK_TEMP_ROOT, sdk_name)
175 if os.path.exists(sdk_root):
176 shutil.rmtree(sdk_root)
179 logging.info(f
"Version : {version}")
180 logging.info(f
"Platform: {platform}")
181 logging.info(f
"SDK root: {sdk_root}")
184 sdk_rendering_engine_root =
ensure_dir(os.path.join(sdk_root,
"RenderingEngine"))
185 sdk_render_lib_root =
ensure_dir(os.path.join(sdk_rendering_engine_root,
"RenderingLibrary"))
186 sdk_material_compiler_root =
ensure_dir(os.path.join(sdk_rendering_engine_root,
"MaterialCompiler"))
187 sdk_scripts_root =
ensure_dir(os.path.join(sdk_rendering_engine_root,
"Scripts"))
192 installed_engine_root = os.path.join(INSTALL_ROOT,
"RenderingEngine")
195 installed_render_lib = os.path.join(installed_engine_root,
"RenderingLibrary")
198 os.path.join(installed_render_lib,
"Include"),
199 os.path.join(sdk_render_lib_root,
"Include"),
203 os.path.join(installed_render_lib,
"Library"),
204 os.path.join(sdk_render_lib_root,
"Library"),
210 installed_mc_root = os.path.join(installed_engine_root,
"MaterialCompiler")
211 copy_tree(installed_mc_root, sdk_material_compiler_root)
216 installed_external_root = os.path.join(installed_engine_root,
"External")
217 copy_tree(installed_external_root, os.path.join(sdk_rendering_engine_root,
"External"))
223 os.path.join(REPO_ROOT,
"RenderingEngine",
"Scripts",
"Templates"),
224 os.path.join(sdk_scripts_root,
"Templates"),
230 cmake_template_path = os.path.join(sdk_scripts_root,
"Templates",
"CMakeLists.txt.in")
234 os.path.join(REPO_ROOT,
"RenderingEngine",
"Scripts",
"Templates"),
235 os.path.join(sdk_scripts_root,
"Templates"),
239 create_project_src = os.path.join(REPO_ROOT,
"RenderingEngine",
"Scripts",
"create_project.py")
240 if os.path.isfile(create_project_src):
241 shutil.copy2(create_project_src, os.path.join(sdk_scripts_root,
"create_project.py"))
242 logging.info(
"Copied script: create_project.py")
244 logging.warning(f
"create_project.py not found at {create_project_src}")
247 cmake_template_path = os.path.join(sdk_scripts_root,
"Templates",
"CMakeLists.txt.in")
249 with open(cmake_template_path,
"r", encoding=
"utf-8")
as f:
253 r'option\(RE_DEV_MODE\s+"[^"]+"\s+ON\)',
254 'option(RE_DEV_MODE "Build using RenderingEngine directly from source tree (Windows only)" OFF)',
258 with open(cmake_template_path,
"w", encoding=
"utf-8")
as f:
261 logging.info(
"Updated CMakeLists.txt.in to set RE_DEV_MODE=OFF")
267 doc_dst =
ensure_dir(os.path.join(sdk_root,
"Doc"))
268 for doc
in DOC_FILES:
269 src = os.path.join(REPO_ROOT, doc)
270 if os.path.isfile(src):
271 shutil.copy2(src, doc_dst)
272 logging.info(f
"Copied documentation: {src}")
274 logging.warning(f
"Documentation file missing, skipped: {src}")
279 examples_src_root = os.path.join(REPO_ROOT,
"ContentExamples")
280 examples_dst_root =
ensure_dir(os.path.join(sdk_root,
"ContentExamples"))
282 def ignore_example(dirpath, names):
285 if n
in (
"Build",
"Intermediate",
".vs",
".vscode",
"x64"):
287 elif n.endswith(
".user")
or n.endswith(
".vcxproj")
or n.endswith(
".vcxproj.filters"):
291 if os.path.isdir(examples_src_root):
292 copy_tree(examples_src_root, examples_dst_root, ignore=ignore_example)
293 logging.info(
"Copied ContentExamples folder.")
296 for proj
in os.listdir(examples_dst_root):
297 proj_path = os.path.join(examples_dst_root, proj)
298 if os.path.isdir(proj_path):
299 build_script = os.path.join(proj_path,
"build_project.sh")
302 logging.warning(
"No ContentExamples folder found.")
307 ensure_dir(os.path.join(sdk_root,
"UserApplications"))
312 write_manifest(os.path.join(sdk_root,
"Manifest.txt"), version, platform)
318 archive_path = os.path.join(PACKAGE_ROOT, sdk_name)
321 for ext
in (
".tar.gz",
".zip",
".tgz"):
322 old = archive_path + ext
323 if os.path.exists(old):
326 shutil.make_archive(archive_path,
"gztar", root_dir=SDK_TEMP_ROOT)
327 logging.info(f
"Archive created: {archive_path}.tar.gz")
328 logging.info(
"=== SDK Packaging Complete ===")
330 except Exception
as e:
331 logging.error(f
"SDK packaging failed: {e}", exc_info=
True)
332 print(f
"SDK packaging failed: {e}")