diff --git a/examples/collision_demo/xmake.lua b/examples/collision_demo/xmake.lua index b8c0665..f67e244 100644 --- a/examples/collision_demo/xmake.lua +++ b/examples/collision_demo/xmake.lua @@ -20,6 +20,7 @@ target("collision_demo") set_toolchains("switch") set_targetdir("../../build/examples/collision_demo") + -- 构建后生成 NRO 文件 after_build(function (target) local devkitPro = os.getenv("DEVKITPRO") or "C:/devkitPro" local elf_file = target:targetfile() @@ -37,6 +38,17 @@ target("collision_demo") else os.vrunv(elf2nro, {elf_file, nro_file, "--nacp=" .. nacp_file}) end + print("Generated NRO: " .. nro_file) + end + end) + + -- 打包时将 NRO 文件复制到 package 目录 + after_package(function (target) + local nro_file = path.join(target:targetdir(), "collision_demo.nro") + local package_dir = target:packagedir() + if os.isfile(nro_file) and package_dir then + os.cp(nro_file, package_dir) + print("Copied NRO to package: " .. package_dir) end end) @@ -46,20 +58,39 @@ target("collision_demo") set_targetdir("../../build/examples/collision_demo") add_ldflags("-mwindows", {force = true}) - -- 复制资源 + -- 复制资源到输出目录 after_build(function (target) local romfs = path.join(example_dir, "romfs") if os.isdir(romfs) then local target_dir = path.directory(target:targetfile()) local assets_dir = path.join(target_dir, "assets") + + -- 创建 assets 目录 if not os.isdir(assets_dir) then os.mkdir(assets_dir) end - os.cp(path.join(romfs, "assets/*"), assets_dir) + + -- 复制所有资源文件(包括子目录) + os.cp(path.join(romfs, "assets/**"), assets_dir) print("Copied assets from " .. romfs .. " to " .. assets_dir) else print("Warning: romfs directory not found at " .. romfs) end end) + + -- 打包时将资源复制到 package 目录 + after_package(function (target) + local target_dir = path.directory(target:targetfile()) + local assets_dir = path.join(target_dir, "assets") + local package_dir = target:packagedir() + if os.isdir(assets_dir) and package_dir then + local package_assets = path.join(package_dir, "assets") + if not os.isdir(package_assets) then + os.mkdir(package_assets) + end + os.cp(path.join(assets_dir, "**"), package_assets) + print("Copied assets to package: " .. package_assets) + end + end) end target_end() diff --git a/examples/hello_world/xmake.lua b/examples/hello_world/xmake.lua index 2d7991c..bde16e8 100644 --- a/examples/hello_world/xmake.lua +++ b/examples/hello_world/xmake.lua @@ -20,7 +20,7 @@ target("hello_world") set_toolchains("switch") set_targetdir("../../build/examples/hello_world") - -- 生成 NRO + -- 构建后生成 NRO 文件 after_build(function (target) local devkitPro = os.getenv("DEVKITPRO") or "C:/devkitPro" local elf_file = target:targetfile() @@ -38,6 +38,17 @@ target("hello_world") else os.vrunv(elf2nro, {elf_file, nro_file, "--nacp=" .. nacp_file}) end + print("Generated NRO: " .. nro_file) + end + end) + + -- 打包时将 NRO 文件复制到 package 目录 + after_package(function (target) + local nro_file = path.join(target:targetdir(), "hello_world.nro") + local package_dir = target:packagedir() + if os.isfile(nro_file) and package_dir then + os.cp(nro_file, package_dir) + print("Copied NRO to package: " .. package_dir) end end) @@ -47,20 +58,39 @@ target("hello_world") set_targetdir("../../build/examples/hello_world") add_ldflags("-mwindows", {force = true}) - -- 复制资源 + -- 复制资源到输出目录 after_build(function (target) local romfs = path.join(example_dir, "romfs") if os.isdir(romfs) then local target_dir = path.directory(target:targetfile()) local assets_dir = path.join(target_dir, "assets") + + -- 创建 assets 目录 if not os.isdir(assets_dir) then os.mkdir(assets_dir) end - os.cp(path.join(romfs, "assets/*"), assets_dir) + + -- 复制所有资源文件(包括子目录) + os.cp(path.join(romfs, "assets/**"), assets_dir) print("Copied assets from " .. romfs .. " to " .. assets_dir) else print("Warning: romfs directory not found at " .. romfs) end end) + + -- 打包时将资源复制到 package 目录 + after_package(function (target) + local target_dir = path.directory(target:targetfile()) + local assets_dir = path.join(target_dir, "assets") + local package_dir = target:packagedir() + if os.isdir(assets_dir) and package_dir then + local package_assets = path.join(package_dir, "assets") + if not os.isdir(package_assets) then + os.mkdir(package_assets) + end + os.cp(path.join(assets_dir, "**"), package_assets) + print("Copied assets to package: " .. package_assets) + end + end) end target_end() diff --git a/examples/push_box/xmake.lua b/examples/push_box/xmake.lua index 4e22790..b56576d 100644 --- a/examples/push_box/xmake.lua +++ b/examples/push_box/xmake.lua @@ -20,6 +20,7 @@ target("push_box") set_toolchains("switch") set_targetdir("../../build/examples/push_box") + -- 构建后生成 NRO 文件 after_build(function (target) local devkitPro = os.getenv("DEVKITPRO") or "C:/devkitPro" local elf_file = target:targetfile() @@ -37,6 +38,17 @@ target("push_box") else os.vrunv(elf2nro, {elf_file, nro_file, "--nacp=" .. nacp_file}) end + print("Generated NRO: " .. nro_file) + end + end) + + -- 打包时将 NRO 文件复制到 package 目录 + after_package(function (target) + local nro_file = path.join(target:targetdir(), "push_box.nro") + local package_dir = target:packagedir() + if os.isfile(nro_file) and package_dir then + os.cp(nro_file, package_dir) + print("Copied NRO to package: " .. package_dir) end end) @@ -46,20 +58,39 @@ target("push_box") set_targetdir("../../build/examples/push_box") add_ldflags("-mwindows", {force = true}) - -- 复制资源 + -- 复制资源到输出目录 after_build(function (target) local romfs = path.join(example_dir, "romfs") if os.isdir(romfs) then local target_dir = path.directory(target:targetfile()) local assets_dir = path.join(target_dir, "assets") + + -- 创建 assets 目录 if not os.isdir(assets_dir) then os.mkdir(assets_dir) end - os.cp(path.join(romfs, "assets/*"), assets_dir) + + -- 复制所有资源文件(包括子目录) + os.cp(path.join(romfs, "assets/**"), assets_dir) print("Copied assets from " .. romfs .. " to " .. assets_dir) else print("Warning: romfs directory not found at " .. romfs) end end) + + -- 打包时将资源复制到 package 目录 + after_package(function (target) + local target_dir = path.directory(target:targetfile()) + local assets_dir = path.join(target_dir, "assets") + local package_dir = target:packagedir() + if os.isdir(assets_dir) and package_dir then + local package_assets = path.join(package_dir, "assets") + if not os.isdir(package_assets) then + os.mkdir(package_assets) + end + os.cp(path.join(assets_dir, "**"), package_assets) + print("Copied assets to package: " .. package_assets) + end + end) end target_end() diff --git a/examples/spatial_index_demo/xmake.lua b/examples/spatial_index_demo/xmake.lua index 6916886..f16751f 100644 --- a/examples/spatial_index_demo/xmake.lua +++ b/examples/spatial_index_demo/xmake.lua @@ -20,6 +20,7 @@ target("spatial_index_demo") set_toolchains("switch") set_targetdir("../../build/examples/spatial_index_demo") + -- 构建后生成 NRO 文件 after_build(function (target) local devkitPro = os.getenv("DEVKITPRO") or "C:/devkitPro" local elf_file = target:targetfile() @@ -37,6 +38,17 @@ target("spatial_index_demo") else os.vrunv(elf2nro, {elf_file, nro_file, "--nacp=" .. nacp_file}) end + print("Generated NRO: " .. nro_file) + end + end) + + -- 打包时将 NRO 文件复制到 package 目录 + after_package(function (target) + local nro_file = path.join(target:targetdir(), "spatial_index_demo.nro") + local package_dir = target:packagedir() + if os.isfile(nro_file) and package_dir then + os.cp(nro_file, package_dir) + print("Copied NRO to package: " .. package_dir) end end) @@ -46,20 +58,39 @@ target("spatial_index_demo") set_targetdir("../../build/examples/spatial_index_demo") add_ldflags("-mwindows", {force = true}) - -- 复制资源 + -- 复制资源到输出目录 after_build(function (target) local romfs = path.join(example_dir, "romfs") if os.isdir(romfs) then local target_dir = path.directory(target:targetfile()) local assets_dir = path.join(target_dir, "assets") + + -- 创建 assets 目录 if not os.isdir(assets_dir) then os.mkdir(assets_dir) end - os.cp(path.join(romfs, "assets/*"), assets_dir) + + -- 复制所有资源文件(包括子目录) + os.cp(path.join(romfs, "assets/**"), assets_dir) print("Copied assets from " .. romfs .. " to " .. assets_dir) else print("Warning: romfs directory not found at " .. romfs) end end) + + -- 打包时将资源复制到 package 目录 + after_package(function (target) + local target_dir = path.directory(target:targetfile()) + local assets_dir = path.join(target_dir, "assets") + local package_dir = target:packagedir() + if os.isdir(assets_dir) and package_dir then + local package_assets = path.join(package_dir, "assets") + if not os.isdir(package_assets) then + os.mkdir(package_assets) + end + os.cp(path.join(assets_dir, "**"), package_assets) + print("Copied assets to package: " .. package_assets) + end + end) end target_end()