From f0db6ffedd8856ce4c90d35a8448e406ff08f91d Mon Sep 17 00:00:00 2001
From: "Edward A. Lee" <eal@berkeley.edu>
Date: Sun, 24 Nov 2024 07:28:53 -0800
Subject: [PATCH 1/2] Removed unused method

---
 .../launcher/FedLauncherGenerator.java        | 20 -------------------
 1 file changed, 20 deletions(-)

diff --git a/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java b/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java
index 332ee003c6..1d340f44f4 100644
--- a/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java
+++ b/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java
@@ -513,26 +513,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();

From adf461b0f5c9a90c13cc243c952a7c719949f33c Mon Sep 17 00:00:00 2001
From: "Edward A. Lee" <eal@berkeley.edu>
Date: Sun, 24 Nov 2024 11:46:27 -0800
Subject: [PATCH 2/2] Use tar to transfer source files to remote host

---
 .../launcher/FedLauncherGenerator.java        | 21 +++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java b/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java
index 1d340f44f4..10816dc111 100644
--- a/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java
+++ b/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java
@@ -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 "
@@ -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)