165 filename=os.path.join(LOGS_ROOT,
"packaging.log"),
167 format=
"%(asctime)s %(levelname)s: %(message)s",
169 logging.info(
"=== SDK Packaging Started ===")
175 sdk_name = f
"RenderingEngine-v{version}-SDK-{platform}"
176 sdk_root = os.path.join(SDK_TEMP_ROOT, sdk_name)
179 if os.path.exists(sdk_root):
180 shutil.rmtree(sdk_root)
183 logging.info(f
"Version : {version}")
184 logging.info(f
"Platform: {platform}")
185 logging.info(f
"SDK root: {sdk_root}")
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"))
196 installed_engine_root = os.path.join(INSTALL_ROOT,
"RenderingEngine")
199 installed_render_lib = os.path.join(installed_engine_root,
"RenderingLibrary")
202 os.path.join(installed_render_lib,
"Include"),
203 os.path.join(sdk_render_lib_root,
"Include"),
207 os.path.join(installed_render_lib,
"Library"),
208 os.path.join(sdk_render_lib_root,
"Library"),
214 installed_mc_root = os.path.join(installed_engine_root,
"MaterialCompiler")
215 copy_tree(installed_mc_root, sdk_material_compiler_root)
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"))
227 os.path.join(REPO_ROOT,
"RenderingEngine",
"Scripts",
"Templates"),
228 os.path.join(sdk_scripts_root,
"Templates"),
234 cmake_template_path = os.path.join(sdk_scripts_root,
"Templates",
"CMakeLists.txt.in")
238 os.path.join(REPO_ROOT,
"RenderingEngine",
"Scripts",
"Templates"),
239 os.path.join(sdk_scripts_root,
"Templates"),
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")
248 logging.warning(f
"create_project.py not found at {create_project_src}")
251 cmake_template_path = os.path.join(sdk_scripts_root,
"Templates",
"CMakeLists.txt.in")
253 with open(cmake_template_path,
"r", encoding=
"utf-8")
as f:
257 r'option\(RE_DEV_MODE\s+"[^"]+"\s+ON\)',
258 'option(RE_DEV_MODE "Build using RenderingEngine directly from source tree (Windows only)" OFF)',
262 with open(cmake_template_path,
"w", encoding=
"utf-8")
as f:
265 logging.info(
"Updated CMakeLists.txt.in to set RE_DEV_MODE=OFF")
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}")
278 logging.warning(f
"Documentation file missing, skipped: {src}")
283 examples_src_root = os.path.join(REPO_ROOT,
"ContentExamples")
284 examples_dst_root =
ensure_dir(os.path.join(sdk_root,
"ContentExamples"))
286 def ignore_example(dirpath, names):
289 if n
in (
"Build",
"Intermediate",
".vs",
".vscode",
"x64"):
291 elif n.endswith(
".user")
or n.endswith(
".vcxproj")
or n.endswith(
".vcxproj.filters"):
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.")
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")
306 logging.warning(
"No ContentExamples folder found.")
311 ensure_dir(os.path.join(sdk_root,
"UserApplications"))
316 write_manifest(os.path.join(sdk_root,
"Manifest.txt"), version, platform)
322 archive_path = os.path.join(PACKAGE_ROOT, sdk_name)
325 for ext
in (
".tar.gz",
".zip",
".tgz"):
326 old = archive_path + ext
327 if os.path.exists(old):
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 ===")
334 except Exception
as e:
335 logging.error(f
"SDK packaging failed: {e}", exc_info=
True)
336 print(f
"SDK packaging failed: {e}")