diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2018-06-05 21:03:06 +0200 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2018-06-05 21:03:06 +0200 |
commit | 7cb42f4368e873e5930cf84bc2494a8e8172a046 (patch) | |
tree | ed773278240546b1b525c066b95a4e69150aabf1 /ice40/main.cc | |
parent | bd08f9e698269764d9e06052470d4a699f69f951 (diff) | |
download | nextpnr-7cb42f4368e873e5930cf84bc2494a8e8172a046.tar.gz nextpnr-7cb42f4368e873e5930cf84bc2494a8e8172a046.tar.bz2 nextpnr-7cb42f4368e873e5930cf84bc2494a8e8172a046.zip |
Initial GUI work
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; } |