cmd/gomobile: don't override the build tags

Fixes golang/go#13082.

Change-Id: I0956efb1045cc04dcda5034e2ff6e3089be192e0
Reviewed-on: https://go-review.googlesource.com/16433
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
Burcu Dogan 2015-10-28 12:45:15 -07:00
parent 7c674f7f33
commit c6f2181dba
3 changed files with 9 additions and 5 deletions

View File

@ -26,6 +26,7 @@ func TestIOSBuild(t *testing.T) {
buildTarget = "ios"
gopath = filepath.SplitList(os.Getenv("GOPATH"))[0]
cmdBuild.flag.Parse([]string{"golang.org/x/mobile/example/basic"})
ctx.BuildTags = []string{"tag1"}
err := runBuild(cmdBuild)
if err != nil {
t.Log(buf.String())
@ -49,8 +50,8 @@ mkdir -p $WORK/main
echo "{{template "infoplist" .Xinfo}}" > $WORK/main/Info.plist
mkdir -p $WORK/main/Images.xcassets/AppIcon.appiconset
echo "{{.Xcontents}}" > $WORK/main/Images.xcassets/AppIcon.appiconset/Contents.json
GOOS=darwin GOARCH=arm GOARM=7 CC=clang-iphoneos CXX=clang-iphoneos CGO_CFLAGS=-isysroot=iphoneos -arch armv7 CGO_LDFLAGS=-isysroot=iphoneos -arch armv7 CGO_ENABLED=1 go build -p={{.NumCPU}} -pkgdir=$GOMOBILE/pkg_darwin_arm -tags="" -x -tags=ios -o=$WORK/arm golang.org/x/mobile/example/basic
GOOS=darwin GOARCH=arm64 CC=clang-iphoneos CXX=clang-iphoneos CGO_CFLAGS=-isysroot=iphoneos -arch arm64 CGO_LDFLAGS=-isysroot=iphoneos -arch arm64 CGO_ENABLED=1 go build -p={{.NumCPU}} -pkgdir=$GOMOBILE/pkg_darwin_arm64 -tags="" -x -tags=ios -o=$WORK/arm64 golang.org/x/mobile/example/basic
GOOS=darwin GOARCH=arm GOARM=7 CC=clang-iphoneos CXX=clang-iphoneos CGO_CFLAGS=-isysroot=iphoneos -arch armv7 CGO_LDFLAGS=-isysroot=iphoneos -arch armv7 CGO_ENABLED=1 go build -p={{.NumCPU}} -pkgdir=$GOMOBILE/pkg_darwin_arm -tags="tag1,ios" -x -o=$WORK/arm golang.org/x/mobile/example/basic
GOOS=darwin GOARCH=arm64 CC=clang-iphoneos CXX=clang-iphoneos CGO_CFLAGS=-isysroot=iphoneos -arch arm64 CGO_LDFLAGS=-isysroot=iphoneos -arch arm64 CGO_ENABLED=1 go build -p={{.NumCPU}} -pkgdir=$GOMOBILE/pkg_darwin_arm64 -tags="tag1,ios" -x -o=$WORK/arm64 golang.org/x/mobile/example/basic
xcrun lipo -create $WORK/arm $WORK/arm64 -o $WORK/main/main
mkdir -p $WORK/main/assets
xcrun xcodebuild -configuration Release -project $WORK/main.xcodeproj

View File

@ -60,8 +60,10 @@ func goIOSBuild(pkg *build.Package) (map[string]bool, error) {
}
}
ctx.BuildTags = append(ctx.BuildTags, "ios")
armPath := filepath.Join(tmpdir, "arm")
if err := goBuild(src, darwinArmEnv, "-tags=ios", "-o="+armPath); err != nil {
if err := goBuild(src, darwinArmEnv, "-o="+armPath); err != nil {
return nil, err
}
nmpkgs, err := extractPkgs(darwinArmNM, armPath)
@ -70,7 +72,7 @@ func goIOSBuild(pkg *build.Package) (map[string]bool, error) {
}
arm64Path := filepath.Join(tmpdir, "arm64")
if err := goBuild(src, darwinArm64Env, "-tags=ios", "-o="+arm64Path); err != nil {
if err := goBuild(src, darwinArm64Env, "-o="+arm64Path); err != nil {
return nil, err
}

View File

@ -53,6 +53,7 @@ func TestAndroidBuild(t *testing.T) {
os.Setenv("HOMEDRIVE", "C:")
}
cmdBuild.flag.Parse([]string{"golang.org/x/mobile/example/basic"})
ctx.BuildTags = []string{"tag1"}
err := runBuild(cmdBuild)
if err != nil {
t.Log(buf.String())
@ -70,5 +71,5 @@ func TestAndroidBuild(t *testing.T) {
var androidBuildTmpl = template.Must(template.New("output").Parse(`GOMOBILE={{.GOPATH}}/pkg/gomobile
WORK=$WORK
GOOS=android GOARCH=arm GOARM=7 CC=$GOMOBILE/android-{{.NDK}}/arm/bin/arm-linux-androideabi-gcc{{.EXE}} CXX=$GOMOBILE/android-{{.NDK}}/arm/bin/arm-linux-androideabi-g++{{.EXE}} CGO_ENABLED=1 go build -p={{.NumCPU}} -pkgdir=$GOMOBILE/pkg_android_arm -tags="" -x -buildmode=c-shared -o $WORK/libbasic.so golang.org/x/mobile/example/basic
GOOS=android GOARCH=arm GOARM=7 CC=$GOMOBILE/android-{{.NDK}}/arm/bin/arm-linux-androideabi-gcc{{.EXE}} CXX=$GOMOBILE/android-{{.NDK}}/arm/bin/arm-linux-androideabi-g++{{.EXE}} CGO_ENABLED=1 go build -p={{.NumCPU}} -pkgdir=$GOMOBILE/pkg_android_arm -tags="tag1" -x -buildmode=c-shared -o $WORK/libbasic.so golang.org/x/mobile/example/basic
`))