in pkg/rbeconfigsgen/rbeconfigsgen.go [751:785]
func assembleConfigTarball(o *Options, oc outputConfigs) error {
out, err := os.Create(o.OutputTarball)
if err != nil {
return fmt.Errorf("unable to open output tarball %q for writing: %w", o.OutputTarball, err)
}
outTar := tar.NewWriter(out)
// Always write the LICENSE first.
if err := writeGeneratedFileToTarball(oc.license, outTar); err != nil {
return fmt.Errorf("unable to write the %q file to the output tarball %q: %w", oc.license.name, o.OutputTarball, err)
}
if o.GenCPPConfigs {
if err := copyCppConfigsToTarball(oc.cppConfigsTarball, outTar); err != nil {
return fmt.Errorf("unable to copy C++ configs from the C++ config tarball %q to the output tarball %q: %w", oc.cppConfigsTarball, o.OutputTarball, err)
}
}
if o.GenJavaConfigs {
if err := writeGeneratedFileToTarball(oc.javaBuild, outTar); err != nil {
return fmt.Errorf("unable to write the BUILD file %q containing the Java toolchain definition to the output tarball %q: %w", oc.javaBuild.name, o.OutputTarball, err)
}
}
if err := writeGeneratedFileToTarball(oc.configBuild, outTar); err != nil {
return fmt.Errorf("unable to write the crosstool top/platform BUILD file %q to the output tarball %q: %w", oc.configBuild.name, o.OutputTarball, err)
}
// Can't ignore failures when closing the output tarball because it writes metadata without which
// the tarball is invalid.
if err := outTar.Close(); err != nil {
return fmt.Errorf("error trying to finish writing the output tarball %q: %w", o.OutputTarball, err)
}
log.Printf("Generated Bazel toolchain configs output tarball %q.", o.OutputTarball)
return nil
}