Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy flag implemented #437

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ llvm-clang/**
**/.idea/**
**/cmake-build-debug/**
**/CMakeFiles/**
**/build/**
!**/build/.gitkeep
build/**
!build/.gitkeep
**/src/result/**
*.bak

Expand Down
9 changes: 9 additions & 0 deletions project/scripts/download_resources.sh
Original file line number Diff line number Diff line change
@@ -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.
40 changes: 29 additions & 11 deletions project/src/transpiler/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
* SOFTWARE.
*/

#include <stdlib.h>
#include <string.h>

#include <csignal>
#include <cstdlib>

Expand Down Expand Up @@ -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 "
"<C-file-name_> <EO-file-name_> [--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 "
"<C-file-name_> <EO-file-name_> [--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);
Expand Down