#!/bin/sh # # Ronny Wichers Schreur # #set -vx # shell debug options #set -e # strategy: # get all sources from CVS # copy and build from non-clean sources # copy build from clean sources (with distribution) # build distribution step 1 # test # copy build from clean sources (with new build) # test # TODO # ... reduce number of C compilers # ... build *everything* from CVS # ... also for other platforms, mac should be easiest # ... test bootstrap BUILDSCRIPT=`cygpath --unix --absolute "$0"` BUILDDIR=`dirname "$BUILDSCRIPT"` # # Configure section # # Where to build ROOT="$BUILDDIR" # dos command shell COMMAND=`cygpath --unix $COMSPEC` # CVS command if test -e "C:\Program Files\TortoiseCVS"; then TORTOISE_ROOT=`cygpath --unix "C:\Program Files\TortoiseCVS"` CVS_RSH=TortoisePlinkSSH2.bat else TORTOISE_ROOT=`cygpath --unix "C:\Program Files (x86)\TortoiseCVS"` CVS_RSH=TortoisePlink.exe fi PATH=$TORTOISE_ROOT:$PATH CVS=cvs # CVS options CVS_CLEAN_INTERNAL=":ext:@leto.cs.kun.nl:/vol/st/repository" CVS_CLEAN_PUBLIC=":pserver:anonymous@cvs-srv.cs.kun.nl:/clean" CVS_ROOT="$CVS_CLEAN_INTERNAL" CVS_REVISION=HEAD CVS_QUIET=-Q CVS_GET_CMD="export -r "$CVS_REVISION"" # also possible 'checkout' # Clean System CLEANROOT=`cygpath --unix "C:\Documents and Settings\ronny\Desktop\build Clean 2.1.1b1\Clean 2.1.0"` # CodeWarrior if test -e "C:\Program Files\Metrowerks\CodeWarrior\bin\IDE.exe"; then CWIDE=`cygpath --unix "C:\Program Files\Metrowerks\CodeWarrior\bin\IDE.exe"` else CWIDE=`cygpath --unix "C:\Program Files (x86)\Metrowerks\CodeWarrior\bin\IDE.exe"` fi # MS Visual .NET if test -e "C:\Program Files\Microsoft Visual Studio .NET 2003"; then VSROOT="C:\Program Files\Microsoft Visual Studio .NET 2003" VSDEVENV=`cygpath --unix "$VSROOT\Common7\IDE\devenv.exe"` VSVARS="$VSROOT\Common7\Tools\vsvars32.bat" VSCC="$VSROOT\VC7\BIN\cl.exe" else VSROOT="C:\Program Files (x86)\Microsoft Visual Studio" VSDEVENV=`cygpath --unix "$VSROOT\Common\MSDev98\Bin\msdev.exe"` VSVARS="$VSROOT\VC98\Bin\vcvars32.bat" VSCC="$VSROOT\VC98\Bin\cl.exe" fi STDENV_SYSTEM_MODULES="StdBool StdChar StdFile StdInt StdMisc StdReal StdString" log () # $1: message { echo "$1" } fatal () # $1: message { log "$1" exit 1 } checkreturncodeoptionallyfail () # $1: where # $2: error message # $3: return code # $4: 0: don't fail, otherwise: fail { if test $3 -ne 0; then if test $4 -eq 0; then log "$1: warning ($3) $2" else fatal "$1: error ($3) $2" fi fi } checkreturncode () # $1: where # $2: error message # $3: return code { checkreturncodeoptionallyfail "$1" "$2" $3 1 } checkcleanreturncode () # $1: clean system dir # $2: where # $3: error message # $4: return code { if test "$1" = "$CLEANROOT" ; then checkcleanreturncode_fail=0 else checkcleanreturncode_fail=1 fi checkreturncodeoptionallyfail "$2" "$3" $4 $checkcleanreturncode_fail } cvsget () # $1: destination directory # $2: cvs module { # for some reason # % cvs -d destination/cvsmodule cvsmodule # doesn't seem to work that's why we cd to the destination dir log "CVS '$CVS_EXPORT_CMD' '$2'" ( cd "$1" $CVS -d "$CVS_ROOT" $CVS_QUIET $CVS_GET_CMD "$2" checkreturncode "cvsget" "getting '$1' to '$2'" $? ) } makedir () # $1: directory path { if test -e "$1"; then fatal "makedir: directory '$1' already exists" fi mkdir -p "$1" checkreturncode "makedir" "creating '$1'" $? } move () # $1: source path # $2: destination path { if test ! -e "$1"; then fatal "move source '$1' does not exist" fi if test -e "$2"; then fatal "move destination '$2' already exists" fi mv "$1" "$2" checkreturncode "move" "moving '$1' to '$2'" $? } remove () # $1: directory or file path { if test ! -e "$1"; then fatal "remove '$1' does not exist" fi rm -r "$1" checkreturncode "remove" "removing '$1'" $? } duplicate () # $1: source path # $2: destination path { log "duplicating '$1' -> '$2'" if test ! -e "$1"; then fatal "duplicate: source '$1' does not exist" fi if test -e "$2"; then fatal "duplicate: destination '$2' already exists" fi cp -r "$1" "$2" checkreturncode "duplicate" "copying '$1' to '$2'" $? } vscc () # $1: C .c file path { vscc_file=`cygpath --absolute --windows "$1"` vscc_dir=`dirname "$1"` (cd "$vscc_dir" cat < '$2'" if test ! -e "$1"; then fatal "xduplicate: source '$1' does not exist" fi if test ! -e "$2"; then cp -r "$1" "$2" checkreturncode "xduplicate" "copying '$1' to '$2'" $? fi } xduplicate2 () # $1: source path # $2: destination dir { log "duplicating '$1' -> '$2'" if test ! -e "$1"; then fatal "xduplicate: source '$1' does not exist" fi if test ! -e "$2"; then fatal "xduplicate: destination '$2' does not exist" fi xduplicate2_file=`basename "$1"` xduplicate "$1" "$2/$xduplicate2_file" } xduplicatefiles () # $1: source path # $2: destination path { log "duplicating files '$1' -> '$2'" if test ! -e "$1"; then fatal "xduplicate: source '$1' does not exist" fi if test ! -e "$2"; then fatal "xduplicate: destination '$2' does not exist" fi for xduplicatefiles_source in "$1"/*; do xduplicatefiles_file=`basename "$xduplicatefiles_source"` xduplicate "$xduplicatefiles_source" "$2/$xduplicatefiles_file" done } xmove () # $1: source path # $2: destination path { if test ! -e "$2"; then if test ! -e "$1"; then fatal "xmove source '$1' does not exist" fi mv "$1" "$2" checkreturncode "xmove" "moving '$1' to '$2'" $? fi } xremove () # $1: directory or file path { if test -e "$1"; then rm -r "$1" checkreturncode "xremove" "removing '$1'" $? fi } NONCLEAN_COMPONENTS="runtimesystem backend dynamicchannel dynamicgraphconversion idersrc ioobjects codegen stdenvobj" runtimesystem_build () # $1: cvs dir # $2: build dir { xduplicate "$1/RuntimeSystem" "$2/runtimesystem" chmod +x "$2/runtimesystem/build_windows_object_files.sh" (cd "$2/runtimesystem" ./build_windows_object_files.sh ) } runtimesystem_dist () # $1: non-Clean build dir # $2: dist dir { for objectfile in _startup1.o _startup1Profile.o _startup1Trace.o _startup2.o ; do xduplicate2 "$1/RuntimeSystem/$objectfile" "$2/Libraries/StdEnv/Clean System Files" xduplicate2 "$1/RuntimeSystem/$objectfile" "$2/Libraries/StdEnv Sparkle/Clean System Files" done } backend_build () # $1: cvs dir # $2: build dir { xduplicate "$1/compiler/backendC" "$2/backend" cwbuild "$2/backend/backend.mcp" backend.dll } backend_dist () # $1: non-Clean build dir # $2: dist dir { xduplicate "$1/backend/backend.dll" "$2/Tools/Clean System/backend.dll" } dynamicchannel_build () # $1: cvs dir # $2: build dir { xduplicate "$1/dynamic/dynamics/Channel" "$2/dynamicchannel" (cd "$2/dynamicchannel" cat <