blob: a58c22a298c0a9a375d4c77a414f0ac8f3a67aae [file] [edit]
package actions
import (
goflag "flag"
"os"
"cos.googlesource.com/cos/tools.git/src/pkg/kernel"
"github.com/golang/glog"
"github.com/spf13/cobra"
flag "github.com/spf13/pflag"
)
var arch, build, board, configFile string
var useRegional bool
var staging bool
var rootCmd = &cobra.Command{
Use: "cos-kernel [action]",
Short: "cos-kernel - Tool for interacting with the COS kernel",
Long: `The cos-kernel tool performs common COS kernel development operations.
It supports workflows such as:
* Building a COS kernel from a local source tree.
* Building a COS kernel variant (e.g., lakitu-arm64, kselftest).
* Running arbitrary make commands using the COS toolchain.
* Downloading the COS C toolchain and kernel headers.
* Preparing patches for a new kernel feature.`,
SilenceUsage: true,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
if staging {
os.Setenv("CLOUDSDK_API_CLIENT_OVERRIDES_COMPUTE", "staging_v1")
os.Setenv("CLOUDSDK_CORE_DISABLE_WARNINGS", "1")
kernel.GcloudExecutable = "/google/data/ro/teams/cloud-sdk/gcloud"
}
},
}
func addCommonFlags(flags *flag.FlagSet) {
flags.StringVarP(&arch, "arch", "a", "",
"the compiler architecture (e.g., x86_64, aarch64; defaults to the arch of the running kernel)")
flags.StringVar(&build, "build", "",
"the kernel build; this can be either a build number (e.g., 12345.01.02) or a branch (e.g., release-R117)")
flags.StringVar(&board, "board", "",
"the kernel board")
flags.BoolVar(&useRegional, "use-regional-bucket", true,
"use regional GCS buckets (e.g. cos-tools-us-central1) for downloading artifacts")
}
func init() {
flag.CommandLine.AddGoFlagSet(goflag.CommandLine)
rootCmd.PersistentFlags().BoolVar(&staging, "staging", false, "use gcloud staging")
}
func Execute() {
if err := rootCmd.Execute(); err != nil {
glog.Exitf("%v", err)
}
}