[16666] | 1 | #!/usr/bin/env bash
|
---|
| 2 | set -e # Exit if any return code not equals 0
|
---|
| 3 |
|
---|
| 4 | ScriptRoot=$(dirname "$(readlink -f "$0")")
|
---|
| 5 | OriginalProgram=0
|
---|
| 6 | CreateDLL=0
|
---|
| 7 | SimpleTest=0
|
---|
| 8 | Archive=0
|
---|
| 9 |
|
---|
| 10 | case "$1" in
|
---|
| 11 | "original")
|
---|
| 12 | OriginalProgram=1
|
---|
| 13 | ;;
|
---|
| 14 | "clean")
|
---|
| 15 | ;;
|
---|
| 16 | "cprog")
|
---|
| 17 | Archive=1
|
---|
| 18 | ;;
|
---|
| 19 | "dll")
|
---|
| 20 | CreateDLL=1
|
---|
| 21 | Archive=1
|
---|
| 22 | ;;
|
---|
| 23 | * | "all")
|
---|
| 24 | CreateDLL=1
|
---|
| 25 | SimpleTest=1
|
---|
| 26 | Archive=1
|
---|
| 27 | ;;
|
---|
| 28 | esac
|
---|
| 29 |
|
---|
| 30 | export GOPATH="${ScriptRoot}:${ScriptRoot}/levmar32"
|
---|
| 31 |
|
---|
| 32 | export GOGC="off"
|
---|
| 33 | export GODEBUG="cgocheck=0"
|
---|
| 34 | export CGO_ENABLED=1
|
---|
| 35 |
|
---|
| 36 | export GOARCH=386
|
---|
| 37 | export GOHOSTARCH=386
|
---|
| 38 | export GOHOSTOS=windows
|
---|
| 39 | export GOOS=windows
|
---|
| 40 |
|
---|
| 41 | cd "$ScriptRoot"
|
---|
| 42 |
|
---|
| 43 | cd ./src/go-pge
|
---|
| 44 |
|
---|
| 45 | if [ $Archive -eq 1 ]; then
|
---|
| 46 | CGO_ENABLED=1 \
|
---|
| 47 | go build -o libpge32.a -ldflags="-s -w " -gcflags=all="-N -l" -buildmode=c-archive \
|
---|
| 48 | pge.go
|
---|
| 49 |
|
---|
| 50 | echo "Created c-archive from go"
|
---|
| 51 |
|
---|
| 52 | gcc -x c testmulti.c -o testmulti32.exe -std=c99 \
|
---|
| 53 | -L. -L../../levmar32/src/go-levmar/levmar-2.6 -L../../levmar32/src/go-levmar/levmar-2.6/libs32 \
|
---|
| 54 | -ggdb -fpic -m32 -pthread \
|
---|
| 55 | -lpge32 -lm -llevmar32 -llapack -lblas -lf2c -ltmglib -lWinMM -lntdll -lWS2_32 \
|
---|
| 56 | -Wno-implicit-function-declaration \
|
---|
| 57 | -Wno-int-conversion
|
---|
| 58 |
|
---|
| 59 | echo "Built C-Test programm"
|
---|
| 60 | fi
|
---|
| 61 |
|
---|
| 62 | if [ $CreateDLL -eq 1 ]; then
|
---|
| 63 | gcc -shared -pthread -o go-pge32.dll pge.c libpge32.a -lWinMM -lntdll -lWS2_32 \
|
---|
| 64 | -L../../levmar32/src/go-levmar/levmar-2.6 -L../../levmar32/src/go-levmar/levmar-2.6/libs32 \
|
---|
| 65 | -lm -llevmar32 -llapack -lblas -lf2c -ltmglib
|
---|
| 66 |
|
---|
| 67 | echo "Created PGE-DLL"
|
---|
| 68 | cp go-pge32.dll ../../
|
---|
| 69 | fi
|
---|
| 70 |
|
---|
| 71 | if [ -f libpge32.a ]; then
|
---|
| 72 | rm -f libpge32.a
|
---|
| 73 | fi
|
---|
| 74 | if [ -f libpge32.h ]; then
|
---|
| 75 | rm -f libpge32.h
|
---|
| 76 | fi
|
---|
| 77 |
|
---|
| 78 | if [ $SimpleTest -eq 1 ]; then
|
---|
| 79 | echo "Starting simple test"
|
---|
| 80 | powershell -File ../../TestResults32.ps1
|
---|
| 81 | fi
|
---|
| 82 |
|
---|
| 83 | if [ $OriginalProgram -eq 1 ]; then
|
---|
| 84 | cd "$ScriptRoot"
|
---|
| 85 | cd "go-code/src/go-pge"
|
---|
| 86 | export GOPATH="${ScriptRoot}/go-code:${ScriptRoot}:${ScriptRoot}/levmar32"
|
---|
| 87 | CGO_ENABLED=1 \
|
---|
| 88 | go build -o go-pge32.exe -ldflags="-s -w " -gcflags=all="-N -l"
|
---|
[16669] | 89 | mv go-pge32.exe "$ScriptRoot/src/go-pge"
|
---|
[16666] | 90 | echo "Rebuilt original application"
|
---|
| 91 | fi
|
---|
| 92 |
|
---|
| 93 |
|
---|