summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go72
1 files changed, 41 insertions, 31 deletions
diff --git a/java/java.go b/java/java.go
index 2ca4ac8f0..94c12bdbb 100644
--- a/java/java.go
+++ b/java/java.go
@@ -219,7 +219,7 @@ type ApexDependency interface {
// Provides build path and install path to DEX jars.
type UsesLibraryDependency interface {
- DexJarBuildPath() android.Path
+ DexJarBuildPath() OptionalDexJarPath
DexJarInstallPath() android.Path
ClassLoaderContexts() dexpreopt.ClassLoaderContextMap
}
@@ -533,6 +533,10 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.installFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),
j.Stem()+".jar", j.outputFile, extraInstallDeps...)
}
+
+ if ctx.Windows() {
+ j.HideFromMake()
+ }
}
func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) {
@@ -1030,14 +1034,14 @@ func InitTestHost(th *TestHost, installable *bool, testSuites []string, autoGenC
type binaryProperties struct {
// installable script to execute the resulting jar
- Wrapper *string `android:"path"`
+ Wrapper *string `android:"path,arch_variant"`
// Name of the class containing main to be inserted into the manifest as Main-Class.
Main_class *string
// Names of modules containing JNI libraries that should be installed alongside the host
// variant of the binary.
- Jni_libs []string
+ Jni_libs []string `android:"arch_variant"`
}
type Binary struct {
@@ -1075,14 +1079,27 @@ func (j *Binary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if j.binaryProperties.Wrapper != nil {
j.wrapperFile = android.PathForModuleSrc(ctx, *j.binaryProperties.Wrapper)
} else {
+ if ctx.Windows() {
+ ctx.PropertyErrorf("wrapper", "wrapper is required for Windows")
+ }
+
j.wrapperFile = android.PathForSource(ctx, "build/soong/scripts/jar-wrapper.sh")
}
+ ext := ""
+ if ctx.Windows() {
+ ext = ".bat"
+ }
+
// The host installation rules make the installed wrapper depend on all the dependencies
// of the wrapper variant, which will include the common variant's jar file and any JNI
// libraries. This is verified by TestBinary.
j.binaryFile = ctx.InstallExecutable(android.PathForModuleInstall(ctx, "bin"),
- ctx.ModuleName(), j.wrapperFile)
+ ctx.ModuleName()+ext, j.wrapperFile)
+ }
+
+ if ctx.Windows() {
+ j.HideFromMake()
}
}
@@ -1156,7 +1173,6 @@ type ImportProperties struct {
Installable *bool
// If not empty, classes are restricted to the specified packages and their sub-packages.
- // This information is used to generate the updatable-bcp-packages.txt file.
Permitted_packages []string
// List of shared java libs that this module has dependencies to
@@ -1198,7 +1214,7 @@ type Import struct {
properties ImportProperties
// output file containing classes.dex and resources
- dexJarFile android.Path
+ dexJarFile OptionalDexJarPath
dexJarInstallFile android.Path
combinedClasspathFile android.Path
@@ -1283,6 +1299,10 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.hideApexVariantFromMake = true
}
+ if ctx.Windows() {
+ j.HideFromMake()
+ }
+
jars := android.PathsForModuleSrc(ctx, j.properties.Jars)
jarName := j.Stem() + ".jar"
@@ -1298,7 +1318,6 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.classLoaderContexts = make(dexpreopt.ClassLoaderContextMap)
var flags javaBuilderFlags
- var deapexerModule android.Module
ctx.VisitDirectDeps(func(module android.Module) {
tag := ctx.OtherModuleDependencyTag(module)
@@ -1319,11 +1338,6 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
addCLCFromDep(ctx, module, j.classLoaderContexts)
-
- // Save away the `deapexer` module on which this depends, if any.
- if tag == android.DeapexerTag {
- deapexerModule = module
- }
})
if Bool(j.properties.Installable) {
@@ -1338,26 +1352,22 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// obtained from the associated deapexer module.
ai := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
if ai.ForPrebuiltApex {
- if deapexerModule == nil {
- // This should never happen as a variant for a prebuilt_apex is only created if the
- // deapexer module has been configured to export the dex implementation jar for this module.
- ctx.ModuleErrorf("internal error: module %q does not depend on a `deapexer` module for prebuilt_apex %q",
- j.Name(), ai.ApexVariationName)
- return
- }
-
// Get the path of the dex implementation jar from the `deapexer` module.
- di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo)
+ di := android.FindDeapexerProviderForModule(ctx)
+ if di == nil {
+ return // An error has been reported by FindDeapexerProviderForModule.
+ }
if dexOutputPath := di.PrebuiltExportPath(apexRootRelativePathToJavaLib(j.BaseModuleName())); dexOutputPath != nil {
- j.dexJarFile = dexOutputPath
+ dexJarFile := makeDexJarPathFromPath(dexOutputPath)
+ j.dexJarFile = dexJarFile
j.dexJarInstallFile = android.PathForModuleInPartitionInstall(ctx, "apex", ai.ApexVariationName, apexRootRelativePathToJavaLib(j.BaseModuleName()))
// Initialize the hiddenapi structure.
- j.initHiddenAPI(ctx, dexOutputPath, outputFile, nil)
+ j.initHiddenAPI(ctx, dexJarFile, outputFile, nil)
} else {
// This should never happen as a variant for a prebuilt_apex is only created if the
// prebuilt_apex has been configured to export the java library dex file.
- ctx.ModuleErrorf("internal error: no dex implementation jar available from prebuilt_apex %q", deapexerModule.Name())
+ ctx.ModuleErrorf("internal error: no dex implementation jar available from prebuilt APEX %s", di.ApexModuleName())
}
} else if Bool(j.dexProperties.Compile_dex) {
sdkDep := decodeSdkDep(ctx, android.SdkContext(j))
@@ -1386,12 +1396,12 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
// Initialize the hiddenapi structure.
- j.initHiddenAPI(ctx, dexOutputFile, outputFile, j.dexProperties.Uncompress_dex)
+ j.initHiddenAPI(ctx, makeDexJarPathFromPath(dexOutputFile), outputFile, j.dexProperties.Uncompress_dex)
// Encode hidden API flags in dex file.
dexOutputFile = j.hiddenAPIEncodeDex(ctx, dexOutputFile)
- j.dexJarFile = dexOutputFile
+ j.dexJarFile = makeDexJarPathFromPath(dexOutputFile)
j.dexJarInstallFile = android.PathForModuleInstall(ctx, "framework", jarName)
}
}
@@ -1429,7 +1439,7 @@ func (j *Import) ImplementationAndResourcesJars() android.Paths {
return android.Paths{j.combinedClasspathFile}
}
-func (j *Import) DexJarBuildPath() android.Path {
+func (j *Import) DexJarBuildPath() OptionalDexJarPath {
return j.dexJarFile
}
@@ -1574,7 +1584,7 @@ type DexImport struct {
properties DexImportProperties
- dexJarFile android.Path
+ dexJarFile OptionalDexJarPath
dexpreopter
@@ -1665,7 +1675,7 @@ func (j *DexImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
})
}
- j.dexJarFile = dexOutputFile
+ j.dexJarFile = makeDexJarPathFromPath(dexOutputFile)
j.dexpreopt(ctx, dexOutputFile)
@@ -1675,7 +1685,7 @@ func (j *DexImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
}
-func (j *DexImport) DexJarBuildPath() android.Path {
+func (j *DexImport) DexJarBuildPath() OptionalDexJarPath {
return j.dexJarFile
}
@@ -1844,7 +1854,7 @@ func addCLCFromDep(ctx android.ModuleContext, depModule android.Module,
// from its CLC should be added to the current CLC.
if sdkLib != nil {
clcMap.AddContext(ctx, dexpreopt.AnySdkVersion, *sdkLib, false, true,
- dep.DexJarBuildPath(), dep.DexJarInstallPath(), dep.ClassLoaderContexts())
+ dep.DexJarBuildPath().PathOrNil(), dep.DexJarInstallPath(), dep.ClassLoaderContexts())
} else {
clcMap.AddContextMap(dep.ClassLoaderContexts(), depName)
}