aboutsummaryrefslogtreecommitdiffstats
path: root/common/command.cc
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2019-06-14 15:18:35 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2019-06-14 15:18:35 +0200
commit66ea9f39f7f5d6e1152105328f9a48a367bd8ce0 (patch)
treec00f2c07205988f67d24a4f6a22ee8f8f301ecf2 /common/command.cc
parentaca372de99b960ca808e49fec27d2aaf890574d3 (diff)
downloadnextpnr-66ea9f39f7f5d6e1152105328f9a48a367bd8ce0.tar.gz
nextpnr-66ea9f39f7f5d6e1152105328f9a48a367bd8ce0.tar.bz2
nextpnr-66ea9f39f7f5d6e1152105328f9a48a367bd8ce0.zip
enable lading of jsons and setting up context
Diffstat (limited to 'common/command.cc')
-rw-r--r--common/command.cc24
1 files changed, 23 insertions, 1 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