diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2018-08-10 19:11:30 +0200 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2018-08-10 19:11:30 +0200 |
commit | e5006d4f2f767aab5c06d4e95151687a54902ad9 (patch) | |
tree | d84b3f03583ba799f31606cc9a68d14e00c842eb | |
parent | 93a0d2456086b2c0e4a50d6ecc43ab028895bcad (diff) | |
download | nextpnr-e5006d4f2f767aab5c06d4e95151687a54902ad9.tar.gz nextpnr-e5006d4f2f767aab5c06d4e95151687a54902ad9.tar.bz2 nextpnr-e5006d4f2f767aab5c06d4e95151687a54902ad9.zip |
Save settings and give nicer names to some
-rw-r--r-- | common/project.cc | 10 | ||||
-rw-r--r-- | gui/basewindow.cc | 2 | ||||
-rw-r--r-- | gui/ice40/mainwindow.cc | 2 | ||||
-rw-r--r-- | ice40/pcf.cc | 2 | ||||
-rw-r--r-- | ice40/project.cc | 4 | ||||
-rw-r--r-- | json/jsonparse.cc | 2 |
6 files changed, 15 insertions, 7 deletions
diff --git a/common/project.cc b/common/project.cc index 949f6878..8ee78c4a 100644 --- a/common/project.cc +++ b/common/project.cc @@ -18,6 +18,7 @@ */ #include "project.h" +#include <algorithm> #include <boost/filesystem/convenience.hpp> #include <boost/property_tree/json_parser.hpp> #include <fstream> @@ -64,11 +65,18 @@ void ProjectHandler::save(Context *ctx, std::string filename) root.put("project.name", boost::filesystem::basename(filename)); root.put("project.arch.name", ctx->archId().c_str(ctx)); root.put("project.arch.type", ctx->archArgsToId(ctx->archArgs()).c_str(ctx)); - std::string fn = ctx->settings[ctx->id("project/input/json")]; + std::string fn = ctx->settings[ctx->id("input/json")]; root.put("project.input.json", make_relative(fn, proj.parent_path()).string()); root.put("project.params.freq", int(ctx->target_freq / 1e6)); root.put("project.params.seed", ctx->rngstate); saveArch(ctx, root, proj.parent_path().string()); + for(auto const &item : ctx->settings) + { + std::string path = "project.settings."; + path += item.first.c_str(ctx); + std::replace(path.begin(), path.end(), '/', '.'); + root.put(path, item.second); + } pt::write_json(f, root); } catch (...) { log_error("Error saving project file.\n"); diff --git a/gui/basewindow.cc b/gui/basewindow.cc index 66df3ca4..4444c8e9 100644 --- a/gui/basewindow.cc +++ b/gui/basewindow.cc @@ -420,7 +420,7 @@ void BaseMainWindow::disableActions() actionNew->setEnabled(true);
actionOpen->setEnabled(true);
- if (ctx->settings.find(ctx->id("project/input/json")) != ctx->settings.end())
+ if (ctx->settings.find(ctx->id("input/json")) != ctx->settings.end())
actionSave->setEnabled(true);
else
actionSave->setEnabled(false);
diff --git a/gui/ice40/mainwindow.cc b/gui/ice40/mainwindow.cc index 9fe80717..f270b112 100644 --- a/gui/ice40/mainwindow.cc +++ b/gui/ice40/mainwindow.cc @@ -191,7 +191,7 @@ void MainWindow::onRouteFinished() { actionSaveAsc->setEnabled(true); } void MainWindow::onProjectLoaded()
{
- if (ctx->settings.find(ctx->id("project/input/pcf")) != ctx->settings.end())
+ if (ctx->settings.find(ctx->id("input/pcf")) != ctx->settings.end())
actionLoadPCF->setEnabled(false);
}
diff --git a/ice40/pcf.cc b/ice40/pcf.cc index d9fc4e68..af5b3e17 100644 --- a/ice40/pcf.cc +++ b/ice40/pcf.cc @@ -66,7 +66,7 @@ bool apply_pcf(Context *ctx, std::string filename, std::istream &in) log_error("unsupported pcf command '%s'\n", cmd.c_str()); } } - ctx->settings.emplace(ctx->id("project/input/pcf"), filename); + ctx->settings.emplace(ctx->id("input/pcf"), filename); return true; } catch (log_execution_error_exception) { return false; diff --git a/ice40/project.cc b/ice40/project.cc index 8ca10e36..47c0903d 100644 --- a/ice40/project.cc +++ b/ice40/project.cc @@ -28,8 +28,8 @@ NEXTPNR_NAMESPACE_BEGIN void ProjectHandler::saveArch(Context *ctx, pt::ptree &root, std::string path) { root.put("project.arch.package", ctx->archArgs().package); - if (ctx->settings.find(ctx->id("project/input/pcf")) != ctx->settings.end()) { - std::string fn = ctx->settings[ctx->id("project/input/pcf")]; + if (ctx->settings.find(ctx->id("input/pcf")) != ctx->settings.end()) { + std::string fn = ctx->settings[ctx->id("input/pcf")]; root.put("project.input.pcf", make_relative(fn, path).string()); } } diff --git a/json/jsonparse.cc b/json/jsonparse.cc index 9e86f93e..d73525bc 100644 --- a/json/jsonparse.cc +++ b/json/jsonparse.cc @@ -754,7 +754,7 @@ bool parse_json_file(std::istream &f, std::string &filename, Context *ctx) log_info("Checksum: 0x%08x\n", ctx->checksum()); log_break(); - ctx->settings.emplace(ctx->id("project/input/json"), filename); + ctx->settings.emplace(ctx->id("input/json"), filename); return true; } catch (log_execution_error_exception) { return false; |