Skip to content

Commit

Permalink
Set _GOPATH correctly when cross-compiling.
Browse files Browse the repository at this point in the history
  • Loading branch information
katzdm committed Apr 9, 2019
1 parent 0fbb778 commit 9ba2b4e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/parse/rules/go_rules.build_defs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Go has a strong built-in concept of packages so it's probably a good idea to mat
rules to Go packages.
"""

_GOPATH = ' '.join(['-I %s -I %s/pkg/%s_%s' % (p, p, CONFIG.OS, CONFIG.ARCH) for p in CONFIG.GOPATH.split(':')])
# This links all the .a files up one level. This is necessary for some Go tools to find them.
_LINK_PKGS_CMD = ' '.join([
'for FN in `find . -name "*.a" | sort`; do ',
Expand Down Expand Up @@ -706,6 +705,9 @@ def _go_library_cmds(complete=True, all_srcs=False, cover=True, filter_srcs=True
filter_cmd = 'export SRCS="$(${TOOLS_FILTER} ${SRCS})"; ' if filter_srcs else ''
# Invokes the Go compiler.
complete_flag = '-complete ' if complete else ''

_GOPATH = ' '.join(
['-I %s -I %s/pkg/%s_%s' % (p, p, CONFIG.OS, CONFIG.ARCH) for p in CONFIG.GOPATH.split(':')])
compile_cmd = '$TOOLS_GO tool compile -trimpath $TMP_DIR %s%s -pack -o $OUT ' % (complete_flag, _GOPATH)
# Annotates files for coverage.
cover_cmd = 'for SRC in $SRCS; do BN=$(basename $SRC); go tool cover -mode=set -var=GoCover_${BN//[.-]/_} $SRC > _tmp.go && mv -f _tmp.go $SRC; done'
Expand All @@ -722,6 +724,9 @@ def _go_library_cmds(complete=True, all_srcs=False, cover=True, filter_srcs=True

def _go_binary_cmds(static=False, ldflags='', pkg_config='', definitions=None, gcov=False):
"""Returns the commands to run for linking a Go binary."""

_GOPATH = ' '.join(
['-I %s -I %s/pkg/%s_%s' % (p, p, CONFIG.OS, CONFIG.ARCH) for p in CONFIG.GOPATH.split(':')])
_link_cmd = '$TOOLS_GO tool link -tmpdir $TMP_DIR -extld $TOOLS_LD %s -o ${OUT} ' % _GOPATH.replace('-I ', '-L ')
prefix = _LINK_PKGS_CMD + _go_import_path_cmd(CONFIG.GO_IMPORT_PATH)

Expand Down

0 comments on commit 9ba2b4e

Please sign in to comment.