Skip to content

Commit

Permalink
Make building emulator optional (allow building tools without buildin…
Browse files Browse the repository at this point in the history
…g MAME) (#11889)
  • Loading branch information
mmicko committed Jan 1, 2024
1 parent 7a1c86c commit d5340b8
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 41 deletions.
9 changes: 9 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# TARGET = mame
# SUBTARGET = tiny
# TOOLS = 1
# EMULATOR = 1
# TESTS = 1
# BENCHMARKS = 1
# OSD = sdl
Expand Down Expand Up @@ -650,6 +651,14 @@ PARAMS += --with-tools
endif
endif

ifndef EMULATOR
PARAMS += --with-emulator
else
ifeq '$(EMULATOR)' '1'
PARAMS += --with-emulator
endif
endif

ifdef TESTS
ifneq '$(TESTS)' '0'
PARAMS += --with-tests
Expand Down
91 changes: 50 additions & 41 deletions scripts/genie.lua
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ newoption {
description = "Enable building tools.",
}

newoption {
trigger = "with-emulator",
description = "Enable building emulator.",
}

newoption {
trigger = "with-tests",
description = "Enable building tests.",
Expand Down Expand Up @@ -529,30 +534,32 @@ 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"))
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"])
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
load(OUT_STR)()
else
error("Definition file for TARGET=" .. _OPTIONS["target"] .. " SUBTARGET=" .. _OPTIONS["subtarget"] .. " does not exist")
end
end

Expand Down Expand Up @@ -1480,32 +1487,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) and (_OPTIONS["SOURCEFILTER"] == nil) then
if (_OPTIONS["target"] == _OPTIONS["subtarget"]) then
startproject (_OPTIONS["target"])
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["target"] .. _OPTIONS["subtarget"])
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"
Expand Down
3 changes: 3 additions & 0 deletions scripts/src/emu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
--
---------------------------------------------------------------------------

if _OPTIONS["with-emulator"] then

project ("emu")
uuid ("e6fa15e4-a354-4526-acef-13c8e80fcacf")
kind (LIBTYPE)
Expand Down Expand Up @@ -308,6 +310,7 @@ custombuildtask {
layoutbuildtask("emu/layout", "triphsxs"),
layoutbuildtask("emu/layout", "quadhsxs"),
}
end

project ("precompile")
uuid ("a6fb15d4-b123-4445-acef-13c8e80fcacf")
Expand Down

0 comments on commit d5340b8

Please sign in to comment.