From 5d18500a74590110c332ddc17961dab522792f84 Mon Sep 17 00:00:00 2001 From: Ariel Antonitis Date: Wed, 24 Mar 2021 18:17:27 -0400 Subject: [PATCH] Generalized remote build script. --- remote_build.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/remote_build.sh b/remote_build.sh index c9b492628f..1f6dbd1f46 100644 --- a/remote_build.sh +++ b/remote_build.sh @@ -1,10 +1,15 @@ #!/bin/bash -# Rsync repo to build machine; build and scp the ROM back +# Push to SSH machine; build and scp build products back -set +v set -e git_branch=$(git branch --show-current) -git push build --force # ssh://merrbot:/home/ubuntu/pokeemerald -ssh merrbot "cd pokeemerald && git reset --hard && git checkout $git_branch && make" -scp merrbot:pokeemerald/pokeemerald.gba romhack.gba +# See https://unix.stackexchange.com/a/13472 +remote_host=$(git remote get-url build | sed -nr -e "s/ssh:\/\/(\w+@?\w*):.*/\1/p") # Extract remote host +remote_path=$(git remote get-url build | sed -nr -e "s/ssh:\/\/\w+@?\w*://p") # Extract remote path +set -x +git push build --force +# `nproc` must be escaped so that it executes on the remote machine +ssh $remote_host "cd $remote_path && git reset --hard && git checkout $git_branch && \ + echo \"Using \`nproc\` job(s)\" && make -j\`nproc\`" +scp "$remote_host:$remote_path/pokeemerald.gba" romhack.gba