summaryrefslogtreecommitdiffstats
path: root/import-layers/yocto-poky/meta/recipes-devtools/go/go-1.6/split-host-and-target-build.patch
blob: afbae02b4e21986ee1e50e2e9591bd5e3f3b2f5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Add new option --target-only to build target components
Separates the host and target pieces of build

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Upstream-Status: Pending
Index: go/src/make.bash
===================================================================
--- go.orig/src/make.bash
+++ go/src/make.bash
@@ -143,12 +143,23 @@ if [ "$1" = "--no-clean" ]; then
 	buildall=""
 	shift
 fi
-./cmd/dist/dist bootstrap $buildall $GO_DISTFLAGS -v # builds go_bootstrap
-# Delay move of dist tool to now, because bootstrap may clear tool directory.
-mv cmd/dist/dist "$GOTOOLDIR"/dist
-echo
 
-if [ "$GOHOSTARCH" != "$GOARCH" -o "$GOHOSTOS" != "$GOOS" ]; then
+do_host_build="yes"
+do_target_build="yes"
+if [ "$1" = "--target-only" ]; then
+	do_host_build="no"
+	shift
+elif [ "$1" = "--host-only" ]; then
+	do_target_build="no"
+	shift
+fi
+
+if [ "$do_host_build" = "yes" ]; then
+	./cmd/dist/dist bootstrap $buildall $GO_DISTFLAGS -v # builds go_bootstrap
+	# Delay move of dist tool to now, because bootstrap may clear tool directory.
+	mv cmd/dist/dist "$GOTOOLDIR"/dist
+	echo
+
 	echo "##### Building packages and commands for host, $GOHOSTOS/$GOHOSTARCH."
 	# CC_FOR_TARGET is recorded as the default compiler for the go tool. When building for the host, however,
 	# use the host compiler, CC, from `cmd/dist/dist env` instead.
@@ -157,11 +168,20 @@ if [ "$GOHOSTARCH" != "$GOARCH" -o "$GOH
 	echo
 fi
 
-echo "##### Building packages and commands for $GOOS/$GOARCH."
-CC="$CC_FOR_TARGET" "$GOTOOLDIR"/go_bootstrap install $GO_FLAGS -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v std cmd
-echo
+if [ "$do_target_build" = "yes" ]; then
+    GO_INSTALL="${GO_TARGET_INSTALL:-std cmd}"
+    echo "##### Building packages and commands for $GOOS/$GOARCH."
+    if [ "$GOHOSTOS" = "$GOOS" -a "$GOHOSTARCH" = "$GOARCH" -a "$do_host_build" = "yes" ]; then
+	rm -rf ./host-tools
+	mkdir ./host-tools
+	mv "$GOTOOLDIR"/* ./host-tools
+	GOTOOLDIR="$PWD/host-tools"
+    fi
+    GOTOOLDIR="$GOTOOLDIR" CC="$CC_FOR_TARGET" "$GOTOOLDIR"/go_bootstrap install $GO_FLAGS -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v ${GO_INSTALL}
+    echo
 
-rm -f "$GOTOOLDIR"/go_bootstrap
+    rm -f "$GOTOOLDIR"/go_bootstrap
+fi
 
 if [ "$1" != "--no-banner" ]; then
 	"$GOTOOLDIR"/dist banner
OpenPOWER on IntegriCloud