|
@@ -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
|
|
|
|
-info
|
|
|
|
-svndir="$DIR/daily"
|
|
|
|
-pkgsrcdir="$svndir/compiler/packages"
|
|
|
|
-unitpath="$pkgsrcdir/fcl-js/src/;$pkgsrcdir/fcl-json/src/;$pkgsrcdir/fcl-passrc/src/;$pkgsrcdir/pastojs/src/"
|
|
|
|
-opts="-B -O1 -Scghi -vewnh"
|
|
|
|
-compilerdir=$svndir/compiler/utils/pas2js
|
|
|
|
-bindir=$svndir/bin/
|
|
|
|
-outdir=$svndir/output
|
|
|
|
-if [ -d "$bindir" ]; then
|
|
|
|
- info Removing previous binaries from "$bindir"
|
|
|
|
- rm -rf "$bindir"/*
|
|
|
|
|
|
+#
|
|
|
|
+# Export sources
|
|
|
|
+#
|
|
|
|
+info "Exporting SVN $SVN to $DIR/daily"
|
|
|
|
+svn export -q $SVN daily
|
|
|
|
+BUILDDIR="$DIR/daily"
|
|
|
|
+PKGDIR="$BUILDDIR/compiler/packages"
|
|
|
|
+UNITPATH="$PKGDIR/fcl-js/src/;$PKGDIR/fcl-json/src/;$PKGDIR/fcl-passrc/src/;$PKGDIR/pastojs/src/"
|
|
|
|
+if [ ! -z "$FPCVER30" ]; then
|
|
|
|
+ UNITPATH="${UNITPATH};$PKGDIR/compat"
|
|
|
|
+fi
|
|
|
|
+OPTS="-B -O1 -Scghi -v0 -ve $EXTRAOPT"
|
|
|
|
+if [ "$FPCCPU" = "x86_64" ]; then
|
|
|
|
+ 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 "$bindir"
|
|
|
|
- mkdir -p "$bindir"
|
|
|
|
|
|
+ info Creating output dir "$BINDIR"
|
|
|
|
+ mkdir -p "$BINDIR"
|
|
fi
|
|
fi
|
|
-if [ -d "$outdir" ]; then
|
|
|
|
- info Removing previous binaries from "$outdir"
|
|
|
|
- rm -rf "$outdir"/*
|
|
|
|
|
|
+if [ -d "$OUTDIR" ]; then
|
|
|
|
+ info Removing previous binaries from "$OUTDIR"
|
|
|
|
+ rm -rf "$OUTDIR"/*
|
|
else
|
|
else
|
|
- info Creating output dir "$outdir"
|
|
|
|
- mkdir -p "$outdir"
|
|
|
|
|
|
+ info Creating output dir "$OUTDIR"
|
|
|
|
+ mkdir -p "$OUTDIR"
|
|
fi
|
|
fi
|
|
|
|
|
|
# pas2js
|
|
# pas2js
|
|
-info Build pas2js in $compilerdir
|
|
|
|
-cd "$compilerdir"
|
|
|
|
-$FPC -Fu"$unitpath" $opts -FE$outdir pas2js.pp
|
|
|
|
-strip $outdir/pas2js
|
|
|
|
|
|
+info
|
|
|
|
+info Build pas2js in $COMPDIR
|
|
|
|
+info "---"
|
|
|
|
+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
|
|
|
|
-cd "$compilerdir"
|
|
|
|
-$FPC -Fu"$unitpath" -fPIC $opts -FE$outdir pas2jslib.pp
|
|
|
|
-strip $outdir/libpas2jslib.so
|
|
|
|
|
|
+info ""
|
|
|
|
+info Build libpas2js in $COMPDIR
|
|
|
|
+info "---"
|
|
|
|
+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
|
|
|
|
-cd "$compilerdir"
|
|
|
|
-$FPC -Fu"$unitpath" $opts -FE$outdir compileserver.pp
|
|
|
|
-strip $outdir/compileserver
|
|
|
|
-info Copying to build dir.
|
|
|
|
-cp $outdir/compileserver $bindir/
|
|
|
|
|
|
+if [ ! -z "$FPCVER30" ]; then
|
|
|
|
+ info ""
|
|
|
|
+ info Version 3.0.x detected: Skipping compileserver build.
|
|
|
|
+ info "---"
|
|
|
|
+else
|
|
|
|
+ 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
|
|
|
|
-cd "$compilerdir"
|
|
|
|
-$FPC -Fu"$unitpath" $opts -FE$outdir webidl2pas.pp
|
|
|
|
-strip $outdir/webidl2pas
|
|
|
|
|
|
+info ""
|
|
|
|
+info Build webidl2pas in $COMPDIR
|
|
|
|
+info "---"
|
|
|
|
+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"
|
|
|
|
-make SKIPWEBCOMPILER=1 P2JS=$svndir/output/pas2js
|
|
|
|
|
|
+cd "$BUILDDIR/demo"
|
|
|
|
+make SKIPWEBCOMPILER=1 P2JS=$BUILDDIR/output/pas2js
|
|
|
|
|
|
info Build webcompiler in demos dir
|
|
info Build webcompiler in demos dir
|
|
-cd "$svndir/demo"
|
|
|
|
-make demowebcompiler P2JS=$svndir/output/pas2js
|
|
|
|
|
|
+cd "$BUILDDIR/demo"
|
|
|
|
+make demowebcompiler P2JS=$BUILDDIR/output/pas2js
|
|
|
|
|
|
|
|
|