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