Add Switch game framework target
This commit is contained in:
@@ -35,6 +35,7 @@ if is_plat("windows") then
|
||||
target("Frostbite2DGame")
|
||||
set_kind("binary")
|
||||
add_files("game/src/**.cpp")
|
||||
remove_files("game/src/switch_game_main.cpp")
|
||||
add_deps("Frostbite2D")
|
||||
add_packages("libsdl2")
|
||||
add_packages("libsdl2_image")
|
||||
@@ -49,3 +50,35 @@ if is_plat("windows") then
|
||||
end)
|
||||
target_end()
|
||||
end
|
||||
|
||||
if is_plat("switch") then
|
||||
target("Frostbite2DGameSwitch")
|
||||
set_kind("binary")
|
||||
set_filename("Frostbite2DGame.elf")
|
||||
add_files("game/src/**.cpp")
|
||||
remove_files("game/src/main.cpp")
|
||||
add_deps("Frostbite2D")
|
||||
add_cxflags("-D__SWITCH__", "-fPIE", {public = true})
|
||||
add_ldflags("-specs=" .. path.join(os.getenv("DEVKITPRO") or "C:/devkitPro", "libnx/switch.specs"), "-fPIE", {force = true})
|
||||
after_build(function (target)
|
||||
local outdir = path.join(target:targetdir(), "switch_game")
|
||||
os.mkdir(outdir)
|
||||
os.cp(path.join(os.projectdir(), "game/assets"),
|
||||
path.join(outdir, "assets"))
|
||||
|
||||
local devkitpro = os.getenv("DEVKITPRO") or "C:/devkitPro"
|
||||
local tools = path.join(devkitpro, "tools/bin")
|
||||
local libnx = path.join(devkitpro, "libnx")
|
||||
local nacp = path.join(outdir, "control.nacp")
|
||||
local nro = path.join(outdir, "NSUnknownGame.nro")
|
||||
os.execv(path.join(tools, "nacptool.exe"), {
|
||||
"--create", "NS Unknown Game", "Frostbite2D", "1.0.0", nacp
|
||||
})
|
||||
os.execv(path.join(tools, "elf2nro.exe"), {
|
||||
target:targetfile(), nro,
|
||||
"--nacp=" .. nacp,
|
||||
"--icon=" .. path.join(libnx, "default_icon.jpg")
|
||||
})
|
||||
end)
|
||||
target_end()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user