fpp/compiler/install
Rob Bocchino fb0e342667 Revise install script
Always restore Version.scala correctly, even if the version
is corrupted
2025-02-18 17:17:07 -08:00

104 lines
2.1 KiB
Bash
Executable File

#!/bin/sh -e
# ----------------------------------------------------------------------
# FPP installer
# ----------------------------------------------------------------------
# To pass flags to sbt, set the environment variable
# FPP_SBT_FLAGS
#
# To override the java command and/or set java flags, set the
# environment variable
# FPP_INSTALL_JAVA
# ----------------------------------------------------------------------
# Check arguments
if test $# -gt 1
then
echo 'usage: install dest-dir' 1>&2
echo ' install' 1>&2
exit 1
fi
# Check for output directory
if test -n "$1"
then
# Convert to absolute path as the `cd` to 'compiler' will break relative paths passed in
mkdir -p "$1"
dest=`cd $1; pwd`
else
dest=bin
fi
# Go to the working directory, so that relative paths work as expected
wd=`dirname $0`
cd $wd
# Pull in the version info
. ../version.sh
scala_version="3.1.2"
if test -n "$FPP_INSTALL_JAVA"
then
java=$FPP_INSTALL_JAVA
else
java=java
fi
echo "java command: $java"
dir=`dirname $dest`
dir=`cd $dir; pwd`
base=`basename $dest`
dest=$dir/$base
tools="
fpp-check
fpp-depend
fpp-filenames
fpp-format
fpp-from-xml
fpp-locate-defs
fpp-locate-uses
fpp-syntax
fpp-to-cpp
fpp-to-json
fpp-to-xml
fpp-to-dict
fpp-to-layout
"
if git describe --tags --always > /dev/null 2>&1
then
# Ask git for the current version, if it is available
version=`git describe --tags --always`
else
# Otherwise use the hard-coded version
version="$VERSION"
fi
util=lib/src/main/scala/util
echo "Updating version to $version"
sed -i.update.bak -e "s/val v = .*/val v = \"$version\"/" \
$util/Version.scala
echo "Building jar files"
cmd="sbt $FPP_SBT_FLAGS assembly"
echo $cmd
$cmd
echo "Restoring Version.scala"
sed -i.restore.bak -e "s/val v = .*/val v = \"[unknown version]\"/" \
$util/Version.scala
mkdir -p $dest
echo "Installing tools at $dest"
for tool in $tools
do
jar=`find tools/$tool -name "*$name*assembly*.jar" | grep "target/scala-$scala_version"`
echo " $jar"
cp $jar $dest/$tool.jar
echo '#!/bin/sh
'$java' -jar "`dirname $0`/'$tool'.jar" "$@"' > $dest/$tool
chmod +x $dest/$tool
done