Convert rust module-info.json to soong
This leads to idendical results as before, with the exception of
the "required" field in module-info.json. Make has more complicated
logic to fill out the required field than soong, and it leads to
make-specific names such as ones suffixed with :32 and don't make sense
in soong. I'm don't think there are critical users of that field though,
so I'll try removing it.
Everything else should be identical to the make-generated information
though.
Bug: 389720048
Test: diff'd module-info.json before and after this cl in soong+make mode
Change-Id: I74aefe578287f07474c15e5f92a0c2780a679047
diff --git a/rust/benchmark.go b/rust/benchmark.go
index eaa2176..daba964 100644
--- a/rust/benchmark.go
+++ b/rust/benchmark.go
@@ -130,3 +130,20 @@
benchmark.binaryDecorator.install(ctx)
}
+
+func (benchmark *benchmarkDecorator) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ benchmark.binaryDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
+ moduleInfoJSON.Class = []string{"NATIVE_TESTS"}
+ if benchmark.testConfig != nil {
+ if _, ok := benchmark.testConfig.(android.WritablePath); ok {
+ moduleInfoJSON.AutoTestConfig = []string{"true"}
+ }
+ moduleInfoJSON.TestConfig = append(moduleInfoJSON.TestConfig, benchmark.testConfig.String())
+ }
+
+ if len(benchmark.Properties.Test_suites) > 0 {
+ moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, benchmark.Properties.Test_suites...)
+ } else {
+ moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, "null-suite")
+ }
+}
diff --git a/rust/binary.go b/rust/binary.go
index d22041b..3c7a482 100644
--- a/rust/binary.go
+++ b/rust/binary.go
@@ -183,3 +183,8 @@
func (binary *binaryDecorator) testBinary() bool {
return false
}
+
+func (binary *binaryDecorator) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ binary.baseCompiler.moduleInfoJSON(ctx, moduleInfoJSON)
+ moduleInfoJSON.Class = []string{"EXECUTABLES"}
+}
diff --git a/rust/compiler.go b/rust/compiler.go
index 1d2fb58..f186ef3 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -78,6 +78,8 @@
checkedCrateRootPath() (android.Path, error)
Aliases() map[string]string
+
+ moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON)
}
func (compiler *baseCompiler) edition() string {
@@ -327,6 +329,31 @@
}
}
+func (compiler *baseCompiler) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ moduleInfoJSON.Class = []string{"ETC"}
+
+ mod := ctx.Module().(*Module)
+
+ moduleInfoJSON.SharedLibs = mod.transitiveAndroidMkSharedLibs.ToList()
+ moduleInfoJSON.Dependencies = append(moduleInfoJSON.Dependencies, mod.transitiveAndroidMkSharedLibs.ToList()...)
+ moduleInfoJSON.Dependencies = append(moduleInfoJSON.Dependencies, mod.Properties.AndroidMkDylibs...)
+ moduleInfoJSON.Dependencies = append(moduleInfoJSON.Dependencies, mod.Properties.AndroidMkHeaderLibs...)
+ moduleInfoJSON.Dependencies = append(moduleInfoJSON.Dependencies, mod.Properties.AndroidMkProcMacroLibs...)
+ moduleInfoJSON.Dependencies = append(moduleInfoJSON.Dependencies, mod.Properties.AndroidMkRlibs...)
+ moduleInfoJSON.Dependencies = append(moduleInfoJSON.Dependencies, mod.Properties.AndroidMkStaticLibs...)
+ moduleInfoJSON.SystemSharedLibs = []string{"none"}
+ moduleInfoJSON.StaticLibs = mod.Properties.AndroidMkStaticLibs
+
+ if mod.sourceProvider != nil {
+ moduleInfoJSON.SubName += mod.sourceProvider.getSubName()
+ }
+ moduleInfoJSON.SubName += mod.AndroidMkSuffix()
+
+ if mod.Properties.IsSdkVariant {
+ moduleInfoJSON.Uninstallable = true
+ }
+}
+
var _ compiler = (*baseCompiler)(nil)
func (compiler *baseCompiler) inData() bool {
diff --git a/rust/library.go b/rust/library.go
index 77280d9..95e7099 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -858,6 +858,20 @@
library.MutatedProperties.VariantIsDisabled = true
}
+func (library *libraryDecorator) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ library.baseCompiler.moduleInfoJSON(ctx, moduleInfoJSON)
+
+ if library.rlib() {
+ moduleInfoJSON.Class = []string{"RLIB_LIBRARIES"}
+ } else if library.dylib() {
+ moduleInfoJSON.Class = []string{"DYLIB_LIBRARIES"}
+ } else if library.static() {
+ moduleInfoJSON.Class = []string{"STATIC_LIBRARIES"}
+ } else if library.shared() {
+ moduleInfoJSON.Class = []string{"SHARED_LIBRARIES"}
+ }
+}
+
var validCrateName = regexp.MustCompile("[^a-zA-Z0-9_]+")
func validateLibraryStem(ctx BaseModuleContext, filename string, crate_name string) {
diff --git a/rust/proc_macro.go b/rust/proc_macro.go
index 28ed68b..837e1a6 100644
--- a/rust/proc_macro.go
+++ b/rust/proc_macro.go
@@ -100,3 +100,9 @@
// Proc_macros are never installed
return false
}
+
+func (library *procMacroDecorator) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ library.baseCompiler.moduleInfoJSON(ctx, moduleInfoJSON)
+
+ moduleInfoJSON.Class = []string{"PROC_MACRO_LIBRARIES"}
+}
diff --git a/rust/rust.go b/rust/rust.go
index c0df9f3..5cc8c07 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -1183,6 +1183,11 @@
mod.setOutputFiles(ctx)
buildComplianceMetadataInfo(ctx, mod, deps)
+
+ moduleInfoJSON := ctx.ModuleInfoJSON()
+ if mod.compiler != nil {
+ mod.compiler.moduleInfoJSON(ctx, moduleInfoJSON)
+ }
}
func (mod *Module) setOutputFiles(ctx ModuleContext) {
diff --git a/rust/source_provider.go b/rust/source_provider.go
index 3236bce..27c62c2 100644
--- a/rust/source_provider.go
+++ b/rust/source_provider.go
@@ -43,6 +43,7 @@
SourceProviderProps() []interface{}
SourceProviderDeps(ctx DepsContext, deps Deps) Deps
setSubName(subName string)
+ getSubName() string
setOutputFiles(outputFiles android.Paths)
}
@@ -100,6 +101,10 @@
sp.subName = subName
}
+func (sp *BaseSourceProvider) getSubName() string {
+ return sp.subName
+}
+
func (sp *BaseSourceProvider) setOutputFiles(outputFiles android.Paths) {
sp.OutputFiles = outputFiles
}
diff --git a/rust/test.go b/rust/test.go
index 5e42c3f..9a59117 100644
--- a/rust/test.go
+++ b/rust/test.go
@@ -259,6 +259,32 @@
return true
}
+func (test *testDecorator) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ test.binaryDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
+ moduleInfoJSON.Class = []string{"NATIVE_TESTS"}
+ if Bool(test.Properties.Test_options.Unit_test) {
+ moduleInfoJSON.IsUnitTest = "true"
+ if ctx.Host() {
+ moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, "host-unit-tests")
+ }
+ }
+ moduleInfoJSON.TestOptionsTags = append(moduleInfoJSON.TestOptionsTags, test.Properties.Test_options.Tags...)
+ if test.testConfig != nil {
+ if _, ok := test.testConfig.(android.WritablePath); ok {
+ moduleInfoJSON.AutoTestConfig = []string{"true"}
+ }
+ moduleInfoJSON.TestConfig = append(moduleInfoJSON.TestConfig, test.testConfig.String())
+ }
+
+ moduleInfoJSON.DataDependencies = append(moduleInfoJSON.DataDependencies, test.Properties.Data_bins...)
+
+ if len(test.Properties.Test_suites) > 0 {
+ moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, test.Properties.Test_suites...)
+ } else {
+ moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, "null-suite")
+ }
+}
+
func rustTestHostMultilib(ctx android.LoadHookContext) {
type props struct {
Target struct {