Merge changes from topic "soong_instrumentation_for"
* changes: Fix instrumentation_for to match LOCAL_INSTRUMENTATION_FOR Fix incremental build issue in aapt2 Support main_class property in java_binary modules Always allow duplicates with identical CRC32 and size
This commit is contained in:
@@ -173,6 +173,10 @@ func (ze zipEntry) CRC32() uint32 {
|
|||||||
return ze.content.FileHeader.CRC32
|
return ze.content.FileHeader.CRC32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ze zipEntry) Size() uint64 {
|
||||||
|
return ze.content.FileHeader.UncompressedSize64
|
||||||
|
}
|
||||||
|
|
||||||
func (ze zipEntry) WriteToZip(dest string, zw *zip.Writer) error {
|
func (ze zipEntry) WriteToZip(dest string, zw *zip.Writer) error {
|
||||||
return zw.CopyFrom(ze.content, dest)
|
return zw.CopyFrom(ze.content, dest)
|
||||||
}
|
}
|
||||||
@@ -195,6 +199,10 @@ func (be bufferEntry) CRC32() uint32 {
|
|||||||
return crc32.ChecksumIEEE(be.content)
|
return crc32.ChecksumIEEE(be.content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (be bufferEntry) Size() uint64 {
|
||||||
|
return uint64(len(be.content))
|
||||||
|
}
|
||||||
|
|
||||||
func (be bufferEntry) WriteToZip(dest string, zw *zip.Writer) error {
|
func (be bufferEntry) WriteToZip(dest string, zw *zip.Writer) error {
|
||||||
w, err := zw.CreateHeader(be.fh)
|
w, err := zw.CreateHeader(be.fh)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -215,6 +223,7 @@ type zipSource interface {
|
|||||||
String() string
|
String() string
|
||||||
IsDir() bool
|
IsDir() bool
|
||||||
CRC32() uint32
|
CRC32() uint32
|
||||||
|
Size() uint64
|
||||||
WriteToZip(dest string, zw *zip.Writer) error
|
WriteToZip(dest string, zw *zip.Writer) error
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,28 +378,30 @@ func mergeZips(readers []namedZipReader, writer *zip.Writer, manifest, entrypoin
|
|||||||
return fmt.Errorf("Directory/file mismatch at %v from %v and %v\n",
|
return fmt.Errorf("Directory/file mismatch at %v from %v and %v\n",
|
||||||
dest, existingSource, source)
|
dest, existingSource, source)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ignoreDuplicates {
|
if ignoreDuplicates {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if emulateJar &&
|
if emulateJar &&
|
||||||
file.Name == jar.ManifestFile || file.Name == jar.ModuleInfoClass {
|
file.Name == jar.ManifestFile || file.Name == jar.ModuleInfoClass {
|
||||||
// Skip manifest and module info files that are not from the first input file
|
// Skip manifest and module info files that are not from the first input file
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !source.IsDir() {
|
|
||||||
if emulateJar {
|
if source.IsDir() {
|
||||||
if existingSource.CRC32() != source.CRC32() {
|
continue
|
||||||
fmt.Fprintf(os.Stdout, "WARNING: Duplicate path %v found in %v and %v\n",
|
|
||||||
dest, existingSource, source)
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
|
if existingSource.CRC32() == source.CRC32() && existingSource.Size() == source.Size() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
return fmt.Errorf("Duplicate path %v found in %v and %v\n",
|
return fmt.Errorf("Duplicate path %v found in %v and %v\n",
|
||||||
dest, existingSource, source)
|
dest, existingSource, source)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if emulateJar {
|
if emulateJar {
|
||||||
jarSort(orderedMappings)
|
jarSort(orderedMappings)
|
||||||
|
@@ -87,6 +87,14 @@ func TestMergeZips(t *testing.T) {
|
|||||||
|
|
||||||
ignoreDuplicates: true,
|
ignoreDuplicates: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "duplicates identical",
|
||||||
|
in: [][]testZipEntry{
|
||||||
|
{a},
|
||||||
|
{a},
|
||||||
|
},
|
||||||
|
out: []testZipEntry{a},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "sort",
|
name: "sort",
|
||||||
in: [][]testZipEntry{
|
in: [][]testZipEntry{
|
||||||
|
@@ -111,7 +111,8 @@ func aapt2CompileDirs(ctx android.ModuleContext, flata android.WritablePath, dir
|
|||||||
|
|
||||||
var aapt2LinkRule = pctx.AndroidStaticRule("aapt2Link",
|
var aapt2LinkRule = pctx.AndroidStaticRule("aapt2Link",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: `${config.Aapt2Cmd} link -o $out $flags --java $genDir --proguard $proguardOptions ` +
|
Command: `rm -rf $genDir && ` +
|
||||||
|
`${config.Aapt2Cmd} link -o $out $flags --java $genDir --proguard $proguardOptions ` +
|
||||||
`--output-text-symbols ${rTxt} $inFlags && ` +
|
`--output-text-symbols ${rTxt} $inFlags && ` +
|
||||||
`${config.SoongZipCmd} -write_if_changed -jar -o $genJar -C $genDir -D $genDir &&` +
|
`${config.SoongZipCmd} -write_if_changed -jar -o $genJar -C $genDir -D $genDir &&` +
|
||||||
`${config.ExtractJarPackagesCmd} -i $genJar -o $extraPackages --prefix '--extra-packages '`,
|
`${config.ExtractJarPackagesCmd} -i $genJar -o $extraPackages --prefix '--extra-packages '`,
|
||||||
|
@@ -250,6 +250,8 @@ func aaptLibs(ctx android.ModuleContext, sdkContext sdkContext) (transitiveStati
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch ctx.OtherModuleDependencyTag(module) {
|
switch ctx.OtherModuleDependencyTag(module) {
|
||||||
|
case instrumentationForTag:
|
||||||
|
// Nothing, instrumentationForTag is treated as libTag for javac but not for aapt2.
|
||||||
case libTag, frameworkResTag:
|
case libTag, frameworkResTag:
|
||||||
if exportPackage != nil {
|
if exportPackage != nil {
|
||||||
sharedLibs = append(sharedLibs, exportPackage)
|
sharedLibs = append(sharedLibs, exportPackage)
|
||||||
|
12
java/app.go
12
java/app.go
@@ -318,12 +318,6 @@ type AndroidTest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
if String(a.appTestProperties.Instrumentation_for) != "" {
|
|
||||||
a.AndroidApp.extraLinkFlags = append(a.AndroidApp.extraLinkFlags,
|
|
||||||
"--rename-instrumentation-target-package",
|
|
||||||
String(a.appTestProperties.Instrumentation_for))
|
|
||||||
}
|
|
||||||
|
|
||||||
a.generateAndroidBuildActions(ctx)
|
a.generateAndroidBuildActions(ctx)
|
||||||
|
|
||||||
a.testConfig = tradefed.AutoGenInstrumentationTestConfig(ctx, a.testProperties.Test_config, a.testProperties.Test_config_template, a.manifestPath)
|
a.testConfig = tradefed.AutoGenInstrumentationTestConfig(ctx, a.testProperties.Test_config, a.testProperties.Test_config_template, a.manifestPath)
|
||||||
@@ -335,6 +329,12 @@ func (a *AndroidTest) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
android.ExtractSourceDeps(ctx, a.testProperties.Test_config_template)
|
android.ExtractSourceDeps(ctx, a.testProperties.Test_config_template)
|
||||||
android.ExtractSourcesDeps(ctx, a.testProperties.Data)
|
android.ExtractSourcesDeps(ctx, a.testProperties.Data)
|
||||||
a.AndroidApp.DepsMutator(ctx)
|
a.AndroidApp.DepsMutator(ctx)
|
||||||
|
if a.appTestProperties.Instrumentation_for != nil {
|
||||||
|
// The android_app dependency listed in instrumentation_for needs to be added to the classpath for javac,
|
||||||
|
// but not added to the aapt2 link includes like a normal android_app or android_library dependency, so
|
||||||
|
// use instrumentationForTag instead of libTag.
|
||||||
|
ctx.AddVariationDependencies(nil, instrumentationForTag, String(a.appTestProperties.Instrumentation_for))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func AndroidTestFactory() android.Module {
|
func AndroidTestFactory() android.Module {
|
||||||
|
@@ -399,6 +399,17 @@ func TransformJetifier(ctx android.ModuleContext, outputFile android.WritablePat
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GenerateMainClassManifest(ctx android.ModuleContext, outputFile android.WritablePath, mainClass string) {
|
||||||
|
ctx.Build(pctx, android.BuildParams{
|
||||||
|
Rule: android.WriteFile,
|
||||||
|
Description: "manifest",
|
||||||
|
Output: outputFile,
|
||||||
|
Args: map[string]string{
|
||||||
|
"content": "Main-Class: " + mainClass + "\n",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
type classpath []android.Path
|
type classpath []android.Path
|
||||||
|
|
||||||
func (x *classpath) FormJavaClassPath(optName string) string {
|
func (x *classpath) FormJavaClassPath(optName string) string {
|
||||||
|
@@ -157,6 +157,8 @@ func (j *Module) r8Flags(ctx android.ModuleContext, flags javaBuilderFlags) (r8F
|
|||||||
if !Bool(opt.Obfuscate) {
|
if !Bool(opt.Obfuscate) {
|
||||||
r8Flags = append(r8Flags, "-dontobfuscate")
|
r8Flags = append(r8Flags, "-dontobfuscate")
|
||||||
}
|
}
|
||||||
|
// TODO(ccross): if this is an instrumentation test of an obfuscated app, use the
|
||||||
|
// dictionary of the app and move the app from libraryjars to injars.
|
||||||
|
|
||||||
return r8Flags, r8Deps
|
return r8Flags, r8Deps
|
||||||
}
|
}
|
||||||
@@ -171,8 +173,6 @@ func (j *Module) compileDex(ctx android.ModuleContext, flags javaBuilderFlags,
|
|||||||
outDir := android.PathForModuleOut(ctx, "dex")
|
outDir := android.PathForModuleOut(ctx, "dex")
|
||||||
|
|
||||||
if useR8 {
|
if useR8 {
|
||||||
// TODO(ccross): if this is an instrumentation test of an obfuscated app, use the
|
|
||||||
// dictionary of the app and move the app from libraryjars to injars.
|
|
||||||
proguardDictionary := android.PathForModuleOut(ctx, "proguard_dictionary")
|
proguardDictionary := android.PathForModuleOut(ctx, "proguard_dictionary")
|
||||||
j.proguardDictionary = proguardDictionary
|
j.proguardDictionary = proguardDictionary
|
||||||
r8Flags, r8Deps := j.r8Flags(ctx, flags)
|
r8Flags, r8Deps := j.r8Flags(ctx, flags)
|
||||||
|
22
java/java.go
22
java/java.go
@@ -309,6 +309,9 @@ type Module struct {
|
|||||||
// list of extra progurad flag files
|
// list of extra progurad flag files
|
||||||
extraProguardFlagFiles android.Paths
|
extraProguardFlagFiles android.Paths
|
||||||
|
|
||||||
|
// manifest file to use instead of properties.Manifest
|
||||||
|
overrideManifest android.OptionalPath
|
||||||
|
|
||||||
// list of SDK lib names that this java moudule is exporting
|
// list of SDK lib names that this java moudule is exporting
|
||||||
exportedSdkLibs []string
|
exportedSdkLibs []string
|
||||||
|
|
||||||
@@ -378,6 +381,7 @@ var (
|
|||||||
kotlinStdlibTag = dependencyTag{name: "kotlin-stdlib"}
|
kotlinStdlibTag = dependencyTag{name: "kotlin-stdlib"}
|
||||||
proguardRaiseTag = dependencyTag{name: "proguard-raise"}
|
proguardRaiseTag = dependencyTag{name: "proguard-raise"}
|
||||||
certificateTag = dependencyTag{name: "certificate"}
|
certificateTag = dependencyTag{name: "certificate"}
|
||||||
|
instrumentationForTag = dependencyTag{name: "instrumentation_for"}
|
||||||
)
|
)
|
||||||
|
|
||||||
type sdkDep struct {
|
type sdkDep struct {
|
||||||
@@ -817,7 +821,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
|||||||
switch tag {
|
switch tag {
|
||||||
case bootClasspathTag:
|
case bootClasspathTag:
|
||||||
deps.bootClasspath = append(deps.bootClasspath, dep.HeaderJars()...)
|
deps.bootClasspath = append(deps.bootClasspath, dep.HeaderJars()...)
|
||||||
case libTag:
|
case libTag, instrumentationForTag:
|
||||||
deps.classpath = append(deps.classpath, dep.HeaderJars()...)
|
deps.classpath = append(deps.classpath, dep.HeaderJars()...)
|
||||||
// sdk lib names from dependencies are re-exported
|
// sdk lib names from dependencies are re-exported
|
||||||
j.exportedSdkLibs = append(j.exportedSdkLibs, dep.ExportedSdkLibs()...)
|
j.exportedSdkLibs = append(j.exportedSdkLibs, dep.ExportedSdkLibs()...)
|
||||||
@@ -1193,8 +1197,8 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
|
|||||||
jars = append(jars, deps.staticJars...)
|
jars = append(jars, deps.staticJars...)
|
||||||
jars = append(jars, deps.staticResourceJars...)
|
jars = append(jars, deps.staticResourceJars...)
|
||||||
|
|
||||||
var manifest android.OptionalPath
|
manifest := j.overrideManifest
|
||||||
if j.properties.Manifest != nil {
|
if !manifest.Valid() && j.properties.Manifest != nil {
|
||||||
manifest = android.OptionalPathForPath(ctx.ExpandSource(*j.properties.Manifest, "manifest"))
|
manifest = android.OptionalPathForPath(ctx.ExpandSource(*j.properties.Manifest, "manifest"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1536,6 +1540,9 @@ func TestHostFactory() android.Module {
|
|||||||
type binaryProperties struct {
|
type binaryProperties struct {
|
||||||
// installable script to execute the resulting jar
|
// installable script to execute the resulting jar
|
||||||
Wrapper *string
|
Wrapper *string
|
||||||
|
|
||||||
|
// Name of the class containing main to be inserted into the manifest as Main-Class.
|
||||||
|
Main_class *string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Binary struct {
|
type Binary struct {
|
||||||
@@ -1556,6 +1563,15 @@ func (j *Binary) HostToolPath() android.OptionalPath {
|
|||||||
func (j *Binary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (j *Binary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
if ctx.Arch().ArchType == android.Common {
|
if ctx.Arch().ArchType == android.Common {
|
||||||
// Compile the jar
|
// Compile the jar
|
||||||
|
if j.binaryProperties.Main_class != nil {
|
||||||
|
if j.properties.Manifest != nil {
|
||||||
|
ctx.PropertyErrorf("main_class", "main_class cannot be used when manifest is set")
|
||||||
|
}
|
||||||
|
manifestFile := android.PathForModuleOut(ctx, "manifest.txt")
|
||||||
|
GenerateMainClassManifest(ctx, manifestFile, String(j.binaryProperties.Main_class))
|
||||||
|
j.overrideManifest = android.OptionalPathForPath(manifestFile)
|
||||||
|
}
|
||||||
|
|
||||||
j.Library.GenerateAndroidBuildActions(ctx)
|
j.Library.GenerateAndroidBuildActions(ctx)
|
||||||
} else {
|
} else {
|
||||||
// Handle the binary wrapper
|
// Handle the binary wrapper
|
||||||
|
Reference in New Issue
Block a user