summaryrefslogtreecommitdiffstatshomepage
path: root/scripts/genie.lua
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/genie.lua')
-rw-r--r--scripts/genie.lua822
1 files changed, 366 insertions, 456 deletions
diff --git a/scripts/genie.lua b/scripts/genie.lua
index 707fc4d1d79..819b753e794 100644
--- a/scripts/genie.lua
+++ b/scripts/genie.lua
@@ -14,8 +14,6 @@ newoption {
premake.check_paths = true
premake.make.override = { "TARGET" }
-premake.xcode.parameters = { 'CLANG_CXX_LANGUAGE_STANDARD = "c++14"', 'CLANG_CXX_LIBRARY = "libc++"' }
-
MAME_DIR = (path.getabsolute("..") .. "/")
--MAME_DIR = string.gsub(MAME_DIR, "(%s)", "\\%1")
local MAME_BUILD_DIR = (MAME_DIR .. _OPTIONS["build-dir"] .. "/")
@@ -37,30 +35,37 @@ end
function str_to_version(str)
local val = 0
- if (str == nil or str == '') then
+ if not str then
return val
end
- local cnt = 10000
- for word in string.gmatch(str, '([^.]+)') do
- val = val + tonumber(word) * cnt
- cnt = cnt / 100
+ local scale = 10000
+ for word, sep in str:gmatch('([^.-]+)([.-]?)') do
+ local part = tonumber(word)
+ if not part then
+ return val
+ end
+ val = val + tonumber(word) * scale
+ scale = scale // 100
+ if (scale == 0) or (sep ~= '.') then
+ return val
+ end
end
return val
end
function findfunction(x)
assert(type(x) == "string")
- local f=_G
+ local f = _G
for v in x:gmatch("[^%.]+") do
- if type(f) ~= "table" then
- return nil, "looking for '"..v.."' expected table, not "..type(f)
- end
- f=f[v]
+ if type(f) ~= "table" then
+ return nil, "looking for '" .. v .. "' expected table, not " .. type(f)
+ end
+ f = f[v]
end
if type(f) == "function" then
- return f
+ return f
else
- return nil, "expected function, not "..type(f)
+ return nil, "expected function, not " .. type(f)
end
end
@@ -71,8 +76,7 @@ end
function precompiledheaders()
if _OPTIONS["precompile"]==nil or (_OPTIONS["precompile"]~=nil and _OPTIONS["precompile"]=="1") then
- configuration { "not xcode4" }
- pchheader("emu.h")
+ pchheader("emu.h")
configuration { }
end
end
@@ -90,19 +94,20 @@ end
function addprojectflags()
local version = str_to_version(_OPTIONS["gcc_version"])
if _OPTIONS["gcc"]~=nil and string.find(_OPTIONS["gcc"], "gcc") then
- if version >= 50100 then
- buildoptions_cpp {
- "-Wsuggest-override",
- }
- end
- if version >= 60000 then
- buildoptions_cpp {
- "-flifetime-dse=1",
- }
- end
+ buildoptions_cpp {
+ "-Wsuggest-override",
+ }
end
end
+function opt_tool(hash, entry)
+ if _OPTIONS["with-tools"] then
+ hash[entry] = true
+ return true
+ end
+ return hash[entry]
+end
+
CPUS = {}
SOUNDS = {}
MACHINES = {}
@@ -116,6 +121,11 @@ newoption {
}
newoption {
+ trigger = "with-emulator",
+ description = "Enable building emulator.",
+}
+
+newoption {
trigger = "with-tests",
description = "Enable building tests.",
}
@@ -139,31 +149,11 @@ newoption {
{ "freebsd", "FreeBSD" },
{ "netbsd", "NetBSD" },
{ "openbsd", "OpenBSD" },
- { "pnacl", "Native Client - PNaCl" },
{ "linux", "Linux" },
- { "ios", "iOS" },
{ "macosx", "OSX" },
{ "windows", "Windows" },
{ "haiku", "Haiku" },
{ "solaris", "Solaris SunOS" },
- { "steamlink", "Steam Link" },
- { "rpi", "Raspberry Pi" },
- { "ci20", "Creator-Ci20" },
- },
-}
-
-newoption {
- trigger = 'with-bundled-sdl2',
- description = 'Build bundled SDL2 library',
-}
-
-newoption {
- trigger = "distro",
- description = "Choose distribution",
- allowed = {
- { "generic", "generic" },
- { "debian-stable", "debian-stable" },
- { "ubuntu-intrepid", "ubuntu-intrepid" },
},
}
@@ -198,6 +188,11 @@ newoption {
}
newoption {
+ trigger = "AR",
+ description = "AR replacement",
+}
+
+newoption {
trigger = "TOOLCHAIN",
description = "Toolchain prefix"
}
@@ -341,15 +336,6 @@ newoption {
}
newoption {
- trigger = "FASTDEBUG",
- description = "Fast DEBUG.",
- allowed = {
- { "0", "Disabled" },
- { "1", "Enabled" },
- }
-}
-
-newoption {
trigger = "SEPARATE_BIN",
description = "Use separate bin folders.",
allowed = {
@@ -397,6 +383,11 @@ newoption {
}
newoption {
+ trigger = "SOURCEFILTER",
+ description = "Filter list specifying sources to compile.",
+}
+
+newoption {
trigger = "PLATFORM",
description = "Target machine platform (x86,arm,...)",
}
@@ -434,7 +425,7 @@ else
LIBTYPE = "StaticLib"
end
-PYTHON = "python"
+PYTHON = "python3"
if _OPTIONS["PYTHON_EXECUTABLE"]~=nil then
PYTHON = _OPTIONS["PYTHON_EXECUTABLE"]
@@ -460,11 +451,7 @@ if (_OPTIONS["subtarget"] == nil) then return false end
if (_OPTIONS["target"] == _OPTIONS["subtarget"]) then
solution (_OPTIONS["target"])
else
- if (_OPTIONS["subtarget"]=="mess") then
- solution (_OPTIONS["subtarget"])
- else
- solution (_OPTIONS["target"] .. _OPTIONS["subtarget"])
- end
+ solution (_OPTIONS["target"] .. _OPTIONS["subtarget"])
end
@@ -473,28 +460,26 @@ configurations {
"Release",
}
-if _ACTION == "xcode4" then
- platforms {
- "x64",
- }
-else
- platforms {
- "x32",
- "x64",
- "Native", -- for targets where bitness is not specified
- }
-end
+platforms {
+ "x32",
+ "x64",
+ "Native", -- for targets where bitness is not specified
+}
language "C++"
flags {
"StaticRuntime",
+ "Cpp17",
}
configuration { "vs20*" }
buildoptions {
"/bigobj",
}
+ buildoptions_cpp {
+ "/Zc:__cplusplus",
+ }
flags {
"ExtraWarnings",
}
@@ -517,54 +502,14 @@ configuration { "Release", "vs20*" }
"NoEditAndContinue",
"NoIncrementalLink",
}
-
-configuration { "vsllvm" }
- buildoptions {
- "/bigobj",
- }
- flags {
- "NoPCH",
- "ExtraWarnings",
- }
- if not _OPTIONS["NOWERROR"] then
- flags{
- "FatalWarnings",
+ if _OPTIONS["SYMBOLS"] then
+ flags {
+ "Symbols",
}
end
-
-configuration { "Debug", "vsllvm" }
- flags {
- "Symbols",
- "NoMultiProcessorCompilation",
- }
-
-configuration { "Release", "vsllvm" }
- flags {
- "Optimize",
- "NoEditAndContinue",
- "NoIncrementalLink",
- }
-
--- Force VS2015/17 targets to use bundled SDL2
-if string.sub(_ACTION,1,4) == "vs20" and _OPTIONS["osd"]=="sdl" then
- if _OPTIONS["with-bundled-sdl2"]==nil then
- _OPTIONS["with-bundled-sdl2"] = "1"
- end
-end
--- Build SDL2 for Android
-if _OPTIONS["targetos"] == "android" then
- _OPTIONS["with-bundled-sdl2"] = "1"
-end
-
configuration {}
-if _OPTIONS["osd"] == "uwp" then
- windowstargetplatformversion("10.0.14393.0")
- windowstargetplatformminversion("10.0.14393.0")
- premake._filelevelconfig = true
-end
-
msgcompile ("Compiling $(subst ../,,$<)...")
msgcompile_objc ("Objective-C compiling $(subst ../,,$<)...")
@@ -579,18 +524,33 @@ msgprecompile ("Precompiling $(subst ../,,$<)...")
messageskip { "SkipCreatingMessage", "SkipBuildingMessage", "SkipCleaningMessage" }
-if (_OPTIONS["PROJECT"] ~= nil) then
- PROJECT_DIR = path.join(path.getabsolute(".."),"projects",_OPTIONS["PROJECT"]) .. "/"
- if (not os.isfile(path.join("..", "projects", _OPTIONS["PROJECT"], "scripts", "target", _OPTIONS["target"],_OPTIONS["subtarget"] .. ".lua"))) then
- error("File definition for TARGET=" .. _OPTIONS["target"] .. " SUBTARGET=" .. _OPTIONS["subtarget"] .. " does not exist")
- end
- dofile (path.join(".." ,"projects", _OPTIONS["PROJECT"], "scripts", "target", _OPTIONS["target"],_OPTIONS["subtarget"] .. ".lua"))
-end
-if (_OPTIONS["SOURCES"] == nil and _OPTIONS["PROJECT"] == nil) then
- if (not os.isfile(path.join("target", _OPTIONS["target"],_OPTIONS["subtarget"] .. ".lua"))) then
- error("File definition for TARGET=" .. _OPTIONS["target"] .. " SUBTARGET=" .. _OPTIONS["subtarget"] .. " does not exist")
+if _OPTIONS["with-emulator"] then
+ if (_OPTIONS["PROJECT"] ~= nil) then
+ PROJECT_DIR = path.join(path.getabsolute(".."),"projects",_OPTIONS["PROJECT"]) .. "/"
+ if (not os.isfile(path.join("..", "projects", _OPTIONS["PROJECT"], "scripts", "target", _OPTIONS["target"],_OPTIONS["subtarget"] .. ".lua"))) then
+ error("File definition for TARGET=" .. _OPTIONS["target"] .. " SUBTARGET=" .. _OPTIONS["subtarget"] .. " does not exist")
+ end
+ dofile (path.join(".." ,"projects", _OPTIONS["PROJECT"], "scripts", "target", _OPTIONS["target"],_OPTIONS["subtarget"] .. ".lua"))
+ elseif (_OPTIONS["SOURCES"] == nil) and (_OPTIONS["SOURCEFILTER"] == nil) then
+ local subtargetscript = path.join("target", _OPTIONS["target"], _OPTIONS["subtarget"] .. ".lua")
+ local subtargetfilter = path.join(MAME_DIR, "src", _OPTIONS["target"], _OPTIONS["subtarget"] .. ".flt")
+ if os.isfile(subtargetscript) then
+ dofile(subtargetscript)
+ elseif os.isfile(subtargetfilter) then
+ local makedep = path.join(MAME_DIR, "scripts", "build", "makedep.py")
+ local driverlist = path.join(MAME_DIR, "src", _OPTIONS["target"], _OPTIONS["target"] .. ".lst")
+ local OUT_STR = os.outputof(
+ string.format(
+ "%s %s -r %s filterproject -t %s -f %s %s",
+ PYTHON, makedep, MAME_DIR, _OPTIONS["subtarget"], subtargetfilter, driverlist))
+ if #OUT_STR == 0 then
+ error("Error creating projects from driver filter file for subtarget " .. _OPTIONS["subtarget"])
+ end
+ load(OUT_STR)()
+ else
+ error("Definition file for TARGET=" .. _OPTIONS["target"] .. " SUBTARGET=" .. _OPTIONS["subtarget"] .. " does not exist")
+ end
end
- dofile (path.join("target", _OPTIONS["target"],_OPTIONS["subtarget"] .. ".lua"))
end
configuration { "gmake or ninja" }
@@ -600,21 +560,9 @@ configuration { "gmake or ninja" }
dofile ("toolchain.lua")
-if _OPTIONS["targetos"]=="windows" then
- configuration { "x64" }
- defines {
- "X64_WINDOWS_ABI",
- }
- configuration { }
-end
-
-- Avoid error when invoking genie --help.
if (_ACTION == nil) then return false end
--- define PTR64 if we are a 64-bit target
-configuration { "x64 or android-*64"}
- defines { "PTR64=1" }
-
-- define MAME_DEBUG if we are a debugging build
configuration { "Debug" }
defines {
@@ -623,13 +571,6 @@ configuration { "Debug" }
-- "BGFX_CONFIG_DEBUG=1",
}
-if _OPTIONS["FASTDEBUG"]=="1" then
- defines {
- "MAME_DEBUG_FAST",
- "NDEBUG",
- }
-end
-
configuration { }
if _OPTIONS["PROFILER"]=="1" then
@@ -692,14 +633,21 @@ else
"LSB_FIRST",
}
if _OPTIONS["targetos"]=="macosx" then
- configuration { "x64" }
+ configuration { "arm64" }
+ buildoptions {
+ "-arch arm64",
+ }
+ linkoptions {
+ "-arch arm64",
+ }
+ configuration { "x64", "not arm64" }
buildoptions {
"-arch x86_64",
}
linkoptions {
"-arch x86_64",
}
- configuration { "x32" }
+ configuration { "x32", "not arm64" }
buildoptions {
"-arch i386",
}
@@ -732,24 +680,22 @@ else
}
end
-if _OPTIONS["NOASM"]=="1" then
+if _OPTIONS["NOASM"] == "1" then
defines {
"MAME_NOASM"
}
end
-if not _OPTIONS["FORCE_DRC_C_BACKEND"] then
- if _OPTIONS["BIGENDIAN"]~="1" then
- configuration { "x64" }
- defines {
- "NATIVE_DRC=drcbe_x64",
- }
- configuration { "x32" }
- defines {
- "NATIVE_DRC=drcbe_x86",
- }
- configuration { }
- end
+if _OPTIONS["FORCE_DRC_C_BACKEND"] then
+ configuration { }
+ defines {
+ "NATIVE_DRC=drcbe_c",
+ }
+elseif (_OPTIONS["PLATFORM"] == "x86") or (_OPTIONS["PLATFORM"] == "arm64") then
+ configuration { }
+ defines {
+ "ASMJIT_STATIC",
+ }
end
defines {
@@ -767,33 +713,17 @@ end
}
local version = str_to_version(_OPTIONS["gcc_version"])
-if string.find(_OPTIONS["gcc"], "clang") and ((version < 30500) or (_OPTIONS["targetos"]=="macosx" and (version <= 60000))) then
- buildoptions_cpp {
- "-x c++",
- "-std=c++1y",
- }
-
- buildoptions_objcpp {
- "-x objective-c++",
- "-std=c++1y",
- }
-else
buildoptions_cpp {
- "-x c++",
- "-std=c++14",
+ "-std=c++17",
}
buildoptions_objcpp {
- "-x objective-c++",
- "-std=c++14",
+ "-std=c++17",
}
-end
-- this speeds it up a bit by piping between the preprocessor/compiler/assembler
- if not ("pnacl" == _OPTIONS["gcc"]) then
- buildoptions {
- "-pipe",
- }
- end
+ buildoptions {
+ "-pipe",
+ }
-- add -g if we need symbols, and ensure we have frame pointers
if _OPTIONS["SYMBOLS"]~=nil and _OPTIONS["SYMBOLS"]~="0" then
buildoptions {
@@ -914,6 +844,7 @@ end
configuration { "mingw-clang" }
buildoptions {
"-Xclang -flto-visibility-public-std", -- workround for __imp___ link errors
+ "-Wno-nonportable-include-path", -- workround for clang 9.0.0 case sensitivity bug when including GL/glext.h
}
configuration { }
@@ -1013,11 +944,11 @@ end
buildoptions {
"-Wall",
"-Wcast-align",
- "-Wundef",
"-Wformat-security",
+ "-Wundef",
"-Wwrite-strings",
- "-Wno-sign-compare",
"-Wno-conversion",
+ "-Wno-sign-compare",
"-Wno-error=deprecated-declarations",
}
-- warnings only applicable to C compiles
@@ -1040,6 +971,7 @@ end
-- warnings only applicable to C++ compiles
buildoptions_cpp {
"-Woverloaded-virtual",
+ "-Wvla",
}
if _OPTIONS["SANITIZE"] then
@@ -1078,61 +1010,73 @@ end
local version = str_to_version(_OPTIONS["gcc_version"])
- if string.find(_OPTIONS["gcc"], "clang") or string.find(_OPTIONS["gcc"], "pnacl") or string.find(_OPTIONS["gcc"], "asmjs") or string.find(_OPTIONS["gcc"], "android") then
- if (version < 30400) then
- print("Clang version 3.4 or later needed")
+ if string.find(_OPTIONS["gcc"], "clang") or string.find(_OPTIONS["gcc"], "asmjs") or string.find(_OPTIONS["gcc"], "android") then
+ if version < 70000 then
+ print("Clang version 7.0 or later needed")
os.exit(-1)
end
buildoptions {
+ "-fdiagnostics-show-note-include-stack",
+ "-Wno-error=tautological-compare",
"-Wno-cast-align",
- "-Wno-tautological-compare",
- "-Wno-unused-value",
"-Wno-constant-logical-operand",
- "-Wno-missing-braces", -- clang is not as permissive as GCC about std::array initialization
- "-fdiagnostics-show-note-include-stack",
+ "-Wno-extern-c-compat",
+ "-Wno-ignored-qualifiers",
+ "-Wno-pragma-pack", -- clang 6.0 complains when the packing change lifetime is not contained within a header file.
+ "-Wno-unknown-attributes",
+ "-Wno-unknown-warning-option",
+ "-Wno-unused-value",
+ "-Wno-unused-const-variable",
}
- if (version >= 30500) then
+ if ((version >= 100000) and (_OPTIONS["targetos"] ~= 'macosx')) or (version >= 120000) then
buildoptions {
- "-Wno-unknown-warning-option",
- "-Wno-extern-c-compat",
- "-Wno-unknown-attributes",
- "-Wno-ignored-qualifiers"
+ "-Wno-xor-used-as-pow", -- clang 10.0 complains that expressions like 10 ^ 7 look like exponention
}
end
- if (version >= 60000) then
+ if version >= 140000 then
buildoptions {
- "-Wno-pragma-pack" -- clang 6.0 complains when the packing change lifetime is not contained within a header file.
+ "-Wno-bitwise-instead-of-logical", -- clang 14.0 complains about &, | on bools in asmjit
}
end
else
- if (version < 50000) then
- print("GCC version 5.0 or later needed")
+ if version < 100300 then
+ print("GCC version 10.3 or later needed")
os.exit(-1)
end
+ buildoptions_cpp {
+ "-Wimplicit-fallthrough",
+ }
+ buildoptions_objcpp {
+ "-Wimplicit-fallthrough",
+ }
+ buildoptions {
+ "-Wno-error=unused-result", -- needed for fgets,fread on linux
+ -- array bounds checking seems to be buggy in 4.8.1 (try it on video/stvvdp1.c and video/model1.c without -Wno-array-bounds)
+ "-Wno-error=array-bounds",
+ "-Wno-error=attributes", -- GCC fails to recognize some uses of [[maybe_unused]]
+ "-Wno-error=stringop-truncation", -- ImGui again
+ "-Wno-stringop-overflow", -- generates false positives when assigning an int rvalue to a u8 variable without an explicit cast
+ }
+ if version >= 110000 then
buildoptions {
- "-Wno-unused-result", -- needed for fgets,fread on linux
- -- array bounds checking seems to be buggy in 4.8.1 (try it on video/stvvdp1.c and video/model1.c without -Wno-array-bounds)
- "-Wno-array-bounds",
+ "-Wno-nonnull", -- luaengine.cpp lambdas do not need "this" captured but GCC 11.1 erroneously insists
+ "-Wno-stringop-overread", -- machine/bbc.cpp in GCC 11.1
}
- if (version >= 80000) then
+ end
+ if version >= 120000 then
buildoptions {
- "-Wno-format-overflow", -- try machine/bfm_sc45_helper.cpp in GCC 8.0.1, among others
- "-Wno-stringop-truncation", -- ImGui again
- "-Wno-stringop-overflow", -- formats/victor9k_dsk.cpp bugs the compiler
+ "-Wno-error=maybe-uninitialized",
+ "-Wno-error=uninitialized", -- netlist
}
+ end
+ if version >= 130000 then
buildoptions_cpp {
- "-Wno-class-memaccess", -- many instances in ImGui and BGFX
+ "-Wno-xor-used-as-pow",
}
end
end
end
-if (_OPTIONS["PLATFORM"]=="alpha") then
- defines {
- "PTR64=1",
- }
-end
-
if (_OPTIONS["PLATFORM"]=="arm") then
buildoptions {
"-Wno-cast-align",
@@ -1143,21 +1087,6 @@ if (_OPTIONS["PLATFORM"]=="arm64") then
buildoptions {
"-Wno-cast-align",
}
- defines {
- "PTR64=1",
- }
-end
-
-if (_OPTIONS["PLATFORM"]=="riscv64") then
- defines {
- "PTR64=1",
- }
-end
-
-if (_OPTIONS["PLATFORM"]=="mips64") then
- defines {
- "PTR64=1",
- }
end
local subdir
@@ -1178,110 +1107,100 @@ configuration { "asmjs" }
"-s USE_SDL_TTF=2",
}
buildoptions_cpp {
- "-x c++",
- "-std=c++14",
+ "-std=c++17",
+ "-s EXCEPTION_CATCHING_ALLOWED=\"['_ZN15running_machine17start_all_devicesEv','_ZN12cli_frontend7executeEiPPc','_ZN8chd_file11open_commonEb','_ZN8chd_file13read_metadataEjjRNSt3__212basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE','_ZN8chd_file13read_metadataEjjRNSt3__26vectorIhNS0_9allocatorIhEEEE','_ZNK19netlist_mame_device19base_validity_checkER16validity_checker']\"",
+ }
+ defines {
+ "ASIO_HAS_PTHREADS",
}
linkoptions {
"-Wl,--start-group",
- }
+ "-O" .. _OPTIONS["OPTIMIZE"],
+ "-s USE_SDL=2",
+ "-s USE_SDL_TTF=2",
+ "-s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=\"['\\$$ERRNO_CODES']\"",
+ "-s EXPORTED_FUNCTIONS=\"['_main', '_malloc', '__ZN15running_machine30emscripten_get_running_machineEv', '__ZN15running_machine17emscripten_get_uiEv', '__ZN15running_machine20emscripten_get_soundEv', '__ZN15mame_ui_manager12set_show_fpsEb', '__ZNK15mame_ui_manager8show_fpsEv', '__ZN13sound_manager4muteEbh', '_SDL_PauseAudio', '_SDL_SendKeyboardKey', '__ZN15running_machine15emscripten_saveEPKc', '__ZN15running_machine15emscripten_loadEPKc', '__ZN15running_machine21emscripten_hard_resetEv', '__ZN15running_machine21emscripten_soft_resetEv', '__ZN15running_machine15emscripten_exitEv']\"",
+ "-s EXPORTED_RUNTIME_METHODS=\"['cwrap']\"",
+ "-s ERROR_ON_UNDEFINED_SYMBOLS=0",
+ "-s STACK_SIZE=5MB",
+ "-s MAX_WEBGL_VERSION=2",
+ "--pre-js " .. _MAKE.esc(MAME_DIR) .. "src/osd/modules/sound/js_sound.js",
+ "--post-js " .. _MAKE.esc(MAME_DIR) .. "scripts/resources/emscripten/emscripten_post.js",
+ "--embed-file " .. _MAKE.esc(MAME_DIR) .. "bgfx/chains@bgfx/chains",
+ "--embed-file " .. _MAKE.esc(MAME_DIR) .. "bgfx/effects@bgfx/effects",
+ "--embed-file " .. _MAKE.esc(MAME_DIR) .. "bgfx/shaders/essl@bgfx/shaders/essl",
+ "--embed-file " .. _MAKE.esc(MAME_DIR) .. "artwork/bgfx@artwork/bgfx",
+ "--embed-file " .. _MAKE.esc(MAME_DIR) .. "artwork/lut-default.png@artwork/lut-default.png",
+ "--embed-file " .. _MAKE.esc(MAME_DIR) .. "artwork/slot-mask.png@artwork/slot-mask.png",
+ }
+ if _OPTIONS["SYMBOLS"]~=nil and _OPTIONS["SYMBOLS"]~="0" then
+ linkoptions {
+ "-g" .. _OPTIONS["SYMLEVEL"],
+ }
+ end
+ if _OPTIONS["WEBASSEMBLY"] then
+ linkoptions {
+ "-s WASM=" .. _OPTIONS["WEBASSEMBLY"],
+ }
+ else
+ linkoptions {
+ "-s WASM=1",
+ }
+ end
+ if _OPTIONS["WEBASSEMBLY"]~=nil and _OPTIONS["WEBASSEMBLY"]=="0" then
+ -- define a fixed memory size because allowing memory growth disables asm.js optimizations
+ linkoptions {
+ "-s ALLOW_MEMORY_GROWTH=0",
+ "-s INITIAL_MEMORY=256MB",
+ }
+ else
+ linkoptions {
+ "-s ALLOW_MEMORY_GROWTH=1",
+ "-s INITIAL_MEMORY=24MB"
+ }
+ end
archivesplit_size "20"
configuration { "android*" }
buildoptions {
- "-Wno-undef",
- "-Wno-typedef-redefinition",
- "-Wno-unknown-warning-option",
- "-Wno-incompatible-ms-struct",
- }
- buildoptions_cpp {
- "-x c++",
- "-std=c++14",
- "-Wno-extern-c-compat",
- "-Wno-tautological-constant-out-of-range-compare",
- "-Wno-tautological-pointer-compare",
+ "-Wno-error=undef", -- in ASIO
+ "-Wno-error=macro-redefined", -- PAGE_SIZE,PAGE_MASK in fairlight/cmi.cpp
}
archivesplit_size "20"
-configuration { "android-arm64" }
- buildoptions {
- "-Wno-asm-operand-widths",
- }
-
-configuration { "pnacl" }
- buildoptions {
- "-std=gnu89",
- "-Wno-inline-new-delete",
- }
- buildoptions_cpp {
- "-x c++",
- "-std=c++14",
- }
- archivesplit_size "20"
-
-configuration { "linux-* or rpi or ci20"}
+configuration { "linux-*" }
links {
"dl",
"rt",
}
- if _OPTIONS["distro"]=="debian-stable" then
- defines
- {
- "NO_AFFINITY_NP",
- }
- end
-
-
-
-configuration { "steamlink" }
- links {
- "dl",
- "EGL",
- "GLESv2",
- "SDL2",
- }
- defines {
- "EGL_API_FB",
- }
-
-configuration { "rpi" }
- links {
- "SDL2",
- "fontconfig",
- "X11",
- "GLESv2",
- "EGL",
- "bcm_host",
- "vcos",
- "vchiq_arm",
- "pthread",
- }
-
+ flags {
+ "LinkSupportCircularDependencies",
+ }
-configuration { "ci20" }
- links {
- "SDL2",
- "asound",
- "fontconfig",
- "freetype",
- "pthread",
- }
+configuration { "freebsd or netbsd" }
+ flags {
+ "LinkSupportCircularDependencies",
+ }
-configuration { "osx* or xcode4" }
+configuration { "osx*" }
links {
"pthread",
}
configuration { "mingw*" }
- if _OPTIONS["osd"]~="sdl"
- then
+ if _OPTIONS["osd"]=="sdl" then
+ linkoptions {
+ "-Wl,--start-group",
+ }
+ else
linkoptions {
"-static",
}
+ flags {
+ "LinkSupportCircularDependencies",
+ }
end
- linkoptions {
- "-Wl,--start-group",
- }
links {
"user32",
"winmm",
@@ -1295,27 +1214,6 @@ configuration { "mingw*" }
"userenv",
}
-configuration { "mingw-clang" }
- local version = str_to_version(_OPTIONS["gcc_version"])
- if _OPTIONS["gcc"]~=nil and string.find(_OPTIONS["gcc"], "clang") and ((version < 30900)) then
- linkoptions {
- "-pthread",
- }
- end
-
-configuration { "vsllvm" }
- defines {
- "XML_STATIC",
- "WIN32",
- "_WIN32",
- "_CRT_NONSTDC_NO_DEPRECATE",
- "_CRT_SECURE_NO_DEPRECATE",
- "_CRT_STDIO_LEGACY_WIDE_SPECIFIERS",
- }
- includedirs {
- MAME_DIR .. "3rdparty/dxsdk/Include"
- }
-
configuration { "vs20*" }
defines {
"XML_STATIC",
@@ -1326,8 +1224,6 @@ configuration { "vs20*" }
"_CRT_STDIO_LEGACY_WIDE_SPECIFIERS",
}
--- Windows Store/Phone projects already link against the available libraries.
-if _OPTIONS["vs"]==nil or not (string.startswith(_OPTIONS["vs"], "winstore8") or string.startswith(_OPTIONS["vs"], "winphone8")) then
links {
"user32",
"winmm",
@@ -1340,72 +1236,45 @@ if _OPTIONS["vs"]==nil or not (string.startswith(_OPTIONS["vs"], "winstore8") or
"shell32",
"userenv",
}
-end
buildoptions {
- "/WX", -- Treats all compiler warnings as errors.
- "/wd4025", -- warning C4025: 'number' : based pointer passed to function with variable arguments: parameter number
- "/wd4003", -- warning C4003: not enough actual parameters for macro 'xxx'
+ "/Zc:preprocessor",
+ "/utf-8",
+ "/permissive-",
+ "/w45038", -- warning C5038: data member 'member1' will be initialized after data member 'member2'
+ }
+
+ buildoptions {
"/wd4018", -- warning C4018: 'x' : signed/unsigned mismatch
- "/wd4061", -- warning C4061: enumerator 'xxx' in switch of enum 'xxx' is not explicitly handled by a case label
+ "/wd4060", -- warning C4060: switch statement contains no 'case' or 'default' labels
+ "/wd4065", -- warning C4065: switch statement contains 'default' but no 'case' labels
"/wd4100", -- warning C4100: 'xxx' : unreferenced formal parameter
"/wd4127", -- warning C4127: conditional expression is constant
- "/wd4131", -- warning C4131: 'xxx' : uses old-style declarator
- "/wd4141", -- warning C4141: 'xxx' : used more than once
"/wd4146", -- warning C4146: unary minus operator applied to unsigned type, result still unsigned
- "/wd4150", -- warning C4150: deletion of pointer to incomplete type 'xxx'; no destructor called
- "/wd4189", -- warning C4189: 'xxx' : local variable is initialized but not referenced
- "/wd4191", -- warning C4191: 'type cast' : unsafe conversion from 'xxx' to 'xxx' // 64-bit only
"/wd4201", -- warning C4201: nonstandard extension used : nameless struct/union
- "/wd4232", -- warning C4232: nonstandard extension used : 'xxx' : address of dllimport 'xxx' is not static, identity not guaranteed
- "/wd4242", -- warning C4242: 'x' : conversion from 'xxx' to 'xxx', possible loss of data
"/wd4244", -- warning C4244: 'argument' : conversion from 'xxx' to 'xxx', possible loss of data
+ "/wd4245", -- warning C4245: 'conversion' : conversion from 'type1' to 'type2', signed/unsigned mismatch
"/wd4250", -- warning C4250: 'xxx' : inherits 'xxx' via dominance
- "/wd4255", -- warning C4255: 'xxx' : no function prototype given: converting '()' to '(void)'
- "/wd4296", -- warning C4296: 'x' : expression is always false
- "/wd4306", -- warning C4306: 'xxx': conversion from 'type1' to 'type2' of greater size // 64-bit only
+ "/wd4267", -- warning C4267: 'var' : conversion from 'size_t' to 'type', possible loss of data
+ "/wd4305", -- warning C4305: 'conversion': truncation from 'type1' to 'type2'
"/wd4310", -- warning C4310: cast truncates constant value
- "/wd4312", -- warning C4312: 'type cast' : conversion from 'xxx' to 'xxx' of greater size
+ "/wd4319", -- warning C4319: 'operator' : zero extending 'type' to 'type' of greater size
"/wd4324", -- warning C4324: 'xxx' : structure was padded due to __declspec(align())
- "/wd4347", -- warning C4347: behavior change: 'xxx' is called instead of 'xxx' // obsolete VS2005 - VS2010 only
- "/wd4435", -- warning C4435: 'xxx' : Object layout under /vd2 will change due to virtual base 'xxx'
- "/wd4510", -- warning C4510: 'xxx' : default constructor could not be generated
- "/wd4512", -- warning C4512: 'xxx' : assignment operator could not be generated
- "/wd4514", -- warning C4514: 'xxx' : unreferenced inline function has been removed
- "/wd4521", -- warning C4521: 'xxx' : multiple copy constructors specified
- "/wd4571", -- warning C4611: interaction between '_setjmp' and C++ object destruction is non-portable
- "/wd4610", -- warning C4619: #pragma warning : there is no warning number 'xxx'
- "/wd4611", -- warning C4571: Informational: catch(...) semantics changed since Visual C++ 7.1; structured exceptions (SEH) are no longer caught
- "/wd4619", -- warning C4610: struct 'xxx' can never be instantiated - user defined constructor required
- "/wd4625", -- warning C4625: 'xxx' : copy constructor could not be generated because a base class copy constructor is inaccessible or deleted
- "/wd4626", -- warning C4626: 'xxx' : assignment operator could not be generated because a base class assignment operator is inaccessible or deleted
- "/wd4640", -- warning C4640: 'xxx' : construction of local static object is not thread-safe
- "/wd4668", -- warning C4668: 'xxx' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
+ "/wd4334", -- warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
+ "/wd4389", -- warning C4389: 'operator' : signed/unsigned mismatch
+ "/wd4456", -- warning C4456: declaration of 'xxx' hides previous local declaration
+ "/wd4457", -- warning C4457: declaration of 'xxx' hides function parameter
+ "/wd4458", -- warning C4458: declaration of 'xxx' hides class member
+ "/wd4459", -- warning C4459: declaration of 'xxx' hides global declaration
+ "/wd4611", -- warning C4611: interaction between '_setjmp' and C++ object destruction is non-portable
+ "/wd4646", -- warning C4646: function declared with 'noreturn' has non-void return type
+ "/wd4701", -- warning C4701: potentially uninitialized local variable 'name' used
"/wd4702", -- warning C4702: unreachable code
- "/wd4706", -- warning C4706: assignment within conditional expression
- "/wd4710", -- warning C4710: 'xxx' : function not inlined
- "/wd4711", -- warning C4711: function 'xxx' selected for automatic inline expansion // optimized only
"/wd4805", -- warning C4805: 'x' : unsafe mix of type 'xxx' and type 'xxx' in operation
- "/wd4820", -- warning C4820: 'xxx' : 'x' bytes padding added after data member 'xxx'
- "/wd4826", -- warning C4826: Conversion from 'type1 ' to 'type_2' is sign-extended. This may cause unexpected runtime behavior. // 32-bit only
- "/wd4365", -- warning C4365: 'action' : conversion from 'type_1' to 'type_2', signed/unsigned mismatch
- "/wd4389", -- warning C4389: 'operator' : signed/unsigned mismatch
- "/wd4245", -- warning C4245: 'conversion' : conversion from 'type1' to 'type2', signed/unsigned mismatch
- "/wd4388", -- warning C4388: signed/unsigned mismatch
- "/wd4267", -- warning C4267: 'var' : conversion from 'size_t' to 'type', possible loss of data
- "/wd4005", -- warning C4005: The macro identifier is defined twice. The compiler uses the second macro definition
- "/wd4350", -- warning C4350: behavior change: 'member1' called instead of 'member2'
+ "/wd4806", -- warning C4806: 'operation': unsafe operation: no value of type 'type' promoted to type 'type' can equal the given constant
"/wd4996", -- warning C4996: 'function': was declared deprecated
- "/wd4191", -- warning C4191: 'operator/operation' : unsafe conversion from 'type of expression' to 'type required'
- "/wd4060", -- warning C4060: switch statement contains no 'case' or 'default' labels
- "/wd4065", -- warning C4065: switch statement contains 'default' but no 'case' labels
- "/wd4640", -- warning C4640: 'instance' : construction of local static object is not thread-safe
- "/wd4290", -- warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
- "/wd4355", -- warning C4355: 'this' : used in base member initializer list
- "/wd4800", -- warning C4800: 'type' : forcing value to bool 'true' or 'false' (performance warning)
- "/wd4371", -- warning C4371: layout of class may have changed from a previous version of the compiler due to better packing of member 'member'
- "/wd4548", -- warning C4548: expression before comma has no effect; expected expression with side-effect
}
+
if _OPTIONS["vs"]=="intel-15" then
buildoptions {
"/Qwd9", -- remark #9: nested comment is not allowed
@@ -1443,79 +1312,92 @@ if _OPTIONS["vs"]=="intel-15" then
}
end
- linkoptions {
- "/ignore:4221", -- LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
- }
- includedirs {
- MAME_DIR .. "3rdparty/dxsdk/Include"
- }
-configuration { "vs201*" }
- buildoptions {
- "/wd4334", -- warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
- "/wd4456", -- warning C4456: declaration of 'xxx' hides previous local declaration
- "/wd4457", -- warning C4457: declaration of 'xxx' hides function parameter
- "/wd4458", -- warning C4458: declaration of 'xxx' hides class member
- "/wd4459", -- warning C4459: declaration of 'xxx' hides global declaration
- "/wd4838", -- warning C4838: conversion from 'xxx' to 'yyy' requires a narrowing conversion
- "/wd4091", -- warning C4091: 'typedef ': ignored on left of '' when no variable is declared
- "/wd4463", -- warning C4463: overflow; assigning 1 to bit-field that can only hold values from -1 to 0
- "/wd4297", -- warning C4297: 'xxx::~xxx': function assumed not to throw an exception but does
- "/wd4319", -- warning C4319: 'operator' : zero extending 'type' to 'type' of greater size
- "/wd4592", -- warning C4592: symbol will be dynamically initialized (implementation limitation)
- }
-configuration { "winphone8* or winstore8*" }
- linkoptions {
- "/ignore:4264" -- LNK4264: archiving object file compiled with /ZW into a static library; note that when authoring Windows Runtime types it is not recommended to link with a static library that contains Windows Runtime metadata
- }
-configuration { "vsllvm" }
+if _OPTIONS["vs"]=="clangcl" then
buildoptions {
- "-Wno-tautological-constant-out-of-range-compare",
+ "-Wno-enum-conversion",
"-Wno-ignored-qualifiers",
+ "-Wno-missing-braces",
"-Wno-missing-field-initializers",
- "-Wno-ignored-pragma-optimize",
+ "-Wno-new-returns-null",
+ "-Wno-nonportable-include-path",
+ "-Wno-pointer-bool-conversion",
+ "-Wno-pragma-pack",
+ "-Wno-switch",
+ "-Wno-tautological-constant-out-of-range-compare",
+ "-Wno-tautological-pointer-compare",
"-Wno-unknown-warning-option",
+ "-Wno-unused-const-variable",
"-Wno-unused-function",
"-Wno-unused-label",
"-Wno-unused-local-typedef",
- "-Wno-unused-const-variable",
- "-Wno-unused-parameter",
- "-Wno-unneeded-internal-declaration",
"-Wno-unused-private-field",
- "-Wno-missing-braces",
"-Wno-unused-variable",
- "-Wno-tautological-pointer-compare",
- "-Wno-nonportable-include-path",
- "-Wno-enum-conversion",
- "-Wno-pragma-pack",
- "-Wno-new-returns-null",
- "-Wno-sign-compare",
- "-Wno-switch",
- "-Wno-tautological-undefined-compare",
- "-Wno-deprecated-declarations",
- "-Wno-macro-redefined",
- "-Wno-narrowing",
+ "-Wno-xor-used-as-pow",
+ "-Wno-microsoft-cast",
}
+end
-
--- adding this till we sort out asserts in debug mode
-configuration { "Debug", "gmake" }
- buildoptions_cpp {
- "-Wno-terminate",
- }
+ linkoptions {
+ "/ignore:4221", -- LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
+ }
+ includedirs {
+ MAME_DIR .. "3rdparty/dxsdk/Include"
+ }
configuration { }
-if (_OPTIONS["SOURCES"] ~= nil) then
+if _OPTIONS["SOURCES"] ~= nil then
+ if _OPTIONS["SOURCEFILTER"] ~= nil then
+ error("SOURCES and SOURCEFILTER cannot be combined")
+ end
+
+ local makedep = path.join(MAME_DIR, "scripts", "build", "makedep.py")
local str = _OPTIONS["SOURCES"]
+ local sourceargs = ""
for word in string.gmatch(str, '([^,]+)') do
- if (not os.isfile(path.join(MAME_DIR ,word))) then
- print("File " .. word.. " does not exist")
- os.exit()
+ local fullpath = path.join(MAME_DIR, word)
+ if (not os.isfile(fullpath)) and (not os.isdir(fullpath)) then
+ word = path.join("src", _OPTIONS["target"], word)
+ fullpath = path.join(MAME_DIR, word)
+ if (not os.isfile(fullpath)) and (not os.isdir(fullpath)) then
+ error("File/directory " .. word .. " does not exist")
+ end
end
+ sourceargs = sourceargs .. " " .. word
+ end
+
+ local driverlist = path.join(MAME_DIR, "src", _OPTIONS["target"], _OPTIONS["target"] .. ".lst")
+ local OUT_STR = os.outputof(
+ string.format(
+ "%s %s -r %s sourcesproject -t %s -l %s %s",
+ PYTHON, makedep, MAME_DIR, _OPTIONS["subtarget"], driverlist, sourceargs))
+ if #OUT_STR == 0 then
+ error("Error creating projects from specified source files")
+ end
+ load(OUT_STR)()
+
+ local driverlist = path.join(MAME_DIR, "src", _OPTIONS["target"], _OPTIONS["target"] .. ".lst")
+ local driverfilter = path.join(GEN_DIR, _OPTIONS["target"], _OPTIONS["subtarget"] .. ".flt")
+ os.outputof(
+ string.format(
+ "%s %s -r %s sourcesfilter -l %s %s > %s",
+ PYTHON, makedep, MAME_DIR, driverlist, sourceargs, driverfilter))
+elseif _OPTIONS["SOURCEFILTER"] ~= nil then
+ local driverfilter = path.join(MAME_DIR, _OPTIONS["SOURCEFILTER"])
+ if not os.isfile(driverfilter) then
+ error("File " .. _OPTIONS["SOURCEFILTER"] .. " does not exist")
+ end
+
+ local makedep = path.join(MAME_DIR, "scripts", "build", "makedep.py")
+ local driverlist = path.join(MAME_DIR, "src", _OPTIONS["target"], _OPTIONS["target"] .. ".lst")
+ local OUT_STR = os.outputof(
+ string.format(
+ "%s %s -r %s filterproject -t %s -f %s %s",
+ PYTHON, makedep, MAME_DIR, _OPTIONS["subtarget"], driverfilter, driverlist))
+ if #OUT_STR == 0 then
+ error("Error creating projects from specified driver filter file")
end
- OUT_STR = os.outputof( PYTHON .. " " .. MAME_DIR .. "scripts/build/makedep.py " .. MAME_DIR .. " " .. _OPTIONS["SOURCES"] .. " target " .. _OPTIONS["subtarget"])
load(OUT_STR)()
- os.outputof( PYTHON .. " " .. MAME_DIR .. "scripts/build/makedep.py " .. MAME_DIR .. " " .. _OPTIONS["SOURCES"] .. " drivers " .. _OPTIONS["subtarget"] .. " > ".. GEN_DIR .. _OPTIONS["target"] .. "/" .. _OPTIONS["subtarget"]..".flt")
end
group "libs"
@@ -1525,8 +1407,8 @@ if (not os.isfile(path.join("src", "osd", _OPTIONS["osd"] .. ".lua"))) then
end
dofile(path.join("src", "osd", _OPTIONS["osd"] .. ".lua"))
dofile(path.join("src", "lib.lua"))
-if (MACHINES["NETLIST"]~=null or _OPTIONS["with-tools"]) then
-dofile(path.join("src", "netlist.lua"))
+if opt_tool(MACHINES, "NETLIST") then
+ dofile(path.join("src", "netlist.lua"))
end
--if (STANDALONE~=true) then
dofile(path.join("src", "formats.lua"))
@@ -1541,36 +1423,34 @@ group "core"
dofile(path.join("src", "emu.lua"))
-if (STANDALONE~=true) then
- dofile(path.join("src", "mame", "frontend.lua"))
-end
-
group "devices"
dofile(path.join("src", "devices.lua"))
devicesProject(_OPTIONS["target"],_OPTIONS["subtarget"])
-if (STANDALONE~=true) then
- group "drivers"
- findfunction("createProjects_" .. _OPTIONS["target"] .. "_" .. _OPTIONS["subtarget"])(_OPTIONS["target"], _OPTIONS["subtarget"])
-end
+if _OPTIONS["with-emulator"] then
+ if (STANDALONE~=true) then
+ dofile(path.join("src", "mame", "frontend.lua"))
+ end
-group "emulator"
-dofile(path.join("src", "main.lua"))
-if (_OPTIONS["SOURCES"] == nil) then
- if (_OPTIONS["target"] == _OPTIONS["subtarget"]) then
- startproject (_OPTIONS["target"])
- else
- if (_OPTIONS["subtarget"]=="mess") then
- startproject (_OPTIONS["subtarget"])
+ if (STANDALONE~=true) then
+ group "drivers"
+ findfunction("createProjects_" .. _OPTIONS["target"] .. "_" .. _OPTIONS["subtarget"])(_OPTIONS["target"], _OPTIONS["subtarget"])
+ end
+
+ group "emulator"
+ dofile(path.join("src", "main.lua"))
+ if (_OPTIONS["SOURCES"] == nil) and (_OPTIONS["SOURCEFILTER"] == nil) then
+ if (_OPTIONS["target"] == _OPTIONS["subtarget"]) then
+ startproject (_OPTIONS["target"])
else
startproject (_OPTIONS["target"] .. _OPTIONS["subtarget"])
end
+ else
+ startproject (_OPTIONS["subtarget"])
end
-else
- startproject (_OPTIONS["subtarget"])
+ mainProject(_OPTIONS["target"],_OPTIONS["subtarget"])
+ strip()
end
-mainProject(_OPTIONS["target"],_OPTIONS["subtarget"])
-strip()
if _OPTIONS["with-tools"] then
group "tools"
@@ -1586,3 +1466,33 @@ if _OPTIONS["with-benchmarks"] then
group "benchmarks"
dofile(path.join("src", "benchmarks.lua"))
end
+
+function generate_has_header(hashname, hash)
+ fname = GEN_DIR .. "has_" .. hashname:lower() .. ".h"
+ file = io.open(fname, "w")
+ file:write("// Generated file, edition is futile\n")
+ file:write("\n")
+ file:write(string.format("#ifndef GENERATED_HAS_%s_H\n", hashname))
+ file:write(string.format("#define GENERATED_HAS_%s_H\n", hashname))
+ file:write("\n")
+ active = {}
+ for k, v in pairs(hash) do
+ if v then
+ active[#active+1] = k
+ end
+ end
+ table.sort(active)
+ for _, k in ipairs(active) do
+ file:write(string.format("#define HAS_%s_%s\n", hashname, k))
+ end
+ file:write("\n")
+ file:write("#endif\n")
+ file:close()
+end
+
+generate_has_header("CPUS", CPUS)
+generate_has_header("SOUNDS", SOUNDS)
+generate_has_header("MACHINES", MACHINES)
+generate_has_header("VIDEOS", VIDEOS)
+generate_has_header("BUSES", BUSES)
+generate_has_header("FORMATS", FORMATS)