rsc.io/go@v0.0.0-20150416155037-e040fd465409/misc/cgo/testcarchive/test.bash (about) 1 #!/usr/bin/env bash 2 # Copyright 2015 The Go Authors. All rights reserved. 3 # Use of this source code is governed by a BSD-style 4 # license that can be found in the LICENSE file. 5 6 set -e 7 8 ccargs="" 9 if [ "$(go env GOOS)" == "darwin" ]; then 10 ccargs="-Wl,-no_pie" 11 # For darwin/arm. 12 # TODO(crawshaw): Can we do better? 13 ccargs="$ccargs -framework CoreFoundation" 14 fi 15 16 # TODO(crawshaw): Consider a go env for exec script name. 17 bin=./testp 18 exec_script=go_$(go env GOOS)_$(go env GOARCH)_exec 19 if [ "$(which $exec_script)" != "" ]; then 20 bin="$exec_script ./testp" 21 fi 22 23 GOPATH=$(pwd) go build -buildmode=c-archive src/libgo/libgo.go 24 $(go env CC) $(go env GOGCCFLAGS) $ccargs -o testp main.c libgo.a 25 $bin 26 rm libgo.a testp 27 28 GOPATH=$(pwd) go build -buildmode=c-archive -o libgo.a libgo 29 $(go env CC) $(go env GOGCCFLAGS) $ccargs -o testp main.c libgo.a 30 $bin 31 rm libgo.a testp