Skip to content

Commit

Permalink
Improve the dist.sh script
Browse files Browse the repository at this point in the history
* Use copy function to copy config files, too.
* Copy the platform-agnostic launch scripts, too.
* Use -v flags instead of set -x for output log.
* Get rid of the macOS Contents/* nesting here.
  • Loading branch information
ctrueden committed Feb 7, 2025
1 parent 3ffae6f commit dcd46d7
Showing 1 changed file with 24 additions and 31 deletions.
55 changes: 24 additions & 31 deletions bin/dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,58 +9,51 @@ test -d build || { echo '[ERROR] No build folder; please `make compile-all` firs
appName=$1
test "$appName" || appName=launcher

copyBinary() {
copyFile() {
srcPath=$1
destDir=$2
destName=$3
makeExec=$4
if [ ! -f "$srcPath" ]; then return; fi
mkdir -p "$destDir"
(set -x; cp "$srcPath" "$destDir/$destName")
if [ "$makeExec" ]; then (set -x; chmod +x "$destDir/$destName"); fi
test "$destName" || destName="${srcPath##*/}"
mkdir -pv "$destDir"
cp -v "$srcPath" "$destDir/$destName"
if [ "$makeExec" ]; then chmod -v +x "$destDir/$destName"; fi
}

# Clear out previous dist directory.
rm -rf dist
rm -rfv dist

# Copy native launcher executables.
for launcherBinary in build/launcher*
do
targetFilename="$appName${launcherBinary#build/launcher}"
binaryType=$(file -b "$launcherBinary" 2>/dev/null)
case "$binaryType" in
ELF*) copyBinary "$launcherBinary" dist "$targetFilename" true ;;
Mach-O*) copyBinary "$launcherBinary" dist/Contents/MacOS "$targetFilename" true ;;
*) copyBinary "$launcherBinary" dist "$targetFilename" ;;
ELF*|Mach-O*) copyFile "$launcherBinary" dist "$targetFilename" true ;;
*) copyFile "$launcherBinary" dist "$targetFilename" ;;
esac
done

# Copy jaunch configurator executables.
copyBinary build/bin/linuxArm64/releaseExecutable/jaunch.kexe dist/jaunch jaunch-linux-arm64 true
copyBinary build/bin/linuxX64/releaseExecutable/jaunch.kexe dist/jaunch jaunch-linux-x64 true
copyBinary build/bin/macosArm64/releaseExecutable/jaunch.kexe dist/Contents/MacOS jaunch-macos-arm64 true
copyBinary build/bin/macosX64/releaseExecutable/jaunch.kexe dist/Contents/MacOS jaunch-macos-x64 true
copyBinary build/bin/macosUniversal/releaseExecutable/jaunch.kexe dist/Contents/MacOS jaunch-macos true
copyBinary build/bin/windowsArm64/releaseExecutable/jaunch.exe dist/jaunch jaunch-windows-arm64.exe
copyBinary build/bin/windowsX64/releaseExecutable/jaunch.exe dist/jaunch jaunch-windows-x64.exe
copyFile build/bin/linuxArm64/releaseExecutable/jaunch.kexe dist/jaunch jaunch-linux-arm64 true
copyFile build/bin/linuxX64/releaseExecutable/jaunch.kexe dist/jaunch jaunch-linux-x64 true
copyFile build/bin/macosArm64/releaseExecutable/jaunch.kexe dist/jaunch jaunch-macos-arm64 true
copyFile build/bin/macosX64/releaseExecutable/jaunch.kexe dist/jaunch jaunch-macos-x64 true
copyFile build/bin/macosUniversal/releaseExecutable/jaunch.kexe dist/jaunch jaunch-macos true
copyFile build/bin/windowsArm64/releaseExecutable/jaunch.exe dist/jaunch jaunch-windows-arm64.exe
copyFile build/bin/windowsX64/releaseExecutable/jaunch.exe dist/jaunch jaunch-windows-x64.exe

# Copy Props.class helper program and TOML configuration files.
mkdir -p dist/jaunch
for f in \
Props.class \
common.toml \
jvm.toml \
python.toml
do
if [ ! -f "dist/jaunch/$f" ]
then
(set -x; cp "configs/$f" dist/jaunch/)
fi
done
if [ ! -f dist/jaunch/launcher.toml ]
then
(set -x; cp configs/repl.toml dist/jaunch/launcher.toml)
fi
copyFile configs/Props.class dist/jaunch
copyFile configs/common.toml dist/jaunch
copyFile configs/jvm.toml dist/jaunch
copyFile configs/python.toml dist/jaunch
copyFile configs/repl.toml dist/jaunch "$appName.toml"

# Copy platform-agnostic launch scripts.
copyFile configs/launcher.sh dist "$appName.sh" true
copyFile configs/launcher.bat dist "$appName.bat"

# Wrap it up into a tarball.
tar czf jaunch.tar.gz dist

0 comments on commit dcd46d7

Please sign in to comment.