diff options
author | 2025-01-29 15:14:17 -0800 | |
---|---|---|
committer | 2025-01-29 15:29:06 -0800 | |
commit | 58eef4f7de976345ce33c94cfc45440634158448 (patch) | |
tree | f67c7370762e3871e739acda33d81c4e04b2c606 | |
parent | d2c82e1253469a518acf2cf6431ee966551da693 (diff) |
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
-rw-r--r-- | rust/benchmark.go | 17 | ||||
-rw-r--r-- | rust/binary.go | 5 | ||||
-rw-r--r-- | rust/compiler.go | 27 | ||||
-rw-r--r-- | rust/library.go | 14 | ||||
-rw-r--r-- | rust/proc_macro.go | 6 | ||||
-rw-r--r-- | rust/rust.go | 5 | ||||
-rw-r--r-- | rust/source_provider.go | 5 | ||||
-rw-r--r-- | rust/test.go | 26 |
8 files changed, 105 insertions, 0 deletions
diff --git a/rust/benchmark.go b/rust/benchmark.go index eaa2176a2..daba9642e 100644 --- a/rust/benchmark.go +++ b/rust/benchmark.go @@ -130,3 +130,20 @@ func (benchmark *benchmarkDecorator) install(ctx ModuleContext) { 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 d22041b27..3c7a48274 100644 --- a/rust/binary.go +++ b/rust/binary.go @@ -183,3 +183,8 @@ func (binary *binaryDecorator) staticallyLinked() bool { 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 1d2fb58c3..f186ef38f 100644 --- a/rust/compiler.go +++ b/rust/compiler.go @@ -78,6 +78,8 @@ type compiler interface { 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) stdLinkage(device bool) RustLinkage { } } +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 77280d959..95e7099a6 100644 --- a/rust/library.go +++ b/rust/library.go @@ -858,6 +858,20 @@ func (library *libraryDecorator) SetDisabled() { 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 28ed68b71..837e1a6c8 100644 --- a/rust/proc_macro.go +++ b/rust/proc_macro.go @@ -100,3 +100,9 @@ func (procMacro *procMacroDecorator) everInstallable() bool { // 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 c0df9f3da..5cc8c07ec 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -1183,6 +1183,11 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { 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 3236bce74..27c62c21a 100644 --- a/rust/source_provider.go +++ b/rust/source_provider.go @@ -43,6 +43,7 @@ type SourceProvider interface { SourceProviderProps() []interface{} SourceProviderDeps(ctx DepsContext, deps Deps) Deps setSubName(subName string) + getSubName() string setOutputFiles(outputFiles android.Paths) } @@ -100,6 +101,10 @@ func (sp *BaseSourceProvider) setSubName(subName string) { 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 5e42c3f60..9a59117cc 100644 --- a/rust/test.go +++ b/rust/test.go @@ -259,6 +259,32 @@ func (test *testDecorator) testBinary() bool { 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 { |