Added make opions for filter file, adjusted source path display.

Added SOURCEFILTER option to specify a driver filter file in your make
options, e.g. like make SUBTARGET=custom SOURCEFILTER=mydrivers.flt (or
put it in your useroptions.mak if you'll be using it a lot).  It
functions more-or-less like SOURCES on steroids.

Changed the way system/device source file paths are displayed to suit
the new source layout better.  INI file loading hasn't changed, that
still just uses the base file name.

Added overlooked trigger to src/bus.lua to include NES controller bus if
the NES zapper sensor is needed.
This commit is contained in:
Vas Crabb 2022-06-28 16:33:06 +10:00
parent dbf04f771a
commit 513e30cbbb
9 changed files with 186 additions and 89 deletions

View file

@ -104,7 +104,9 @@
# QT_HOME = /usr/lib64/qt48/
# SOURCES = src/mame/drivers/asteroid.cpp,src/mame/audio/llander.cpp
# SOURCES = src/mame/atari/asteroid.cpp,src/mame/cinemat/cchasm.cpp
# SOURCEFILTER = mydrivers.flt
# FORCE_VERSION_COMPILE = 1
@ -875,6 +877,10 @@ ifdef SOURCES
PARAMS += --SOURCES='$(SOURCES)'
endif
ifdef SOURCEFILTER
PARAMS += --SOURCEFILTER='$(SOURCEFILTER)'
endif
ifdef FORCE_VERSION_COMPILE
PARAMS += --FORCE_VERSION_COMPILE='$(FORCE_VERSION_COMPILE)'
endif
@ -930,6 +936,9 @@ SCRIPTS = scripts/genie.lua \
$(wildcard src/osd/$(OSD)/$(OSD).mak) \
$(wildcard src/$(TARGET)/$(SUBTARGET_FULL).mak)
ifdef SOURCEFILTER
SCRIPTS += $(SOURCEFILTER)
else
ifndef SOURCES
ifdef PROJECT
SCRIPTS += projects/$(PROJECT)/scripts/target/$(TARGET)/$(SUBTARGET_FULL).lua
@ -938,6 +947,7 @@ else
#SCRIPTS += scripts/target/$(TARGET)/$(SUBTARGET_FULL).lua
endif
endif
endif
ifdef REGENIE
SCRIPTS+= regenie

View file

@ -392,6 +392,11 @@ newoption {
description = "List of sources to compile.",
}
newoption {
trigger = "SOURCEFILTER",
description = "Filter list specifying sources to compile.",
}
newoption {
trigger = "PLATFORM",
description = "Target machine platform (x86,arm,...)",
@ -552,21 +557,21 @@ if (_OPTIONS["PROJECT"] ~= nil) 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
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 cmd = string.format(
"%s %s filterproject -r %s -t %s -f %s %s",
PYTHON, path.join(MAME_DIR, "scripts", "build", "makedep.py"),
MAME_DIR, _OPTIONS["subtarget"], subtargetfilter, path.join(MAME_DIR, "src", _OPTIONS["target"] , _OPTIONS["target"] .. ".lst"))
local OUT_STR = os.outputof(cmd)
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 filterproject -r %s -t %s -f %s %s",
PYTHON, makedep, MAME_DIR, _OPTIONS["subtarget"], subtargetfilter, driverlist))
load(OUT_STR)()
else
error("File definition for TARGET=" .. _OPTIONS["target"] .. " SUBTARGET=" .. _OPTIONS["subtarget"] .. " does not exist")
error("Definition file for TARGET=" .. _OPTIONS["target"] .. " SUBTARGET=" .. _OPTIONS["subtarget"] .. " does not exist")
end
end
@ -1420,19 +1425,46 @@ end
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()
if not os.isfile(path.join(MAME_DIR, word)) then
error("File " .. word .. " does not exist")
end
sourceargs = sourceargs .. " " .. word
end
local OUT_STR = os.outputof( PYTHON .. " " .. MAME_DIR .. "scripts/build/makedep.py sourcesproject -r " .. MAME_DIR .. " -t " .. _OPTIONS["subtarget"] .. sourceargs )
local OUT_STR = os.outputof(
string.format(
"%s %s sourcesproject -r %s -t %s %s",
PYTHON, makedep, MAME_DIR, _OPTIONS["subtarget"], sourceargs))
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 sourcesfilter -l %s %s > %s",
PYTHON, makedep, 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 filterproject -r %s -t %s -f %s %s",
PYTHON, makedep, MAME_DIR, _OPTIONS["subtarget"], driverfilter, driverlist))
load(OUT_STR)()
os.outputof( PYTHON .. " " .. MAME_DIR .. "scripts/build/makedep.py sourcesfilter -l " .. MAME_DIR .. "src/" .. _OPTIONS["target"] .. "/" .. _OPTIONS["target"] .. ".lst" .. sourceargs .. " > ".. GEN_DIR .. _OPTIONS["target"] .. "/" .. _OPTIONS["subtarget"] .. ".flt" )
end
group "libs"
@ -1473,7 +1505,7 @@ end
group "emulator"
dofile(path.join("src", "main.lua"))
if (_OPTIONS["SOURCES"] == nil) then
if (_OPTIONS["SOURCES"] == nil) and (_OPTIONS["SOURCEFILTER"] == nil) then
if (_OPTIONS["target"] == _OPTIONS["subtarget"]) then
startproject (_OPTIONS["target"])
else

