Files
mercury/tools/build_srcdist
Julien Fischer 8cba9908ae Set the version for 20.06 betas.
tools/build_srdist:
   As above.
2020-06-02 21:22:36 +10:00

119 lines
2.7 KiB
Bash
Executable File

#!/bin/bash
# Copyright (C) 2013-2015 The Mercury team.
#
# This script builds the Mercury source distribution.
#
set -e
DATE=`date '+%Y-%m-%d'`
ROTD_VERSION=20.06-beta-$DATE
RELEASE_VERSION=$ROTD_VERSION
CC=gcc
RUN=no
PARALLEL=1
TAR=tar
USAGE="\
$0 [options]
Options:
-h
Output this help message and exit.
-r
Use a ROTD style version number with today's date (default).
-v VER
Use VER as the version number.
-n
Do not update VERSION file.
-f
Without this option the build_srcdist script will not run, it will warn
the user that it is destructive and then exit.
-j N
Run N jobs in parallel.
-c CC
Use CC as the C compiler.
-t TAR
Use TAR as the archiving utility (default: tar)
"
while getopts "hrv:nc:fj:t:" OPT; do
case "$OPT" in
h)
echo "$USAGE"
exit 0
;;
r)
RELEASE_VERSION=$ROTD_VERSION
;;
v)
RELEASE_VERSION=$OPTARG
;;
n)
RELEASE_VERSION=""
;;
c)
CC=$OPTARG
;;
f)
RUN=yes
;;
j)
PARALLEL=$OPTARG
;;
t)
TAR=$OPTARG
;;
?)
echo "$USAGE"
exit 1
;;
*)
echo "Getopt error \"$OPT\""
echo "$USAGE"
exit 1
;;
esac
done
if [ "$RUN" = "no" ]; then
echo "Warning: This script is destructive, it will 'git clean' your"
echo "workspace. If you're okay with this and want to proceed, then"
echo "add -f to the command line"
exit 2
fi
if [ ! -d .git ]; then
echo "Error: $0 must be called from the root directory of a Mercury"
echo "git workspace."
exit 2
fi
# NOTE: the hlc.gc.pregen grade that we use below *requires* these settings.
#
NUM_TAG_BITS=2
BITS_PER_WORD=32
BYTES_PER_WORD=4
UNBOXED_FLOATS=no
# Clean up any leftover stage[23] directories in the workspace and 'git clean'
# doesn't completely remove them.
#
/bin/rm -rf stage2 stage3
# git checkout -- VERSION
git submodule deinit -f .
git clean -d -f -x
git rev-parse HEAD > COMMIT_ID
if [ -n "$RELEASE_VERSION" ]; then
sed "s/VERSION=.*/VERSION=$RELEASE_VERSION/" VERSION > VERSION.new
mv VERSION.new VERSION
fi
/bin/rm -f Mmake.params Mmake.stage.params
./prepare.sh
mercury_cv_low_tag_bits=$NUM_TAG_BITS \
mercury_cv_bits_per_word=$BITS_PER_WORD \
mercury_cv_bytes_per_word=$BYTES_PER_WORD \
mercury_cv_unboxed_floats=$UNBOXED_FLOATS \
sh configure --with-cc="$CC" &&
mmake TAR="$TAR" GRADE=hlc.gc.pregen MMAKEFLAGS="EXTRA_MCFLAGS='-O5 --opt-space' -j$PARALLEL" tar