1
0
mirror of https://github.com/golang/go synced 2024-11-18 11:04:42 -07:00
go/misc/cgo/testcarchive/test.bash
David Crawshaw c5befcf0a7 misc/cgo/testcarchive: check that os.Args is set
Change-Id: I4278abca9d2a8f25149fa8935a93d32e7d04a43a
Reviewed-on: https://go-review.googlesource.com/9050
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-17 22:29:51 +00:00

32 lines
881 B
Bash
Executable File

#!/usr/bin/env bash
# Copyright 2015 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
set -e
ccargs=""
if [ "$(go env GOOS)" == "darwin" ]; then
ccargs="-Wl,-no_pie"
# For darwin/arm.
# TODO(crawshaw): Can we do better?
ccargs="$ccargs -framework CoreFoundation"
fi
# TODO(crawshaw): Consider a go env for exec script name.
bin=./testp
exec_script=go_$(go env GOOS)_$(go env GOARCH)_exec
if [ "$(which $exec_script)" != "" ]; then
bin="$exec_script ./testp"
fi
GOPATH=$(pwd) go build -buildmode=c-archive src/libgo/libgo.go
$(go env CC) $(go env GOGCCFLAGS) $ccargs -o testp main.c libgo.a
$bin arg1 arg2
rm libgo.a testp
GOPATH=$(pwd) go build -buildmode=c-archive -o libgo.a libgo
$(go env CC) $(go env GOGCCFLAGS) $ccargs -o testp main.c libgo.a
$bin arg1 arg2
rm libgo.a testp