#!/usr/bin/env bash set -e # Exit if any return code not equals 0 ScriptRoot=$(dirname "$(readlink -f "$0")") OriginalProgram=0 CreateDLL=0 SimpleTest=0 Archive=0 case "$1" in "original") OriginalProgram=1 ;; "clean") ;; "cprog") Archive=1 ;; "dll") CreateDLL=1 Archive=1 ;; * | "all") CreateDLL=1 SimpleTest=1 Archive=1 ;; esac export GOPATH="${ScriptRoot}:${ScriptRoot}/levmar32" export GOGC="off" export GODEBUG="cgocheck=0" export CGO_ENABLED=1 export GOARCH=386 export GOHOSTARCH=386 export GOHOSTOS=windows export GOOS=windows cd "$ScriptRoot" cd ./src/go-pge if [ $Archive -eq 1 ]; then CGO_ENABLED=1 \ go build -o libpge32.a -ldflags="-s -w " -gcflags=all="-N -l" -buildmode=c-archive \ pge.go echo "Created c-archive from go" gcc -x c testmulti.c -o testmulti32.exe -std=c99 \ -L. -L../../levmar32/src/go-levmar/levmar-2.6 -L../../levmar32/src/go-levmar/levmar-2.6/libs32 \ -ggdb -fpic -m32 -pthread \ -lpge32 -lm -llevmar32 -llapack -lblas -lf2c -ltmglib -lWinMM -lntdll -lWS2_32 \ -Wno-implicit-function-declaration \ -Wno-int-conversion echo "Built C-Test programm" fi if [ $CreateDLL -eq 1 ]; then gcc -shared -pthread -o go-pge32.dll pge.c libpge32.a -lWinMM -lntdll -lWS2_32 \ -L../../levmar32/src/go-levmar/levmar-2.6 -L../../levmar32/src/go-levmar/levmar-2.6/libs32 \ -lm -llevmar32 -llapack -lblas -lf2c -ltmglib echo "Created PGE-DLL" cp go-pge32.dll ../../ fi if [ -f libpge32.a ]; then rm -f libpge32.a fi if [ -f libpge32.h ]; then rm -f libpge32.h fi if [ $SimpleTest -eq 1 ]; then echo "Starting simple test" powershell -File ../../TestResults32.ps1 fi if [ $OriginalProgram -eq 1 ]; then cd "$ScriptRoot" cd "go-code/src/go-pge" export GOPATH="${ScriptRoot}/go-code:${ScriptRoot}:${ScriptRoot}/levmar32" CGO_ENABLED=1 \ go build -o go-pge32.exe -ldflags="-s -w " -gcflags=all="-N -l" mv go-pge32.exe "$ScriptRoot/src/go-pge" echo "Rebuilt original application" fi