// Copyright 2018 Google Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package java import ( "android/soong/android" "android/soong/genrule" "fmt" "io" "path" "path/filepath" "sort" "strings" "sync" "github.com/google/blueprint" "github.com/google/blueprint/proptools" ) var ( sdkStubsLibrarySuffix = ".stubs" sdkSystemApiSuffix = ".system" sdkTestApiSuffix = ".test" sdkDocsSuffix = ".docs" sdkXmlFileSuffix = ".xml" ) type stubsLibraryDependencyTag struct { blueprint.BaseDependencyTag name string } type syspropLibraryInterface interface { SyspropJavaModule() *SdkLibrary } var ( publicApiStubsTag = dependencyTag{name: "public"} systemApiStubsTag = dependencyTag{name: "system"} testApiStubsTag = dependencyTag{name: "test"} publicApiFileTag = dependencyTag{name: "publicApi"} systemApiFileTag = dependencyTag{name: "systemApi"} testApiFileTag = dependencyTag{name: "testApi"} ) type apiScope int const ( apiScopePublic apiScope = iota apiScopeSystem apiScopeTest ) var ( javaSdkLibrariesLock sync.Mutex ) // java_sdk_library is to make a Java library that implements optional platform APIs to apps. // It is actually a wrapper of several modules: 1) stubs library that clients are linked against // to, 2) droiddoc module that internally generates API stubs source files, 3) the real runtime // shared library that implements the APIs, and 4) XML file for adding the runtime lib to the // classpath at runtime if requested via . // // TODO: these are big features that are currently missing // 1) disallowing linking to the runtime shared lib // 2) HTML generation func init() { android.RegisterModuleType("java_sdk_library", SdkLibraryFactory) android.PreArchMutators(func(ctx android.RegisterMutatorsContext) { ctx.TopDown("java_sdk_library", SdkLibraryMutator).Parallel() }) android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) { javaSdkLibraries := javaSdkLibraries(ctx.Config()) sort.Strings(*javaSdkLibraries) ctx.Strict("JAVA_SDK_LIBRARIES", strings.Join(*javaSdkLibraries, " ")) }) } type sdkLibraryProperties struct { // list of optional source files that are part of API but not part of runtime library. Api_srcs []string `android:"arch_variant"` // List of Java libraries that will be in the classpath when building stubs Stub_only_libs []string `android:"arch_variant"` // list of package names that will be documented and publicized as API Api_packages []string // list of package names that must be hidden from the API Hidden_api_packages []string // local files that are used within user customized droiddoc options. Droiddoc_option_files []string // additional droiddoc options // Available variables for substitution: // // $(location