2015-03-31 02:20:39 +02:00
|
|
|
// Copyright 2015 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
|
|
|
|
|
|
|
|
// This file contains the module types for compiling Java for Android, and converts the properties
|
2017-06-23 01:51:17 +02:00
|
|
|
// into the flags and filenames necessary to pass to the Module. The final creation of the rules
|
2015-03-31 02:20:39 +02:00
|
|
|
// is handled in builder.go
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2017-09-19 02:41:52 +02:00
|
|
|
"path/filepath"
|
2017-08-02 20:05:49 +02:00
|
|
|
"strconv"
|
2015-03-31 02:20:39 +02:00
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/google/blueprint"
|
2017-08-30 01:02:06 +02:00
|
|
|
"github.com/google/blueprint/proptools"
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
"android/soong/android"
|
2015-04-28 22:28:51 +02:00
|
|
|
"android/soong/genrule"
|
2017-06-23 02:20:19 +02:00
|
|
|
"android/soong/java/config"
|
2015-03-31 02:20:39 +02:00
|
|
|
)
|
|
|
|
|
2015-06-17 23:20:06 +02:00
|
|
|
func init() {
|
2017-07-07 23:35:50 +02:00
|
|
|
android.RegisterModuleType("java_defaults", defaultsFactory)
|
|
|
|
|
2017-10-03 03:10:21 +02:00
|
|
|
android.RegisterModuleType("java_library", LibraryFactory(true))
|
|
|
|
android.RegisterModuleType("java_library_static", LibraryFactory(false))
|
2017-07-20 00:53:04 +02:00
|
|
|
android.RegisterModuleType("java_library_host", LibraryHostFactory)
|
|
|
|
android.RegisterModuleType("java_binary", BinaryFactory)
|
|
|
|
android.RegisterModuleType("java_binary_host", BinaryHostFactory)
|
2017-08-02 20:05:49 +02:00
|
|
|
android.RegisterModuleType("java_import", ImportFactory)
|
|
|
|
android.RegisterModuleType("java_import_host", ImportFactoryHost)
|
2016-10-12 23:28:16 +02:00
|
|
|
android.RegisterModuleType("android_app", AndroidAppFactory)
|
|
|
|
|
|
|
|
android.RegisterSingletonType("logtags", LogtagsSingleton)
|
2015-06-17 23:20:06 +02:00
|
|
|
}
|
|
|
|
|
2015-03-31 02:20:39 +02:00
|
|
|
// TODO:
|
|
|
|
// Autogenerated files:
|
|
|
|
// Proto
|
|
|
|
// Renderscript
|
|
|
|
// Post-jar passes:
|
|
|
|
// Proguard
|
2017-06-23 00:36:39 +02:00
|
|
|
// Jacoco
|
2015-03-31 02:20:39 +02:00
|
|
|
// Jarjar
|
|
|
|
// Dex
|
|
|
|
// Rmtypedefs
|
|
|
|
// DroidDoc
|
|
|
|
// Findbugs
|
|
|
|
|
2017-07-07 23:35:50 +02:00
|
|
|
type CompilerProperties struct {
|
2015-05-11 22:39:40 +02:00
|
|
|
// list of source files used to compile the Java module. May be .java, .logtags, .proto,
|
|
|
|
// or .aidl files.
|
2015-07-01 03:15:24 +02:00
|
|
|
Srcs []string `android:"arch_variant"`
|
|
|
|
|
|
|
|
// list of source files that should not be used to build the Java module.
|
|
|
|
// This is most useful in the arch/multilib variants to remove non-common files
|
|
|
|
Exclude_srcs []string `android:"arch_variant"`
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2015-05-11 22:39:40 +02:00
|
|
|
// list of directories containing Java resources
|
2017-09-28 02:33:10 +02:00
|
|
|
Java_resource_dirs []string `android:"arch_variant"`
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2017-09-28 02:33:10 +02:00
|
|
|
// list of directories that should be excluded from java_resource_dirs
|
|
|
|
Exclude_java_resource_dirs []string `android:"arch_variant"`
|
2015-07-01 03:15:24 +02:00
|
|
|
|
2017-09-28 02:42:05 +02:00
|
|
|
// list of files to use as Java resources
|
|
|
|
Java_resources []string `android:"arch_variant"`
|
|
|
|
|
|
|
|
// list of files that should be excluded from java_resources
|
|
|
|
Exclude_java_resources []string `android:"arch_variant"`
|
|
|
|
|
2017-10-02 05:33:03 +02:00
|
|
|
// don't build against the default libraries (bootclasspath, legacy-test, core-junit,
|
2015-05-11 22:39:40 +02:00
|
|
|
// ext, and framework for device targets)
|
2017-08-30 01:02:06 +02:00
|
|
|
No_standard_libs *bool
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2017-10-02 05:33:03 +02:00
|
|
|
// don't build against the framework libraries (legacy-test, core-junit,
|
|
|
|
// ext, and framework for device targets)
|
|
|
|
No_framework_libs *bool
|
|
|
|
|
2015-05-11 22:39:40 +02:00
|
|
|
// list of module-specific flags that will be used for javac compiles
|
|
|
|
Javacflags []string `android:"arch_variant"`
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2015-05-11 22:39:40 +02:00
|
|
|
// list of of java libraries that will be in the classpath
|
2017-07-19 20:22:16 +02:00
|
|
|
Libs []string `android:"arch_variant"`
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2015-05-11 22:39:40 +02:00
|
|
|
// list of java libraries that will be compiled into the resulting jar
|
2017-07-19 20:22:16 +02:00
|
|
|
Static_libs []string `android:"arch_variant"`
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2015-05-11 22:39:40 +02:00
|
|
|
// manifest file to be included in resulting jar
|
2015-09-24 00:26:20 +02:00
|
|
|
Manifest *string
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2017-06-23 02:01:52 +02:00
|
|
|
// if not blank, run jarjar using the specified rules file
|
|
|
|
Jarjar_rules *string
|
2017-08-08 22:17:59 +02:00
|
|
|
|
|
|
|
// If not blank, set the java version passed to javac as -source and -target
|
|
|
|
Java_version *string
|
2017-09-01 01:45:16 +02:00
|
|
|
|
|
|
|
// If set to false, don't allow this module to be installed. Defaults to true.
|
|
|
|
Installable *bool
|
2017-09-06 22:41:06 +02:00
|
|
|
|
2017-09-28 02:42:05 +02:00
|
|
|
// If set to true, include sources used to compile the module in to the final jar
|
|
|
|
Include_srcs *bool
|
|
|
|
|
2017-09-06 22:41:06 +02:00
|
|
|
// List of modules to use as annotation processors
|
|
|
|
Annotation_processors []string
|
|
|
|
|
|
|
|
// List of classes to pass to javac to use as annotation processors
|
|
|
|
Annotation_processor_classes []string
|
2017-06-23 02:01:52 +02:00
|
|
|
}
|
|
|
|
|
2017-07-07 23:35:50 +02:00
|
|
|
type CompilerDeviceProperties struct {
|
2017-06-23 02:01:52 +02:00
|
|
|
// list of module-specific flags that will be used for dex compiles
|
|
|
|
Dxflags []string `android:"arch_variant"`
|
|
|
|
|
2015-05-11 22:39:40 +02:00
|
|
|
// if not blank, set to the version of the sdk to compile against
|
|
|
|
Sdk_version string
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2015-05-11 22:39:40 +02:00
|
|
|
// Set for device java libraries, and for host versions of device java libraries
|
|
|
|
// built for testing
|
|
|
|
Dex bool `blueprint:"mutated"`
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2015-05-11 22:39:40 +02:00
|
|
|
// directories to pass to aidl tool
|
|
|
|
Aidl_includes []string
|
2015-04-08 22:03:43 +02:00
|
|
|
|
2015-05-11 22:39:40 +02:00
|
|
|
// directories that should be added as include directories
|
|
|
|
// for any aidl sources of modules that depend on this module
|
|
|
|
Export_aidl_include_dirs []string
|
|
|
|
}
|
2015-04-08 22:03:43 +02:00
|
|
|
|
2017-06-23 01:51:17 +02:00
|
|
|
// Module contains the properties and members used by all java module types
|
|
|
|
type Module struct {
|
2016-05-19 00:37:25 +02:00
|
|
|
android.ModuleBase
|
2017-07-07 23:35:50 +02:00
|
|
|
android.DefaultableModuleBase
|
2015-05-11 22:39:40 +02:00
|
|
|
|
2017-07-07 23:35:50 +02:00
|
|
|
properties CompilerProperties
|
|
|
|
deviceProperties CompilerDeviceProperties
|
2015-03-31 02:20:39 +02:00
|
|
|
|
|
|
|
// output file suitable for inserting into the classpath of another compile
|
2016-05-19 00:37:25 +02:00
|
|
|
classpathFile android.Path
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2017-09-15 22:00:47 +02:00
|
|
|
// output file containing classes.dex
|
|
|
|
dexJarFile android.Path
|
|
|
|
|
|
|
|
// output files containing resources
|
|
|
|
resourceJarFiles android.Paths
|
|
|
|
|
2015-04-16 23:09:14 +02:00
|
|
|
// output file suitable for installing or running
|
2016-05-19 00:37:25 +02:00
|
|
|
outputFile android.Path
|
2015-04-16 23:09:14 +02:00
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
exportAidlIncludeDirs android.Paths
|
2015-04-08 22:03:43 +02:00
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
logtagsSrcs android.Paths
|
2015-04-11 02:45:20 +02:00
|
|
|
|
2015-04-16 23:09:14 +02:00
|
|
|
// filelists of extra source files that should be included in the javac command line,
|
|
|
|
// for example R.java generated by aapt for android apps
|
2016-05-19 00:37:25 +02:00
|
|
|
ExtraSrcLists android.Paths
|
2015-04-16 23:09:14 +02:00
|
|
|
|
2015-03-31 02:20:39 +02:00
|
|
|
// installed file for binary dependency
|
2016-05-19 00:37:25 +02:00
|
|
|
installFile android.Path
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
|
|
|
|
2017-07-20 00:53:04 +02:00
|
|
|
type Dependency interface {
|
2017-08-02 20:05:49 +02:00
|
|
|
ClasspathFiles() android.Paths
|
2017-09-15 22:00:47 +02:00
|
|
|
ResourceJarFiles() android.Paths
|
2016-05-19 00:37:25 +02:00
|
|
|
AidlIncludeDirs() android.Paths
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
|
|
|
|
2017-07-07 23:35:50 +02:00
|
|
|
func InitJavaModule(module android.DefaultableModule, hod android.HostOrDeviceSupported) {
|
|
|
|
android.InitAndroidArchModule(module, hod, android.MultilibCommon)
|
|
|
|
android.InitDefaultableModule(module)
|
|
|
|
}
|
|
|
|
|
2017-07-08 00:59:46 +02:00
|
|
|
type dependencyTag struct {
|
|
|
|
blueprint.BaseDependencyTag
|
|
|
|
name string
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
|
|
|
|
2017-07-08 00:59:46 +02:00
|
|
|
var (
|
2017-09-15 22:00:47 +02:00
|
|
|
staticLibTag = dependencyTag{name: "staticlib"}
|
|
|
|
libTag = dependencyTag{name: "javalib"}
|
|
|
|
bootClasspathTag = dependencyTag{name: "bootclasspath"}
|
|
|
|
frameworkResTag = dependencyTag{name: "framework-res"}
|
2017-07-08 00:59:46 +02:00
|
|
|
)
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2017-09-19 02:41:52 +02:00
|
|
|
type sdkDep struct {
|
|
|
|
useModule, useFiles, useDefaultLibs bool
|
|
|
|
module string
|
|
|
|
jar android.Path
|
|
|
|
aidl android.Path
|
|
|
|
}
|
|
|
|
|
|
|
|
func decodeSdkDep(ctx android.BaseContext, v string) sdkDep {
|
|
|
|
switch v {
|
|
|
|
case "", "current", "system_current", "test_current":
|
|
|
|
// OK
|
|
|
|
default:
|
|
|
|
if _, err := strconv.Atoi(v); err != nil {
|
|
|
|
ctx.PropertyErrorf("sdk_version", "invalid sdk version")
|
|
|
|
return sdkDep{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
toFile := func(v string) sdkDep {
|
|
|
|
dir := filepath.Join("prebuilts/sdk", v)
|
|
|
|
jar := filepath.Join(dir, "android.jar")
|
|
|
|
aidl := filepath.Join(dir, "framework.aidl")
|
|
|
|
jarPath := android.ExistentPathForSource(ctx, "sdkdir", jar)
|
|
|
|
aidlPath := android.ExistentPathForSource(ctx, "sdkdir", aidl)
|
|
|
|
if !jarPath.Valid() {
|
|
|
|
ctx.PropertyErrorf("sdk_version", "invalid sdk version %q, %q does not exist", v, jar)
|
|
|
|
return sdkDep{}
|
|
|
|
}
|
|
|
|
if !aidlPath.Valid() {
|
|
|
|
ctx.PropertyErrorf("sdk_version", "invalid sdk version %q, %q does not exist", v, aidl)
|
|
|
|
return sdkDep{}
|
|
|
|
}
|
|
|
|
return sdkDep{
|
|
|
|
useFiles: true,
|
|
|
|
jar: jarPath.Path(),
|
|
|
|
aidl: aidlPath.Path(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
toModule := func(m string) sdkDep {
|
|
|
|
return sdkDep{
|
|
|
|
useModule: true,
|
|
|
|
module: m,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-23 00:30:06 +02:00
|
|
|
if ctx.AConfig().UnbundledBuild() && v != "" {
|
2017-09-19 02:41:52 +02:00
|
|
|
return toFile(v)
|
|
|
|
}
|
|
|
|
|
|
|
|
switch v {
|
|
|
|
case "":
|
|
|
|
return sdkDep{
|
|
|
|
useDefaultLibs: true,
|
|
|
|
}
|
|
|
|
case "current":
|
|
|
|
return toModule("android_stubs_current")
|
|
|
|
case "system_current":
|
|
|
|
return toModule("android_system_stubs_current")
|
|
|
|
case "test_current":
|
|
|
|
return toModule("android_test_stubs_current")
|
|
|
|
default:
|
|
|
|
return toFile(v)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-08 00:59:46 +02:00
|
|
|
func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
2017-08-30 01:02:06 +02:00
|
|
|
if !proptools.Bool(j.properties.No_standard_libs) {
|
2017-07-08 00:59:46 +02:00
|
|
|
if ctx.Device() {
|
2017-09-19 02:41:52 +02:00
|
|
|
sdkDep := decodeSdkDep(ctx, j.deviceProperties.Sdk_version)
|
|
|
|
if sdkDep.useDefaultLibs {
|
2017-09-24 04:57:16 +02:00
|
|
|
ctx.AddDependency(ctx.Module(), bootClasspathTag, config.DefaultBootclasspathLibraries...)
|
2017-10-02 05:33:03 +02:00
|
|
|
if !proptools.Bool(j.properties.No_framework_libs) {
|
|
|
|
ctx.AddDependency(ctx.Module(), libTag, config.DefaultLibraries...)
|
|
|
|
}
|
2017-09-19 02:41:52 +02:00
|
|
|
}
|
|
|
|
if sdkDep.useModule {
|
|
|
|
ctx.AddDependency(ctx.Module(), bootClasspathTag, sdkDep.module)
|
2017-07-08 00:59:46 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if j.deviceProperties.Dex {
|
2017-09-24 04:57:16 +02:00
|
|
|
ctx.AddDependency(ctx.Module(), bootClasspathTag, config.DefaultBootclasspathLibraries...)
|
2017-07-08 00:59:46 +02:00
|
|
|
}
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
|
|
|
}
|
2017-07-20 00:53:04 +02:00
|
|
|
ctx.AddDependency(ctx.Module(), libTag, j.properties.Libs...)
|
|
|
|
ctx.AddDependency(ctx.Module(), staticLibTag, j.properties.Static_libs...)
|
2017-09-15 22:00:47 +02:00
|
|
|
ctx.AddDependency(ctx.Module(), libTag, j.properties.Annotation_processors...)
|
2017-08-30 22:27:57 +02:00
|
|
|
|
|
|
|
android.ExtractSourcesDeps(ctx, j.properties.Srcs)
|
2017-09-28 02:42:05 +02:00
|
|
|
android.ExtractSourcesDeps(ctx, j.properties.Java_resources)
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
|
|
|
|
2017-06-23 01:51:17 +02:00
|
|
|
func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath,
|
2016-05-19 00:37:25 +02:00
|
|
|
aidlIncludeDirs android.Paths) []string {
|
2015-04-08 22:03:43 +02:00
|
|
|
|
2017-06-23 02:01:52 +02:00
|
|
|
localAidlIncludes := android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl_includes)
|
2015-04-08 22:03:43 +02:00
|
|
|
|
|
|
|
var flags []string
|
2015-09-24 00:26:20 +02:00
|
|
|
if aidlPreprocess.Valid() {
|
|
|
|
flags = append(flags, "-p"+aidlPreprocess.String())
|
2015-04-08 22:03:43 +02:00
|
|
|
} else {
|
2016-05-19 00:37:25 +02:00
|
|
|
flags = append(flags, android.JoinWithPrefix(aidlIncludeDirs.Strings(), "-I"))
|
2015-04-08 22:03:43 +02:00
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
flags = append(flags, android.JoinWithPrefix(j.exportAidlIncludeDirs.Strings(), "-I"))
|
|
|
|
flags = append(flags, android.JoinWithPrefix(localAidlIncludes.Strings(), "-I"))
|
|
|
|
flags = append(flags, "-I"+android.PathForModuleSrc(ctx).String())
|
2017-07-13 23:41:17 +02:00
|
|
|
if src := android.ExistentPathForSource(ctx, "", "src"); src.Valid() {
|
|
|
|
flags = append(flags, "-I"+src.String())
|
|
|
|
}
|
2015-04-08 22:03:43 +02:00
|
|
|
|
2015-04-13 22:53:40 +02:00
|
|
|
return flags
|
2015-04-08 22:03:43 +02:00
|
|
|
}
|
|
|
|
|
2017-09-06 22:41:06 +02:00
|
|
|
type deps struct {
|
2017-09-15 22:00:47 +02:00
|
|
|
classpath android.Paths
|
|
|
|
bootClasspath android.Paths
|
|
|
|
staticJars android.Paths
|
|
|
|
staticJarResources android.Paths
|
|
|
|
aidlIncludeDirs android.Paths
|
|
|
|
srcFileLists android.Paths
|
|
|
|
aidlPreprocess android.OptionalPath
|
2017-09-06 22:41:06 +02:00
|
|
|
}
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2017-09-06 22:41:06 +02:00
|
|
|
func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
|
|
|
var deps deps
|
2017-09-19 02:41:52 +02:00
|
|
|
|
|
|
|
sdkDep := decodeSdkDep(ctx, j.deviceProperties.Sdk_version)
|
|
|
|
if sdkDep.useFiles {
|
|
|
|
deps.classpath = append(deps.classpath, sdkDep.jar)
|
|
|
|
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, sdkDep.aidl)
|
|
|
|
}
|
|
|
|
|
2015-03-31 02:20:39 +02:00
|
|
|
ctx.VisitDirectDeps(func(module blueprint.Module) {
|
|
|
|
otherName := ctx.OtherModuleName(module)
|
2017-07-07 23:47:12 +02:00
|
|
|
tag := ctx.OtherModuleDependencyTag(module)
|
|
|
|
|
2017-07-20 00:53:04 +02:00
|
|
|
dep, _ := module.(Dependency)
|
|
|
|
if dep == nil {
|
2017-07-07 23:47:12 +02:00
|
|
|
switch tag {
|
|
|
|
case android.DefaultsDepTag, android.SourceDepTag:
|
2017-09-14 00:46:47 +02:00
|
|
|
// Nothing to do
|
2017-07-07 23:47:12 +02:00
|
|
|
default:
|
|
|
|
ctx.ModuleErrorf("depends on non-java module %q", otherName)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-08 00:59:46 +02:00
|
|
|
switch tag {
|
|
|
|
case bootClasspathTag:
|
2017-09-06 22:41:06 +02:00
|
|
|
deps.bootClasspath = append(deps.bootClasspath, dep.ClasspathFiles()...)
|
2017-07-20 00:53:04 +02:00
|
|
|
case libTag:
|
2017-09-06 22:41:06 +02:00
|
|
|
deps.classpath = append(deps.classpath, dep.ClasspathFiles()...)
|
2017-07-20 00:53:04 +02:00
|
|
|
case staticLibTag:
|
2017-09-06 22:41:06 +02:00
|
|
|
deps.classpath = append(deps.classpath, dep.ClasspathFiles()...)
|
|
|
|
deps.staticJars = append(deps.staticJars, dep.ClasspathFiles()...)
|
2017-09-15 22:00:47 +02:00
|
|
|
deps.staticJarResources = append(deps.staticJarResources, dep.ResourceJarFiles()...)
|
2017-07-08 00:59:46 +02:00
|
|
|
case frameworkResTag:
|
2017-07-07 23:47:12 +02:00
|
|
|
if ctx.ModuleName() == "framework" {
|
|
|
|
// framework.jar has a one-off dependency on the R.java and Manifest.java files
|
|
|
|
// generated by framework-res.apk
|
2017-09-06 22:41:06 +02:00
|
|
|
deps.srcFileLists = append(deps.srcFileLists, module.(*AndroidApp).aaptJavaFileList)
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
2017-07-08 00:59:46 +02:00
|
|
|
default:
|
|
|
|
panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
2017-07-08 00:59:46 +02:00
|
|
|
|
2017-09-06 22:41:06 +02:00
|
|
|
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
|
2015-03-31 02:20:39 +02:00
|
|
|
})
|
|
|
|
|
2017-09-06 22:41:06 +02:00
|
|
|
return deps
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
|
|
|
|
2017-06-23 01:51:17 +02:00
|
|
|
func (j *Module) compile(ctx android.ModuleContext) {
|
2015-04-08 22:03:43 +02:00
|
|
|
|
2017-06-23 02:01:52 +02:00
|
|
|
j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.deviceProperties.Export_aidl_include_dirs)
|
2015-04-08 22:03:43 +02:00
|
|
|
|
2017-09-06 22:41:06 +02:00
|
|
|
deps := j.collectDeps(ctx)
|
2015-04-08 22:03:43 +02:00
|
|
|
|
2015-04-13 22:53:40 +02:00
|
|
|
var flags javaBuilderFlags
|
|
|
|
|
|
|
|
javacFlags := j.properties.Javacflags
|
2017-09-06 21:52:16 +02:00
|
|
|
if ctx.AConfig().Getenv("EXPERIMENTAL_USE_OPENJDK9") == "" {
|
|
|
|
javacFlags = config.StripJavac9Flags(javacFlags)
|
|
|
|
}
|
2017-08-08 22:17:59 +02:00
|
|
|
|
|
|
|
if j.properties.Java_version != nil {
|
|
|
|
flags.javaVersion = *j.properties.Java_version
|
|
|
|
} else {
|
|
|
|
flags.javaVersion = "${config.DefaultJavaVersion}"
|
|
|
|
}
|
|
|
|
|
2017-09-15 22:00:47 +02:00
|
|
|
flags.bootClasspath.AddPaths(deps.bootClasspath)
|
|
|
|
flags.classpath.AddPaths(deps.classpath)
|
|
|
|
|
2015-04-13 22:53:40 +02:00
|
|
|
if len(javacFlags) > 0 {
|
|
|
|
ctx.Variable(pctx, "javacFlags", strings.Join(javacFlags, " "))
|
|
|
|
flags.javacFlags = "$javacFlags"
|
|
|
|
}
|
|
|
|
|
2017-09-06 22:41:06 +02:00
|
|
|
aidlFlags := j.aidlFlags(ctx, deps.aidlPreprocess, deps.aidlIncludeDirs)
|
2015-04-13 22:53:40 +02:00
|
|
|
if len(aidlFlags) > 0 {
|
|
|
|
ctx.Variable(pctx, "aidlFlags", strings.Join(aidlFlags, " "))
|
|
|
|
flags.aidlFlags = "$aidlFlags"
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
|
|
|
|
2015-07-01 03:15:24 +02:00
|
|
|
srcFiles := ctx.ExpandSources(j.properties.Srcs, j.properties.Exclude_srcs)
|
2015-04-08 22:03:43 +02:00
|
|
|
|
2015-04-11 02:45:20 +02:00
|
|
|
srcFiles = j.genSources(ctx, srcFiles, flags)
|
2015-04-08 22:03:43 +02:00
|
|
|
|
2015-04-28 22:28:51 +02:00
|
|
|
ctx.VisitDirectDeps(func(module blueprint.Module) {
|
|
|
|
if gen, ok := module.(genrule.SourceFileGenerator); ok {
|
|
|
|
srcFiles = append(srcFiles, gen.GeneratedSourceFiles()...)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2017-09-06 22:41:06 +02:00
|
|
|
deps.srcFileLists = append(deps.srcFileLists, j.ExtraSrcLists...)
|
2015-04-16 23:09:14 +02:00
|
|
|
|
2017-08-30 23:24:55 +02:00
|
|
|
var jars android.Paths
|
|
|
|
|
2015-04-11 00:41:49 +02:00
|
|
|
if len(srcFiles) > 0 {
|
2017-09-28 02:39:56 +02:00
|
|
|
var extraJarDeps android.Paths
|
2017-08-14 23:16:06 +02:00
|
|
|
if ctx.AConfig().IsEnvTrue("RUN_ERROR_PRONE") {
|
|
|
|
// If error-prone is enabled, add an additional rule to compile the java files into
|
|
|
|
// a separate set of classes (so that they don't overwrite the normal ones and require
|
2017-09-28 02:39:56 +02:00
|
|
|
// a rebuild when error-prone is turned off).
|
2017-08-14 23:16:06 +02:00
|
|
|
// TODO(ccross): Once we always compile with javac9 we may be able to conditionally
|
|
|
|
// enable error-prone without affecting the output class files.
|
2017-09-28 02:39:56 +02:00
|
|
|
errorprone := RunErrorProne(ctx, srcFiles, deps.srcFileLists, flags, nil)
|
2017-08-14 23:16:06 +02:00
|
|
|
extraJarDeps = append(extraJarDeps, errorprone)
|
|
|
|
}
|
|
|
|
|
2017-09-28 02:39:56 +02:00
|
|
|
// Compile java sources into .class files
|
|
|
|
classes := TransformJavaToClasses(ctx, srcFiles, deps.srcFileLists, flags, extraJarDeps)
|
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-08-30 23:24:55 +02:00
|
|
|
jars = append(jars, classes)
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
|
|
|
|
2017-09-28 02:42:05 +02:00
|
|
|
dirArgs, dirDeps := ResourceDirsToJarArgs(ctx, j.properties.Java_resource_dirs, j.properties.Exclude_java_resource_dirs)
|
|
|
|
fileArgs, fileDeps := ResourceFilesToJarArgs(ctx, j.properties.Java_resources, j.properties.Exclude_java_resources)
|
|
|
|
|
|
|
|
var resArgs []string
|
|
|
|
var resDeps android.Paths
|
|
|
|
|
|
|
|
resArgs = append(resArgs, dirArgs...)
|
|
|
|
resDeps = append(resDeps, dirDeps...)
|
|
|
|
|
|
|
|
resArgs = append(resArgs, fileArgs...)
|
|
|
|
resDeps = append(resDeps, fileDeps...)
|
|
|
|
|
|
|
|
if proptools.Bool(j.properties.Include_srcs) {
|
|
|
|
srcArgs, srcDeps := ResourceFilesToJarArgs(ctx, j.properties.Srcs, j.properties.Exclude_srcs)
|
|
|
|
resArgs = append(resArgs, srcArgs...)
|
|
|
|
resDeps = append(resDeps, srcDeps...)
|
|
|
|
}
|
2017-09-28 02:41:35 +02:00
|
|
|
|
|
|
|
if len(resArgs) > 0 {
|
2017-08-30 23:24:55 +02:00
|
|
|
// Combine classes + resources into classes-full-debug.jar
|
2017-09-28 02:41:35 +02:00
|
|
|
resourceJar := TransformResourcesToJar(ctx, resArgs, resDeps)
|
2017-08-30 23:24:55 +02:00
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2017-09-15 22:00:47 +02:00
|
|
|
j.resourceJarFiles = append(j.resourceJarFiles, resourceJar)
|
2017-08-30 23:24:55 +02:00
|
|
|
jars = append(jars, resourceJar)
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
2015-04-04 01:54:17 +02:00
|
|
|
|
2017-09-15 22:00:47 +02:00
|
|
|
// Propagate the resources from the transitive closure of static dependencies for copying
|
|
|
|
// into dex jars
|
|
|
|
j.resourceJarFiles = append(j.resourceJarFiles, deps.staticJarResources...)
|
|
|
|
|
|
|
|
// static classpath jars have the resources in them, so the resource jars aren't necessary here
|
2017-09-06 22:41:06 +02:00
|
|
|
jars = append(jars, deps.staticJars...)
|
2017-08-30 23:24:55 +02:00
|
|
|
|
2017-09-13 07:50:46 +02:00
|
|
|
manifest := android.OptionalPathForModuleSrc(ctx, j.properties.Manifest)
|
|
|
|
|
2017-08-30 23:24:55 +02:00
|
|
|
// Combine the classes built from sources, any manifests, and any static libraries into
|
2017-09-28 03:03:17 +02:00
|
|
|
// classes.jar. If there is only one input jar this step will be skipped.
|
2017-09-13 07:50:46 +02:00
|
|
|
outputFile := TransformJarsToJar(ctx, "classes.jar", jars, manifest, false)
|
2017-08-30 23:24:55 +02:00
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
if j.properties.Jarjar_rules != nil {
|
2016-05-19 00:37:25 +02:00
|
|
|
jarjar_rules := android.PathForModuleSrc(ctx, *j.properties.Jarjar_rules)
|
2017-09-28 03:03:17 +02:00
|
|
|
// Transform classes.jar into classes-jarjar.jar
|
2015-04-04 01:54:17 +02:00
|
|
|
outputFile = TransformJarJar(ctx, outputFile, jarjar_rules)
|
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-31 02:20:39 +02:00
|
|
|
j.classpathFile = outputFile
|
|
|
|
|
2017-09-21 03:04:44 +02:00
|
|
|
// TODO(ccross): handle hostdex
|
2017-09-28 02:59:10 +02:00
|
|
|
if ctx.Device() && len(srcFiles) > 0 && j.installable() {
|
2017-06-23 02:01:52 +02:00
|
|
|
dxFlags := j.deviceProperties.Dxflags
|
2015-03-31 02:20:39 +02:00
|
|
|
if false /* emma enabled */ {
|
|
|
|
// If you instrument class files that have local variable debug information in
|
|
|
|
// them emma does not correctly maintain the local variable table.
|
|
|
|
// This will cause an error when you try to convert the class files for Android.
|
|
|
|
// The workaround here is to build different dex file here based on emma switch
|
|
|
|
// then later copy into classes.dex. When emma is on, dx is run with --no-locals
|
|
|
|
// option to remove local variable information
|
|
|
|
dxFlags = append(dxFlags, "--no-locals")
|
|
|
|
}
|
|
|
|
|
2015-04-08 02:11:30 +02:00
|
|
|
if ctx.AConfig().Getenv("NO_OPTIMIZE_DX") != "" {
|
2015-03-31 02:20:39 +02:00
|
|
|
dxFlags = append(dxFlags, "--no-optimize")
|
|
|
|
}
|
|
|
|
|
2015-04-08 02:11:30 +02:00
|
|
|
if ctx.AConfig().Getenv("GENERATE_DEX_DEBUG") != "" {
|
2015-03-31 02:20:39 +02:00
|
|
|
dxFlags = append(dxFlags,
|
|
|
|
"--debug",
|
|
|
|
"--verbose",
|
2016-05-19 00:37:25 +02:00
|
|
|
"--dump-to="+android.PathForModuleOut(ctx, "classes.lst").String(),
|
2015-03-31 02:20:39 +02:00
|
|
|
"--dump-width=1000")
|
|
|
|
}
|
|
|
|
|
2017-08-31 21:30:37 +02:00
|
|
|
var minSdkVersion string
|
|
|
|
switch j.deviceProperties.Sdk_version {
|
|
|
|
case "", "current", "test_current", "system_current":
|
|
|
|
minSdkVersion = strconv.Itoa(ctx.AConfig().DefaultAppTargetSdkInt())
|
|
|
|
default:
|
|
|
|
minSdkVersion = j.deviceProperties.Sdk_version
|
|
|
|
}
|
|
|
|
|
|
|
|
dxFlags = append(dxFlags, "--min-sdk-version="+minSdkVersion)
|
|
|
|
|
2015-03-31 02:20:39 +02:00
|
|
|
flags.dxFlags = strings.Join(dxFlags, " ")
|
|
|
|
|
2017-09-15 22:00:47 +02:00
|
|
|
desugarFlags := []string{
|
|
|
|
"--min_sdk_version " + minSdkVersion,
|
|
|
|
"--desugar_try_with_resources_if_needed=false",
|
|
|
|
"--allow_empty_bootclasspath",
|
|
|
|
}
|
|
|
|
|
|
|
|
if inList("--core-library", dxFlags) {
|
|
|
|
desugarFlags = append(desugarFlags, "--core_library")
|
|
|
|
}
|
|
|
|
|
|
|
|
flags.desugarFlags = strings.Join(desugarFlags, " ")
|
|
|
|
|
|
|
|
desugarJar := TransformDesugar(ctx, outputFile, flags)
|
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2015-03-31 02:20:39 +02:00
|
|
|
// Compile classes.jar into classes.dex
|
2017-09-15 22:00:47 +02:00
|
|
|
dexJarFile := TransformClassesJarToDexJar(ctx, desugarJar, flags)
|
2015-03-31 02:20:39 +02:00
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-09-15 22:00:47 +02:00
|
|
|
jars := android.Paths{dexJarFile}
|
|
|
|
jars = append(jars, j.resourceJarFiles...)
|
|
|
|
|
|
|
|
outputFile = TransformJarsToJar(ctx, "javalib.jar", jars, android.OptionalPath{}, true)
|
|
|
|
|
|
|
|
j.dexJarFile = outputFile
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
2015-04-16 23:09:14 +02:00
|
|
|
ctx.CheckbuildFile(outputFile)
|
|
|
|
j.outputFile = outputFile
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
|
|
|
|
2017-09-28 02:59:10 +02:00
|
|
|
func (j *Module) installable() bool {
|
|
|
|
return j.properties.Installable == nil || *j.properties.Installable
|
|
|
|
}
|
|
|
|
|
2017-07-20 00:53:04 +02:00
|
|
|
var _ Dependency = (*Library)(nil)
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2017-08-02 20:05:49 +02:00
|
|
|
func (j *Module) ClasspathFiles() android.Paths {
|
|
|
|
return android.Paths{j.classpathFile}
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
|
|
|
|
2017-09-15 22:00:47 +02:00
|
|
|
func (j *Module) ResourceJarFiles() android.Paths {
|
|
|
|
return j.resourceJarFiles
|
|
|
|
}
|
|
|
|
|
2017-06-23 01:51:17 +02:00
|
|
|
func (j *Module) AidlIncludeDirs() android.Paths {
|
2015-04-08 22:03:43 +02:00
|
|
|
return j.exportAidlIncludeDirs
|
|
|
|
}
|
|
|
|
|
2017-06-23 01:51:17 +02:00
|
|
|
var _ logtagsProducer = (*Module)(nil)
|
2015-04-11 02:45:20 +02:00
|
|
|
|
2017-06-23 01:51:17 +02:00
|
|
|
func (j *Module) logtags() android.Paths {
|
2015-04-11 02:45:20 +02:00
|
|
|
return j.logtagsSrcs
|
|
|
|
}
|
|
|
|
|
2015-03-31 02:20:39 +02:00
|
|
|
//
|
|
|
|
// Java libraries (.jar file)
|
|
|
|
//
|
|
|
|
|
2017-07-20 00:53:04 +02:00
|
|
|
type Library struct {
|
2017-06-23 01:51:17 +02:00
|
|
|
Module
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
|
|
|
|
2017-07-20 00:53:04 +02:00
|
|
|
func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
2017-06-23 01:51:17 +02:00
|
|
|
j.compile(ctx)
|
2015-04-16 23:09:14 +02:00
|
|
|
|
2017-09-28 02:59:10 +02:00
|
|
|
if j.installable() {
|
2017-09-01 01:45:16 +02:00
|
|
|
j.installFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),
|
|
|
|
ctx.ModuleName()+".jar", j.outputFile)
|
|
|
|
}
|
2015-04-16 23:09:14 +02:00
|
|
|
}
|
|
|
|
|
2017-07-20 00:53:04 +02:00
|
|
|
func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) {
|
2017-06-23 01:51:17 +02:00
|
|
|
j.deps(ctx)
|
|
|
|
}
|
|
|
|
|
2017-10-03 03:10:21 +02:00
|
|
|
func LibraryFactory(installable bool) func() android.Module {
|
|
|
|
return func() android.Module {
|
|
|
|
module := &Library{}
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2017-10-03 03:10:21 +02:00
|
|
|
if !installable {
|
|
|
|
module.properties.Installable = proptools.BoolPtr(false)
|
|
|
|
}
|
|
|
|
module.deviceProperties.Dex = true
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2017-10-03 03:10:21 +02:00
|
|
|
module.AddProperties(
|
|
|
|
&module.Module.properties,
|
|
|
|
&module.Module.deviceProperties)
|
2017-06-24 00:06:31 +02:00
|
|
|
|
2017-10-03 03:10:21 +02:00
|
|
|
InitJavaModule(module, android.HostAndDeviceSupported)
|
|
|
|
return module
|
|
|
|
}
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
|
|
|
|
2017-07-20 00:53:04 +02:00
|
|
|
func LibraryHostFactory() android.Module {
|
|
|
|
module := &Library{}
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2017-06-24 00:06:31 +02:00
|
|
|
module.AddProperties(&module.Module.properties)
|
|
|
|
|
2017-07-07 23:35:50 +02:00
|
|
|
InitJavaModule(module, android.HostSupported)
|
2017-06-24 00:06:31 +02:00
|
|
|
return module
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Java Binaries (.jar file plus wrapper script)
|
|
|
|
//
|
|
|
|
|
2017-07-20 00:53:04 +02:00
|
|
|
type binaryProperties struct {
|
2015-05-11 22:39:40 +02:00
|
|
|
// installable script to execute the resulting jar
|
|
|
|
Wrapper string
|
|
|
|
}
|
|
|
|
|
2017-07-20 00:53:04 +02:00
|
|
|
type Binary struct {
|
|
|
|
Library
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2017-07-20 00:53:04 +02:00
|
|
|
binaryProperties binaryProperties
|
2017-08-11 02:09:43 +02:00
|
|
|
|
|
|
|
wrapperFile android.ModuleSrcPath
|
|
|
|
binaryFile android.OutputPath
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
|
|
|
|
2017-07-20 00:53:04 +02:00
|
|
|
func (j *Binary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
|
|
j.Library.GenerateAndroidBuildActions(ctx)
|
2015-03-31 02:20:39 +02:00
|
|
|
|
|
|
|
// Depend on the installed jar (j.installFile) so that the wrapper doesn't get executed by
|
|
|
|
// another build rule before the jar has been installed.
|
2017-08-11 02:09:43 +02:00
|
|
|
j.wrapperFile = android.PathForModuleSrc(ctx, j.binaryProperties.Wrapper)
|
2017-08-31 21:29:17 +02:00
|
|
|
j.binaryFile = ctx.InstallExecutable(android.PathForModuleInstall(ctx, "bin"),
|
|
|
|
ctx.ModuleName(), j.wrapperFile, j.installFile)
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
|
|
|
|
2017-07-20 00:53:04 +02:00
|
|
|
func (j *Binary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
2017-06-23 01:51:17 +02:00
|
|
|
j.deps(ctx)
|
|
|
|
}
|
|
|
|
|
2017-07-20 00:53:04 +02:00
|
|
|
func BinaryFactory() android.Module {
|
|
|
|
module := &Binary{}
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2017-06-23 02:01:52 +02:00
|
|
|
module.deviceProperties.Dex = true
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2017-06-24 00:06:31 +02:00
|
|
|
module.AddProperties(
|
2017-06-23 02:01:52 +02:00
|
|
|
&module.Module.properties,
|
|
|
|
&module.Module.deviceProperties,
|
|
|
|
&module.binaryProperties)
|
2017-06-24 00:06:31 +02:00
|
|
|
|
2017-07-07 23:35:50 +02:00
|
|
|
InitJavaModule(module, android.HostAndDeviceSupported)
|
2017-06-24 00:06:31 +02:00
|
|
|
return module
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
|
|
|
|
2017-07-20 00:53:04 +02:00
|
|
|
func BinaryHostFactory() android.Module {
|
|
|
|
module := &Binary{}
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2017-06-24 00:06:31 +02:00
|
|
|
module.AddProperties(
|
2017-06-23 02:01:52 +02:00
|
|
|
&module.Module.properties,
|
|
|
|
&module.Module.deviceProperties,
|
|
|
|
&module.binaryProperties)
|
2017-06-24 00:06:31 +02:00
|
|
|
|
2017-07-07 23:35:50 +02:00
|
|
|
InitJavaModule(module, android.HostSupported)
|
2017-06-24 00:06:31 +02:00
|
|
|
return module
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Java prebuilts
|
|
|
|
//
|
|
|
|
|
2017-08-02 20:05:49 +02:00
|
|
|
type ImportProperties struct {
|
|
|
|
Jars []string
|
|
|
|
}
|
|
|
|
|
|
|
|
type Import struct {
|
2016-05-19 00:37:25 +02:00
|
|
|
android.ModuleBase
|
2017-07-07 23:47:12 +02:00
|
|
|
prebuilt android.Prebuilt
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2017-08-02 20:05:49 +02:00
|
|
|
properties ImportProperties
|
|
|
|
|
2017-08-30 23:24:55 +02:00
|
|
|
classpathFiles android.Paths
|
|
|
|
combinedClasspathFile android.Path
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
|
|
|
|
2017-08-02 20:05:49 +02:00
|
|
|
func (j *Import) Prebuilt() *android.Prebuilt {
|
2017-07-07 23:47:12 +02:00
|
|
|
return &j.prebuilt
|
|
|
|
}
|
|
|
|
|
2017-08-02 20:05:49 +02:00
|
|
|
func (j *Import) PrebuiltSrcs() []string {
|
|
|
|
return j.properties.Jars
|
|
|
|
}
|
|
|
|
|
|
|
|
func (j *Import) Name() string {
|
2017-07-28 00:41:32 +02:00
|
|
|
return j.prebuilt.Name(j.ModuleBase.Name())
|
|
|
|
}
|
|
|
|
|
2017-08-02 20:05:49 +02:00
|
|
|
func (j *Import) DepsMutator(ctx android.BottomUpMutatorContext) {
|
2016-10-12 23:38:15 +02:00
|
|
|
}
|
|
|
|
|
2017-08-02 20:05:49 +02:00
|
|
|
func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
|
|
j.classpathFiles = android.PathsForModuleSrc(ctx, j.properties.Jars)
|
|
|
|
|
2017-09-13 07:50:46 +02:00
|
|
|
j.combinedClasspathFile = TransformJarsToJar(ctx, "classes.jar", j.classpathFiles, android.OptionalPath{}, false)
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
|
|
|
|
2017-08-02 20:05:49 +02:00
|
|
|
var _ Dependency = (*Import)(nil)
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2017-08-02 20:05:49 +02:00
|
|
|
func (j *Import) ClasspathFiles() android.Paths {
|
|
|
|
return j.classpathFiles
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
|
|
|
|
2017-09-15 22:00:47 +02:00
|
|
|
func (j *Import) ResourceJarFiles() android.Paths {
|
|
|
|
// resources are in the ClasspathFiles
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-08-02 20:05:49 +02:00
|
|
|
func (j *Import) AidlIncludeDirs() android.Paths {
|
2015-04-08 22:03:43 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-08-02 20:05:49 +02:00
|
|
|
var _ android.PrebuiltInterface = (*Import)(nil)
|
2015-03-31 02:20:39 +02:00
|
|
|
|
2017-08-02 20:05:49 +02:00
|
|
|
func ImportFactory() android.Module {
|
|
|
|
module := &Import{}
|
2017-06-24 00:06:31 +02:00
|
|
|
|
2017-08-02 20:05:49 +02:00
|
|
|
module.AddProperties(&module.properties)
|
|
|
|
|
|
|
|
android.InitPrebuiltModule(module, &module.properties.Jars)
|
2017-06-24 00:06:31 +02:00
|
|
|
android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
|
|
|
|
return module
|
2015-03-31 02:20:39 +02:00
|
|
|
}
|
|
|
|
|
2017-08-02 20:05:49 +02:00
|
|
|
func ImportFactoryHost() android.Module {
|
|
|
|
module := &Import{}
|
|
|
|
|
|
|
|
module.AddProperties(&module.properties)
|
|
|
|
|
|
|
|
android.InitPrebuiltModule(module, &module.properties.Jars)
|
|
|
|
android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
|
|
|
|
return module
|
|
|
|
}
|
|
|
|
|
2015-03-31 02:20:39 +02:00
|
|
|
func inList(s string, l []string) bool {
|
|
|
|
for _, e := range l {
|
|
|
|
if e == s {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2017-07-07 23:35:50 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Defaults
|
|
|
|
//
|
|
|
|
type Defaults struct {
|
|
|
|
android.ModuleBase
|
|
|
|
android.DefaultsModuleBase
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Defaults) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|
|
|
}
|
|
|
|
|
|
|
|
func defaultsFactory() android.Module {
|
|
|
|
return DefaultsFactory()
|
|
|
|
}
|
|
|
|
|
|
|
|
func DefaultsFactory(props ...interface{}) android.Module {
|
|
|
|
module := &Defaults{}
|
|
|
|
|
|
|
|
module.AddProperties(props...)
|
|
|
|
module.AddProperties(
|
|
|
|
&CompilerProperties{},
|
|
|
|
&CompilerDeviceProperties{},
|
|
|
|
)
|
|
|
|
|
|
|
|
android.InitDefaultsModule(module)
|
|
|
|
|
|
|
|
return module
|
|
|
|
}
|