#!/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}/levmar" export GOGC="off" export GODEBUG="cgocheck=0" export CGO_ENABLED=1 export GOARCH=amd64 export GOHOSTARCH=amd64 export GOHOSTOS=windows export GOOS=windows cd "$ScriptRoot" cd ./src/go-pge if [ $Archive -eq 1 ]; then CGO_ENABLED=1 \ go build -o libpge.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 testmulti.exe -std=c99 \ -L. -L../../levmar/src/go-levmar/levmar-2.6 -L../../levmar/src/go-levmar/levmar-2.6/libs64 \ -ggdb -fpic -m64 -pthread \ -lpge -lm -llevmar -llapack -lblas -lf2c -ltmglib -lWinMM -lntdll -lWS2_32 \ -Wno-implicit-function-declaration echo "Built C-Test programm" fi if [ $CreateDLL -eq 1 ]; then gcc -shared -pthread -o go-pge.dll pge.c libpge.a -lWinMM -lntdll -lWS2_32 \ -L../../levmar/src/go-levmar/levmar-2.6 -L../../levmar/src/go-levmar/levmar-2.6/libs64 \ -lm -llevmar -llapack -lblas -lf2c -ltmglib echo "Created PGE-DLL" cp go-pge.dll ../../ fi if [ -f libpge.a ]; then rm -f libpge.a fi if [ -f libpge.h ]; then rm -f libpge.h fi if [ $SimpleTest -eq 1 ]; then echo "Starting simple test" powershell -File ../../TestResults.ps1 fi if [ $OriginalProgram -eq 1 ]; then cd "$ScriptRoot" cd "go-code/src/go-pge" export GOPATH="${ScriptRoot}/go-code:${ScriptRoot}:${ScriptRoot}/levmar" CGO_ENABLED=1 \ go build -o go-pge.exe -ldflags="-s -w " -gcflags=all="-N -l" mv go-pge.exe "$ScriptRoot/src/go-pge" echo "Rebuilt original application" fi