diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2019-06-14 15:18:35 +0200 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2019-06-14 15:18:35 +0200 |
commit | 66ea9f39f7f5d6e1152105328f9a48a367bd8ce0 (patch) | |
tree | c00f2c07205988f67d24a4f6a22ee8f8f301ecf2 /common | |
parent | aca372de99b960ca808e49fec27d2aaf890574d3 (diff) | |
download | nextpnr-66ea9f39f7f5d6e1152105328f9a48a367bd8ce0.tar.gz nextpnr-66ea9f39f7f5d6e1152105328f9a48a367bd8ce0.tar.bz2 nextpnr-66ea9f39f7f5d6e1152105328f9a48a367bd8ce0.zip |
enable lading of jsons and setting up context
Diffstat (limited to 'common')
-rw-r--r-- | common/command.cc | 24 | ||||
-rw-r--r-- | common/command.h | 3 |
2 files changed, 25 insertions, 2 deletions
diff --git a/common/command.cc b/common/command.cc index 7b0b2caa..1a8f810e 100644 --- a/common/command.cc +++ b/common/command.cc @@ -245,7 +245,7 @@ int CommandHandler::executeMain(std::unique_ptr<Context> ctx) #ifndef NO_GUI if (vm.count("gui")) { Application a(argc, argv, (vm.count("gui-no-aa") > 0)); - MainWindow w(std::move(ctx), chipArgs); + MainWindow w(std::move(ctx), this); try { if (vm.count("json")) { std::string filename = vm["json"].as<std::string>(); @@ -378,6 +378,28 @@ int CommandHandler::exec() } } +std::unique_ptr<Context> CommandHandler::load_json(std::string filename) +{ + vm.clear(); + std::unordered_map<std::string,Property> values; + { + std::ifstream f(filename); + if (!load_json_settings(f, filename, values)) + log_error("Loading design failed.\n"); + } + std::unique_ptr<Context> ctx = createContext(values); + settings = std::unique_ptr<Settings>(new Settings(ctx.get())); + setupContext(ctx.get()); + setupArchContext(ctx.get()); + { + std::ifstream f(filename); + if (!parse_json_file(f, filename, ctx.get())) + log_error("Loading design failed.\n"); + } + customAfterLoad(ctx.get()); + return ctx; +} + void CommandHandler::run_script_hook(const std::string &name) { #ifndef NO_PYTHON diff --git a/common/command.h b/common/command.h index 5c5ceb9a..c7b58517 100644 --- a/common/command.h +++ b/common/command.h @@ -22,6 +22,7 @@ #define COMMAND_H #include <boost/program_options.hpp> +#include <fstream> #include "nextpnr.h" #include "settings.h" @@ -36,6 +37,7 @@ class CommandHandler virtual ~CommandHandler(){}; int exec(); + std::unique_ptr<Context> load_json(std::string filename); protected: virtual void setupArchContext(Context *ctx) = 0; @@ -57,7 +59,6 @@ class CommandHandler protected: po::variables_map vm; - ArchArgs chipArgs; std::unique_ptr<Settings> settings; private: |