| package actions | |
| import ( | |
| "context" | |
| "strings" | |
| "cos.googlesource.com/cos/tools.git/src/pkg/dkms" | |
| "github.com/spf13/cobra" | |
| ) | |
| var buildCmd = &cobra.Command{ | |
| Use: "build", | |
| Short: "Builds a module from the DKMS tree", | |
| Long: strings.TrimSpace(` | |
| Compiles the modules in a DKMS package using the MAKE command from dkms.conf | |
| and saves the results to the package's build directory in the DKMS tree. | |
| If a --gcs-bucket is provided, this will attempt to download the compiled | |
| modules from the package, and will only fall back to building them locally if | |
| they are not present and downloadable from the bucket. If --upload is also | |
| passed, this will upload modules to the bucket after they have been compiled. | |
| If the package is not already added to the DKMS source tree, this will try to | |
| add it. See the add command for more details. | |
| If --install-build-dependencies is passed and a local build must be performed, | |
| this will install the appropriate compiler toolchain and kernel headers for | |
| the specified kernel. | |
| If any patches should be applied before building the package, as specified in | |
| dkms.conf, this will apply them. | |
| If --make-variables is set to "default", the following default make variables | |
| will be appended to the MAKE command: | |
| ARCH=${arch} | |
| CC=toolchain/bin/${arch}-cros-linux-gnu-clang | |
| CXX=toolchain/bin/${arch}-cros-linux-gnu-clang++ | |
| LD=toolchain/bin/${arch}-cros-linux-gnu-ld.lld | |
| STRIP=toolchain/bin/llvm-strip | |
| OBJCOPY=toolchain/bin/llvm-objcopy | |
| HOSTCC=${arch}-pc-linux-gnu-clang | |
| HOSTCXX=${arch}-pc-linux-gnu-clang++ | |
| HOSTLD=${arch}-pc-linux-gnu-clang | |
| `), | |
| Args: ParseArgs, | |
| RunE: func(cmd *cobra.Command, args []string) error { | |
| if RootGCSBucket == nil { | |
| return dkms.Build(RootPackage, RootOptions) | |
| } else { | |
| return dkms.CachedBuild(context.Background(), RootPackage, RootGCSBucket, RootOptions) | |
| } | |
| }, | |
| } | |
| func init() { | |
| rootCmd.AddCommand(buildCmd) | |
| } |