1
0
mirror of https://github.com/golang/go synced 2024-11-23 13:00:07 -07:00
go/misc/cgo/fortran/test.bash
Martin Möhrmann 082881daf8 misc/cgo/fortran: fix gfortran compile test
Fixes #14544

Change-Id: I58b0b164ebbfeafe4ab32039a063df53e3018a6d
Reviewed-on: https://go-review.googlesource.com/22730
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Sean Lake <odysseus9672@gmail.com>
2016-05-04 15:08:16 +00:00

40 lines
761 B
Bash
Executable File

#!/usr/bin/env bash
# Copyright 2016 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.
# This directory is intended to test the use of Fortran with cgo.
set -e
FC=$1
goos=$(go env GOOS)
libext="so"
if [ "$goos" == "darwin" ]; then
libext="dylib"
fi
case "$FC" in
*gfortran*)
libpath=$(dirname $($FC -print-file-name=libgfortran.$libext))
export CGO_LDFLAGS="$CGO_LDFLAGS -Wl,-rpath,$libpath -L $libpath"
;;
esac
if ! $FC helloworld/helloworld.f90 -o main.exe >& /dev/null; then
echo "skipping Fortran test: could not build helloworld.f90 with $FC"
exit 0
fi
rm -f main.exe
status=0
if ! go test; then
echo "FAIL: go test"
status=1
fi
exit $status