REDRIVER2/src_rebuild/premake5.lua

249 lines
5.5 KiB
Lua
Raw Normal View History

-- premake5.lua
require "premake_modules/usage"
require "premake_modules/emscripten"
------------------------------------------
newoption {
trigger = "raspberry-pi",
description = "adds specific define for compiling on Raspberry Pi"
}
table.insert(premake.option.get("os").allowed, { "emscripten", "Emscripten" })
------------------------------------------
2020-07-24 18:15:59 +02:00
-- you can redefine dependencies
SDL2_DIR = os.getenv("SDL2_DIR") or "dependencies/SDL2"
OPENAL_DIR = os.getenv("OPENAL_DIR") or "dependencies/openal-soft"
JPEG_DIR = os.getenv("JPEG_DIR") or "dependencies/jpeg"
WEBDEMO_DIR = os.getenv("WEBDEMO_DIR") or "../../../content/web_demo@/" -- FIXME: make it better
2021-07-09 13:40:06 +02:00
RED2_DIR = os.getenv("RED2_DIR") or "../../data@/"
WEBSHELL_PATH = "../platform/Emscripten" -- must be relative to makefile path (SADLY)
GAME_REGION = os.getenv("GAME_REGION") or "NTSC_VERSION" -- or PAL_VERSION
GAME_VERSION = os.getenv("APPVEYOR_BUILD_VERSION") or nil
if not (GAME_REGION == "NTSC_VERSION" or GAME_REGION == "PAL_VERSION") then
error("'GAME_REGION' should be 'NTSC_VERSION' or 'PAL_VERSION'")
2020-07-24 18:15:59 +02:00
end
------------------------------------------
workspace "REDRIVER2"
location "project_%{_ACTION}_%{os.target()}"
configurations { "Debug", "Release", "Release_dev" }
2020-07-24 18:15:59 +02:00
defines { VERSION }
if os.target() == "emscripten" then
platforms { "emscripten" }
buildoptions {
"-s TOTAL_MEMORY=1073741824",
"-s USE_SDL=2",
"-s FULL_ES2=1",
2021-06-22 06:17:18 +02:00
--"-s USE_WEBGL2=1",
"-s ASYNCIFY=1",
"-s ALLOW_MEMORY_GROWTH=1",
"-s GL_TESTING=1",
"-Wno-c++11-narrowing",
"-Wno-constant-conversion",
"-Wno-writable-strings",
"-Wno-unused-value",
"-Wno-switch",
"-Wno-shift-op-parentheses",
"-Wno-parentheses",
"-Wno-format",
}
linkoptions {
"-s TOTAL_MEMORY=1073741824",
"-s USE_SDL=2",
"-s FULL_ES2=1",
2021-06-22 06:17:18 +02:00
--"-s USE_WEBGL2=1",
"-s ASYNCIFY=1",
"-s ALLOW_MEMORY_GROWTH=1",
"-s GL_TESTING=1",
("--shell-file " .. WEBSHELL_PATH .. "/shell.html"),
2021-07-09 13:40:06 +02:00
("--preload-file " .. WEBDEMO_DIR),
("--preload-file " .. RED2_DIR),
"-s 'EXPORTED_RUNTIME_METHODS=[\"ccall\", \"writeArrayToMemory\"]'"
}
filter { "kind:*App" }
targetextension ".html"
postbuildcommands {
"{COPY} " .. WEBSHELL_PATH .. "/style.css %{cfg.buildtarget.directory}",
"{COPY} " .. WEBSHELL_PATH .. "/lsfs.js %{cfg.buildtarget.directory}"
}
else
platforms { "x86" } --, "x86_64" }
end
startproject "REDRIVER2"
configuration "raspberry-pi"
defines { "__RPI__" }
filter "system:Linux"
buildoptions {
"-Wno-narrowing",
"-Wno-endif-labels",
"-Wno-write-strings",
"-Wno-format-security",
"-Wno-unused-result",
"-fpermissive"
}
cppdialect "C++11"
2020-12-10 22:06:44 +01:00
filter {"system:Linux", "platforms:x86"}
buildoptions {
"-m32"
}
linkoptions {
"-m32"
}
filter "system:Windows"
disablewarnings { "4996", "4554", "4244", "4101", "4838", "4309" }
filter "configurations:Debug"
defines {
"_DEBUG",
"DEBUG"
}
symbols "On"
filter "configurations:Release"
defines {
"NDEBUG",
}
filter "configurations:Release_dev"
defines {
"NDEBUG",
}
if os.target() == "windows" or os.target() == "emscripten" then
include "premake_libjpeg.lua"
end
-- Psy-Cross layer
2022-01-20 19:57:57 +01:00
include "premake5_psycross.lua"
-- game iteslf
project "REDRIVER2"
kind "WindowedApp"
language "c++"
targetdir "bin/%{cfg.buildcfg}"
includedirs {
2020-12-28 11:28:40 +01:00
"Game",
}
uses {
"PsyCross",
}
defines { GAME_REGION }
defines { "BUILD_CONFIGURATION_STRING=\"%{cfg.buildcfg}\"" }
if GAME_VERSION ~= nil then
local resVersion = string.gsub(GAME_VERSION, "%.", ",")
defines{ "GAME_VERSION_N=\""..GAME_VERSION.."\"" }
defines{ "GAME_VERSION_RES="..resVersion.."" }
end
files {
2020-12-28 11:28:40 +01:00
"Game/**.h",
"Game/**.c"
}
filter {"system:Windows or linux or platforms:emscripten"}
--dependson { "PsyX" }
links { "jpeg" }
files {
"utils/**.h",
"utils/**.cpp",
"utils/**.c",
"redriver2_psxpc.cpp",
"DebugOverlay.cpp",
}
filter "platforms:emscripten"
includedirs {
OPENAL_DIR.."/include",
JPEG_DIR.."/",
2021-07-09 13:40:06 +02:00
}
files {
"platform/Emscripten/*.cpp",
}
filter "system:Windows"
entrypoint "mainCRTStartup"
2021-07-09 13:40:06 +02:00
files { -- TEMP
"platform/Emscripten/*.h",
"platform/Emscripten/*.css",
"platform/Emscripten/*.html",
}
2021-07-10 10:15:53 +02:00
files {
2021-07-09 13:40:06 +02:00
"platform/Windows/resource.h",
"platform/Windows/Resource.rc",
"platform/Windows/main.ico"
}
includedirs {
2020-07-24 18:15:59 +02:00
SDL2_DIR.."/include",
OPENAL_DIR.."/include",
JPEG_DIR.."/",
}
linkoptions {
"/SAFESEH:NO", -- Image Has Safe Exception Handers: No. Because of openal-soft
}
filter "system:linux"
includedirs {
"/usr/include/SDL2"
}
links {
"GL",
"openal",
"SDL2",
2020-11-19 16:27:50 +01:00
"dl",
}
filter "configurations:Debug"
targetsuffix "_dbg"
defines {
"DEBUG_OPTIONS",
"COLLISION_DEBUG",
"CUTSCENE_RECORDER"
}
symbols "On"
filter "configurations:Release"
2020-12-20 11:40:16 +01:00
optimize "Speed"
filter "configurations:Release_dev"
targetsuffix "_dev"
defines {
"DEBUG_OPTIONS",
"COLLISION_DEBUG",
"CUTSCENE_RECORDER"
}
optimize "Speed"
filter { "files:**.c", "files:**.C" }
compileas "C++"