* Some improvements

This commit is contained in:
michael 2019-04-04 17:06:15 +00:00
parent 9d2677ad0e
commit 00baed38ae

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# Some variables
BASEURL="https://svn.freepascal.org/svn/projects/pas2js/"
function info { function info {
echo "Info: $*" echo "Info: $*"
@ -6,27 +8,37 @@ function info {
function usage { function usage {
echo "usage $0 [options] [FPC [SVN]]" echo "usage $0 [options] [FPC [SVN]]"
echo '-c compiler set compiler to use'
echo '-d directory set base directory for checkout'
echo '-h help this help message'
echo '-o OPTS extra compiler options'
echo '-z URL set url for checkout. Can be relative to pas2js repo'
}
function doCompile {
info "Compiler command line: $*"
$FPC $*
} }
set -e set -e
while test $# != 0 while test $# != 0
do do
f=$1 f=$1
case $f in case $f in
'-c') shift '-c') shift
FPC=$1;; FPC="$1";;
'-d') shift '-d') shift
DIR=$1;; DIR="$1";;
'-z') shift '-z') shift
SVN=$f;; SVN="$1";;
'-o') shift
EXTRAOPTS="$1";;
'-h') usage '-h') usage
exit;; exit;;
*) *)
if [ -z "$FPC" ]; then if [ -z "$FPC" ]; then
FPC=$f FPC=$1
else else
if [ -z "$SVN" ]; then if [ -z "$SVN" ]; then
SVN=$f SVN=$1
else else
usage usage
fi fi
@ -34,89 +46,142 @@ do
esac esac
shift shift
done done
#
# Collect some info , set defaults
#
info FPC $FPC
info SVN $SVN
info DIR $DIR
if [ -z "$FPC" ]; then if [ -z "$FPC" ]; then
FPC=fpc FPC=fpc
fi fi
if [ -z "$SVN" ]; then if [ -z "$SVN" ]; then
SVN=https://svn.freepascal.org/svn/projects/pas2js/trunk SVN=${BASEURL}trunk
else
PROT=$(echo $SVN | sed -n '/.*:\/\//p')
if [ -z "$PROT" ]; then
SVN="${BASEURL}${SVN}"
fi
fi fi
if [ -z "$DIR" ]; then if [ -z "$DIR" ]; then
DIR=~/P2JS DIR=$TMP
if [ -z "$DIR" ]; then
DIR=$TEMP
fi
if [ -z "$DIR" ]; then
DIR=~/tmp
fi
fi fi
info Changing directory to $DIR
FPCVER=$($FPC -iV)
FPCVER30=$(echo $FPCVER | grep '3.0')
FPCCPU=$($FPC -iTP)
#
# Get started
#
info "SVN URL: $SVN"
info "Compiler version: $FPCVER"
info "Base directory: $DIR"
info ""
info ""
#
# Change to base dir
#
info Changing directory to base dir $DIR
mkdir -p $DIR mkdir -p $DIR
cd $DIR cd $DIR
if [ -d daily ]; then if [ -d daily ]; then
info Removing previous dir info Removing previous dir
rm -rf daily rm -rf daily
fi fi
info Checking out SVN $SVN #
svn co -q $SVN daily # Export sources
info #
svndir="$DIR/daily" info "Exporting SVN $SVN to $DIR/daily"
pkgsrcdir="$svndir/compiler/packages" svn export -q $SVN daily
unitpath="$pkgsrcdir/fcl-js/src/;$pkgsrcdir/fcl-json/src/;$pkgsrcdir/fcl-passrc/src/;$pkgsrcdir/pastojs/src/" BUILDDIR="$DIR/daily"
opts="-B -O1 -Scghi -vewnh" PKGDIR="$BUILDDIR/compiler/packages"
compilerdir=$svndir/compiler/utils/pas2js UNITPATH="$PKGDIR/fcl-js/src/;$PKGDIR/fcl-json/src/;$PKGDIR/fcl-passrc/src/;$PKGDIR/pastojs/src/"
bindir=$svndir/bin/ if [ ! -z "$FPCVER30" ]; then
outdir=$svndir/output UNITPATH="${UNITPATH};$PKGDIR/compat"
if [ -d "$bindir" ]; then
info Removing previous binaries from "$bindir"
rm -rf "$bindir"/*
else
info Creating output dir "$bindir"
mkdir -p "$bindir"
fi fi
if [ -d "$outdir" ]; then OPTS="-B -O1 -Scghi -v0 -ve $EXTRAOPT"
info Removing previous binaries from "$outdir" if [ "$FPCCPU" = "x86_64" ]; then
rm -rf "$outdir"/* LIBOPT="-fPIC"
fi
COMPDIR=$BUILDDIR/compiler/utils/pas2js
BINDIR=$BUILDDIR/bin/
OUTDIR=$BUILDDIR/output
if [ -d "$BINDIR" ]; then
info Removing previous binaries from "$BINDIR"
rm -rf "$BINDIR"/*
else else
info Creating output dir "$outdir" info Creating output dir "$BINDIR"
mkdir -p "$outdir" mkdir -p "$BINDIR"
fi
if [ -d "$OUTDIR" ]; then
info Removing previous binaries from "$OUTDIR"
rm -rf "$OUTDIR"/*
else
info Creating output dir "$OUTDIR"
mkdir -p "$OUTDIR"
fi fi
# pas2js # pas2js
info Build pas2js in $compilerdir info
cd "$compilerdir" info Build pas2js in $COMPDIR
$FPC -Fu"$unitpath" $opts -FE$outdir pas2js.pp info "---"
strip $outdir/pas2js cd "$COMPDIR"
doCompile -Fu"$UNITPATH" $OPTS -FE$OUTDIR pas2js.pp
strip $OUTDIR/pas2js
info Copying to build dir. info Copying to build dir.
cp $outdir/pas2js $bindir/ cp $OUTDIR/pas2js $BINDIR/
# libpas2js # libpas2js
info Build libpas2js in $compilerdir info ""
cd "$compilerdir" info Build libpas2js in $COMPDIR
$FPC -Fu"$unitpath" -fPIC $opts -FE$outdir pas2jslib.pp info "---"
strip $outdir/libpas2jslib.so cd "$COMPDIR"
doCompile -Fu"$UNITPATH" $OPTS $LIBOPT -FE$OUTDIR pas2jslib.pp
strip $OUTDIR/libpas2jslib.so
info Copying to build dir. info Copying to build dir.
cp $outdir/libpas2jslib.so $bindir/ cp $OUTDIR/libpas2jslib.so $BINDIR/
# compileserver # compileserver
info Build compileserver in $compilerdir if [ ! -z "$FPCVER30" ]; then
cd "$compilerdir" info ""
$FPC -Fu"$unitpath" $opts -FE$outdir compileserver.pp info Version 3.0.x detected: Skipping compileserver build.
strip $outdir/compileserver info "---"
info Copying to build dir. else
cp $outdir/compileserver $bindir/ info ""
info Build compileserver in $COMPDIR
info "---"
cd "$COMPDIR"
doCompile -Fu"$UNITPATH" $OPTS -FE$OUTDIR compileserver.pp
strip $OUTDIR/compileserver
info Copying to build dir.
cp $OUTDIR/compileserver $BINDIR/
fi
# webidl # webidl
info Build compileserver in $compilerdir info ""
cd "$compilerdir" info Build webidl2pas in $COMPDIR
$FPC -Fu"$unitpath" $opts -FE$outdir webidl2pas.pp info "---"
strip $outdir/webidl2pas cd "$COMPDIR"
doCompile -Fu"$UNITPATH" $OPTS -FE$OUTDIR -Fu$PKGDIR/webidl/src webidl2pas.pp
strip $OUTDIR/webidl2pas
info Copying to build dir. info Copying to build dir.
cp $outdir/webidl2pas $bindir/ cp $OUTDIR/webidl2pas $BINDIR/
# all done # all done
info Compiled binaries: info Compiled binaries:
ls -l $bindir ls -l $BINDIR
info Build demos in $snvdir/demo without webcompiler info Build demos in $snvdir/demo without webcompiler
cd "$svndir/demo" cd "$BUILDDIR/demo"
make SKIPWEBCOMPILER=1 P2JS=$svndir/output/pas2js make SKIPWEBCOMPILER=1 P2JS=$BUILDDIR/output/pas2js
info Build webcompiler in demos dir info Build webcompiler in demos dir
cd "$svndir/demo" cd "$BUILDDIR/demo"
make demowebcompiler P2JS=$svndir/output/pas2js make demowebcompiler P2JS=$BUILDDIR/output/pas2js