java_sdk_library is to make a Java library that implements optional SDK APIs to apps. It is actually a wrapper for 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 API, and 4) XML file for adding the runtime lib to the classpath at runtime if requested via <uses-library>. Note: this is only the initial CL for the feature. Followings are features currently missing and under development. 1) check for API consistency 2) install stubs libs as the dist artifacts 3) ensuring that apps have appropriate <uses-library> tag 4) disallowing linking to the runtime shared lib 5) HTML generation Bug: 77575606 Test: m -j Change-Id: I4a4ccf6e730e041703c63bb275d8860d0de96887
92 lines
2.6 KiB
Go
92 lines
2.6 KiB
Go
// Copyright 2016 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 android
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
)
|
|
|
|
// prebuilt_etc is for prebuilts that will be installed to
|
|
// <partition>/etc/<subdir>
|
|
|
|
func init() {
|
|
RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
|
|
}
|
|
|
|
type prebuiltEtcProperties struct {
|
|
// Source file of this prebuilt.
|
|
Srcs []string `android:"arch_variant"`
|
|
|
|
// optional subdirectory under which this file is installed into
|
|
Sub_dir *string `android:"arch_variant"`
|
|
}
|
|
|
|
type prebuiltEtc struct {
|
|
ModuleBase
|
|
prebuilt Prebuilt
|
|
|
|
properties prebuiltEtcProperties
|
|
|
|
sourceFilePath Path
|
|
installDirPath OutputPath
|
|
}
|
|
|
|
func (p *prebuiltEtc) Prebuilt() *Prebuilt {
|
|
return &p.prebuilt
|
|
}
|
|
|
|
func (p *prebuiltEtc) DepsMutator(ctx BottomUpMutatorContext) {
|
|
if len(p.properties.Srcs) == 0 {
|
|
ctx.PropertyErrorf("srcs", "missing prebuilt source file")
|
|
}
|
|
|
|
if len(p.properties.Srcs) > 1 {
|
|
ctx.PropertyErrorf("srcs", "multiple prebuilt source files")
|
|
}
|
|
|
|
// To support ":modulename" in src
|
|
ExtractSourceDeps(ctx, &(p.properties.Srcs)[0])
|
|
}
|
|
|
|
func (p *prebuiltEtc) GenerateAndroidBuildActions(ctx ModuleContext) {
|
|
p.sourceFilePath = ctx.ExpandSource(p.properties.Srcs[0], "srcs")
|
|
p.installDirPath = PathForModuleInstall(ctx, "etc", String(p.properties.Sub_dir))
|
|
}
|
|
|
|
func (p *prebuiltEtc) AndroidMk() AndroidMkData {
|
|
return AndroidMkData{
|
|
Custom: func(w io.Writer, name, prefix, moduleDir string, data AndroidMkData) {
|
|
fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
|
|
fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
|
|
fmt.Fprintln(w, "LOCAL_MODULE :=", name)
|
|
fmt.Fprintln(w, "LOCAL_MODULE_CLASS := ETC")
|
|
fmt.Fprintln(w, "LOCAL_MODULE_TAGS := optional")
|
|
fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", p.sourceFilePath.String())
|
|
fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", "$(OUT_DIR)/"+p.installDirPath.RelPathString())
|
|
fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
|
|
},
|
|
}
|
|
}
|
|
|
|
func PrebuiltEtcFactory() Module {
|
|
module := &prebuiltEtc{}
|
|
module.AddProperties(&module.properties)
|
|
|
|
InitPrebuiltModule(module, &(module.properties.Srcs))
|
|
InitAndroidModule(module)
|
|
return module
|
|
}
|