diff options
| author | ZipCPU <dgisselq@ieee.org> | 2018-06-06 14:44:54 -0400 |
|---|---|---|
| committer | ZipCPU <dgisselq@ieee.org> | 2018-06-06 14:44:54 -0400 |
| commit | 16b9a2f1b5ad10aa0b426183b4e071d3afb09e88 (patch) | |
| tree | d38578150224f95b8ce539ad2db7e32c92d397ac /ice40 | |
| parent | 5e463b8543585e4e1d2d3f80a2e32142015a73dd (diff) | |
| download | nextpnr-16b9a2f1b5ad10aa0b426183b4e071d3afb09e88.tar.gz nextpnr-16b9a2f1b5ad10aa0b426183b4e071d3afb09e88.tar.bz2 nextpnr-16b9a2f1b5ad10aa0b426183b4e071d3afb09e88.zip | |
Attempt to add JSON parser--not working yet w/ build system
Diffstat (limited to 'ice40')
| -rw-r--r-- | ice40/main.cc | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/ice40/main.cc b/ice40/main.cc index 185c7f53..9295bde4 100644 --- a/ice40/main.cc +++ b/ice40/main.cc @@ -20,9 +20,11 @@ #include "mainwindow.h" #include <QApplication> #include <iostream> +#include <fstream> #include "version.h" #include <boost/program_options.hpp> #include "pybindings.h" +#include "jsonparse.h" void svg_dump_el(const GraphicElement &el) { @@ -52,6 +54,7 @@ int main(int argc, char *argv[]) options.add_options()("gui","start gui"); options.add_options()("svg","dump SVG file"); options.add_options()("file", po::value<std::string>(), "python file to execute"); + options.add_options()("json", po::value<std::string>(), "JSON design file to ingest"); options.add_options()("version,v","show version"); options.add_options()("lp384","set device type to iCE40LP384"); options.add_options()("lp1k","set device type to iCE40LP1K"); @@ -66,19 +69,20 @@ int main(int argc, char *argv[]) po::variables_map vm; try { po::parsed_options parsed = po::command_line_parser(argc, argv). - options(options). - positional(pos). - run(); + options(options). + positional(pos). + run(); - po::store(parsed, vm); + po::store(parsed, vm); - po::notify(vm); + po::notify(vm); + } + + catch(std::exception& e) + { + std::cout << e.what() << "\n"; + return 1; } - catch(std::exception& e) - { - std::cout << e.what() << "\n"; - return 1; - } if (vm.count("help") || argc == 1) { @@ -90,7 +94,9 @@ int main(int argc, char *argv[]) if (vm.count("version")) { - std::cout << basename(argv[0]) << " -- Next Generation Place and Route (git sha1 " GIT_COMMIT_HASH_STR ")\n"; + std::cout << basename(argv[0]) + << " -- Next Generation Place and Route (git sha1 " + GIT_COMMIT_HASH_STR ")\n"; return 1; } @@ -199,11 +205,19 @@ int main(int argc, char *argv[]) std::cout << "</svg>\n"; } + if (vm.count("json")) + { + std::string filename = vm["json"].as<std::string>(); + std::istream *f = new std::ifstream(filename); + + parse_json_file(f, filename, &design); + } + if (vm.count("file")) { std::string filename = vm["file"].as<std::string>(); execute_python_file(argv[0],filename.c_str()); - } + } return 0; } |
