From fafc3d11de1b44e3c87b597cc011c1bdfec70ee5 Mon Sep 17 00:00:00 2001 From: mpl Date: Fri, 11 Mar 2016 19:57:36 +0100 Subject: [PATCH] make.go: build for ARM in its own versioned gopath dir Fixes issues #691 #692 Change-Id: I47dcd1c672c0c810ebe47bce1a6badcedfca139b --- make.go | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/make.go b/make.go index 31388f3f5..e6698154a 100644 --- a/make.go +++ b/make.go @@ -61,7 +61,7 @@ var ( ifModsSince = flag.Int64("if_mods_since", 0, "If non-zero return immediately without building if there aren't any filesystem modifications past this time (in unix seconds)") buildARCH = flag.String("arch", runtime.GOARCH, "Architecture to build for.") buildOS = flag.String("os", runtime.GOOS, "Operating system to build for.") - buildARM = flag.String("arm", "7", "ARM version to use if building against arm.") + buildARM = flag.String("arm", "7", "ARM version to use if building for ARM. Note that this version applies even if the host arch is ARM too (and possibly of a different version).") stampVersion = flag.Bool("stampversion", true, "Stamp version into buildinfo.GitInfo") ) @@ -247,15 +247,25 @@ func main() { } } +func baseDirName(sql bool) string { + buildBaseDir := "build-gopath" + if !sql { + buildBaseDir += "-nosqlite" + } + // We don't even consider whether we're cross-compiling. As long as we + // build for ARM, we do it in its own versioned dir. + if *buildARCH == "arm" { + buildBaseDir += "-armv" + *buildARM + } + return buildBaseDir +} + // create the tmp GOPATH, and mirror to it from camRoot. // return the latest modtime among all of the walked files. func mirror(sql bool) (latestSrcMod time.Time) { verifyCamlistoreRoot(camRoot) - buildBaseDir := "build-gopath" - if !sql { - buildBaseDir += "-nosqlite" - } + buildBaseDir := baseDirName(sql) buildGoPath = filepath.Join(camRoot, "tmp", buildBaseDir) buildSrcDir = filepath.Join(buildGoPath, "src", "camlistore.org") @@ -350,18 +360,22 @@ func cleanGoEnv() (clean []string) { if *buildARCH != runtime.GOARCH && strings.HasPrefix(env, "GOARCH=") { continue } + // If we're building for ARM (regardless of cross-compiling or not), we reset GOARM + if *buildARCH == "arm" && strings.HasPrefix(env, "GOARM=") { + continue + } + clean = append(clean, env) } if *buildOS != runtime.GOOS { clean = append(clean, envPair("GOOS", *buildOS)) } - // TODO: If we ever want to cross-compile on ARMvx to ARMvy, this code below has to be fixed. - // See https://github.com/camlistore/camlistore/issues/692 if *buildARCH != runtime.GOARCH { clean = append(clean, envPair("GOARCH", *buildARCH)) - if *buildARCH == "arm" { - clean = append(clean, envPair("GOARM", *buildARM)) - } + } + // If we're building for ARM (regardless of cross-compiling or not), we reset GOARM + if *buildARCH == "arm" { + clean = append(clean, envPair("GOARM", *buildARM)) } return }