summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apex/apex.go2
-rw-r--r--apex/prebuilt.go5
-rw-r--r--cc/library.go28
-rw-r--r--filesystem/android_device.go54
-rw-r--r--filesystem/system_other.go21
-rw-r--r--rust/library_test.go39
6 files changed, 141 insertions, 8 deletions
diff --git a/apex/apex.go b/apex/apex.go
index 4dd3d4cc0..bda5f2f2a 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -2263,6 +2263,8 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
FlatListPath: a.FlatListPath(),
Updatable: a.Updatable(),
})
+
+ android.SetProvider(ctx, filesystem.ApexKeyPathInfoProvider, filesystem.ApexKeyPathInfo{a.apexKeysPath})
}
// Set prebuiltInfoProvider. This will be used by `apex_prebuiltinfo_singleton` to print out a metadata file
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index 0a970276a..89b0091be 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -21,6 +21,7 @@ import (
"android/soong/android"
"android/soong/dexpreopt"
+ "android/soong/filesystem"
"android/soong/java"
"android/soong/provenance"
@@ -677,6 +678,8 @@ func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
ctx.SetOutputFiles(android.Paths{p.outputApex}, "")
+
+ android.SetProvider(ctx, filesystem.ApexKeyPathInfoProvider, filesystem.ApexKeyPathInfo{p.apexKeysPath})
}
func (p *Prebuilt) ProvenanceMetaDataFile() android.Path {
@@ -873,4 +876,6 @@ func (a *ApexSet) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
ctx.SetOutputFiles(android.Paths{a.outputApex}, "")
+
+ android.SetProvider(ctx, filesystem.ApexKeyPathInfoProvider, filesystem.ApexKeyPathInfo{a.apexKeysPath})
}
diff --git a/cc/library.go b/cc/library.go
index ee7610d08..8a2b6bdbd 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -220,6 +220,7 @@ func init() {
func RegisterLibraryBuildComponents(ctx android.RegistrationContext) {
ctx.RegisterModuleType("cc_library_static", LibraryStaticFactory)
+ ctx.RegisterModuleType("cc_rustlibs_for_make", LibraryMakeRustlibsFactory)
ctx.RegisterModuleType("cc_library_shared", LibrarySharedFactory)
ctx.RegisterModuleType("cc_library", LibraryFactory)
ctx.RegisterModuleType("cc_library_host_static", LibraryHostStaticFactory)
@@ -249,6 +250,19 @@ func LibraryStaticFactory() android.Module {
return module.Init()
}
+// cc_rustlibs_for_make creates a static library which bundles together rust_ffi_static
+// deps for Make. This should not be depended on in Soong, and is probably not the
+// module you need unless you are sure of what you're doing. These should only
+// be declared as dependencies in Make. To ensure inclusion, rust_ffi_static modules
+// should be declared in the whole_static_libs property.
+func LibraryMakeRustlibsFactory() android.Module {
+ module, library := NewLibrary(android.HostAndDeviceSupported)
+ library.BuildOnlyStatic()
+ library.wideStaticlibForMake = true
+ module.sdkMemberTypes = []android.SdkMemberType{staticLibrarySdkMemberType}
+ return module.Init()
+}
+
// cc_library_shared creates a shared library for a device and/or host.
func LibrarySharedFactory() android.Module {
module, library := NewLibrary(android.HostAndDeviceSupported)
@@ -437,6 +451,10 @@ type libraryDecorator struct {
// Path to the file containing the APIs exported by this library
stubsSymbolFilePath android.Path
+
+ // Forces production of the generated Rust staticlib for cc_library_static.
+ // Intended to be used to provide these generated staticlibs for Make.
+ wideStaticlibForMake bool
}
// linkerProps returns the list of properties structs relevant for this library. (For example, if
@@ -1055,6 +1073,16 @@ func (library *libraryDecorator) linkStatic(ctx ModuleContext,
library.objects = library.objects.Append(objs)
library.wholeStaticLibsFromPrebuilts = android.CopyOfPaths(deps.WholeStaticLibsFromPrebuilts)
+ if library.wideStaticlibForMake {
+ if generatedLib := GenerateRustStaticlib(ctx, deps.RustRlibDeps); generatedLib != nil {
+ // WholeStaticLibsFromPrebuilts are .a files that get included whole into the resulting staticlib
+ // so reuse that here for our Rust staticlibs because we don't have individual object files for
+ // these.
+ deps.WholeStaticLibsFromPrebuilts = append(deps.WholeStaticLibsFromPrebuilts, generatedLib)
+ }
+
+ }
+
fileName := ctx.ModuleName() + staticLibraryExtension
outputFile := android.PathForModuleOut(ctx, fileName)
builderFlags := flagsToBuilderFlags(flags)
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index 31678aa3b..a2fa0f08a 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -175,7 +175,7 @@ func (a *androidDevice) GenerateAndroidBuildActions(ctx android.ModuleContext) {
allInstalledModules := a.allInstalledModules(ctx)
- a.buildTargetFilesZip(ctx)
+ a.buildTargetFilesZip(ctx, allInstalledModules)
a.buildProguardZips(ctx, allInstalledModules)
var deps []android.Path
@@ -393,7 +393,7 @@ type targetFilesystemZipCopy struct {
destSubdir string
}
-func (a *androidDevice) buildTargetFilesZip(ctx android.ModuleContext) {
+func (a *androidDevice) buildTargetFilesZip(ctx android.ModuleContext, allInstalledModules []android.Module) {
targetFilesDir := android.PathForModuleOut(ctx, "target_files_dir")
targetFilesZip := android.PathForModuleOut(ctx, "target_files.zip")
@@ -497,7 +497,7 @@ func (a *androidDevice) buildTargetFilesZip(ctx android.ModuleContext) {
}
a.copyImagesToTargetZip(ctx, builder, targetFilesDir)
- a.copyMetadataToTargetZip(ctx, builder, targetFilesDir)
+ a.copyMetadataToTargetZip(ctx, builder, targetFilesDir, allInstalledModules)
builder.Command().
BuiltTool("soong_zip").
@@ -549,7 +549,7 @@ func (a *androidDevice) copyImagesToTargetZip(ctx android.ModuleContext, builder
}
}
-func (a *androidDevice) copyMetadataToTargetZip(ctx android.ModuleContext, builder *android.RuleBuilder, targetFilesDir android.WritablePath) {
+func (a *androidDevice) copyMetadataToTargetZip(ctx android.ModuleContext, builder *android.RuleBuilder, targetFilesDir android.WritablePath, allInstalledModules []android.Module) {
// Create a META/ subdirectory
builder.Command().Textf("mkdir -p %s/META", targetFilesDir.String())
if proptools.Bool(a.deviceProps.Ab_ota_updater) {
@@ -587,7 +587,22 @@ func (a *androidDevice) copyMetadataToTargetZip(ctx android.ModuleContext, build
if android.InList(partition, []string{"userdata"}) {
continue
}
- builder.Command().Textf("cp").Input(fsInfos[partition].FilesystemConfig).Textf(" %s/META/%s", targetFilesDir.String(), a.filesystemConfigNameForTargetFiles(partition))
+ if partition != "vendor_ramdisk" {
+ // vendor_ramdisk will be handled separately.
+ builder.Command().Textf("cp").Input(fsInfos[partition].FilesystemConfig).Textf(" %s/META/%s", targetFilesDir.String(), a.filesystemConfigNameForTargetFiles(partition))
+ }
+ if partition == "ramdisk" {
+ // Create an additional copy at boot_filesystem_config.txt
+ builder.Command().Textf("cp").Input(fsInfos[partition].FilesystemConfig).Textf(" %s/META/boot_filesystem_config.txt", targetFilesDir.String())
+ }
+ if partition == "system" {
+ // Create root_filesystem_config from the assembled ROOT/ intermediates directory
+ a.generateFilesystemConfigForTargetFiles(ctx, builder, targetFilesDir.String(), targetFilesDir.String()+"/ROOT", "root_filesystem_config.txt")
+ }
+ if partition == "vendor_ramdisk" {
+ // Create vendor_boot_filesystem_config from the assembled VENDOR_BOOT/RAMDISK intermediates directory
+ a.generateFilesystemConfigForTargetFiles(ctx, builder, targetFilesDir.String(), targetFilesDir.String()+"/VENDOR_BOOT/RAMDISK", "vendor_boot_filesystem_config.txt")
+ }
}
// Copy ramdisk_node_list
if ramdiskNodeList := android.PathForModuleSrc(ctx, proptools.String(a.deviceProps.Ramdisk_node_list)); ramdiskNodeList != nil {
@@ -597,6 +612,35 @@ func (a *androidDevice) copyMetadataToTargetZip(ctx android.ModuleContext, build
if releaseTools := android.PathForModuleSrc(ctx, proptools.String(a.deviceProps.Releasetools_extension)); releaseTools != nil {
builder.Command().Textf("cp").Input(releaseTools).Textf(" %s/META/", targetFilesDir.String())
}
+ // apexkeys.txt
+ var installedApexKeys []android.Path
+ for _, installedModule := range allInstalledModules {
+ if info, ok := android.OtherModuleProvider(ctx, installedModule, ApexKeyPathInfoProvider); ok {
+ installedApexKeys = append(installedApexKeys, info.ApexKeyPath)
+ }
+ }
+ installedApexKeys = android.SortedUniquePaths(installedApexKeys) // Sort by keypath to match make
+ builder.Command().Text("cat").Inputs(installedApexKeys).Textf(" >> %s/META/apexkeys.txt", targetFilesDir.String())
+
+}
+
+type ApexKeyPathInfo struct {
+ ApexKeyPath android.Path
+}
+
+var ApexKeyPathInfoProvider = blueprint.NewProvider[ApexKeyPathInfo]()
+
+func (a *androidDevice) generateFilesystemConfigForTargetFiles(ctx android.ModuleContext, builder *android.RuleBuilder, targetFilesDir, stagingDir, filename string) {
+ fsConfigOut := android.PathForModuleOut(ctx, filename)
+ ctx.Build(pctx, android.BuildParams{
+ Rule: fsConfigRule,
+ Output: fsConfigOut,
+ Args: map[string]string{
+ "rootDir": stagingDir,
+ "prefix": "",
+ },
+ })
+ builder.Command().Textf("cp").Input(fsConfigOut).Textf(" %s/META/", targetFilesDir)
}
// Filenames for the partition specific fs_config files.
diff --git a/filesystem/system_other.go b/filesystem/system_other.go
index 5309e9012..cbfd78b5b 100644
--- a/filesystem/system_other.go
+++ b/filesystem/system_other.go
@@ -172,9 +172,10 @@ func (m *systemOtherImage) GenerateAndroidBuildActions(ctx android.ModuleContext
builder.Build("build_system_other_hermetic", "build system other")
fsInfo := FilesystemInfo{
- Output: output,
- OutputHermetic: outputHermetic,
- RootDir: stagingDir,
+ Output: output,
+ OutputHermetic: outputHermetic,
+ RootDir: stagingDir,
+ FilesystemConfig: m.generateFilesystemConfig(ctx, stagingDir, stagingDirTimestamp),
}
android.SetProvider(ctx, FilesystemProvider, fsInfo)
@@ -183,6 +184,20 @@ func (m *systemOtherImage) GenerateAndroidBuildActions(ctx android.ModuleContext
ctx.CheckbuildFile(output)
}
+func (s *systemOtherImage) generateFilesystemConfig(ctx android.ModuleContext, stagingDir, stagingDirTimestamp android.Path) android.Path {
+ out := android.PathForModuleOut(ctx, "filesystem_config.txt")
+ ctx.Build(pctx, android.BuildParams{
+ Rule: fsConfigRule,
+ Input: stagingDirTimestamp, // assemble the staging directory
+ Output: out,
+ Args: map[string]string{
+ "rootDir": stagingDir.String(),
+ "prefix": "system/",
+ },
+ })
+ return out
+}
+
func (f *systemOtherImage) propFileForHermeticImg(ctx android.ModuleContext, builder *android.RuleBuilder, inputPropFile android.Path) android.Path {
propFilePinnedTimestamp := android.PathForModuleOut(ctx, "for_target_files", "prop")
builder.Command().Textf("cat").Input(inputPropFile).Flag(">").Output(propFilePinnedTimestamp).
diff --git a/rust/library_test.go b/rust/library_test.go
index 6db95253f..6cc4f2517 100644
--- a/rust/library_test.go
+++ b/rust/library_test.go
@@ -426,6 +426,45 @@ func TestRustFFIExportedIncludes(t *testing.T) {
android.AssertStringDoesContain(t, "cFlags for lib module", libfooStatic.Args["cFlags"], " -Irust_includes ")
}
+// Make sure cc_rustlibs_for_make has the expected behavior, and that
+// cc_library_static does as well.
+// This is here instead of cc/library_test.go because the test needs to
+// define a rust_ffi module which can't be done in soong-cc to avoid the
+// circular dependency.
+func TestCCRustlibsForMake(t *testing.T) {
+ t.Parallel()
+ result := testRust(t, `
+ rust_ffi_static {
+ name: "libbar",
+ srcs: ["foo.rs"],
+ crate_name: "bar",
+ export_include_dirs: ["rust_includes"],
+ host_supported: true,
+ }
+
+ cc_rustlibs_for_make {
+ name: "libmakerustlibs",
+ whole_static_libs: ["libbar"],
+ }
+
+ cc_library_static {
+ name: "libccstatic",
+ whole_static_libs: ["libbar"],
+ }
+ `)
+
+ libmakerustlibs := result.ModuleForTests(t, "libmakerustlibs", "android_arm64_armv8-a_static").MaybeRule("rustc")
+ libccstatic := result.ModuleForTests(t, "libccstatic", "android_arm64_armv8-a_static").MaybeRule("rustc")
+
+ if libmakerustlibs.Output == nil {
+ t.Errorf("cc_rustlibs_for_make is not generating a Rust staticlib when it should")
+ }
+
+ if libccstatic.Output != nil {
+ t.Errorf("cc_library_static is generating a Rust staticlib when it should not")
+ }
+}
+
func TestRustVersionScript(t *testing.T) {
ctx := testRust(t, `
rust_library {