diff --git a/.gitignore b/.gitignore index 0ea3ca0f..56579fb5 100644 --- a/.gitignore +++ b/.gitignore @@ -47,8 +47,8 @@ llvm-clang/** **/.idea/** **/cmake-build-debug/** **/CMakeFiles/** -**/build/** -!**/build/.gitkeep +build/** +!build/.gitkeep **/src/result/** *.bak diff --git a/project/scripts/download_resources.sh b/project/scripts/download_resources.sh new file mode 100644 index 00000000..25476f60 --- /dev/null +++ b/project/scripts/download_resources.sh @@ -0,0 +1,9 @@ +#wget "https://github.com/polystat/c2eo/tree/master/project/eo-lib" +echo copy eo-lib to "$1" +cp -r ./../eo-lib/ "$1" + +# @todo #1049:30min In this implementation, we simply +# copy the current implementation, which lies at the +# relative address locally. We have to download the +# current version from the repository. The address +# is given above in the comment. \ No newline at end of file diff --git a/project/src/transpiler/main.cpp b/project/src/transpiler/main.cpp index 3f9753b5..54ec72c5 100644 --- a/project/src/transpiler/main.cpp +++ b/project/src/transpiler/main.cpp @@ -22,6 +22,9 @@ * SOFTWARE. */ +#include +#include + #include #include @@ -102,29 +105,44 @@ int main(int argc, const char **argv) { const char **parser_argv = TransformArgv(argv); filename = argv[2]; - if (argc == 4) { - if (std::string("--meta") != argv[3]) { - llvm::errs() - << "exception: incorrect command line format. Necessary: c2eo " - " [--meta]\n"; - return -1; - } - transpiler.GenerateMeta(); - } - package_name = filename.substr(0, filename.size() - 3); if (package_name.rfind('/') != std::string::npos) { package_name = package_name.substr(package_name.rfind('/') + 1); } transpiler.SetPackageName(package_name); - std::string path_name; + std::string path_name = ""; auto pos = filename.rfind('/'); if (pos != std::string::npos) { path_name = filename.substr(0, pos + 1); } transpiler.SetPathName(path_name); + if (argc == 4) { + if (std::string("--copy") == argv[3]) { + auto path = path_name; + if (path == "") { + path = "."; + } + + int sz = path.length(); + + char dest[40 + sz] = "bash ./../scripts/download_resources.sh "; + for (int i = 0; i < sz; ++i) { + dest[40 + i] = path[i]; + } + + // run download_resources.sh with argument 'path' + int status = system(dest); + } else if (std::string("--meta") != argv[3]) { + llvm::errs() + << "exception: incorrect command line format. Necessary: c2eo " + " [--meta]\n"; + return -1; + } + transpiler.GenerateMeta(); + } + int parser_argc = parser_arg_count; auto expected_parser = CommonOptionsParser::create( parser_argc, parser_argv, MyToolCategory, llvm::cl::Optional);