diff --git a/src/parse/rules/go_rules.build_defs b/src/parse/rules/go_rules.build_defs index a77d33a635..c815c26598 100644 --- a/src/parse/rules/go_rules.build_defs +++ b/src/parse/rules/go_rules.build_defs @@ -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 ', @@ -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' @@ -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)