fpp/compiler/install
bocchino d78ec7b13a Revise install scripts
Refactor install
Add install-trace for installing tools with tracing enabled
2022-05-23 16:04:07 -07:00

85 lines
1.6 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
# ----------------------------------------------------------------------
scala_version="3.1.2"
if test -n "$FPP_INSTALL_JAVA"
then
java=$FPP_INSTALL_JAVA
else
java=java
fi
echo "java command: $java"
if test $# -gt 1
then
echo 'usage: install dest-dir' 1>&2
echo ' install' 1>&2
exit 1
fi
if test -n "$1"
then
dest=$1
else
dest=bin
fi
wd=`dirname $0`
cd $wd
dir=`dirname $dest`
dir=`cd $dir; pwd`
base=`basename $dest`
dest=$dir/$base
tools="
fpp-check
fpp-depend
fpp-filenames
fpp-format
fpp-syntax
fpp-from-xml
fpp-locate-defs
fpp-locate-uses
fpp-to-cpp
fpp-to-xml
"
version=`git describe --tags --always`
util=lib/src/main/scala/util
echo "Updating version to $version"
sed -i.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"
cp $util/Version.scala.bak $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