Browse code

imporve hardcoded CC on cross compile

Since commit applied in moby [61a3285 Support cross-compile for arm]
it hardcoded var-CC to support cross-compile for arm

Correct it with "${parameter:-word}" format, it is helpful for user
define toolchains

(Use Default Values. If parameter is unset or null, the expansion of
word is substituted. Otherwise, the value of parameter is substituted.)

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>

Hongxu Jia authored on 2019/07/17 18:34:04
Showing 1 changed files
... ...
@@ -44,27 +44,27 @@ if [ "$(go env GOOS)/$(go env GOARCH)" != "$(go env GOHOSTOS)/$(go env GOHOSTARC
44 44
 	# must be cross-compiling!
45 45
 	case "$(go env GOOS)/$(go env GOARCH)" in
46 46
 		windows/amd64)
47
-			export CC=x86_64-w64-mingw32-gcc
47
+			export CC="${CC:-x86_64-w64-mingw32-gcc}"
48 48
 			export CGO_ENABLED=1
49 49
 			;;
50 50
 		linux/arm)
51 51
 			case "${GOARM}" in
52 52
 			5|"")
53
-				export CC=arm-linux-gnueabi-gcc
53
+				export CC="${CC:-arm-linux-gnueabi-gcc}"
54 54
 				export CGO_ENABLED=1
55 55
 				;;
56 56
 			7)
57
-				export CC=arm-linux-gnueabihf-gcc
57
+				export CC="${CC:-arm-linux-gnueabihf-gcc}"
58 58
 				export CGO_ENABLED=1
59 59
 				;;
60 60
 			esac
61 61
 			;;
62 62
 		linux/arm64)
63
-			export CC=aarch64-linux-gnu-gcc
63
+			export CC="${CC:-aarch64-linux-gnu-gcc}"
64 64
 			export CGO_ENABLED=1
65 65
 			;;
66 66
 		linux/amd64)
67
-			export CC=x86_64-linux-gnu-gcc
67
+			export CC="${CC:-x86_64-linux-gnu-gcc}"
68 68
 			export CGO_ENABLED=1
69 69
 			;;
70 70
 	esac