#!/bin/sh # #set -vx # shell debug options set -e # strategy: # get all sources from svn # 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 svn # ... 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` SVN=svn # Clean System CLEANROOT="`pwd`/Clean_3.0_32" # MS Visual .NET if test -e "C:\Program Files\Microsoft Visual Studio 14.0"; then VSROOT="C:\Program Files\Microsoft Visual Studio 14.0" VSDEVENV=`cygpath --unix "$VSROOT\Common7\IDE\devenv.exe"` VSVARS="$VSROOT\VC\bin\vcvars32.bat" VSCC="$VSROOT\VC\bin\cl.exe" VSCC_INLINE="" else 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" VSCC_INLINE="" else VSROOT="C:\Program Files\Microsoft Visual Studio" VSDEVENV=`cygpath --unix "$VSROOT\Common\MSDev98\Bin\msdev.exe"` VSVARS="$VSROOT\VC98\Bin\vcvars32.bat" VSCC="$VSROOT\VC98\Bin\cl.exe" VSCC_INLINE="/Dinline=__forceinline" fi 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 } svn_get () # $1 $2 $3 { w1=`cygpath --absolute --windows "$1"` log "svn '$2' '$3'" $SVN export -q "https://svn.cs.ru.nl/repos/$2" "$w1/$3" } git_get () # $1 $2 $3 { w1=`cygpath --absolute --windows "$1"` log "git '$2' '$3'" "/c/Program Files/Git/cmd/git.exe" clone --depth 1 "https://gitlab.science.ru.nl/$2" "$w1/$3" } 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"` vscc_object_file=`basename $vscc_file .c`.o # here documents (cd "$vscc_dir" "$COMMAND" < "$1/fonts/NimbusMonoPS-Regular.ttf" curl "http://git.ghostscript.com/?p=urw-core35-fonts.git;a=blob_plain;f=NimbusMonoPS-Bold.ttf;hb=refs/heads/master" -H "Host: git.ghostscript.com" -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" -H "Accept-Language: en-US,en;q=0.5" --compressed -H "DNT: 1" -H "Connection: keep-alive" -H "Upgrade-Insecure-Requests: 1" > "$1/fonts/NimbusMonoPS-Bold.ttf" (cd "$1/fonts"; wget "https://get.fontspace.co/download/family/8j4z/36725246f64c4594a48441c88f803e0b/liberation-sans-font.zip") (cd "$1/fonts"; unzip liberation-sans-font.zip LiberationSansBold-1adM.ttf LiberationSansItalic-RJre.ttf LiberationSans-BaDn.ttf) mv "$1/fonts/LiberationSans-BaDn.ttf" "$1/fonts/LiberationSans-Regular.ttf" mv "$1/fonts/LiberationSansBold-1adM.ttf" "$1/fonts/LiberationSans-Bold.ttf" mv "$1/fonts/LiberationSansItalic-RJre.ttf" "$1/fonts/LiberationSans-Italic.ttf" } xduplicate () # $1: source path # $2: destination path { log "duplicating '$1' -> '$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 "xduplicate2: source '$1' does not exist" fi if test ! -e "$2"; then fatal "xduplicate2: destination '$2' does not exist" fi xduplicate2_file=`basename "$1"` xduplicate "$1" "$2/$xduplicate2_file" } xduplicate3 () # $1: source path # $2: destination path { log "duplicating '$1' -> '$2'" if test ! -e "$1"; then fatal "xduplicate3: source '$1' does not exist" fi if test ! -e "$2"; then fatal "xduplicate3: destination '$2' does not exist" fi cp -r -t "$2" "$1"/* checkreturncode "xduplicate3" "copying '$1' to '$2'" $? } 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 tcpip codegen stdenvobj gast platform" 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" ( cd "$2/backend/CleanCompilerSources" PATH="/cygdrive/c/MinGW/bin":$PATH make -f Makefile.windows_mingw ) } 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 <> "./Clean_3.0_32/Libraries/StdEnv/Clean System Files/kernel_library" fi echo "SystemTimeToTzSpecificLocalTime@12" >> "./Clean_3.0_32/Libraries/StdEnv/Clean System Files/kernel_library" fi #dos2unix cvssource/RuntimeSystem/build_windows_object_files.sh tr -d "\r" < "$ROOT/cvssource/RuntimeSystem/build_windows_object_files.sh" > "$ROOT/cvssource/RuntimeSystem/build_windows_object_files.sh_" mv "$ROOT/cvssource/RuntimeSystem/build_windows_object_files.sh_" "$ROOT/cvssource/RuntimeSystem/build_windows_object_files.sh" buildnonclean "$ROOT/cvssource" "$ROOT/nonclean" buildclean "$CLEANROOT" "$ROOT/cvssource" "$ROOT/nonclean" "$ROOT/step0/clean" dist "$ROOT/cvssource" "$ROOT/nonclean" "$ROOT/step0/clean" "$ROOT/step0/dist" buildclean "$ROOT/step0/dist" "$ROOT/cvssource" "$ROOT/nonclean" "$ROOT/step1/clean" dist "$ROOT/cvssource" "$ROOT/nonclean" "$ROOT/step1/clean" "$ROOT/step1/dist" buildclean "$ROOT/step1/dist" "$ROOT/cvssource" "$ROOT/nonclean" "$ROOT/step2/clean" dist "$ROOT/cvssource" "$ROOT/nonclean" "$ROOT/step2/clean" "$ROOT/step2/dist" buildallcleanprojectfiles "$ROOT/step1/dist" "$ROOT/step1/dist/Examples" log "Build successful!!!" mkdir -p target/clean-classic mv "$ROOT/step2/dist"/* target/clean-classic/