local example_dir = os.scriptdir() target("image_display_demo") set_kind("binary") add_files("main.cpp") add_includedirs("../../include") add_deps("extra2d") if is_plat("switch") then set_targetdir("../../build/examples/image_display_demo") after_build(function (target) local devkitPro = os.getenv("DEVKITPRO") or "C:/devkitPro" local elf_file = target:targetfile() local output_dir = path.directory(elf_file) local nacp_file = path.join(output_dir, "image_display_demo.nacp") local nro_file = path.join(output_dir, "image_display_demo.nro") local nacptool = path.join(devkitPro, "tools/bin/nacptool.exe") local elf2nro = path.join(devkitPro, "tools/bin/elf2nro.exe") local romfs = path.join(example_dir, "romfs") local assets_source = path.join(example_dir, "../scene_graph_demo/romfs/assets") local assets_target = path.join(romfs, "assets") local shader_source = path.join(example_dir, "../../shader") local shader_target = path.join(romfs, "shader") if not os.isdir(romfs) then os.mkdir(romfs) end if not os.isdir(assets_target) then os.mkdir(assets_target) end if os.isdir(assets_source) then os.cp(path.join(assets_source, "**"), assets_target) end if os.isdir(shader_source) then if not os.isdir(shader_target) then os.mkdir(shader_target) end os.cp(path.join(shader_source, "*"), shader_target) end if os.isfile(nacptool) and os.isfile(elf2nro) then os.vrunv(nacptool, {"--create", "Image Display Demo", "Extra2D Team", "1.0.0", nacp_file}) if os.isdir(romfs) then os.vrunv(elf2nro, {elf_file, nro_file, "--nacp=" .. nacp_file, "--romfsdir=" .. romfs}) else os.vrunv(elf2nro, {elf_file, nro_file, "--nacp=" .. nacp_file}) end end end) elseif is_plat("mingw") then set_targetdir("../../build/examples/image_display_demo") after_build(function (target) local target_dir = path.directory(target:targetfile()) local assets_dir = path.join(target_dir, "assets") local assets_source = path.join(example_dir, "../scene_graph_demo/romfs/assets") local shader_source = path.join(example_dir, "../../shader") local shader_target = path.join(target_dir, "shader") if not os.isdir(assets_dir) then os.mkdir(assets_dir) end if os.isdir(assets_source) then os.cp(path.join(assets_source, "**"), assets_dir) print("Copied assets from " .. assets_source .. " to " .. assets_dir) end if os.isdir(shader_source) then if not os.isdir(shader_target) then os.mkdir(shader_target) end os.cp(path.join(shader_source, "*"), shader_target) print("Copied shaders from " .. shader_source .. " to " .. shader_target) end end) end target_end()