Skip to content

Commit

Permalink
Merge #66455 #66498
Browse files Browse the repository at this point in the history
66455: build: add script for cross-compilation job to windows via bazel r=rail a=rickystewart

We need to teach `bazci` about the configurations and add a new script
to support this. Also run both the Linux cross job and the Windows cross
job with `-c opt`, so we can start getting optimized builds.

Also add a small hack to `proj` to work around
OSGeo/PROJ#1235.

Closes #66208
Closes #66209

Release note: None

66498: roachprod: update to recommended ubuntu focal image r=rail a=rickystewart

The previous version was deprecated -- see #66183 for context.

Release note: None

Co-authored-by: Ricky Stewart <[email protected]>
  • Loading branch information
craig[bot] and rickystewart committed Jun 16, 2021
3 parents 14bd70c + c8abc23 + f3bd444 commit 1b3b128
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 13 deletions.
12 changes: 4 additions & 8 deletions build/bazelutil/bazelbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@

set -xeuo pipefail

# TODO(ricky): switching configurations to build `bazci` for the host before
# building the actual `cockroach` binary introduces some delays. It doesn't
# cause bazel to throw away its entire cache or anything, but it definitely
# rebuilds more than is technically necessary. This merits more investigation.
# TODO(ricky): I think it might be necessary to teach `bazci` about the
# configurations instead of asking `bazci` to just pass the configuration flags
# down to Bazel unchanged, but for now it seems fine.
bazel build //pkg/cmd/bazci --config=ci
$(bazel info bazel-bin)/pkg/cmd/bazci/bazci_/bazci build //pkg/cmd/cockroach-short -- --config=ci --config=crosslinux
$(bazel info bazel-bin)/pkg/cmd/bazci/bazci_/bazci --compilation_mode opt \
--config ci \
--config crosslinux \
build //pkg/cmd/cockroach-short
13 changes: 13 additions & 0 deletions build/bazelutil/bazelbuildwindows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -xeuo pipefail

# TODO(ricky): switching configurations to build `bazci` for the host before
# building the actual `cockroach` binary introduces some delays. It doesn't
# cause bazel to throw away its entire cache or anything, but it definitely
# rebuilds more than is technically necessary. This merits more investigation.
bazel build //pkg/cmd/bazci --config=ci
$(bazel info bazel-bin)/pkg/cmd/bazci/bazci_/bazci --compilation_mode opt \
--config ci \
--config crosswindows \
build //pkg/cmd/cockroach-short
3 changes: 2 additions & 1 deletion build/bazelutil/bazeltest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
set -xeuo pipefail

bazel build //pkg/cmd/bazci --config=ci
$(bazel info bazel-bin)/pkg/cmd/bazci/bazci_/bazci test //pkg:small_tests //pkg:medium_tests //pkg:large_tests //pkg:enormous_tests -- --config=ci
$(bazel info bazel-bin)/pkg/cmd/bazci/bazci_/bazci --config ci \
test //pkg:small_tests //pkg:medium_tests //pkg:large_tests //pkg:enormous_tests
12 changes: 12 additions & 0 deletions build/teamcity-bazel-windows-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -euo pipefail

source "$(dirname "${0}")/teamcity-support.sh" # For $root
source "$(dirname "${0}")/teamcity-bazel-support.sh" # For run_bazel

tc_prepare

tc_start_block "Run Bazel build"
run_bazel build/bazelutil/bazelbuildwindows.sh
tc_end_block "Run Bazel build"
2 changes: 1 addition & 1 deletion c-deps/proj
Submodule proj updated 1 files
+0 −1 CMakeLists.txt
43 changes: 41 additions & 2 deletions pkg/cmd/bazci/bazci.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package main

import (
"fmt"
"os"
"os/exec"
"strings"
Expand All @@ -24,7 +25,9 @@ const (
)

var (
artifactsDir string
artifactsDir string
configs []string
compilationMode string

rootCmd = &cobra.Command{
Use: "bazci",
Expand All @@ -47,6 +50,16 @@ func init() {
"artifacts_dir",
"/artifacts",
"path where artifacts should be staged")
rootCmd.Flags().StringVar(
&compilationMode,
"compilation_mode",
"dbg",
"compilation mode to pass down to Bazel (dbg or opt)")
rootCmd.Flags().StringSliceVar(
&configs,
"config",
[]string{},
"list of build configs to apply to bazel calls")
}

// parsedArgs looks basically like the `args` slice that Cobra gives us, but
Expand Down Expand Up @@ -115,9 +128,15 @@ type buildInfo struct {
tests []string
}

func runBazelReturningStdout(arg ...string) (string, error) {
func runBazelReturningStdout(subcmd string, arg ...string) (string, error) {
if subcmd != "query" {
arg = append(configArgList(), arg...)
arg = append(arg, "-c", compilationMode)
}
arg = append([]string{subcmd}, arg...)
buf, err := exec.Command("bazel", arg...).Output()
if err != nil {
fmt.Println("Failed to run Bazel with args: ", arg)
return "", err
}
return strings.TrimSpace(string(buf)), nil
Expand Down Expand Up @@ -188,7 +207,10 @@ func bazciImpl(cmd *cobra.Command, args []string) error {
go func() {
processArgs := []string{parsedArgs.subcmd}
processArgs = append(processArgs, parsedArgs.targets...)
processArgs = append(processArgs, configArgList()...)
processArgs = append(processArgs, "-c", compilationMode)
processArgs = append(processArgs, parsedArgs.additional...)
fmt.Println("running bazel w/ args: ", processArgs)
cmd := exec.Command("bazel", processArgs...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
Expand All @@ -202,3 +224,20 @@ func bazciImpl(cmd *cobra.Command, args []string) error {

return makeWatcher(completion, info).Watch()
}

func configArgList() []string {
ret := []string{}
for _, config := range configs {
ret = append(ret, "--config="+config)
}
return ret
}

func usingCrossWindowsConfig() bool {
for _, config := range configs {
if config == "crosswindows" {
return true
}
}
return false
}
3 changes: 3 additions & 0 deletions pkg/cmd/bazci/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ func (w watcher) stageBinaryArtifacts() error {
head := strings.ReplaceAll(strings.TrimPrefix(bin, "//"), ":", "/")
components := strings.Split(bin, ":")
relBinPath := path.Join(head+"_", components[len(components)-1])
if usingCrossWindowsConfig() {
relBinPath = relBinPath + ".exe"
}
err := w.maybeStageArtifact(binSourceDir, relBinPath, 0777, finalizePhase,
copyContentTo)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/roachprod/vm/gce/gcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func (o *providerOpts) ConfigureCreateFlags(flags *pflag.FlagSet) {
"Machine type (see https://cloud.google.com/compute/docs/machine-types)")
flags.StringVar(&o.MinCPUPlatform, ProviderName+"-min-cpu-platform", "",
"Minimum CPU platform (see https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform)")
flags.StringVar(&o.Image, ProviderName+"-image", "ubuntu-2004-focal-v20210325",
flags.StringVar(&o.Image, ProviderName+"-image", "ubuntu-2004-focal-v20210603",
"Image to use to create the vm, "+
"use `gcloud compute images list --filter=\"family=ubuntu-2004-lts\"` to list available images")

Expand Down

0 comments on commit 1b3b128

Please sign in to comment.