build: let a .goroot symlink set the GOROOT environment and path.

Change-Id: I4e7d560fc4b9974af85b043e13157104894c27be
This commit is contained in:
Brad Fitzpatrick 2011-10-15 19:41:43 -07:00
parent 3de908e849
commit 5a0de07a47
3 changed files with 14 additions and 1 deletions

1
.gitignore vendored
View File

@ -15,3 +15,4 @@ _embed_*.go
_cgo*
clients/go/camgsinit/camgsinit
clients/go/camwebdav/camwebdav
.goroot

View File

@ -1 +1 @@
6g version release.r60.2 9933
6g version release.r60.2 9925

View File

@ -62,6 +62,8 @@ EOM
;
}
setup_environment_from_goroot_symlink();
my %built; # target -> bool (was it already built?)
# Note: the target key is usually the directory, but may be overridden. use
@ -629,6 +631,16 @@ sub generate_embed_file {
print $dest "func init() {\n\tFiles.Add(\"$base_file\", \"$escaped\");\n}\n";
}
sub setup_environment_from_goroot_symlink {
return unless -e ".goroot";
my $root = readlink ".goroot";
unless (-d $root) {
die "Optional file $Findbin::Bin/.goroot points to invalid GOROOT directory $root\n";
}
$ENV{"GOROOT"} = $root;
$ENV{"PATH"} = "$root/bin:$ENV{PATH}";
}
__DATA__
TARGET: clients/go/camdbinit