in pkg/rbeconfigsgen/rbeconfigsgen.go [981:1044]
func Run(o Options) error {
if err := processTempDir(&o); err != nil {
return fmt.Errorf("unable to initialize a local temporary working directory to store intermediate files: %w", err)
}
d, err := newDockerRunner(o.ToolchainContainer, o.Cleanup)
if err != nil {
return fmt.Errorf("failed to initialize a docker container: %w", err)
}
defer d.cleanup()
o.PlatformParams.ToolchainContainer = d.resolvedImage
if _, err := d.execCmd("mkdir", workdir(o.ExecOS)); err != nil {
return fmt.Errorf("failed to create an empty working directory in the container")
}
d.workdir = workdir(o.ExecOS)
bazelPath := o.BazelPath
if bazelPath == "" {
bazelPath, err = installBazelisk(d, o.TempWorkDir, o.ExecOS)
if err != nil {
return fmt.Errorf("failed to install Bazelisk into the toolchain container: %w", err)
}
}
cppConfigsTarball, err := genCppConfigs(d, &o, bazelPath)
if err != nil {
return fmt.Errorf("failed to generate C++ configs: %w", err)
}
javaBuild, err := genJavaConfigs(d, &o)
if err != nil {
return fmt.Errorf("failed to extract information about the installed JDK version in the toolchain container needed to generate Java configs: %w", err)
}
configBuild, err := genConfigBuild(&o)
if err != nil {
return fmt.Errorf("unable to generate the BUILD file with the C++ crosstool and/or the default platform definition: %w", err)
}
oc := outputConfigs{
license: generatedFile{
name: "LICENSE",
contents: licenseBlob,
},
cppConfigsTarball: cppConfigsTarball,
configBuild: configBuild,
javaBuild: javaBuild,
}
if err := assembleConfigs(&o, oc); err != nil {
return fmt.Errorf("unable to assemble C++/Java/Crosstool top/Platform definitions to generate the final toolchain configs output: %w", err)
}
if err := createManifest(&o); err != nil {
return fmt.Errorf("unable to create the manifest file: %w", err)
}
if o.Cleanup {
if err := os.RemoveAll(o.TempWorkDir); err != nil {
log.Printf("Warning: Unable to delete temporary working directory %q: %v", o.TempWorkDir, err)
}
}
return nil
}