View file

@ -3087,6 +3087,7 @@ end
---------------------------------------------------
--
--@src/devices/bus/nes_ctrl/ctrl.h,BUSES["NES_CTRL"] = true
--@src/devices/bus/nes_ctrl/zapper_sensor.h,BUSES["NES_CTRL"] = true
---------------------------------------------------
if (BUSES["NES_CTRL"]~=null) then

View file

@ -11,7 +11,7 @@
function mainProject(_target, _subtarget)
local projname
if (_OPTIONS["SOURCES"] == nil) then
if (_OPTIONS["SOURCES"] == nil) and (_OPTIONS["SOURCEFILTER"] == nil) then
if (_target == _subtarget) then
projname = _target
else
@ -282,68 +282,80 @@ if (STANDALONE~=true) then
GEN_DIR .. _target .. "/" .. _subtarget .. "/drivlist.cpp",
}
if (_OPTIONS["SOURCES"] == nil) then
if os.isfile(MAME_DIR .. "src/" .. _target .."/" .. _subtarget ..".flt") then
dependency {
{ GEN_DIR .. _target .. "/" .. _subtarget .."/drivlist.cpp", MAME_DIR .. "src/".._target .."/" .. _target ..".lst", true },
}
custombuildtask {
local driverlist = MAME_DIR .. "src/" .. _target .. "/" .. _target .. ".lst"
local driverssrc = GEN_DIR .. _target .. "/" .. _subtarget .. "/drivlist.cpp"
if _OPTIONS["SOURCES"] ~= nil then
dependency {
{ driverssrc, driverlist, true },
}
custombuildtask {
{
GEN_DIR .. _target .."/" .. _subtarget .. ".flt" ,
driverssrc,
{ MAME_DIR .. "scripts/build/makedep.py", driverlist },
{
MAME_DIR .. "src/" .. _target .. "/" .. _subtarget .. ".flt",
GEN_DIR .. _target .. "/" .. _subtarget .. "/drivlist.cpp",
{ MAME_DIR .. "scripts/build/makedep.py", MAME_DIR .. "src/" .. _target .."/" .. _target .. ".lst" },
{
"@echo Building driver list...",
PYTHON .. " $(1) driverlist $(2) -f $(<) > $(@)"
}
},
}
elseif os.isfile(MAME_DIR .. "src/" .._target .. "/" .. _subtarget ..".lst") then
custombuildtask {
"@echo Building driver list...",
PYTHON .. " $(1) driverlist $(2) -f $(<) > $(@)"
}
},
}
elseif _OPTIONS["SOURCEFILTER"] ~= nil then
dependency {
{ driverssrc, driverlist, true },
}
custombuildtask {
{
MAME_DIR .. _OPTIONS["SOURCEFILTER"],
driverssrc,
{ MAME_DIR .. "scripts/build/makedep.py", driverlist },
{
MAME_DIR .. "src/" .. _target .. "/" .. _subtarget .. ".lst",
GEN_DIR .. _target .. "/" .. _subtarget .."/drivlist.cpp",
{ MAME_DIR .. "scripts/build/makedep.py" },
{
"@echo Building driver list...",
PYTHON .. " $(1) driverlist $(<) > $(@)"
}
},
}
else
dependency {
{ GEN_DIR .. _target .. "/" .. _target .."/drivlist.cpp", MAME_DIR .. "src/".._target .."/" .. _target ..".lst", true },
}
custombuildtask {
"@echo Building driver list...",
PYTHON .. " $(1) driverlist $(2) -f $(<) > $(@)"
}
},
}
elseif os.isfile(MAME_DIR .. "src/" .. _target .."/" .. _subtarget ..".flt") then
dependency {
{ driverssrc, driverlist, true },
}
custombuildtask {
{
MAME_DIR .. "src/" .. _target .. "/" .. _subtarget .. ".flt",
driverssrc,
{ MAME_DIR .. "scripts/build/makedep.py", driverlist },
{
MAME_DIR .. "src/" .. _target .. "/" .. _target .. ".lst",
GEN_DIR .. _target .. "/" .. _target .. "/drivlist.cpp",
{ MAME_DIR .. "scripts/build/makedep.py" },
{
"@echo Building driver list...",
PYTHON .. " $(1) driverlist $(<) > $(@)"
}
},
}
end
end
if (_OPTIONS["SOURCES"] ~= nil) then
dependency {
{ GEN_DIR .. _target .. "/" .. _subtarget .."/drivlist.cpp", MAME_DIR .. "src/".._target .."/" .. _target ..".lst", true },
}
custombuildtask {
"@echo Building driver list...",
PYTHON .. " $(1) driverlist $(2) -f $(<) > $(@)"
}
},
}
elseif os.isfile(MAME_DIR .. "src/" .._target .. "/" .. _subtarget ..".lst") then
custombuildtask {
{
MAME_DIR .. "src/" .. _target .. "/" .. _subtarget .. ".lst",
driverssrc,
{ MAME_DIR .. "scripts/build/makedep.py" },
{
GEN_DIR .. _target .."/" .. _subtarget ..".flt" ,
GEN_DIR .. _target .. "/" .. _subtarget .."/drivlist.cpp",
{ MAME_DIR .. "scripts/build/makedep.py", MAME_DIR .. "src/".._target .."/" .. _target ..".lst" },
{
"@echo Building driver list...",
PYTHON .. " $(1) driverlist $(2) -f $(<) > $(@)"
}
},
}
"@echo Building driver list...",
PYTHON .. " $(1) driverlist $(<) > $(@)"
}
},
}
else
dependency {
{ driverssrc, driverlist, true },
}
custombuildtask {
{
driverlist,
driverssrc,
{ MAME_DIR .. "scripts/build/makedep.py" },
{
"@echo Building driver list...",
PYTHON .. " $(1) driverlist $(<) > $(@)"
}
},
}
end
configuration { "mingw*" }

