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

Cleaner source directories copied to remote hosts #2440

Merged
merged 2 commits into from
Nov 25, 2024
Merged
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
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
Loading