Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c4a77332 authored by Paul Duffin's avatar Paul Duffin Committed by Android (Google) Code Review
Browse files

Merge "Move classpaths.proto related info into a separate provider." into sc-dev

parents fe07b367 72ede0fa
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -2053,13 +2053,19 @@ func apexBootclasspathFragmentFiles(ctx android.ModuleContext, module blueprint.
	}

	// Add classpaths.proto config.
	classpathProtoOutput := bootclasspathFragmentInfo.ClasspathFragmentProtoOutput
	classpathProto := newApexFile(ctx, classpathProtoOutput, classpathProtoOutput.Base(), bootclasspathFragmentInfo.ClasspathFragmentProtoInstallDir.Rel(), etc, nil)
	filesToAdd = append(filesToAdd, classpathProto)
	filesToAdd = append(filesToAdd, apexClasspathFragmentProtoFile(ctx, module))

	return filesToAdd
}

// apexClasspathFragmentProtoFile returns apexFile structure defining the classpath.proto config that
// the module contributes to the apex.
func apexClasspathFragmentProtoFile(ctx android.ModuleContext, module blueprint.Module) apexFile {
	fragmentInfo := ctx.OtherModuleProvider(module, java.ClasspathFragmentProtoContentInfoProvider).(java.ClasspathFragmentProtoContentInfo)
	classpathProtoOutput := fragmentInfo.ClasspathFragmentProtoOutput
	return newApexFile(ctx, classpathProtoOutput, classpathProtoOutput.Base(), fragmentInfo.ClasspathFragmentProtoInstallDir.Rel(), etc, nil)
}

// apexFileForBootclasspathFragmentContentModule creates an apexFile for a bootclasspath_fragment
// content module, i.e. a library that is part of the bootclasspath.
func apexFileForBootclasspathFragmentContentModule(ctx android.ModuleContext, fragmentModule blueprint.Module, javaModule javaModule) apexFile {
+5 −27
Original line number Diff line number Diff line
@@ -268,22 +268,6 @@ var BootclasspathFragmentApexContentInfoProvider = blueprint.NewProvider(Bootcla
// BootclasspathFragmentApexContentInfo contains the bootclasspath_fragments contributions to the
// apex contents.
type BootclasspathFragmentApexContentInfo struct {
	// ClasspathFragmentProtoOutput is an output path for the generated classpaths.proto config of this module.
	//
	// The file should be copied to a relevant place on device, see ClasspathFragmentProtoInstallDir
	// for more details.
	ClasspathFragmentProtoOutput android.OutputPath

	// ClasspathFragmentProtoInstallDir contains information about on device location for the generated classpaths.proto file.
	//
	// The path encodes expected sub-location within partitions, i.e. etc/classpaths/<proto-file>,
	// for ClasspathFragmentProtoOutput. To get sub-location, instead of the full output / make path
	// use android.InstallPath#Rel().
	//
	// This is only relevant for APEX modules as they perform their own installation; while regular
	// system files are installed via ClasspathFragmentBase#androidMkEntries().
	ClasspathFragmentProtoInstallDir android.InstallPath

	// The image config, internal to this module (and the dex_bootjars singleton).
	//
	// Will be nil if the BootclasspathFragmentApexContentInfo has not been provided for a specific module. That can occur
@@ -396,25 +380,19 @@ func (b *BootclasspathFragmentModule) GenerateAndroidBuildActions(ctx android.Mo
	// Perform hidden API processing.
	b.generateHiddenAPIBuildActions(ctx, contents)

	// Construct the boot image info from the config.
	info := BootclasspathFragmentApexContentInfo{
		ClasspathFragmentProtoInstallDir: b.classpathFragmentBase().installDirPath,
		ClasspathFragmentProtoOutput:     b.classpathFragmentBase().outputFilepath,
		imageConfig:                      nil,
	}

	if !SkipDexpreoptBootJars(ctx) {
		// Force the GlobalSoongConfig to be created and cached for use by the dex_bootjars
		// GenerateSingletonBuildActions method as it cannot create it for itself.
		dexpreopt.GetGlobalSoongConfig(ctx)
		info.imageConfig = b.getImageConfig(ctx)

		// Only generate the boot image if the configuration does not skip it.
		b.generateBootImageBuildActions(ctx, contents)
	}

	// Make it available for other modules.
	ctx.SetProvider(BootclasspathFragmentApexContentInfoProvider, info)
		// Make the boot image info available for other modules
		ctx.SetProvider(BootclasspathFragmentApexContentInfoProvider, BootclasspathFragmentApexContentInfo{
			imageConfig: b.getImageConfig(ctx),
		})
	}
}

// generateClasspathProtoBuildActions generates all required build actions for classpath.proto config
+27 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package java

import (
	"fmt"
	"github.com/google/blueprint"
	"strings"

	"android/soong/android"
@@ -120,6 +121,12 @@ func (c *ClasspathFragmentBase) generateClasspathProtoBuildActions(ctx android.M
		FlagWithOutput("--output=", c.outputFilepath)

	rule.Build("classpath_fragment", "Compiling "+c.outputFilepath.String())

	classpathProtoInfo := ClasspathFragmentProtoContentInfo{
		ClasspathFragmentProtoInstallDir: c.installDirPath,
		ClasspathFragmentProtoOutput:     c.outputFilepath,
	}
	ctx.SetProvider(ClasspathFragmentProtoContentInfoProvider, classpathProtoInfo)
}

func writeClasspathsJson(ctx android.ModuleContext, output android.WritablePath, jars []classpathJar) {
@@ -157,3 +164,23 @@ func (c *ClasspathFragmentBase) androidMkEntries() []android.AndroidMkEntries {
		},
	}}
}

var ClasspathFragmentProtoContentInfoProvider = blueprint.NewProvider(ClasspathFragmentProtoContentInfo{})

type ClasspathFragmentProtoContentInfo struct {
	// ClasspathFragmentProtoOutput is an output path for the generated classpaths.proto config of this module.
	//
	// The file should be copied to a relevant place on device, see ClasspathFragmentProtoInstallDir
	// for more details.
	ClasspathFragmentProtoOutput android.OutputPath

	// ClasspathFragmentProtoInstallDir contains information about on device location for the generated classpaths.proto file.
	//
	// The path encodes expected sub-location within partitions, i.e. etc/classpaths/<proto-file>,
	// for ClasspathFragmentProtoOutput. To get sub-location, instead of the full output / make path
	// use android.InstallPath#Rel().
	//
	// This is only relevant for APEX modules as they perform their own installation; while regular
	// system files are installed via ClasspathFragmentBase#androidMkEntries().
	ClasspathFragmentProtoInstallDir android.InstallPath
}