#!/bin/bash # Some variables BASEURL="https://svn.freepascal.org/svn/projects/pas2js/" function info { echo "Info: $*" } function usage { 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 while test $# != 0 do f=$1 case $f in '-c') shift FPC="$1";; '-d') shift DIR="$1";; '-z') shift SVN="$1";; '-o') shift EXTRAOPTS="$1";; '-h') usage exit;; *) if [ -z "$FPC" ]; then FPC=$1 else if [ -z "$SVN" ]; then SVN=$1 else usage fi fi esac shift done # # Collect some info , set defaults # info FPC $FPC info SVN $SVN info DIR $DIR if [ -z "$FPC" ]; then FPC=fpc fi if [ -z "$SVN" ]; then SVN=${BASEURL}trunk else PROT=$(echo $SVN | sed -n '/.*:\/\//p') if [ -z "$PROT" ]; then SVN="${BASEURL}${SVN}" fi fi if [ -z "$DIR" ]; then DIR=$TMP if [ -z "$DIR" ]; then DIR=$TEMP fi if [ -z "$DIR" ]; then DIR=~/tmp fi fi 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 cd $DIR if [ -d daily ]; then info Removing previous dir rm -rf daily fi # # 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 info Creating output dir "$BINDIR" 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 # 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. cp $OUTDIR/pas2js $BINDIR/ # libpas2js 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. cp $OUTDIR/libpas2jslib.so $BINDIR/ # compileserver 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 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. cp $OUTDIR/webidl2pas $BINDIR/ # all done info Compiled binaries: ls -l $BINDIR info Build demos in $snvdir/demo without webcompiler cd "$BUILDDIR/demo" make SKIPWEBCOMPILER=1 P2JS=$BUILDDIR/output/pas2js info Build webcompiler in demos dir cd "$BUILDDIR/demo" make demowebcompiler P2JS=$BUILDDIR/output/pas2js