diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2015-07-19 21:39:28 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2015-07-19 21:49:03 +0200 |
commit | ae2d05eee4ffcec4c0611d907779ce8ef61d3a6e (patch) | |
tree | 6b86d64d03dfda4efc4a41e5814a229507289cb9 /apps/generate.cpp | |
parent | 0374af511d7efdb856af372f126e66e5a78841d7 (diff) | |
download | ble-toys-ae2d05eee4ffcec4c0611d907779ce8ef61d3a6e.tar.gz ble-toys-ae2d05eee4ffcec4c0611d907779ce8ef61d3a6e.tar.bz2 ble-toys-ae2d05eee4ffcec4c0611d907779ce8ef61d3a6e.tar.xz ble-toys-ae2d05eee4ffcec4c0611d907779ce8ef61d3a6e.zip |
o Going back to a bunch of cpp files instead of launcher+bunch of header files. This ends up with an easier build file and faster builds with CMake's "OBJECT" library type.
Diffstat (limited to 'apps/generate.cpp')
-rw-r--r-- | apps/generate.cpp | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/apps/generate.cpp b/apps/generate.cpp deleted file mode 100644 index a088e6e..0000000 --- a/apps/generate.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include <cstdlib> -#include <iostream> -#include <fstream> -#include <regex> - -using namespace std; - -int main(int argc, char *argv[]) { - cout << "Generating " << argv[1] << endl; - - ofstream out; - - out.open(argv[1], ofstream::out); - - if (!out.is_open()) { - return EXIT_FAILURE; - } - - out << "#pragma once" << endl - << endl - << "#include <string>" << endl - << "#include <boost/algorithm/string/predicate.hpp>" << endl - << endl; - - vector<pair<string, string>> apps; - - regex r("-"); - for (int i = 2; i < argc; i++) { - string app_name = argv[i]; - stringstream buf; - - regex_replace(ostream_iterator<char>(buf), app_name.begin(), app_name.end(), r, "_"); - string class_name = buf.str(); - - apps.emplace_back(make_pair(app_name, class_name)); - } - - for_each(begin(apps), end(apps), [&](pair<string, string> pair) { - // out << "class " << pair.second << ";" << endl; - out << "#include \"" << pair.first << ".h\"" << endl; - }); - out << endl; - - bool first = true; - - out << "namespace trygvis {" << endl - << "namespace apps {" << endl - << endl - << "template<typename App>" << endl - << "int launch_app(int argc, const char *argv[]);" << endl - << endl; - - out << "int launch(const std::string app_name, int argc, const char *argv[]) {" << endl; - - for_each(begin(apps), end(apps), [&](auto pair) { - out << " "; - if (!first) { - out << "} else "; - } else { - first = false; - } - - out << "if (boost::ends_with(app_name, \"" << pair.first << "\")) {" << endl - << " return launch_app<" << pair.second << ">(argc, argv);" << endl; - }); - - out << " } else {" << endl - << " return EXIT_FAILURE;" << endl - << " }" << endl - << "}" << endl - << endl - << "}" << endl - << "}" << endl; - - return EXIT_SUCCESS; -} |