From 28a734436e76d590649bf1862e4f69826bdb0df4 Mon Sep 17 00:00:00 2001 From: couriersud Date: Tue, 27 Dec 2016 11:24:50 +0100 Subject: Added "-r" option to nltool to pass path to a folder containing rom files. Multiple "-r" options may be given. Zip files are not supported, just individual files. [Couriersud] --- src/lib/netlist/prg/nltool.cpp | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/src/lib/netlist/prg/nltool.cpp b/src/lib/netlist/prg/nltool.cpp index c58a5d61c1c..86e01b90ca8 100644 --- a/src/lib/netlist/prg/nltool.cpp +++ b/src/lib/netlist/prg/nltool.cpp @@ -30,6 +30,7 @@ public: opt_cmd (*this, "c", "cmd", "run", "run:convert:listdevices:static", "run|convert|listdevices|static"), opt_file(*this, "f", "file", "-", "file to process (default is stdin)"), opt_defines(*this, "D", "define", "predefine value as macro, e.g. -Dname=value. If '=value' is omitted predefine it as 1. This option may be specified repeatedly."), + opt_rfolders(*this, "r", "rom", "where to look for files"), opt_verb(*this, "v", "verbose", "be verbose - this produces lots of output"), opt_quiet(*this, "q", "quiet", "be quiet - no warnings"), opt_version(*this, "", "version", "display version and exit"), @@ -53,6 +54,7 @@ public: plib::option_str_limit opt_cmd; plib::option_str opt_file; plib::option_vec opt_defines; + plib::option_vec opt_rfolders; plib::option_bool opt_verb; plib::option_bool opt_quiet; plib::option_bool opt_version; @@ -87,6 +89,36 @@ NETLIST_END() CORE IMPLEMENTATION ***************************************************************************/ +class netlist_data_folder_t : public netlist::source_t +{ +public: + netlist_data_folder_t(netlist::setup_t &setup, + pstring folder) + : netlist::source_t(setup, netlist::source_t::DATA) + , m_folder(folder) + { + } + + virtual std::unique_ptr stream(const pstring &file) override + { + pstring name = m_folder + "/" + file; + try + { + auto strm = plib::make_unique_base(name); + return strm; + } + catch (plib::pexception e) + { + + } + return std::unique_ptr(nullptr); + } + +private: + pstring m_folder; +}; + + class netlist_tool_t : public netlist::netlist_t { public: @@ -109,13 +141,17 @@ public: void read_netlist(const pstring &filename, const pstring &name, const std::vector &logs, - const std::vector &defines) + const std::vector &defines, + const std::vector &roms) { // read the netlist ... for (auto & d : defines) m_setup->register_define(d); + for (auto & r : roms) + m_setup->register_source(plib::make_unique_base(*m_setup, r)); + m_setup->register_source(plib::make_unique_base(*m_setup, filename)); m_setup->include(name); @@ -249,7 +285,7 @@ static void run(tool_options_t &opts) nt.read_netlist(opts.opt_file(), opts.opt_name(), opts.opt_logs(), - opts.opt_defines()); + opts.opt_defines(), opts.opt_rfolders()); std::vector inps = read_input(nt.setup(), opts.opt_inp()); @@ -292,7 +328,7 @@ static void static_compile(tool_options_t &opts) nt.read_netlist(opts.opt_file(), opts.opt_name(), opts.opt_logs(), - opts.opt_defines()); + opts.opt_defines(), opts.opt_rfolders()); nt.solver()->create_solver_code(pout_strm); -- cgit v1.2.3