From ce56425a6b2329cd365beb5021ca6cf1b9dc6597 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 12 Jan 2022 11:13:32 -0800 Subject: [PATCH] Annotate more java dependencies for licensing Annotate more dependencies as runtime linked or toolchain. Bug: 207445310 Test: m checkbuild Change-Id: Ia5dc3321a1e476b16058eee94d6dc494fe1e933e --- android/license_metadata.go | 11 +++++++++++ dexpreopt/config.go | 1 + java/hiddenapi.go | 1 + java/java.go | 15 ++++++++++----- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/android/license_metadata.go b/android/license_metadata.go index 4c71a8c0b..544295cfa 100644 --- a/android/license_metadata.go +++ b/android/license_metadata.go @@ -224,6 +224,9 @@ const ( // LicenseAnnotationSharedDependency should be returned by LicenseAnnotations implementations // of dependency tags when the usage of the dependency is dynamic, for example a shared library // linkage for native modules or as a classpath library for java modules. + // + // Dependency tags that need to always return LicenseAnnotationSharedDependency + // can embed LicenseAnnotationSharedDependencyTag to implement LicenseAnnotations. LicenseAnnotationSharedDependency LicenseAnnotation = "dynamic" // LicenseAnnotationToolchain should be returned by LicenseAnnotations implementations of @@ -234,6 +237,14 @@ const ( LicenseAnnotationToolchain LicenseAnnotation = "toolchain" ) +// LicenseAnnotationSharedDependencyTag can be embedded in a dependency tag to implement +// LicenseAnnotations that always returns LicenseAnnotationSharedDependency. +type LicenseAnnotationSharedDependencyTag struct{} + +func (LicenseAnnotationSharedDependencyTag) LicenseAnnotations() []LicenseAnnotation { + return []LicenseAnnotation{LicenseAnnotationSharedDependency} +} + // LicenseAnnotationToolchainDependencyTag can be embedded in a dependency tag to implement // LicenseAnnotations that always returns LicenseAnnotationToolchain. type LicenseAnnotationToolchainDependencyTag struct{} diff --git a/dexpreopt/config.go b/dexpreopt/config.go index 1f99a96c1..153b0256f 100644 --- a/dexpreopt/config.go +++ b/dexpreopt/config.go @@ -408,6 +408,7 @@ func dex2oatModuleName(config android.Config) string { type dex2oatDependencyTag struct { blueprint.BaseDependencyTag + android.LicenseAnnotationToolchainDependencyTag } func (d dex2oatDependencyTag) ExcludeFromVisibilityEnforcement() { diff --git a/java/hiddenapi.go b/java/hiddenapi.go index 7c8be1e6e..3af5f1c7b 100644 --- a/java/hiddenapi.go +++ b/java/hiddenapi.go @@ -297,6 +297,7 @@ func hiddenAPIEncodeDex(ctx android.ModuleContext, dexInput, flagsCSV android.Pa type hiddenApiAnnotationsDependencyTag struct { blueprint.BaseDependencyTag + android.LicenseAnnotationSharedDependencyTag } // Tag used to mark dependencies on java_library instances that contains Java source files whose diff --git a/java/java.go b/java/java.go index 171415207..35b6a4f05 100644 --- a/java/java.go +++ b/java/java.go @@ -274,6 +274,9 @@ type dependencyTag struct { // True if the dependency is relinked at runtime. runtimeLinked bool + + // True if the dependency is a toolchain, for example an annotation processor. + toolchain bool } // installDependencyTag is a dependency tag that is annotated to cause the installed files of the @@ -287,6 +290,8 @@ type installDependencyTag struct { func (d dependencyTag) LicenseAnnotations() []android.LicenseAnnotation { if d.runtimeLinked { return []android.LicenseAnnotation{android.LicenseAnnotationSharedDependency} + } else if d.toolchain { + return []android.LicenseAnnotation{android.LicenseAnnotationToolchain} } return nil } @@ -329,19 +334,19 @@ var ( staticLibTag = dependencyTag{name: "staticlib"} libTag = dependencyTag{name: "javalib", runtimeLinked: true} java9LibTag = dependencyTag{name: "java9lib", runtimeLinked: true} - pluginTag = dependencyTag{name: "plugin"} - errorpronePluginTag = dependencyTag{name: "errorprone-plugin"} - exportedPluginTag = dependencyTag{name: "exported-plugin"} + pluginTag = dependencyTag{name: "plugin", toolchain: true} + errorpronePluginTag = dependencyTag{name: "errorprone-plugin", toolchain: true} + exportedPluginTag = dependencyTag{name: "exported-plugin", toolchain: true} bootClasspathTag = dependencyTag{name: "bootclasspath", runtimeLinked: true} systemModulesTag = dependencyTag{name: "system modules", runtimeLinked: true} frameworkResTag = dependencyTag{name: "framework-res"} kotlinStdlibTag = dependencyTag{name: "kotlin-stdlib", runtimeLinked: true} kotlinAnnotationsTag = dependencyTag{name: "kotlin-annotations", runtimeLinked: true} - kotlinPluginTag = dependencyTag{name: "kotlin-plugin"} + kotlinPluginTag = dependencyTag{name: "kotlin-plugin", toolchain: true} proguardRaiseTag = dependencyTag{name: "proguard-raise"} certificateTag = dependencyTag{name: "certificate"} instrumentationForTag = dependencyTag{name: "instrumentation_for"} - extraLintCheckTag = dependencyTag{name: "extra-lint-check"} + extraLintCheckTag = dependencyTag{name: "extra-lint-check", toolchain: true} jniLibTag = dependencyTag{name: "jnilib", runtimeLinked: true} syspropPublicStubDepTag = dependencyTag{name: "sysprop public stub"} jniInstallTag = installDependencyTag{name: "jni install"}