Skip to content

Commit

Permalink
jiri-profile-v23: Switch the default to Go 1.6
Browse files Browse the repository at this point in the history
This also involves some formatting changes to files since apparently "go
fmt" has some changes between Go 1.5 and 1.6

Resolves vanadium/issues#1239

MultiPart: 1/2
Change-Id: I57858330578b5594640137559c37b32ad8e8ef77
  • Loading branch information
asimshankar committed Mar 21, 2016
1 parent f1b3b04 commit 2063942
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 42 deletions.
33 changes: 23 additions & 10 deletions jiri-profile-v23/android_profile/android.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type versionSpec struct {
ndkExtract func(seq runutil.Sequence, src, dst string) runutil.Sequence
ndkAPILevel int
platformToolsVersion map[string]string
baseVersion string // Version of the base profile that this requires
}

func ndkArch(goArch string) (string, error) {
Expand Down Expand Up @@ -71,21 +72,25 @@ func Register(installer, profile string) {
ndkDownloadURL: fmt.Sprintf("%s/android-ndk-r9d-%s-%s.tar.bz2", ndkDownloadBaseURL, runtime.GOOS, arch),
ndkExtract: tarExtract,
ndkAPILevel: 9,
baseVersion: "4",
},
"4": &versionSpec{
ndkDownloadURL: fmt.Sprintf("%s/android-ndk-r10e-%s-%s.bin", ndkDownloadBaseURL, runtime.GOOS, arch),
ndkExtract: selfExtract,
ndkAPILevel: 16,
baseVersion: "4",
},
"5": &versionSpec{
ndkDownloadURL: fmt.Sprintf("%s/android-ndk-r10e-%s-%s.bin", ndkDownloadBaseURL, runtime.GOOS, arch),
ndkExtract: selfExtract,
ndkAPILevel: 21,
baseVersion: "4",
},
"7": &versionSpec{
ndkDownloadURL: fmt.Sprintf("%s/android-ndk-r10e-%s-%s.bin", ndkDownloadBaseURL, runtime.GOOS, arch),
ndkExtract: selfExtract,
ndkAPILevel: 21,
baseVersion: "4",
},
"8": &versionSpec{
ndkDownloadURL: fmt.Sprintf("%s/android-ndk-r10e-%s-%s.bin", ndkDownloadBaseURL, runtime.GOOS, arch),
Expand All @@ -95,8 +100,19 @@ func Register(installer, profile string) {
"darwin": "sdk-repo-darwin-platform-tools-2219242",
"linux": "sdk-repo-linux-platform-tools-2219198",
},
baseVersion: "4",
},
}, "8"),
"9": &versionSpec{
ndkDownloadURL: fmt.Sprintf("%s/android-ndk-r10e-%s-%s.bin", ndkDownloadBaseURL, runtime.GOOS, arch),
ndkExtract: selfExtract,
ndkAPILevel: 21,
platformToolsVersion: map[string]string{
"darwin": "sdk-repo-darwin-platform-tools-2219242",
"linux": "sdk-repo-linux-platform-tools-2219198",
},
baseVersion: "5",
},
}, "9"),
}
profilesmanager.Register(m)
}
Expand Down Expand Up @@ -213,13 +229,10 @@ func (m *Manager) installBase(jirix *jiri.X, pdb *profiles.DB, root jiri.RelPath
// So this is a good way to copy the arch/opsys and we just have to set
// the version.
baseTarget, err := profiles.NewTarget(target.String(), env)
baseTarget.SetVersion(m.spec.baseVersion)
if err != nil {
return nil, err
}
// We are setting version 4 to ensure that we get a newer version of Go that
// works on android. It's not clear why the default version of the go
// profile is for an old version of go.
baseTarget.SetVersion("4")
if err := profilesmanager.EnsureProfileTargetIsInstalled(jirix, pdb, m.profileInstaller, "base", root, baseTarget); err != nil {
return nil, err
}
Expand Down Expand Up @@ -292,12 +305,12 @@ func (m *Manager) installAndroidPlatformTools(jirix *jiri.X, target profiles.Tar
androidPlatformToolsZipFile := filepath.Join(tmpDir, "platform-tools.zip")
return jirix.NewSeq().
Call(func() error {
url := platformToolsBaseURL + "/" + suffix + ".zip"
return profilesutil.Fetch(jirix, androidPlatformToolsZipFile, url)
}, "fetch android platform tools").
url := platformToolsBaseURL + "/" + suffix + ".zip"
return profilesutil.Fetch(jirix, androidPlatformToolsZipFile, url)
}, "fetch android platform tools").
Call(func() error {
return profilesutil.Unzip(jirix, androidPlatformToolsZipFile, tmpDir)
}, "unzip android platform tools").
return profilesutil.Unzip(jirix, androidPlatformToolsZipFile, tmpDir)
}, "unzip android platform tools").
MkdirAll(filepath.Dir(outDir), profilesutil.DefaultDirPerm).
Rename(filepath.Join(tmpDir, "platform-tools"), outDir).
Done()
Expand Down
14 changes: 12 additions & 2 deletions jiri-profile-v23/base_profile/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ func Register(installer, profile string) {
{"go", "1.5.2.1:56093743"},
{"syncbase", ""}},
},
}, "1"),
"5": &versionSpec{[]struct{ name, version string }{
{"go", "1.6"},
{"syncbase", ""}},
},
}, "5"),
}
profilesmanager.Register(m)
}
Expand Down Expand Up @@ -113,7 +117,13 @@ func (m *Manager) Install(jirix *jiri.X, pdb *profiles.DB, root jiri.RelPath, ta
os = "darwin"
}
base.Set("GOOS", os)
profilesreader.MergeEnv(profilesreader.ProfileMergePolicies(), base, profileEnvs...)
// Slight modifications to ProfileMergePolicies: Want the values from
// the "go" profile we depend on to prevail.
mp := profilesreader.ProfileMergePolicies()
mp["GOROOT"] = profilesreader.UseLast
mp["GOROOT_BOOTSTRAP"] = profilesreader.IgnoreBaseUseLast
mp["CGO_ENABLED"] = profilesreader.IgnoreBaseUseLast
profilesreader.MergeEnv(mp, base, profileEnvs...)
target.Env.Vars = base.ToSlice()
pdb.InstallProfile(m.profileInstaller, m.profileName, string(root))
return pdb.AddProfileTarget(m.profileInstaller, m.profileName, target)
Expand Down
4 changes: 2 additions & 2 deletions jiri-profile-v23/dart_profile/dart.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ func (m *Manager) installDartSdk(jirix *jiri.X, target profiles.Target, outDir s
sdkZipFile := filepath.Join(tmpDir, "dart-sdk.zip")
return jirix.NewSeq().
Call(func() error {
return profilesutil.Fetch(jirix, sdkZipFile, sdkUrl)
}, "fetch dart sdk").
return profilesutil.Fetch(jirix, sdkZipFile, sdkUrl)
}, "fetch dart sdk").
Call(func() error { return profilesutil.Unzip(jirix, sdkZipFile, tmpDir) }, "unzip dart sdk").
MkdirAll(filepath.Dir(outDir), profilesutil.DefaultDirPerm).
Rename(filepath.Join(tmpDir, "dart-sdk"), outDir).
Expand Down
6 changes: 3 additions & 3 deletions jiri-profile-v23/go_profile/darwin_xcompile.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func useLLVM(jirix *jiri.X, m *Manager, root jiri.RelPath, target profiles.Targe
Pushd(binutilsSrc).
MkdirAll(absBinutilsBin, profilesutil.DefaultDirPerm).
Run("./configure", "--target="+targetABI, "--program-prefix=",
"--prefix="+absBinutilsBin, "--with-sysroot=yes").
"--prefix="+absBinutilsBin, "--with-sysroot=yes").
Run("make", "-j8").
Last("make", "install")
}
Expand All @@ -125,8 +125,8 @@ func useLLVM(jirix *jiri.X, m *Manager, root jiri.RelPath, target profiles.Targe
return jirix.NewSeq().MkdirAll(absClangBuildSrc, profilesutil.DefaultDirPerm).
Pushd(absClangBuildSrc).
Run("cmake", "-GUnix Makefiles", "-DCMAKE_INSTALL_PREFIX="+inst.Abs(jirix),
"-DLLVM_TARGETS_TO_BUILD=ARM",
"-DLLVM_EXTERNAL_CLANG_SOURCE_DIR="+absClangSrc, absLLVMSrc).
"-DLLVM_TARGETS_TO_BUILD=ARM",
"-DLLVM_EXTERNAL_CLANG_SOURCE_DIR="+absClangSrc, absLLVMSrc).
Run("make", "-j8").
Last("make", "install")
}
Expand Down
23 changes: 10 additions & 13 deletions jiri-profile-v23/go_profile/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"v.io/jiri/gitutil"
"v.io/jiri/profiles"
"v.io/jiri/profiles/profilesmanager"
"v.io/jiri/profiles/profilesreader"
"v.io/jiri/profiles/profilesutil"
"v.io/jiri/project"
"v.io/x/lib/envvar"
Expand Down Expand Up @@ -156,7 +155,7 @@ func Register(installer, profile string) {
"560937434d5f2857bb69e0a6881a38201a197a8d", nil},
"1.6": &versionSpec{
"e805bf39458915365924228dc53969ce04e32813", nil},
}, "1.5.1"), // TODO(ashankar): Change to 1.6 once all code has been updated to pass tests with it
}, "1.6"),
}
profilesmanager.Register(m)
}
Expand Down Expand Up @@ -255,6 +254,8 @@ func (m *Manager) Install(jirix *jiri.X, pdb *profiles.DB, root jiri.RelPath, ta
if release := newGoRelease(target.Version()); release != nil &&
len(m.spec.patchFiles) == 0 &&
!env.Contains("GO_FLAGS") {
// Not using a bootstrapped Go, delete any references from env.
env.Delete("GOROOT_BOOTSTRAP")
goInstDir = m.goRoot.Join("shared").Join(target.Version())
fn := func() error { return release.install(jirix, goInstDir.Abs(jirix)) }
if err := profilesutil.AtomicAction(jirix, fn, goInstDir.Abs(jirix), "Install a release version of the Go toolchain"); err != nil {
Expand Down Expand Up @@ -289,9 +290,7 @@ func (m *Manager) Install(jirix *jiri.X, pdb *profiles.DB, root jiri.RelPath, ta
return err
}
}
// Merge our target environment and GOROOT
goEnv := []string{"GOROOT=" + goInstDir.Symbolic()}
profilesreader.MergeEnv(profilesreader.ProfileMergePolicies(), env, goEnv)
env.Set("GOROOT", goInstDir.Symbolic())
target.Env.Vars = env.ToSlice()
target.InstallationDir = string(goInstDir)

Expand Down Expand Up @@ -563,6 +562,12 @@ func darwin_to_ios(jirix *jiri.X, m *Manager, root jiri.RelPath, target profiles
"CC_FOR_TARGET=" + filepath.Join(jirix.Root, "release/swift/clang/clangwrap.sh"),
"CXX_FOR_TARGET=" + filepath.Join(jirix.Root, "release/swift/clang/clangwrap++.sh"),
"GOOS=darwin",
"GOHOSTARCH=amd64",
"GOHOSTOS=darwin",
// We need to explicitly pass the ios build tag to the make.bash script for go so that it won't compile
// crypto code that's meant for the mac. It'll work on the device because those files have a build tag
// of !arm64, but the simulator will fail because those specific APIs don't exist on iOS.
"GO_FLAGS=-tags ios",
}

// 32-bit arm is always armv7 in Apple-land
Expand All @@ -576,14 +581,6 @@ func darwin_to_ios(jirix *jiri.X, m *Manager, root jiri.RelPath, target profiles
// Submitted to golang, currently marked for 1.7: https://go-review.googlesource.com/#/c/19206/
patchPath := filepath.Join(jirix.Root, "release/go/src/v.io/x/devtools/jiri-v23-profile/go/macho_linker.patch")
m.spec.patchFiles = append(m.spec.patchFiles, patchPath)
// Additional to influence make.bash used when building our own toolchain
vars = append(vars,
"GOHOSTARCH=amd64",
"GOHOSTOS=darwin",
// We need to explicitly pass the ios build tag to the make.bash script for go so that it won't compile
// crypto code that's meant for the mac. It'll work on the device because those files have a build tag
// of !arm64, but the simulator will fail because those specific APIs don't exist on iOS.
"GO_FLAGS=-tags ios")
return "", vars, nil
}

Expand Down
8 changes: 4 additions & 4 deletions jiri-profile-v23/mojo_profile/mojo.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,8 @@ func (m *Manager) installAndroidPlatformTools(jirix *jiri.X, outDir string) erro
androidPlatformToolsZipFile := filepath.Join(tmpDir, "platform-tools.zip")
return jirix.NewSeq().
Call(func() error {
return profilesutil.Fetch(jirix, androidPlatformToolsZipFile, androidPlatformToolsUrl(m.spec.androidPlatformToolsVersion))
}, "fetch android platform tools").
return profilesutil.Fetch(jirix, androidPlatformToolsZipFile, androidPlatformToolsUrl(m.spec.androidPlatformToolsVersion))
}, "fetch android platform tools").
Call(func() error { return profilesutil.Unzip(jirix, androidPlatformToolsZipFile, tmpDir) }, "unzip android platform tools").
MkdirAll(filepath.Dir(outDir), profilesutil.DefaultDirPerm).
Rename(filepath.Join(tmpDir, "platform-tools"), outDir).
Expand Down Expand Up @@ -617,8 +617,8 @@ func (m *Manager) installMojoSystemThunks(jirix *jiri.X, outDir string) error {
outFile := filepath.Join(outDir, "libsystem_thunks.a")
return jirix.NewSeq().MkdirAll(outDir, profilesutil.DefaultDirPerm).
Call(func() error {
return profilesutil.Fetch(jirix, outFile, mojoSystemThunksUrl(m.platform, m.buildVersion))
}, "fetch mojo system thunks").Done()
return profilesutil.Fetch(jirix, outFile, mojoSystemThunksUrl(m.platform, m.buildVersion))
}, "fetch mojo system thunks").Done()
}
return profilesutil.AtomicAction(jirix, fn, outDir, "Download Mojo system thunks")
}
Expand Down
6 changes: 3 additions & 3 deletions oncall/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,9 @@ func collectCloudServicesBuildInfo(ctx *tool.Context, zones map[string]*zoneData
Capture(&stdoutBuf, &stderrBuf).
Timeout(debugCommandTimeout).
Last(debug,
"--timeout", debugRPCTimeout.String(),
"--v23.namespace.root", namespaceRoot,
"--v23.credentials", credentialsFlag, "stats", "read", fmt.Sprintf("%s/build.[TPUM]*", buildInfoEndpointPrefix)); err != nil {
"--timeout", debugRPCTimeout.String(),
"--v23.namespace.root", namespaceRoot,
"--v23.credentials", credentialsFlag, "stats", "read", fmt.Sprintf("%s/build.[TPUM]*", buildInfoEndpointPrefix)); err != nil {
return fmt.Errorf("debug command failed: %v\nSTDERR:\n%s\nSTDOUT:\n%s\nEND\n", err, stderrBuf.String(), stdoutBuf.String())
}

Expand Down
10 changes: 5 additions & 5 deletions vcloud/vcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,11 @@ func (n nodeInfo) RunCommand(ctx *tool.Context, user string, cmdline []string) r
var stdouterr bytes.Buffer
err := ctx.NewSeq().Read(nil).Capture(&stdouterr, &stdouterr).
Last("gcloud", "compute", "ssh",
addUser(user, n.Name),
"--project", *flagProject,
"--zone", n.Zone,
"--command", quoteForCommand(cmdline),
)
addUser(user, n.Name),
"--project", *flagProject,
"--zone", n.Zone,
"--command", quoteForCommand(cmdline),
)
return runResult{node: n, out: stdouterr.String(), err: err}
}

Expand Down

0 comments on commit 2063942

Please sign in to comment.