View file

@ -400,7 +400,25 @@ void cli_frontend::listsource(const std::vector<std::string> &args)
{
auto const list_system_source = [] (device_type type)
{
osd_printf_info("%-16s %s\n", type.shortname(), core_filename_extract_base(type.source()));
std::string_view src(type.source());
auto prefix(src.find("src/mame/"));
if (std::string_view::npos == prefix)
prefix = src.find("src\\mame\\");
if (std::string_view::npos != prefix)
{
src.remove_prefix(prefix + 9);
}
else
{
auto prefix(src.find("src/"));
if (std::string_view::npos == prefix)
prefix = src.find("src\\");
if (std::string_view::npos != prefix)
{
src.remove_prefix(prefix + 4);
}
}
osd_printf_info("%-16s %s\n", type.shortname(), src);
};
apply_action(
args,
@ -499,11 +517,17 @@ void cli_frontend::listbrothers(const std::vector<std::string> &args)
drivlist.reset();
while (drivlist.next())
{
int clone_of = drivlist.clone();
std::string_view src(drivlist.driver().type.source());
auto prefix(src.find("src/mame/"));
if (std::string_view::npos == prefix)
prefix = src.find("src\\mame\\");
if (std::string_view::npos != prefix)
src.remove_prefix(prefix + 9);
int const clone_of = drivlist.clone();
if (clone_of != -1)
osd_printf_info("%-20s %-16s %s\n", core_filename_extract_base(drivlist.driver().type.source()), drivlist.driver().name, (clone_of == -1 ? "" : drivlist.driver(clone_of).name));
osd_printf_info("%-20s %-16s %s\n", src, drivlist.driver().name, (clone_of == -1 ? "" : drivlist.driver(clone_of).name));
else
osd_printf_info("%-20s %s\n", core_filename_extract_base(drivlist.driver().type.source()), drivlist.driver().name);
osd_printf_info("%-20s %s\n", src, drivlist.driver().name);
}
}

View file

@ -748,11 +748,13 @@ void output_one(std::ostream &out, driver_enumerator &drivlist, const game_drive
util::stream_format(out, "\t<%s name=\"%s\"", XML_TOP, normalize_string(driver.name));
// strip away any path information from the source_file and output it
const char *start = strrchr(driver.type.source(), '/');
if (!start)
start = strrchr(driver.type.source(), '\\');
start = start ? (start + 1) : driver.type.source();
util::stream_format(out, " sourcefile=\"%s\"", normalize_string(start));
std::string_view src(driver.type.source());
auto prefix(src.find("src/mame/"));
if (std::string_view::npos == prefix)
prefix = src.find("src\\mame\\");
if (std::string_view::npos != prefix)
src.remove_prefix(prefix + 9);
util::stream_format(out, " sourcefile=\"%s\"", normalize_string(src));
// append bios and runnable flags
if (driver.flags & machine_flags::IS_BIOS_ROOT)
@ -844,8 +846,12 @@ void output_one_device(std::ostream &out, machine_config &config, device_t &devi
// start to output info
util::stream_format(out, "\t<%s name=\"%s\"", XML_TOP, normalize_string(device.shortname()));
std::string src(device.source());
strreplace(src,"../", "");
std::string_view src(device.source());
auto prefix(src.find("src/"));
if (std::string_view::npos == prefix)
prefix = src.find("src\\");
if (std::string_view::npos != prefix)
src.remove_prefix(prefix + 4);
util::stream_format(out, " sourcefile=\"%s\" isdevice=\"yes\" runnable=\"no\"", normalize_string(src));
auto const parent(device.type().parent_rom_device_type());
if (parent)

View file

@ -1284,7 +1284,7 @@ void lua_engine::initialize()
game_driver_type["manufacturer"] = sol::readonly(&game_driver::manufacturer);
game_driver_type["parent"] = sol::readonly(&game_driver::parent);
game_driver_type["compatible_with"] = sol::property([] (game_driver const &driver) { return strcmp(driver.compatible_with, "0") ? driver.compatible_with : nullptr; });
game_driver_type["source_file"] = sol::property([] (game_driver const &driver) { return &driver.type.source()[0]; });
game_driver_type["source_file"] = sol::property([] (game_driver const &driver) { return driver.type.source(); });
game_driver_type["orientation"] = sol::property(
[] (game_driver const &driver)
{

View file

@ -362,11 +362,17 @@ std::string machine_info::game_info_string() const
std::ostringstream buf;
// print description, manufacturer, and CPU:
std::string_view src(m_machine.system().type.source());
auto prefix(src.find("src/mame/"));
if (std::string_view::npos == prefix)
prefix = src.find("src\\mame\\");
if (std::string_view::npos != prefix)
src.remove_prefix(prefix + 9);
util::stream_format(buf, _("%1$s\n%2$s %3$s\nDriver: %4$s\n\nCPU:\n"),
system_list::instance().systems()[driver_list::find(m_machine.system().name)].description,
m_machine.system().year,
m_machine.system().manufacturer,
core_filename_extract_base(m_machine.system().type.source()));
src);
// loop over all CPUs
execute_interface_enumerator execiter(m_machine.root_device());

View file

@ -335,7 +335,13 @@ void simple_menu_select_game::custom_render(void *selectedref, float top, float
tempbuf[1] = string_format(_("%1$s, %2$-.100s"), driver->year, driver->manufacturer);
// next line source path
tempbuf[2] = string_format(_("Driver: %1$s"), core_filename_extract_base(driver->type.source()));
std::string_view src(driver->type.source());
auto prefix(src.find("src/mame/"));
if (std::string_view::npos == prefix)
prefix = src.find("src\\mame\\");
if (std::string_view::npos != prefix)
src.remove_prefix(prefix + 9);
tempbuf[2] = string_format(_("Driver: %1$s"), src);
// update cached values if selection changed
if (driver != m_cached_driver)