#!/usr/bin/env bash set -e # Exit if any return code not equals 0 ScriptRoot=$(dirname "$(readlink -f "$0")") BuildHL=0 case "$1" in "cprog") CreateDLL=0 SimpleTest=0 ;; "dll") CreateDLL=1 SimpleTest=0 ;; "hl") BuildHL=1 ;& * | "all") CreateDLL=1 SimpleTest=1 ;; esac export GOPATH="$ScriptRoot" 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 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../go-levmar/levmar-2.6 -L../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" if [ $CreateDLL -eq 1 ]; then gcc -shared -pthread -o go-pge.dll pge.c libpge.a -lWinMM -lntdll -lWS2_32 \ -L../go-levmar/levmar-2.6 -L../go-levmar/levmar-2.6/libs64 \ -lm -llevmar -llapack -lblas -lf2c -ltmglib echo "Created PGE-DLL" cp go-pge.dll ../../ fi rm -f libpge.a rm -f libpge.h echo "Build succeeded" if [ $SimpleTest -eq 1 ]; then echo "Starting simple test" powershell -File ../../TestResults.ps1 fi if [ $BuildHL -eq 1 ]; then echo "Building HL" fi