Skip to content

Commit

Permalink
Merge pull request #2440 from lf-lang/cleaner-dir
Browse files Browse the repository at this point in the history
Cleaner source directories copied to remote hosts
  • Loading branch information
edwardalee authored Nov 25, 2024
2 parents 56635b8 + adf461b commit 5304960
Showing 1 changed file with 15 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ private String getDistCode(Path remoteBase, FederateInstance federate) {
String logDirectory = "~/" + remoteBase + "/" + fileConfig.name + "/log";
String remoteBuildLogFileName = logDirectory + "/build.log";
String buildShellFileName = "build_" + federate.name + ".sh";
String tarFileName = federate.name + ".tar.gz";
return String.join(
"\n",
"echo \"Making directory "
Expand All @@ -443,18 +444,26 @@ private String getDistCode(Path remoteBase, FederateInstance federate) {
+ "; \\",
" date >> " + remoteBuildLogFileName + ";",
"'",
"pushd " + fileConfig.getSrcGenPath() + "/" + federate.name + " > /dev/null",
"echo \"**** Copying source files to host "
+ getUserHost(federate.user, federate.host)
+ "\"",
"scp -r * "
"pushd " + fileConfig.getSrcGenPath() + " > /dev/null",
"echo \"**** Bundling source files into " + tarFileName + "\"",
"tar -czf " + tarFileName + " --exclude build " + federate.name,
"echo \"**** Copying tarfile to host " + getUserHost(federate.user, federate.host) + "\"",
"scp -r "
+ tarFileName
+ " "
+ getUserHost(federate.user, federate.host)
+ ":"
+ remoteBase
+ "/"
+ fileConfig.name
+ "/"
+ federate.name,
+ tarFileName,
"rm " + tarFileName,
"ssh " + getUserHost(federate.user, federate.host) + " '\\",
" cd ~/" + remoteBase + "/" + fileConfig.name + "; \\",
" tar -xzf " + tarFileName + "; \\",
" rm " + tarFileName + ";",
"'",
"popd > /dev/null",
"echo \"**** Generating and executing compile.sh on host "
+ getUserHost(federate.user, federate.host)
Expand Down Expand Up @@ -513,26 +522,6 @@ private String getDistCode(Path remoteBase, FederateInstance federate) {
+ "'");
}

/** Return the body of a shell script file to compile the specified federate. */
private String getCompileScript(Path remoteBase, FederateInstance federate) {
String baseDir = "~/" + remoteBase + "/" + fileConfig.name;
return String.join(
"\n",
"#!/bin/bash -l", // The -l argument makes this a login shell so PATH etc are inherited.
// FIXME: Put copied files in subdirectory federate.name
"cd " + remoteBase + "/fed-gen/" + fileConfig.name + "/src-gen/" + federate.name,
"rm -rf build",
"mkdir -p ~/" + remoteBase + "/log",
// >> appends stdout to the specified file, and 2>&1 appends stderr to the same file.
"mkdir -p build && cd build && cmake .. && make >> "
+ baseDir
+ "/"
+ federate.name
+ ".log 2>&1",
"mkdir -p ~/" + remoteBase + "/bin;\\",
"mv " + federate.name + " ~/" + remoteBase + "/bin;'");
}

private String getUserHost(Object user, Object host) {
if (user == null) {
return host.toString();
Expand Down

0 comments on commit 5304960

Please sign in to comment.