diff options
author | 2022-06-15 05:07:09 +1000 | |
---|---|---|
committer | 2022-06-15 05:07:09 +1000 | |
commit | d8854e4e5563265ba12c50cfcf9fb97cd37a2d40 (patch) | |
tree | 2bcce4741fd6515b0c056c3cddee7ff164be9141 /scripts | |
parent | c1f1ab27178362b6709ce44e9bd0d7f4d3313a3b (diff) |
Updated scripts to support SOURCES= builds after the reorganisation happens.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/build/makedep.py | 62 | ||||
-rw-r--r-- | scripts/genie.lua | 6 | ||||
-rw-r--r-- | scripts/src/main.lua | 65 |
3 files changed, 95 insertions, 38 deletions
diff --git a/scripts/build/makedep.py b/scripts/build/makedep.py index b4d47520c82..d9f92b08ac6 100755 --- a/scripts/build/makedep.py +++ b/scripts/build/makedep.py @@ -562,6 +562,7 @@ def parse_command_line(): subparser.add_argument('sources', metavar='<srcfile>', nargs='+', help='source files to include') subparser = subparsers.add_parser('sourcesfilter', help='generate driver filter for source files') + subparser.add_argument('-l', '--list', metavar='<lstfile>', required=True, help='master driver list file') subparser.add_argument('sources', metavar='<srcfile>', nargs='+', help='source files to include') subparser = subparsers.add_parser('driverlist', help='generate driver list source') @@ -662,9 +663,13 @@ def scan_source_dependencies(options): if ext.lower().startswith('.h'): components = components[:-1] test_siblings(components, base, depth) - if components == ('src', 'mame', 'includes'): - for aspect in ('audio', 'drivers', 'video', 'machine'): - test_siblings(('src', 'mame', aspect), base, depth) + if components[:2] == ('src', 'mame'): + if components[2:] == ('includes', ): + for aspect in ('audio', 'drivers', 'video', 'machine'): + test_siblings(('src', 'mame', aspect), base, depth) + else: + for aspect in ('_a', '_v', '_m'): + test_siblings(components, base + aspect, depth) handler = CppParser.Handler() handler.line = line_hook @@ -741,13 +746,60 @@ def write_project(options, projectfile, mappings, sources): def write_filter(options, filterfile): + def do_parse(p): + def line_hook(text): + text = text.strip() + if text.startswith('#'): + do_parse(os.path.join(os.path.dirname(n), text[1:].lstrip())) + elif text.startswith('@'): + parts = text[1:].lstrip().split(':', 1) + parts[0] = parts[0].strip() + if (parts[0] == 'source') and (len(parts) == 2): + parts[1] = parts[1].strip() + if not parts[1]: + sys.stderr.write('%s:%s: Empty source file name "%s"\n' % (p, parser.input_line, text)) + sys.exit(1) + else: + sources.add(parts[1]) + else: + sys.stderr.write('%s:%s: Unsupported directive "%s"\n' % (p, parser.input_line, text)) + sys.exit(1) + + n = os.path.normpath(p) + if n not in lists: + lists.add(n) + try: + listfile = io.open(n, 'r', encoding='utf-8') + except IOError: + sys.stderr.write('Unable to open list file "%s"\n' % (p, )) + sys.exit(1) + with listfile: + handler = CppParser.Handler() + handler.line = line_hook + parser = CppParser(handler) + try: + parser.parse(listfile) + except IOError: + sys.stderr.write('Error reading list file "%s"\n' % (p, )) + sys.exit(1) + except Exception as e: + sys.stderr.write('Error parsing list file "%s": %s\n' % (p, e)) + sys.exit(1) + + lists = set() + sources = set() + do_parse(options.list) + drivers = set() for source in options.sources: components = tuple(x for x in split_path(source) if x) - if (len(components) > 3) and (components[:3] == ('src', 'mame', 'drivers')): + if (len(components) > 3) and (components[:2] == ('src', 'mame')): ext = os.path.splitext(components[-1])[1].lower() if ext.startswith('.c'): - drivers.add('/'.join(components[3:])) + if components[2] == 'drivers': + drivers.add('/'.join(components[3:])) + elif '/'.join(components[2:]) in sources: + drivers.add('/'.join(components[2:])) for driver in sorted(drivers): filterfile.write(driver + '\n') diff --git a/scripts/genie.lua b/scripts/genie.lua index 76f18039000..dcffb53a0b6 100644 --- a/scripts/genie.lua +++ b/scripts/genie.lua @@ -557,7 +557,7 @@ if (_OPTIONS["PROJECT"] ~= nil) then 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 (_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") end @@ -1416,14 +1416,14 @@ if (_OPTIONS["SOURCES"] ~= nil) then 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") + print("File " .. word .. " does not exist") os.exit() end sourceargs = sourceargs .. " " .. word end OUT_STR = os.outputof( PYTHON .. " " .. MAME_DIR .. "scripts/build/makedep.py sourcesproject -r " .. MAME_DIR .. " -t " .. _OPTIONS["subtarget"] .. sourceargs ) load(OUT_STR)() - os.outputof( PYTHON .. " " .. MAME_DIR .. "scripts/build/makedep.py sourcesfilter" .. sourceargs .. " > ".. GEN_DIR .. _OPTIONS["target"] .. "/" .. _OPTIONS["subtarget"] .. ".flt" ) + 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" diff --git a/scripts/src/main.lua b/scripts/src/main.lua index da2ba71b61f..ec19bc578f6 100644 --- a/scripts/src/main.lua +++ b/scripts/src/main.lua @@ -285,45 +285,50 @@ if (STANDALONE~=true) then } }, } - else - if os.isfile(MAME_DIR .. "src/" .._target .. "/" .. _subtarget ..".lst") then - custombuildtask { + elseif os.isfile(MAME_DIR .. "src/" .._target .. "/" .. _subtarget ..".lst") then + custombuildtask { + { + MAME_DIR .. "src/" .. _target .. "/" .. _subtarget .. ".lst", + GEN_DIR .. _target .. "/" .. _subtarget .."/drivlist.cpp", + { MAME_DIR .. "scripts/build/makedep.py" }, { - 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 $(<) > $(@)" + } + }, + } + else + dependency { + { GEN_DIR .. _target .. "/" .. _target .."/drivlist.cpp", MAME_DIR .. "src/".._target .."/" .. _target ..".lst", true }, + } + custombuildtask { + { + MAME_DIR .. "src/" .. _target .. "/" .. _target .. ".lst", + GEN_DIR .. _target .. "/" .. _target .. "/drivlist.cpp", + { MAME_DIR .. "scripts/build/makedep.py" }, { - 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 + "@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 }, + { GEN_DIR .. _target .. "/" .. _subtarget .."/drivlist.cpp", MAME_DIR .. "src/".._target .."/" .. _target ..".lst", true }, } custombuildtask { - { 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 $(<) > $(@)" }}, + { + 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 $(<) > $(@)" + } + }, } end |