diff options
author | ZipCPU <dgisselq@ieee.org> | 2018-06-06 07:55:18 -0400 |
---|---|---|
committer | ZipCPU <dgisselq@ieee.org> | 2018-06-06 07:55:18 -0400 |
commit | d0ee08aeb12a8fb7237b31083666d9b165f13f69 (patch) | |
tree | e09d84b0389462f2c1959ce59438d88a7b5f9ed2 /ice40/main.cc | |
parent | 2e6d0b752ab2d269f822bfd3ea029b100ecf4233 (diff) | |
parent | d3f19cc27ea4634a64821688e9adec6046f4d7de (diff) | |
download | nextpnr-d0ee08aeb12a8fb7237b31083666d9b165f13f69.tar.gz nextpnr-d0ee08aeb12a8fb7237b31083666d9b165f13f69.tar.bz2 nextpnr-d0ee08aeb12a8fb7237b31083666d9b165f13f69.zip |
Merge branch 'master' into gqtech
Diffstat (limited to 'ice40/main.cc')
-rw-r--r-- | ice40/main.cc | 82 |
1 files changed, 75 insertions, 7 deletions
diff --git a/ice40/main.cc b/ice40/main.cc index 1a63f003..e02930bb 100644 --- a/ice40/main.cc +++ b/ice40/main.cc @@ -16,18 +16,86 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ - #include "design.h" +#include "mainwindow.h" +#include <QApplication> +#include <iostream> +#include "version.h" +#include <boost/program_options.hpp> +#include "pybindings.h" -int main() +int main(int argc, char *argv[]) { - ChipArgs chipArgs; - chipArgs.type = ChipArgs::LP384; + namespace po = boost::program_options; + + std::string str; + + po::options_description options("Allowed options"); + options.add_options()("help,h","show help"); + options.add_options()("debug","just a check"); + options.add_options()("gui","start gui"); + options.add_options()("file", po::value<std::string>(), "python file to execute"); + options.add_options()("version,v","show version"); + + po::positional_options_description pos; + pos.add("file", -1); + + po::variables_map vm; + try { + po::parsed_options parsed = po::command_line_parser(argc, argv). + options(options). + positional(pos). + run(); + + po::store(parsed, vm); + + po::notify(vm); + } + catch(std::exception& e) + { + std::cout << e.what() << "\n"; + return 1; + } + + if (vm.count("help") || argc == 1) + { + std::cout << basename(argv[0]) << " -- Next Generation Place and Route (git sha1 " GIT_COMMIT_HASH_STR ")\n"; + std::cout << "\n"; + std::cout << options << "\n"; + return 1; + } + + if (vm.count("version")) + { + std::cout << basename(argv[0]) << " -- Next Generation Place and Route (git sha1 " GIT_COMMIT_HASH_STR ")\n"; + return 1; + } + + if (vm.count("gui")) + { + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); + } - Design design(chipArgs); + if (vm.count("debug")) + { + ChipArgs chipArgs; + chipArgs.type = ChipArgs::LP384; - for (auto bel : design.chip.getBels()) - printf("%s\n", design.chip.getBelName(bel).c_str()); + Design design(chipArgs); + for (auto bel : design.chip.getBels()) + printf("%s\n", design.chip.getBelName(bel).c_str()); + return 0; + } + if (vm.count("file")) + { + std::string filename = vm["file"].as<std::string>(); + execute_python_file(argv[0],filename.c_str()); + } + return 0; } |