Merge changes I0668ff5a,Iff2d7063,I6f8b1e2d,I126db49d,Ic6582260 am: a35294889f
am: 273045701d
am: 2e84d4d4ea
Change-Id: I169c252ec78ad9846b86673bcfbc3eda08059552
This commit is contained in:
@@ -1261,3 +1261,33 @@ func TestJavaSystemModules(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestJavaSystemModulesImport(t *testing.T) {
|
||||
ctx, _ := testJava(t, `
|
||||
java_system_modules_import {
|
||||
name: "system-modules",
|
||||
libs: ["system-module1", "system-module2"],
|
||||
}
|
||||
java_import {
|
||||
name: "system-module1",
|
||||
jars: ["a.jar"],
|
||||
}
|
||||
java_import {
|
||||
name: "system-module2",
|
||||
jars: ["b.jar"],
|
||||
}
|
||||
`)
|
||||
|
||||
// check the existence of the module
|
||||
systemModules := ctx.ModuleForTests("system-modules", "android_common")
|
||||
|
||||
cmd := systemModules.Rule("jarsTosystemModules")
|
||||
|
||||
// make sure the command compiles against the supplied modules.
|
||||
for _, module := range []string{"system-module1.jar", "system-module2.jar"} {
|
||||
if !strings.Contains(cmd.Args["classpath"], module) {
|
||||
t.Errorf("system modules classpath %v does not contain %q", cmd.Args["classpath"],
|
||||
module)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,6 +35,7 @@ func init() {
|
||||
|
||||
func RegisterSystemModulesBuildComponents(ctx android.RegistrationContext) {
|
||||
ctx.RegisterModuleType("java_system_modules", SystemModulesFactory)
|
||||
ctx.RegisterModuleType("java_system_modules_import", systemModulesImportFactory)
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -92,6 +93,9 @@ func TransformJarsToSystemModules(ctx android.ModuleContext, jars android.Paths)
|
||||
return outDir, outputs.Paths()
|
||||
}
|
||||
|
||||
// java_system_modules creates a system module from a set of java libraries that can
|
||||
// be referenced from the system_modules property. It must contain at a minimum the
|
||||
// java.base module which must include classes from java.lang amongst other java packages.
|
||||
func SystemModulesFactory() android.Module {
|
||||
module := &SystemModules{}
|
||||
module.AddProperties(&module.properties)
|
||||
@@ -157,3 +161,30 @@ func (system *SystemModules) AndroidMk() android.AndroidMkData {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// A prebuilt version of java_system_modules. It does not import the
|
||||
// generated system module, it generates the system module from imported
|
||||
// java libraries in the same way that java_system_modules does. It just
|
||||
// acts as a prebuilt, i.e. can have the same base name as another module
|
||||
// type and the one to use is selected at runtime.
|
||||
func systemModulesImportFactory() android.Module {
|
||||
module := &systemModulesImport{}
|
||||
module.AddProperties(&module.properties)
|
||||
android.InitPrebuiltModule(module, &module.properties.Libs)
|
||||
android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
|
||||
android.InitDefaultableModule(module)
|
||||
return module
|
||||
}
|
||||
|
||||
type systemModulesImport struct {
|
||||
SystemModules
|
||||
prebuilt android.Prebuilt
|
||||
}
|
||||
|
||||
func (system *systemModulesImport) Name() string {
|
||||
return system.prebuilt.Name(system.ModuleBase.Name())
|
||||
}
|
||||
|
||||
func (system *systemModulesImport) Prebuilt() *android.Prebuilt {
|
||||
return &system.prebuilt
|
||||
}
|
||||
|
Reference in New Issue
Block a user