2018-10-10 07:01:00 +02:00
|
|
|
// Copyright (C) 2018 The Android Open Source Project
|
|
|
|
//
|
|
|
|
// 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 apex
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"path/filepath"
|
|
|
|
"runtime"
|
2018-10-10 07:05:29 +02:00
|
|
|
"sort"
|
2018-10-10 07:01:00 +02:00
|
|
|
"strings"
|
2019-08-23 04:17:39 +02:00
|
|
|
"sync"
|
2018-10-10 07:01:00 +02:00
|
|
|
|
|
|
|
"android/soong/android"
|
|
|
|
"android/soong/cc"
|
|
|
|
"android/soong/java"
|
2019-02-27 23:19:50 +01:00
|
|
|
"android/soong/python"
|
2018-10-10 07:01:00 +02:00
|
|
|
|
|
|
|
"github.com/google/blueprint"
|
2019-02-27 23:19:50 +01:00
|
|
|
"github.com/google/blueprint/bootstrap"
|
2018-10-10 07:01:00 +02:00
|
|
|
"github.com/google/blueprint/proptools"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
pctx = android.NewPackageContext("android/apex")
|
|
|
|
|
|
|
|
// Create a canned fs config file where all files and directories are
|
|
|
|
// by default set to (uid/gid/mode) = (1000/1000/0644)
|
|
|
|
// TODO(b/113082813) make this configurable using config.fs syntax
|
|
|
|
generateFsConfig = pctx.StaticRule("generateFsConfig", blueprint.RuleParams{
|
2018-11-02 12:50:42 +01:00
|
|
|
Command: `echo '/ 1000 1000 0755' > ${out} && ` +
|
2018-11-20 19:04:58 +01:00
|
|
|
`echo '/apex_manifest.json 1000 1000 0644' >> ${out} && ` +
|
2018-10-11 06:23:09 +02:00
|
|
|
`echo ${ro_paths} | tr ' ' '\n' | awk '{print "/"$$1 " 1000 1000 0644"}' >> ${out} && ` +
|
2019-01-08 06:04:17 +01:00
|
|
|
`echo ${exec_paths} | tr ' ' '\n' | awk '{print "/"$$1 " 0 2000 0755"}' >> ${out}`,
|
2018-10-10 07:01:00 +02:00
|
|
|
Description: "fs_config ${out}",
|
2018-10-11 06:23:09 +02:00
|
|
|
}, "ro_paths", "exec_paths")
|
2018-10-10 07:01:00 +02:00
|
|
|
|
2019-09-26 17:38:03 +02:00
|
|
|
apexManifestRule = pctx.StaticRule("apexManifestRule", blueprint.RuleParams{
|
2019-08-01 10:41:43 +02:00
|
|
|
Command: `rm -f $out && ${jsonmodify} $in ` +
|
|
|
|
`-a provideNativeLibs ${provideNativeLibs} ` +
|
2019-09-26 17:38:03 +02:00
|
|
|
`-a requireNativeLibs ${requireNativeLibs} ` +
|
|
|
|
`${opt} ` +
|
|
|
|
`-o $out`,
|
2019-08-01 10:41:43 +02:00
|
|
|
CommandDeps: []string{"${jsonmodify}"},
|
2019-09-26 17:38:03 +02:00
|
|
|
Description: "prepare ${out}",
|
|
|
|
}, "provideNativeLibs", "requireNativeLibs", "opt")
|
2019-08-01 10:41:43 +02:00
|
|
|
|
2018-10-10 07:01:00 +02:00
|
|
|
// TODO(b/113233103): make sure that file_contexts is sane, i.e., validate
|
|
|
|
// against the binary policy using sefcontext_compiler -p <policy>.
|
|
|
|
|
|
|
|
// TODO(b/114327326): automate the generation of file_contexts
|
|
|
|
apexRule = pctx.StaticRule("apexRule", blueprint.RuleParams{
|
|
|
|
Command: `rm -rf ${image_dir} && mkdir -p ${image_dir} && ` +
|
2019-07-30 20:56:56 +02:00
|
|
|
`(. ${out}.copy_commands) && ` +
|
2018-10-10 07:01:00 +02:00
|
|
|
`APEXER_TOOL_PATH=${tool_path} ` +
|
2018-11-20 01:57:52 +01:00
|
|
|
`${apexer} --force --manifest ${manifest} ` +
|
2018-10-10 07:01:00 +02:00
|
|
|
`--file_contexts ${file_contexts} ` +
|
|
|
|
`--canned_fs_config ${canned_fs_config} ` +
|
2018-11-30 02:12:15 +01:00
|
|
|
`--payload_type image ` +
|
2018-12-27 08:04:18 +01:00
|
|
|
`--key ${key} ${opt_flags} ${image_dir} ${out} `,
|
2018-10-10 07:01:00 +02:00
|
|
|
CommandDeps: []string{"${apexer}", "${avbtool}", "${e2fsdroid}", "${merge_zips}",
|
|
|
|
"${mke2fs}", "${resize2fs}", "${sefcontext_compile}",
|
2019-06-13 06:48:54 +02:00
|
|
|
"${soong_zip}", "${zipalign}", "${aapt2}", "prebuilts/sdk/current/public/android.jar"},
|
2019-07-30 20:56:56 +02:00
|
|
|
Rspfile: "${out}.copy_commands",
|
|
|
|
RspfileContent: "${copy_commands}",
|
|
|
|
Description: "APEX ${image_dir} => ${out}",
|
2018-12-27 08:04:18 +01:00
|
|
|
}, "tool_path", "image_dir", "copy_commands", "manifest", "file_contexts", "canned_fs_config", "key", "opt_flags")
|
2018-11-16 20:36:28 +01:00
|
|
|
|
2018-11-30 02:12:15 +01:00
|
|
|
zipApexRule = pctx.StaticRule("zipApexRule", blueprint.RuleParams{
|
|
|
|
Command: `rm -rf ${image_dir} && mkdir -p ${image_dir} && ` +
|
2019-07-30 20:56:56 +02:00
|
|
|
`(. ${out}.copy_commands) && ` +
|
2018-11-30 02:12:15 +01:00
|
|
|
`APEXER_TOOL_PATH=${tool_path} ` +
|
|
|
|
`${apexer} --force --manifest ${manifest} ` +
|
|
|
|
`--payload_type zip ` +
|
|
|
|
`${image_dir} ${out} `,
|
2019-07-30 20:56:56 +02:00
|
|
|
CommandDeps: []string{"${apexer}", "${merge_zips}", "${soong_zip}", "${zipalign}", "${aapt2}"},
|
|
|
|
Rspfile: "${out}.copy_commands",
|
|
|
|
RspfileContent: "${copy_commands}",
|
|
|
|
Description: "ZipAPEX ${image_dir} => ${out}",
|
2018-11-30 02:12:15 +01:00
|
|
|
}, "tool_path", "image_dir", "copy_commands", "manifest")
|
|
|
|
|
2018-11-16 20:36:28 +01:00
|
|
|
apexProtoConvertRule = pctx.AndroidStaticRule("apexProtoConvertRule",
|
|
|
|
blueprint.RuleParams{
|
|
|
|
Command: `${aapt2} convert --output-format proto $in -o $out`,
|
|
|
|
CommandDeps: []string{"${aapt2}"},
|
|
|
|
})
|
|
|
|
|
|
|
|
apexBundleRule = pctx.StaticRule("apexBundleRule", blueprint.RuleParams{
|
2018-11-23 05:22:21 +01:00
|
|
|
Command: `${zip2zip} -i $in -o $out ` +
|
2018-11-20 19:04:58 +01:00
|
|
|
`apex_payload.img:apex/${abi}.img ` +
|
|
|
|
`apex_manifest.json:root/apex_manifest.json ` +
|
2019-09-04 22:26:18 +02:00
|
|
|
`AndroidManifest.xml:manifest/AndroidManifest.xml ` +
|
|
|
|
`assets/NOTICE.html.gz:assets/NOTICE.html.gz`,
|
2018-11-16 20:36:28 +01:00
|
|
|
CommandDeps: []string{"${zip2zip}"},
|
|
|
|
Description: "app bundle",
|
|
|
|
}, "abi")
|
2019-08-31 15:38:05 +02:00
|
|
|
|
|
|
|
emitApexContentRule = pctx.StaticRule("emitApexContentRule", blueprint.RuleParams{
|
|
|
|
Command: `rm -f ${out} && touch ${out} && (. ${out}.emit_commands)`,
|
|
|
|
Rspfile: "${out}.emit_commands",
|
|
|
|
RspfileContent: "${emit_commands}",
|
|
|
|
Description: "Emit APEX image content",
|
|
|
|
}, "emit_commands")
|
|
|
|
|
|
|
|
diffApexContentRule = pctx.StaticRule("diffApexContentRule", blueprint.RuleParams{
|
|
|
|
Command: `diff --unchanged-group-format='' \` +
|
|
|
|
`--changed-group-format='%<' \` +
|
|
|
|
`${image_content_file} ${whitelisted_files_file} || (` +
|
|
|
|
`echo -e "New unexpected files were added to ${apex_module_name}." ` +
|
|
|
|
` "To fix the build run following command:" && ` +
|
|
|
|
`echo "system/apex/tools/update_whitelist.sh ${whitelisted_files_file} ${image_content_file}" && ` +
|
|
|
|
`exit 1)`,
|
|
|
|
Description: "Diff ${image_content_file} and ${whitelisted_files_file}",
|
|
|
|
}, "image_content_file", "whitelisted_files_file", "apex_module_name")
|
2018-10-10 07:01:00 +02:00
|
|
|
)
|
|
|
|
|
2018-11-30 02:12:15 +01:00
|
|
|
var imageApexSuffix = ".apex"
|
|
|
|
var zipApexSuffix = ".zipapex"
|
|
|
|
|
|
|
|
var imageApexType = "image"
|
|
|
|
var zipApexType = "zip"
|
2018-10-10 07:01:00 +02:00
|
|
|
|
|
|
|
type dependencyTag struct {
|
|
|
|
blueprint.BaseDependencyTag
|
|
|
|
name string
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
2018-10-30 13:20:05 +01:00
|
|
|
sharedLibTag = dependencyTag{name: "sharedLib"}
|
|
|
|
executableTag = dependencyTag{name: "executable"}
|
|
|
|
javaLibTag = dependencyTag{name: "javaLib"}
|
|
|
|
prebuiltTag = dependencyTag{name: "prebuilt"}
|
2019-06-26 13:48:34 +02:00
|
|
|
testTag = dependencyTag{name: "test"}
|
2018-10-30 13:20:05 +01:00
|
|
|
keyTag = dependencyTag{name: "key"}
|
|
|
|
certificateTag = dependencyTag{name: "certificate"}
|
2019-06-27 04:30:33 +02:00
|
|
|
usesTag = dependencyTag{name: "uses"}
|
2019-08-27 06:55:42 +02:00
|
|
|
androidAppTag = dependencyTag{name: "androidApp"}
|
2018-10-10 07:01:00 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2019-04-03 01:14:11 +02:00
|
|
|
pctx.Import("android/soong/android")
|
2018-10-30 13:20:05 +01:00
|
|
|
pctx.Import("android/soong/java")
|
2018-10-10 07:01:00 +02:00
|
|
|
pctx.HostBinToolVariable("apexer", "apexer")
|
2018-10-05 20:34:32 +02:00
|
|
|
// ART minimal builds (using the master-art manifest) do not have the "frameworks/base"
|
|
|
|
// projects, and hence cannot built 'aapt2'. Use the SDK prebuilt instead.
|
|
|
|
hostBinToolVariableWithPrebuilt := func(name, prebuiltDir, tool string) {
|
|
|
|
pctx.VariableFunc(name, func(ctx android.PackageVarContext) string {
|
2019-01-23 22:04:05 +01:00
|
|
|
if !ctx.Config().FrameworksBaseDirExists(ctx) {
|
2018-10-05 20:34:32 +02:00
|
|
|
return filepath.Join(prebuiltDir, runtime.GOOS, "bin", tool)
|
|
|
|
} else {
|
|
|
|
return pctx.HostBinToolPath(ctx, tool).String()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
hostBinToolVariableWithPrebuilt("aapt2", "prebuilts/sdk/tools", "aapt2")
|
2018-10-10 07:01:00 +02:00
|
|
|
pctx.HostBinToolVariable("avbtool", "avbtool")
|
|
|
|
pctx.HostBinToolVariable("e2fsdroid", "e2fsdroid")
|
|
|
|
pctx.HostBinToolVariable("merge_zips", "merge_zips")
|
|
|
|
pctx.HostBinToolVariable("mke2fs", "mke2fs")
|
|
|
|
pctx.HostBinToolVariable("resize2fs", "resize2fs")
|
|
|
|
pctx.HostBinToolVariable("sefcontext_compile", "sefcontext_compile")
|
|
|
|
pctx.HostBinToolVariable("soong_zip", "soong_zip")
|
2018-11-16 20:36:28 +01:00
|
|
|
pctx.HostBinToolVariable("zip2zip", "zip2zip")
|
2018-10-10 07:01:00 +02:00
|
|
|
pctx.HostBinToolVariable("zipalign", "zipalign")
|
2019-08-01 10:41:43 +02:00
|
|
|
pctx.HostBinToolVariable("jsonmodify", "jsonmodify")
|
2018-10-10 07:01:00 +02:00
|
|
|
|
Introduce module type 'sdk'
This change introduces a new module type named 'sdk'. It is a logical
group of prebuilt modules that together provide a context (e.g. APIs)
in which Mainline modules (such as APEXes) are built.
A prebuilt module (e.g. java_import) can join an sdk by adding it to the
sdk module as shown below:
sdk {
name: "mysdk#20",
java_libs: ["myjavalib_mysdk_20"],
}
java_import {
name: "myjavalib_mysdk_20",
srcs: ["myjavalib-v20.jar"],
sdk_member_name: "myjavalib",
}
sdk {
name: "mysdk#21",
java_libs: ["myjavalib_mysdk_21"],
}
java_import {
name: "myjavalib_mysdk_21",
srcs: ["myjavalib-v21.jar"],
sdk_member_name: "myjavalib",
}
java_library {
name: "myjavalib",
srcs: ["**/*/*.java"],
}
An APEX can specify the SDK(s) that it wants to build with via the new
'uses_sdks' property.
apex {
name: "myapex",
java_libs: ["libX", "libY"],
uses_sdks: ["mysdk#20"],
}
With this, libX, libY, and their transitive dependencies are all built
with the version 20 of myjavalib (the first java_import module) instead
of the other one (which is for version 21) and java_library having the
same name (which is for ToT).
Bug: 138182343
Test: m (sdk_test.go added)
Change-Id: I7e14c524a7d6a0d9f575fb20822080f39818c01e
2019-07-17 13:08:41 +02:00
|
|
|
android.RegisterModuleType("apex", BundleFactory)
|
2019-02-07 22:20:53 +01:00
|
|
|
android.RegisterModuleType("apex_test", testApexBundleFactory)
|
2019-08-23 04:17:39 +02:00
|
|
|
android.RegisterModuleType("apex_vndk", vndkApexBundleFactory)
|
2019-02-07 08:27:23 +01:00
|
|
|
android.RegisterModuleType("apex_defaults", defaultsFactory)
|
2019-03-26 23:07:36 +01:00
|
|
|
android.RegisterModuleType("prebuilt_apex", PrebuiltFactory)
|
2018-10-10 07:01:00 +02:00
|
|
|
|
2019-10-07 08:34:50 +02:00
|
|
|
android.PreDepsMutators(RegisterPreDepsMutators)
|
Introduce module type 'sdk'
This change introduces a new module type named 'sdk'. It is a logical
group of prebuilt modules that together provide a context (e.g. APIs)
in which Mainline modules (such as APEXes) are built.
A prebuilt module (e.g. java_import) can join an sdk by adding it to the
sdk module as shown below:
sdk {
name: "mysdk#20",
java_libs: ["myjavalib_mysdk_20"],
}
java_import {
name: "myjavalib_mysdk_20",
srcs: ["myjavalib-v20.jar"],
sdk_member_name: "myjavalib",
}
sdk {
name: "mysdk#21",
java_libs: ["myjavalib_mysdk_21"],
}
java_import {
name: "myjavalib_mysdk_21",
srcs: ["myjavalib-v21.jar"],
sdk_member_name: "myjavalib",
}
java_library {
name: "myjavalib",
srcs: ["**/*/*.java"],
}
An APEX can specify the SDK(s) that it wants to build with via the new
'uses_sdks' property.
apex {
name: "myapex",
java_libs: ["libX", "libY"],
uses_sdks: ["mysdk#20"],
}
With this, libX, libY, and their transitive dependencies are all built
with the version 20 of myjavalib (the first java_import module) instead
of the other one (which is for version 21) and java_library having the
same name (which is for ToT).
Bug: 138182343
Test: m (sdk_test.go added)
Change-Id: I7e14c524a7d6a0d9f575fb20822080f39818c01e
2019-07-17 13:08:41 +02:00
|
|
|
android.PostDepsMutators(RegisterPostDepsMutators)
|
2019-10-08 14:59:58 +02:00
|
|
|
|
|
|
|
android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) {
|
|
|
|
apexFileContextsInfos := apexFileContextsInfos(ctx.Config())
|
|
|
|
sort.Strings(*apexFileContextsInfos)
|
|
|
|
ctx.Strict("APEX_FILE_CONTEXTS_INFOS", strings.Join(*apexFileContextsInfos, " "))
|
|
|
|
})
|
Introduce module type 'sdk'
This change introduces a new module type named 'sdk'. It is a logical
group of prebuilt modules that together provide a context (e.g. APIs)
in which Mainline modules (such as APEXes) are built.
A prebuilt module (e.g. java_import) can join an sdk by adding it to the
sdk module as shown below:
sdk {
name: "mysdk#20",
java_libs: ["myjavalib_mysdk_20"],
}
java_import {
name: "myjavalib_mysdk_20",
srcs: ["myjavalib-v20.jar"],
sdk_member_name: "myjavalib",
}
sdk {
name: "mysdk#21",
java_libs: ["myjavalib_mysdk_21"],
}
java_import {
name: "myjavalib_mysdk_21",
srcs: ["myjavalib-v21.jar"],
sdk_member_name: "myjavalib",
}
java_library {
name: "myjavalib",
srcs: ["**/*/*.java"],
}
An APEX can specify the SDK(s) that it wants to build with via the new
'uses_sdks' property.
apex {
name: "myapex",
java_libs: ["libX", "libY"],
uses_sdks: ["mysdk#20"],
}
With this, libX, libY, and their transitive dependencies are all built
with the version 20 of myjavalib (the first java_import module) instead
of the other one (which is for version 21) and java_library having the
same name (which is for ToT).
Bug: 138182343
Test: m (sdk_test.go added)
Change-Id: I7e14c524a7d6a0d9f575fb20822080f39818c01e
2019-07-17 13:08:41 +02:00
|
|
|
}
|
|
|
|
|
2019-10-07 08:34:50 +02:00
|
|
|
func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) {
|
|
|
|
ctx.TopDown("apex_vndk", apexVndkMutator).Parallel()
|
|
|
|
ctx.BottomUp("apex_vndk_deps", apexVndkDepsMutator).Parallel()
|
|
|
|
}
|
|
|
|
|
Introduce module type 'sdk'
This change introduces a new module type named 'sdk'. It is a logical
group of prebuilt modules that together provide a context (e.g. APIs)
in which Mainline modules (such as APEXes) are built.
A prebuilt module (e.g. java_import) can join an sdk by adding it to the
sdk module as shown below:
sdk {
name: "mysdk#20",
java_libs: ["myjavalib_mysdk_20"],
}
java_import {
name: "myjavalib_mysdk_20",
srcs: ["myjavalib-v20.jar"],
sdk_member_name: "myjavalib",
}
sdk {
name: "mysdk#21",
java_libs: ["myjavalib_mysdk_21"],
}
java_import {
name: "myjavalib_mysdk_21",
srcs: ["myjavalib-v21.jar"],
sdk_member_name: "myjavalib",
}
java_library {
name: "myjavalib",
srcs: ["**/*/*.java"],
}
An APEX can specify the SDK(s) that it wants to build with via the new
'uses_sdks' property.
apex {
name: "myapex",
java_libs: ["libX", "libY"],
uses_sdks: ["mysdk#20"],
}
With this, libX, libY, and their transitive dependencies are all built
with the version 20 of myjavalib (the first java_import module) instead
of the other one (which is for version 21) and java_library having the
same name (which is for ToT).
Bug: 138182343
Test: m (sdk_test.go added)
Change-Id: I7e14c524a7d6a0d9f575fb20822080f39818c01e
2019-07-17 13:08:41 +02:00
|
|
|
func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) {
|
|
|
|
ctx.TopDown("apex_deps", apexDepsMutator)
|
|
|
|
ctx.BottomUp("apex", apexMutator).Parallel()
|
|
|
|
ctx.BottomUp("apex_flattened", apexFlattenedMutator).Parallel()
|
|
|
|
ctx.BottomUp("apex_uses", apexUsesMutator).Parallel()
|
2018-10-10 07:01:00 +02:00
|
|
|
}
|
|
|
|
|
2019-08-23 04:17:39 +02:00
|
|
|
var (
|
|
|
|
vndkApexListKey = android.NewOnceKey("vndkApexList")
|
|
|
|
vndkApexListMutex sync.Mutex
|
|
|
|
)
|
|
|
|
|
2019-10-07 08:34:50 +02:00
|
|
|
func vndkApexList(config android.Config) map[string]string {
|
2019-08-23 04:17:39 +02:00
|
|
|
return config.Once(vndkApexListKey, func() interface{} {
|
2019-10-07 08:34:50 +02:00
|
|
|
return map[string]string{}
|
|
|
|
}).(map[string]string)
|
2019-08-23 04:17:39 +02:00
|
|
|
}
|
|
|
|
|
2019-10-07 08:34:50 +02:00
|
|
|
func apexVndkMutator(mctx android.TopDownMutatorContext) {
|
2019-08-23 04:17:39 +02:00
|
|
|
if ab, ok := mctx.Module().(*apexBundle); ok && ab.vndkApex {
|
|
|
|
if ab.IsNativeBridgeSupported() {
|
|
|
|
mctx.PropertyErrorf("native_bridge_supported", "%q doesn't support native bridge binary.", mctx.ModuleType())
|
|
|
|
}
|
2019-10-01 13:02:42 +02:00
|
|
|
|
2019-10-07 08:34:50 +02:00
|
|
|
vndkVersion := ab.vndkVersion(mctx.DeviceConfig())
|
|
|
|
// Ensure VNDK APEX mount point is formatted as com.android.vndk.v###
|
|
|
|
ab.properties.Apex_name = proptools.StringPtr("com.android.vndk.v" + vndkVersion)
|
2019-10-01 13:02:42 +02:00
|
|
|
|
2019-10-07 08:34:50 +02:00
|
|
|
// vndk_version should be unique
|
2019-08-23 04:17:39 +02:00
|
|
|
vndkApexListMutex.Lock()
|
|
|
|
defer vndkApexListMutex.Unlock()
|
|
|
|
vndkApexList := vndkApexList(mctx.Config())
|
|
|
|
if other, ok := vndkApexList[vndkVersion]; ok {
|
2019-10-07 08:34:50 +02:00
|
|
|
mctx.PropertyErrorf("vndk_version", "%v is already defined in %q", vndkVersion, other)
|
2019-08-23 04:17:39 +02:00
|
|
|
}
|
2019-10-07 08:34:50 +02:00
|
|
|
vndkApexList[vndkVersion] = mctx.ModuleName()
|
2019-08-23 04:17:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-07 08:34:50 +02:00
|
|
|
func apexVndkDepsMutator(mctx android.BottomUpMutatorContext) {
|
|
|
|
if m, ok := mctx.Module().(*cc.Module); ok && cc.IsForVndkApex(mctx, m) {
|
|
|
|
vndkVersion := m.VndkVersion()
|
2019-08-23 04:17:39 +02:00
|
|
|
vndkApexList := vndkApexList(mctx.Config())
|
2019-10-07 08:34:50 +02:00
|
|
|
if vndkApex, ok := vndkApexList[vndkVersion]; ok {
|
|
|
|
mctx.AddReverseDependency(mctx.Module(), sharedLibTag, vndkApex)
|
2019-08-23 04:17:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-10 07:01:00 +02:00
|
|
|
// Mark the direct and transitive dependencies of apex bundles so that they
|
|
|
|
// can be built for the apex bundles.
|
|
|
|
func apexDepsMutator(mctx android.TopDownMutatorContext) {
|
2019-02-04 23:45:06 +01:00
|
|
|
if a, ok := mctx.Module().(*apexBundle); ok {
|
2018-11-16 20:36:28 +01:00
|
|
|
apexBundleName := mctx.ModuleName()
|
2018-10-10 07:01:00 +02:00
|
|
|
mctx.WalkDeps(func(child, parent android.Module) bool {
|
Don't create unnecessary APEX variations
This change fixes a problem that APEX variations are created for the
modules that actually shouldn't built for any APEX. For example,
consider this case.
apex { name: "myapex", native_shared_libs: ["mylib"],}
cc_library { name: "mylib", shared_libs: ["libfoo#10"],}
cc_library { name: "libfoo",
shared_libs: ["libbar"],
stubs: { versions: ["10"], }, }
cc_library { name: "libbar", ...}
Before this change, both the stubs and non-stubs variations of libfoo
were mutated with apexMuator, which is incorrect for the non-stubs
varia; there is no dependency chain from the apex "myapex" to the
non-stubs variation, but to the stubs variation due to the #10 syntax.
This was happening becauses we used the name of the module to determine
whether it should be built for APEX or not. Both stubs and non-stubs
variations have the same module name "libfoo".
Fixing this issue by recording the list of APEX variations required
directly on the module. So, the stubs variation of libfoo has myapex in
its apex variations list, but the non-stubs variation doesn't, and thus
apexMutator does not pick up the non-stubs variation.
Test: m (apex_test updated and passing)
Test: cherry-pick ag/5747464 and m
Change-Id: I31e618626809a828a55fff513ef5f81f79637afa
2018-12-10 17:35:25 +01:00
|
|
|
depName := mctx.OtherModuleName(child)
|
|
|
|
// If the parent is apexBundle, this child is directly depended.
|
|
|
|
_, directDep := parent.(*apexBundle)
|
2019-02-07 22:20:53 +01:00
|
|
|
if a.installable() && !a.testApex {
|
2019-02-04 23:45:06 +01:00
|
|
|
// TODO(b/123892969): Workaround for not having any way to annotate test-apexs
|
|
|
|
// non-installable apex's cannot be installed and so should not prevent libraries from being
|
|
|
|
// installed to the system.
|
|
|
|
android.UpdateApexDependency(apexBundleName, depName, directDep)
|
|
|
|
}
|
Don't create unnecessary APEX variations
This change fixes a problem that APEX variations are created for the
modules that actually shouldn't built for any APEX. For example,
consider this case.
apex { name: "myapex", native_shared_libs: ["mylib"],}
cc_library { name: "mylib", shared_libs: ["libfoo#10"],}
cc_library { name: "libfoo",
shared_libs: ["libbar"],
stubs: { versions: ["10"], }, }
cc_library { name: "libbar", ...}
Before this change, both the stubs and non-stubs variations of libfoo
were mutated with apexMuator, which is incorrect for the non-stubs
varia; there is no dependency chain from the apex "myapex" to the
non-stubs variation, but to the stubs variation due to the #10 syntax.
This was happening becauses we used the name of the module to determine
whether it should be built for APEX or not. Both stubs and non-stubs
variations have the same module name "libfoo".
Fixing this issue by recording the list of APEX variations required
directly on the module. So, the stubs variation of libfoo has myapex in
its apex variations list, but the non-stubs variation doesn't, and thus
apexMutator does not pick up the non-stubs variation.
Test: m (apex_test updated and passing)
Test: cherry-pick ag/5747464 and m
Change-Id: I31e618626809a828a55fff513ef5f81f79637afa
2018-12-10 17:35:25 +01:00
|
|
|
|
2018-10-10 07:01:00 +02:00
|
|
|
if am, ok := child.(android.ApexModule); ok && am.CanHaveApexVariants() {
|
Don't create unnecessary APEX variations
This change fixes a problem that APEX variations are created for the
modules that actually shouldn't built for any APEX. For example,
consider this case.
apex { name: "myapex", native_shared_libs: ["mylib"],}
cc_library { name: "mylib", shared_libs: ["libfoo#10"],}
cc_library { name: "libfoo",
shared_libs: ["libbar"],
stubs: { versions: ["10"], }, }
cc_library { name: "libbar", ...}
Before this change, both the stubs and non-stubs variations of libfoo
were mutated with apexMuator, which is incorrect for the non-stubs
varia; there is no dependency chain from the apex "myapex" to the
non-stubs variation, but to the stubs variation due to the #10 syntax.
This was happening becauses we used the name of the module to determine
whether it should be built for APEX or not. Both stubs and non-stubs
variations have the same module name "libfoo".
Fixing this issue by recording the list of APEX variations required
directly on the module. So, the stubs variation of libfoo has myapex in
its apex variations list, but the non-stubs variation doesn't, and thus
apexMutator does not pick up the non-stubs variation.
Test: m (apex_test updated and passing)
Test: cherry-pick ag/5747464 and m
Change-Id: I31e618626809a828a55fff513ef5f81f79637afa
2018-12-10 17:35:25 +01:00
|
|
|
am.BuildForApex(apexBundleName)
|
2018-10-10 07:01:00 +02:00
|
|
|
return true
|
|
|
|
} else {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create apex variations if a module is included in APEX(s).
|
|
|
|
func apexMutator(mctx android.BottomUpMutatorContext) {
|
|
|
|
if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() {
|
Don't create unnecessary APEX variations
This change fixes a problem that APEX variations are created for the
modules that actually shouldn't built for any APEX. For example,
consider this case.
apex { name: "myapex", native_shared_libs: ["mylib"],}
cc_library { name: "mylib", shared_libs: ["libfoo#10"],}
cc_library { name: "libfoo",
shared_libs: ["libbar"],
stubs: { versions: ["10"], }, }
cc_library { name: "libbar", ...}
Before this change, both the stubs and non-stubs variations of libfoo
were mutated with apexMuator, which is incorrect for the non-stubs
varia; there is no dependency chain from the apex "myapex" to the
non-stubs variation, but to the stubs variation due to the #10 syntax.
This was happening becauses we used the name of the module to determine
whether it should be built for APEX or not. Both stubs and non-stubs
variations have the same module name "libfoo".
Fixing this issue by recording the list of APEX variations required
directly on the module. So, the stubs variation of libfoo has myapex in
its apex variations list, but the non-stubs variation doesn't, and thus
apexMutator does not pick up the non-stubs variation.
Test: m (apex_test updated and passing)
Test: cherry-pick ag/5747464 and m
Change-Id: I31e618626809a828a55fff513ef5f81f79637afa
2018-12-10 17:35:25 +01:00
|
|
|
am.CreateApexVariations(mctx)
|
2019-10-08 14:59:58 +02:00
|
|
|
} else if a, ok := mctx.Module().(*apexBundle); ok {
|
2018-10-10 07:01:00 +02:00
|
|
|
// apex bundle itself is mutated so that it and its modules have same
|
|
|
|
// apex variant.
|
|
|
|
apexBundleName := mctx.ModuleName()
|
|
|
|
mctx.CreateVariations(apexBundleName)
|
2019-10-08 14:59:58 +02:00
|
|
|
|
|
|
|
// collects APEX list
|
|
|
|
if mctx.Device() && a.installable() {
|
|
|
|
addApexFileContextsInfos(mctx, a)
|
|
|
|
}
|
2018-10-10 07:01:00 +02:00
|
|
|
}
|
|
|
|
}
|
2019-09-06 10:37:42 +02:00
|
|
|
|
2019-10-08 14:59:58 +02:00
|
|
|
var (
|
|
|
|
apexFileContextsInfosKey = android.NewOnceKey("apexFileContextsInfosKey")
|
|
|
|
apexFileContextsInfosMutex sync.Mutex
|
|
|
|
)
|
|
|
|
|
|
|
|
func apexFileContextsInfos(config android.Config) *[]string {
|
|
|
|
return config.Once(apexFileContextsInfosKey, func() interface{} {
|
|
|
|
return &[]string{}
|
|
|
|
}).(*[]string)
|
|
|
|
}
|
|
|
|
|
|
|
|
func addApexFileContextsInfos(ctx android.BaseModuleContext, a *apexBundle) {
|
|
|
|
apexName := proptools.StringDefault(a.properties.Apex_name, ctx.ModuleName())
|
|
|
|
fileContextsName := proptools.StringDefault(a.properties.File_contexts, ctx.ModuleName())
|
|
|
|
|
|
|
|
apexFileContextsInfosMutex.Lock()
|
|
|
|
defer apexFileContextsInfosMutex.Unlock()
|
|
|
|
apexFileContextsInfos := apexFileContextsInfos(ctx.Config())
|
|
|
|
*apexFileContextsInfos = append(*apexFileContextsInfos, apexName+":"+fileContextsName)
|
|
|
|
}
|
|
|
|
|
2019-09-06 10:37:42 +02:00
|
|
|
func apexFlattenedMutator(mctx android.BottomUpMutatorContext) {
|
2019-09-17 06:50:45 +02:00
|
|
|
if ab, ok := mctx.Module().(*apexBundle); ok {
|
2019-09-06 10:37:42 +02:00
|
|
|
if !mctx.Config().FlattenApex() || mctx.Config().UnbundledBuild() {
|
|
|
|
modules := mctx.CreateLocalVariations("", "flattened")
|
|
|
|
modules[0].(*apexBundle).SetFlattened(false)
|
|
|
|
modules[1].(*apexBundle).SetFlattened(true)
|
2019-09-17 06:50:45 +02:00
|
|
|
} else {
|
|
|
|
ab.SetFlattened(true)
|
|
|
|
ab.SetFlattenedConfigValue()
|
2019-09-06 10:37:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-27 04:30:33 +02:00
|
|
|
func apexUsesMutator(mctx android.BottomUpMutatorContext) {
|
|
|
|
if ab, ok := mctx.Module().(*apexBundle); ok {
|
|
|
|
mctx.AddFarVariationDependencies(nil, usesTag, ab.properties.Uses...)
|
|
|
|
}
|
|
|
|
}
|
2018-10-10 07:01:00 +02:00
|
|
|
|
2019-01-30 03:07:33 +01:00
|
|
|
type apexNativeDependencies struct {
|
|
|
|
// List of native libraries
|
|
|
|
Native_shared_libs []string
|
2019-08-23 04:17:39 +02:00
|
|
|
|
2019-01-30 03:07:33 +01:00
|
|
|
// List of native executables
|
|
|
|
Binaries []string
|
2019-08-23 04:17:39 +02:00
|
|
|
|
2019-06-26 13:48:34 +02:00
|
|
|
// List of native tests
|
|
|
|
Tests []string
|
2019-01-30 03:07:33 +01:00
|
|
|
}
|
2019-08-23 04:17:39 +02:00
|
|
|
|
2019-01-30 03:07:33 +01:00
|
|
|
type apexMultilibProperties struct {
|
|
|
|
// Native dependencies whose compile_multilib is "first"
|
|
|
|
First apexNativeDependencies
|
|
|
|
|
|
|
|
// Native dependencies whose compile_multilib is "both"
|
|
|
|
Both apexNativeDependencies
|
|
|
|
|
|
|
|
// Native dependencies whose compile_multilib is "prefer32"
|
|
|
|
Prefer32 apexNativeDependencies
|
|
|
|
|
|
|
|
// Native dependencies whose compile_multilib is "32"
|
|
|
|
Lib32 apexNativeDependencies
|
|
|
|
|
|
|
|
// Native dependencies whose compile_multilib is "64"
|
|
|
|
Lib64 apexNativeDependencies
|
|
|
|
}
|
|
|
|
|
2018-10-10 07:01:00 +02:00
|
|
|
type apexBundleProperties struct {
|
|
|
|
// Json manifest file describing meta info of this APEX bundle. Default:
|
2018-11-20 19:04:58 +01:00
|
|
|
// "apex_manifest.json"
|
2019-03-05 07:35:41 +01:00
|
|
|
Manifest *string `android:"path"`
|
2018-10-10 07:01:00 +02:00
|
|
|
|
2019-02-07 18:53:06 +01:00
|
|
|
// AndroidManifest.xml file used for the zip container of this APEX bundle.
|
|
|
|
// If unspecified, a default one is automatically generated.
|
2019-03-05 07:35:41 +01:00
|
|
|
AndroidManifest *string `android:"path"`
|
2019-02-07 18:53:06 +01:00
|
|
|
|
2019-09-19 17:37:20 +02:00
|
|
|
// Canonical name of the APEX bundle. Used to determine the path to the activated APEX on
|
|
|
|
// device (/apex/<apex_name>).
|
|
|
|
// If unspecified, defaults to the value of name.
|
2019-03-18 06:26:32 +01:00
|
|
|
Apex_name *string
|
|
|
|
|
2018-11-09 22:37:15 +01:00
|
|
|
// Determines the file contexts file for setting security context to each file in this APEX bundle.
|
|
|
|
// Specifically, when this is set to <value>, /system/sepolicy/apex/<value>_file_contexts file is
|
|
|
|
// used.
|
|
|
|
// Default: <name_of_this_module>
|
2018-10-10 07:01:00 +02:00
|
|
|
File_contexts *string
|
|
|
|
|
|
|
|
// List of native shared libs that are embedded inside this APEX bundle
|
|
|
|
Native_shared_libs []string
|
|
|
|
|
2019-06-26 13:48:34 +02:00
|
|
|
// List of executables that are embedded inside this APEX bundle
|
2018-10-10 07:01:00 +02:00
|
|
|
Binaries []string
|
|
|
|
|
|
|
|
// List of java libraries that are embedded inside this APEX bundle
|
|
|
|
Java_libs []string
|
|
|
|
|
|
|
|
// List of prebuilt files that are embedded inside this APEX bundle
|
|
|
|
Prebuilts []string
|
2018-10-12 14:49:38 +02:00
|
|
|
|
2019-06-26 13:48:34 +02:00
|
|
|
// List of tests that are embedded inside this APEX bundle
|
|
|
|
Tests []string
|
|
|
|
|
2018-10-12 14:49:38 +02:00
|
|
|
// Name of the apex_key module that provides the private key to sign APEX
|
|
|
|
Key *string
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
|
2018-11-30 02:12:15 +01:00
|
|
|
// The type of APEX to build. Controls what the APEX payload is. Either
|
|
|
|
// 'image', 'zip' or 'both'. Default: 'image'.
|
|
|
|
Payload_type *string
|
|
|
|
|
2018-10-30 13:20:05 +01:00
|
|
|
// The name of a certificate in the default certificate directory, blank to use the default product certificate,
|
|
|
|
// or an android_app_certificate module name in the form ":module".
|
|
|
|
Certificate *string
|
|
|
|
|
2018-12-13 15:14:57 +01:00
|
|
|
// Whether this APEX is installable to one of the partitions. Default: true.
|
|
|
|
Installable *bool
|
|
|
|
|
2018-12-19 09:12:36 +01:00
|
|
|
// For native libraries and binaries, use the vendor variant instead of the core (platform) variant.
|
|
|
|
// Default is false.
|
|
|
|
Use_vendor *bool
|
|
|
|
|
2019-01-30 03:31:59 +01:00
|
|
|
// For telling the apex to ignore special handling for system libraries such as bionic. Default is false.
|
|
|
|
Ignore_system_library_special_case *bool
|
|
|
|
|
2019-01-30 03:07:33 +01:00
|
|
|
Multilib apexMultilibProperties
|
2019-02-09 03:50:56 +01:00
|
|
|
|
2019-02-13 12:28:58 +01:00
|
|
|
// List of sanitizer names that this APEX is enabled for
|
|
|
|
SanitizerNames []string `blueprint:"mutated"`
|
2019-06-27 04:30:33 +02:00
|
|
|
|
2019-08-09 07:44:36 +02:00
|
|
|
PreventInstall bool `blueprint:"mutated"`
|
|
|
|
|
|
|
|
HideFromMake bool `blueprint:"mutated"`
|
|
|
|
|
2019-06-27 04:30:33 +02:00
|
|
|
// Indicates this APEX provides C++ shared libaries to other APEXes. Default: false.
|
|
|
|
Provide_cpp_shared_libs *bool
|
|
|
|
|
|
|
|
// List of providing APEXes' names so that this APEX can depend on provided shared libraries.
|
|
|
|
Uses []string
|
2019-08-31 15:38:05 +02:00
|
|
|
|
|
|
|
// A txt file containing list of files that are whitelisted to be included in this APEX.
|
|
|
|
Whitelisted_files *string
|
2019-08-27 06:55:42 +02:00
|
|
|
|
|
|
|
// List of APKs to package inside APEX
|
|
|
|
Apps []string
|
2019-09-06 10:37:42 +02:00
|
|
|
|
2019-09-17 06:50:45 +02:00
|
|
|
// To distinguish between flattened and non-flattened apex.
|
|
|
|
// if set true, then output files are flattened.
|
2019-09-06 10:37:42 +02:00
|
|
|
Flattened bool `blueprint:"mutated"`
|
Introduce module type 'sdk'
This change introduces a new module type named 'sdk'. It is a logical
group of prebuilt modules that together provide a context (e.g. APIs)
in which Mainline modules (such as APEXes) are built.
A prebuilt module (e.g. java_import) can join an sdk by adding it to the
sdk module as shown below:
sdk {
name: "mysdk#20",
java_libs: ["myjavalib_mysdk_20"],
}
java_import {
name: "myjavalib_mysdk_20",
srcs: ["myjavalib-v20.jar"],
sdk_member_name: "myjavalib",
}
sdk {
name: "mysdk#21",
java_libs: ["myjavalib_mysdk_21"],
}
java_import {
name: "myjavalib_mysdk_21",
srcs: ["myjavalib-v21.jar"],
sdk_member_name: "myjavalib",
}
java_library {
name: "myjavalib",
srcs: ["**/*/*.java"],
}
An APEX can specify the SDK(s) that it wants to build with via the new
'uses_sdks' property.
apex {
name: "myapex",
java_libs: ["libX", "libY"],
uses_sdks: ["mysdk#20"],
}
With this, libX, libY, and their transitive dependencies are all built
with the version 20 of myjavalib (the first java_import module) instead
of the other one (which is for version 21) and java_library having the
same name (which is for ToT).
Bug: 138182343
Test: m (sdk_test.go added)
Change-Id: I7e14c524a7d6a0d9f575fb20822080f39818c01e
2019-07-17 13:08:41 +02:00
|
|
|
|
2019-09-17 06:50:45 +02:00
|
|
|
// if true, it means that TARGET_FLATTEN_APEX is true and
|
|
|
|
// TARGET_BUILD_APPS is false
|
|
|
|
FlattenedConfigValue bool `blueprint:"mutated"`
|
|
|
|
|
Introduce module type 'sdk'
This change introduces a new module type named 'sdk'. It is a logical
group of prebuilt modules that together provide a context (e.g. APIs)
in which Mainline modules (such as APEXes) are built.
A prebuilt module (e.g. java_import) can join an sdk by adding it to the
sdk module as shown below:
sdk {
name: "mysdk#20",
java_libs: ["myjavalib_mysdk_20"],
}
java_import {
name: "myjavalib_mysdk_20",
srcs: ["myjavalib-v20.jar"],
sdk_member_name: "myjavalib",
}
sdk {
name: "mysdk#21",
java_libs: ["myjavalib_mysdk_21"],
}
java_import {
name: "myjavalib_mysdk_21",
srcs: ["myjavalib-v21.jar"],
sdk_member_name: "myjavalib",
}
java_library {
name: "myjavalib",
srcs: ["**/*/*.java"],
}
An APEX can specify the SDK(s) that it wants to build with via the new
'uses_sdks' property.
apex {
name: "myapex",
java_libs: ["libX", "libY"],
uses_sdks: ["mysdk#20"],
}
With this, libX, libY, and their transitive dependencies are all built
with the version 20 of myjavalib (the first java_import module) instead
of the other one (which is for version 21) and java_library having the
same name (which is for ToT).
Bug: 138182343
Test: m (sdk_test.go added)
Change-Id: I7e14c524a7d6a0d9f575fb20822080f39818c01e
2019-07-17 13:08:41 +02:00
|
|
|
// List of SDKs that are used to build this APEX. A reference to an SDK should be either
|
|
|
|
// `name#version` or `name` which is an alias for `name#current`. If left empty, `platform#current`
|
|
|
|
// is implied. This value affects all modules included in this APEX. In other words, they are
|
|
|
|
// also built with the SDKs specified here.
|
|
|
|
Uses_sdks []string
|
2019-01-30 03:07:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type apexTargetBundleProperties struct {
|
|
|
|
Target struct {
|
|
|
|
// Multilib properties only for android.
|
|
|
|
Android struct {
|
|
|
|
Multilib apexMultilibProperties
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
}
|
2019-08-23 04:17:39 +02:00
|
|
|
|
2019-01-30 03:07:33 +01:00
|
|
|
// Multilib properties only for host.
|
|
|
|
Host struct {
|
|
|
|
Multilib apexMultilibProperties
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
}
|
2019-08-23 04:17:39 +02:00
|
|
|
|
2019-01-30 03:07:33 +01:00
|
|
|
// Multilib properties only for host linux_bionic.
|
|
|
|
Linux_bionic struct {
|
|
|
|
Multilib apexMultilibProperties
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
}
|
2019-08-23 04:17:39 +02:00
|
|
|
|
2019-01-30 03:07:33 +01:00
|
|
|
// Multilib properties only for host linux_glibc.
|
|
|
|
Linux_glibc struct {
|
|
|
|
Multilib apexMultilibProperties
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
}
|
|
|
|
}
|
2018-10-10 07:01:00 +02:00
|
|
|
}
|
|
|
|
|
2019-08-23 04:17:39 +02:00
|
|
|
type apexVndkProperties struct {
|
|
|
|
// Indicates VNDK version of which this VNDK APEX bundles VNDK libs. Default is Platform VNDK Version.
|
|
|
|
Vndk_version *string
|
|
|
|
}
|
|
|
|
|
2018-11-07 18:50:25 +01:00
|
|
|
type apexFileClass int
|
|
|
|
|
|
|
|
const (
|
|
|
|
etc apexFileClass = iota
|
|
|
|
nativeSharedLib
|
|
|
|
nativeExecutable
|
2019-02-05 16:16:29 +01:00
|
|
|
shBinary
|
2019-02-27 23:19:50 +01:00
|
|
|
pyBinary
|
|
|
|
goBinary
|
2018-11-07 18:50:25 +01:00
|
|
|
javaSharedLib
|
2019-06-26 13:48:34 +02:00
|
|
|
nativeTest
|
2019-08-27 06:55:42 +02:00
|
|
|
app
|
2018-11-07 18:50:25 +01:00
|
|
|
)
|
|
|
|
|
2018-11-30 02:12:15 +01:00
|
|
|
type apexPackaging int
|
|
|
|
|
|
|
|
const (
|
|
|
|
imageApex apexPackaging = iota
|
|
|
|
zipApex
|
|
|
|
both
|
|
|
|
)
|
|
|
|
|
|
|
|
func (a apexPackaging) image() bool {
|
|
|
|
switch a {
|
|
|
|
case imageApex, both:
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a apexPackaging) zip() bool {
|
|
|
|
switch a {
|
|
|
|
case zipApex, both:
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a apexPackaging) suffix() string {
|
|
|
|
switch a {
|
|
|
|
case imageApex:
|
|
|
|
return imageApexSuffix
|
|
|
|
case zipApex:
|
|
|
|
return zipApexSuffix
|
|
|
|
case both:
|
|
|
|
panic(fmt.Errorf("must be either zip or image"))
|
|
|
|
default:
|
2019-07-31 15:09:17 +02:00
|
|
|
panic(fmt.Errorf("unknown APEX type %d", a))
|
2018-11-30 02:12:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a apexPackaging) name() string {
|
|
|
|
switch a {
|
|
|
|
case imageApex:
|
|
|
|
return imageApexType
|
|
|
|
case zipApex:
|
|
|
|
return zipApexType
|
|
|
|
case both:
|
|
|
|
panic(fmt.Errorf("must be either zip or image"))
|
|
|
|
default:
|
2019-07-31 15:09:17 +02:00
|
|
|
panic(fmt.Errorf("unknown APEX type %d", a))
|
2018-11-30 02:12:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-07 18:50:25 +01:00
|
|
|
func (class apexFileClass) NameInMake() string {
|
|
|
|
switch class {
|
|
|
|
case etc:
|
|
|
|
return "ETC"
|
|
|
|
case nativeSharedLib:
|
|
|
|
return "SHARED_LIBRARIES"
|
2019-02-27 23:19:50 +01:00
|
|
|
case nativeExecutable, shBinary, pyBinary, goBinary:
|
2018-11-07 18:50:25 +01:00
|
|
|
return "EXECUTABLES"
|
|
|
|
case javaSharedLib:
|
|
|
|
return "JAVA_LIBRARIES"
|
2019-06-26 13:48:34 +02:00
|
|
|
case nativeTest:
|
|
|
|
return "NATIVE_TESTS"
|
2019-08-27 06:55:42 +02:00
|
|
|
case app:
|
2019-10-11 13:46:25 +02:00
|
|
|
// b/142537672 Why isn't this APP? We want to have full control over
|
|
|
|
// the paths and file names of the apk file under the flattend APEX.
|
|
|
|
// If this is set to APP, then the paths and file names are modified
|
|
|
|
// by the Make build system. For example, it is installed to
|
|
|
|
// /system/apex/<apexname>/app/<Appname>/<apexname>.<Appname>/ instead of
|
|
|
|
// /system/apex/<apexname>/app/<Appname> because the build system automatically
|
|
|
|
// appends module name (which is <apexname>.<Appname> to the path.
|
|
|
|
return "ETC"
|
2018-11-07 18:50:25 +01:00
|
|
|
default:
|
2019-07-31 15:09:17 +02:00
|
|
|
panic(fmt.Errorf("unknown class %d", class))
|
2018-11-07 18:50:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type apexFile struct {
|
|
|
|
builtFile android.Path
|
|
|
|
moduleName string
|
|
|
|
installDir string
|
|
|
|
class apexFileClass
|
2018-12-19 09:36:39 +01:00
|
|
|
module android.Module
|
2019-01-18 23:37:31 +01:00
|
|
|
symlinks []string
|
2018-11-07 18:50:25 +01:00
|
|
|
}
|
|
|
|
|
2018-10-10 07:01:00 +02:00
|
|
|
type apexBundle struct {
|
|
|
|
android.ModuleBase
|
|
|
|
android.DefaultableModuleBase
|
Introduce module type 'sdk'
This change introduces a new module type named 'sdk'. It is a logical
group of prebuilt modules that together provide a context (e.g. APIs)
in which Mainline modules (such as APEXes) are built.
A prebuilt module (e.g. java_import) can join an sdk by adding it to the
sdk module as shown below:
sdk {
name: "mysdk#20",
java_libs: ["myjavalib_mysdk_20"],
}
java_import {
name: "myjavalib_mysdk_20",
srcs: ["myjavalib-v20.jar"],
sdk_member_name: "myjavalib",
}
sdk {
name: "mysdk#21",
java_libs: ["myjavalib_mysdk_21"],
}
java_import {
name: "myjavalib_mysdk_21",
srcs: ["myjavalib-v21.jar"],
sdk_member_name: "myjavalib",
}
java_library {
name: "myjavalib",
srcs: ["**/*/*.java"],
}
An APEX can specify the SDK(s) that it wants to build with via the new
'uses_sdks' property.
apex {
name: "myapex",
java_libs: ["libX", "libY"],
uses_sdks: ["mysdk#20"],
}
With this, libX, libY, and their transitive dependencies are all built
with the version 20 of myjavalib (the first java_import module) instead
of the other one (which is for version 21) and java_library having the
same name (which is for ToT).
Bug: 138182343
Test: m (sdk_test.go added)
Change-Id: I7e14c524a7d6a0d9f575fb20822080f39818c01e
2019-07-17 13:08:41 +02:00
|
|
|
android.SdkBase
|
2018-10-10 07:01:00 +02:00
|
|
|
|
2019-01-30 03:07:33 +01:00
|
|
|
properties apexBundleProperties
|
|
|
|
targetProperties apexTargetBundleProperties
|
2019-08-23 04:17:39 +02:00
|
|
|
vndkProperties apexVndkProperties
|
2018-10-10 07:01:00 +02:00
|
|
|
|
2018-11-30 02:12:15 +01:00
|
|
|
apexTypes apexPackaging
|
|
|
|
|
2018-11-16 20:36:28 +01:00
|
|
|
bundleModuleFile android.WritablePath
|
2018-11-30 02:12:15 +01:00
|
|
|
outputFiles map[apexPackaging]android.WritablePath
|
2019-10-02 07:05:35 +02:00
|
|
|
flattenedOutput android.InstallPath
|
|
|
|
installDir android.InstallPath
|
2018-11-07 18:50:25 +01:00
|
|
|
|
2019-07-26 16:20:40 +02:00
|
|
|
prebuiltFileToDelete string
|
|
|
|
|
2019-04-01 04:15:50 +02:00
|
|
|
public_key_file android.Path
|
|
|
|
private_key_file android.Path
|
2019-02-18 07:25:04 +01:00
|
|
|
|
|
|
|
container_certificate_file android.Path
|
|
|
|
container_private_key_file android.Path
|
|
|
|
|
2018-11-07 18:50:25 +01:00
|
|
|
// list of files to be included in this apex
|
|
|
|
filesInfo []apexFile
|
|
|
|
|
2019-02-20 13:49:26 +01:00
|
|
|
// list of module names that this APEX is depending on
|
|
|
|
externalDeps []string
|
|
|
|
|
2019-02-07 22:20:53 +01:00
|
|
|
testApex bool
|
2019-08-23 04:17:39 +02:00
|
|
|
vndkApex bool
|
2019-08-01 10:41:43 +02:00
|
|
|
|
|
|
|
// intermediate path for apex_manifest.json
|
|
|
|
manifestOut android.WritablePath
|
2018-10-10 07:01:00 +02:00
|
|
|
}
|
|
|
|
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,
|
2019-06-26 13:48:34 +02:00
|
|
|
native_shared_libs []string, binaries []string, tests []string,
|
|
|
|
arch string, imageVariation string) {
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
// Use *FarVariation* to be able to depend on modules having
|
|
|
|
// conflicting variations with this module. This is required since
|
|
|
|
// arch variant of an APEX bundle is 'common' but it is 'arm' or 'arm64'
|
|
|
|
// for native shared libs.
|
|
|
|
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "arch", Variation: arch},
|
2018-12-19 09:12:36 +01:00
|
|
|
{Mutator: "image", Variation: imageVariation},
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
{Mutator: "link", Variation: "shared"},
|
2018-12-07 14:42:47 +01:00
|
|
|
{Mutator: "version", Variation: ""}, // "" is the non-stub variant
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
}, sharedLibTag, native_shared_libs...)
|
|
|
|
|
|
|
|
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "arch", Variation: arch},
|
2018-12-19 09:12:36 +01:00
|
|
|
{Mutator: "image", Variation: imageVariation},
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
}, executableTag, binaries...)
|
2019-06-26 13:48:34 +02:00
|
|
|
|
|
|
|
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "arch", Variation: arch},
|
|
|
|
{Mutator: "image", Variation: imageVariation},
|
2019-06-28 16:41:19 +02:00
|
|
|
{Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant
|
2019-06-26 13:48:34 +02:00
|
|
|
}, testTag, tests...)
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
}
|
|
|
|
|
2019-01-30 03:07:33 +01:00
|
|
|
func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
|
|
|
|
if ctx.Os().Class == android.Device {
|
|
|
|
proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Android.Multilib, nil)
|
|
|
|
} else {
|
|
|
|
proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Host.Multilib, nil)
|
|
|
|
if ctx.Os().Bionic() {
|
|
|
|
proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_bionic.Multilib, nil)
|
|
|
|
} else {
|
|
|
|
proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_glibc.Multilib, nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-10 07:01:00 +02:00
|
|
|
func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
targets := ctx.MultiTargets()
|
2019-01-05 03:15:24 +01:00
|
|
|
config := ctx.DeviceConfig()
|
2019-01-30 03:07:33 +01:00
|
|
|
|
|
|
|
a.combineProperties(ctx)
|
|
|
|
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
has32BitTarget := false
|
|
|
|
for _, target := range targets {
|
|
|
|
if target.Arch.ArchType.Multilib == "lib32" {
|
|
|
|
has32BitTarget = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for i, target := range targets {
|
|
|
|
// When multilib.* is omitted for native_shared_libs, it implies
|
|
|
|
// multilib.both.
|
2018-10-10 07:01:00 +02:00
|
|
|
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
{Mutator: "arch", Variation: target.String()},
|
2019-01-05 03:15:24 +01:00
|
|
|
{Mutator: "image", Variation: a.getImageVariation(config)},
|
2018-10-10 07:01:00 +02:00
|
|
|
{Mutator: "link", Variation: "shared"},
|
|
|
|
}, sharedLibTag, a.properties.Native_shared_libs...)
|
|
|
|
|
2019-06-26 13:48:34 +02:00
|
|
|
// When multilib.* is omitted for tests, it implies
|
|
|
|
// multilib.both.
|
|
|
|
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "arch", Variation: target.String()},
|
|
|
|
{Mutator: "image", Variation: a.getImageVariation(config)},
|
2019-06-28 16:41:19 +02:00
|
|
|
{Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant
|
2019-06-26 13:48:34 +02:00
|
|
|
}, testTag, a.properties.Tests...)
|
|
|
|
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
// Add native modules targetting both ABIs
|
|
|
|
addDependenciesForNativeModules(ctx,
|
|
|
|
a.properties.Multilib.Both.Native_shared_libs,
|
2019-06-26 13:48:34 +02:00
|
|
|
a.properties.Multilib.Both.Binaries,
|
|
|
|
a.properties.Multilib.Both.Tests,
|
|
|
|
target.String(),
|
2019-01-05 03:15:24 +01:00
|
|
|
a.getImageVariation(config))
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
|
2019-01-18 23:37:31 +01:00
|
|
|
isPrimaryAbi := i == 0
|
|
|
|
if isPrimaryAbi {
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
// When multilib.* is omitted for binaries, it implies
|
|
|
|
// multilib.first.
|
|
|
|
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "arch", Variation: target.String()},
|
2019-01-05 03:15:24 +01:00
|
|
|
{Mutator: "image", Variation: a.getImageVariation(config)},
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
}, executableTag, a.properties.Binaries...)
|
|
|
|
|
|
|
|
// Add native modules targetting the first ABI
|
|
|
|
addDependenciesForNativeModules(ctx,
|
|
|
|
a.properties.Multilib.First.Native_shared_libs,
|
2019-06-26 13:48:34 +02:00
|
|
|
a.properties.Multilib.First.Binaries,
|
|
|
|
a.properties.Multilib.First.Tests,
|
|
|
|
target.String(),
|
2019-01-05 03:15:24 +01:00
|
|
|
a.getImageVariation(config))
|
2019-01-15 19:47:05 +01:00
|
|
|
|
|
|
|
// When multilib.* is omitted for prebuilts, it implies multilib.first.
|
|
|
|
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "arch", Variation: target.String()},
|
|
|
|
}, prebuiltTag, a.properties.Prebuilts...)
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch target.Arch.ArchType.Multilib {
|
|
|
|
case "lib32":
|
|
|
|
// Add native modules targetting 32-bit ABI
|
|
|
|
addDependenciesForNativeModules(ctx,
|
|
|
|
a.properties.Multilib.Lib32.Native_shared_libs,
|
2019-06-26 13:48:34 +02:00
|
|
|
a.properties.Multilib.Lib32.Binaries,
|
|
|
|
a.properties.Multilib.Lib32.Tests,
|
|
|
|
target.String(),
|
2019-01-05 03:15:24 +01:00
|
|
|
a.getImageVariation(config))
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
|
|
|
|
addDependenciesForNativeModules(ctx,
|
|
|
|
a.properties.Multilib.Prefer32.Native_shared_libs,
|
2019-06-26 13:48:34 +02:00
|
|
|
a.properties.Multilib.Prefer32.Binaries,
|
|
|
|
a.properties.Multilib.Prefer32.Tests,
|
|
|
|
target.String(),
|
2019-01-05 03:15:24 +01:00
|
|
|
a.getImageVariation(config))
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
case "lib64":
|
|
|
|
// Add native modules targetting 64-bit ABI
|
|
|
|
addDependenciesForNativeModules(ctx,
|
|
|
|
a.properties.Multilib.Lib64.Native_shared_libs,
|
2019-06-26 13:48:34 +02:00
|
|
|
a.properties.Multilib.Lib64.Binaries,
|
|
|
|
a.properties.Multilib.Lib64.Tests,
|
|
|
|
target.String(),
|
2019-01-05 03:15:24 +01:00
|
|
|
a.getImageVariation(config))
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
|
|
|
|
if !has32BitTarget {
|
|
|
|
addDependenciesForNativeModules(ctx,
|
|
|
|
a.properties.Multilib.Prefer32.Native_shared_libs,
|
2019-06-26 13:48:34 +02:00
|
|
|
a.properties.Multilib.Prefer32.Binaries,
|
|
|
|
a.properties.Multilib.Prefer32.Tests,
|
|
|
|
target.String(),
|
2019-01-05 03:15:24 +01:00
|
|
|
a.getImageVariation(config))
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
}
|
2019-04-24 23:41:12 +02:00
|
|
|
|
|
|
|
if strings.HasPrefix(ctx.ModuleName(), "com.android.runtime") && target.Os.Class == android.Device {
|
|
|
|
for _, sanitizer := range ctx.Config().SanitizeDevice() {
|
|
|
|
if sanitizer == "hwaddress" {
|
|
|
|
addDependenciesForNativeModules(ctx,
|
|
|
|
[]string{"libclang_rt.hwasan-aarch64-android"},
|
2019-06-26 13:48:34 +02:00
|
|
|
nil, nil, target.String(), a.getImageVariation(config))
|
2019-04-24 23:41:12 +02:00
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
}
|
|
|
|
|
2018-10-12 14:49:38 +02:00
|
|
|
}
|
2018-10-10 07:01:00 +02:00
|
|
|
|
2018-10-12 14:49:38 +02:00
|
|
|
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "arch", Variation: "android_common"},
|
|
|
|
}, javaLibTag, a.properties.Java_libs...)
|
2018-10-10 07:01:00 +02:00
|
|
|
|
2019-08-27 06:55:42 +02:00
|
|
|
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "arch", Variation: "android_common"},
|
|
|
|
}, androidAppTag, a.properties.Apps...)
|
|
|
|
|
2019-02-02 05:13:47 +01:00
|
|
|
if String(a.properties.Key) == "" {
|
|
|
|
ctx.ModuleErrorf("key is missing")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
ctx.AddDependency(ctx.Module(), keyTag, String(a.properties.Key))
|
2018-10-30 13:20:05 +01:00
|
|
|
|
2019-02-11 03:38:15 +01:00
|
|
|
cert := android.SrcIsModule(a.getCertString(ctx))
|
2019-02-02 05:13:47 +01:00
|
|
|
if cert != "" {
|
|
|
|
ctx.AddDependency(ctx.Module(), certificateTag, cert)
|
2018-10-30 13:20:05 +01:00
|
|
|
}
|
Introduce module type 'sdk'
This change introduces a new module type named 'sdk'. It is a logical
group of prebuilt modules that together provide a context (e.g. APIs)
in which Mainline modules (such as APEXes) are built.
A prebuilt module (e.g. java_import) can join an sdk by adding it to the
sdk module as shown below:
sdk {
name: "mysdk#20",
java_libs: ["myjavalib_mysdk_20"],
}
java_import {
name: "myjavalib_mysdk_20",
srcs: ["myjavalib-v20.jar"],
sdk_member_name: "myjavalib",
}
sdk {
name: "mysdk#21",
java_libs: ["myjavalib_mysdk_21"],
}
java_import {
name: "myjavalib_mysdk_21",
srcs: ["myjavalib-v21.jar"],
sdk_member_name: "myjavalib",
}
java_library {
name: "myjavalib",
srcs: ["**/*/*.java"],
}
An APEX can specify the SDK(s) that it wants to build with via the new
'uses_sdks' property.
apex {
name: "myapex",
java_libs: ["libX", "libY"],
uses_sdks: ["mysdk#20"],
}
With this, libX, libY, and their transitive dependencies are all built
with the version 20 of myjavalib (the first java_import module) instead
of the other one (which is for version 21) and java_library having the
same name (which is for ToT).
Bug: 138182343
Test: m (sdk_test.go added)
Change-Id: I7e14c524a7d6a0d9f575fb20822080f39818c01e
2019-07-17 13:08:41 +02:00
|
|
|
|
|
|
|
// TODO(jiyong): ensure that all apexes are with non-empty uses_sdks
|
|
|
|
if len(a.properties.Uses_sdks) > 0 {
|
|
|
|
sdkRefs := []android.SdkRef{}
|
|
|
|
for _, str := range a.properties.Uses_sdks {
|
|
|
|
parsed := android.ParseSdkRef(ctx, str, "uses_sdks")
|
|
|
|
sdkRefs = append(sdkRefs, parsed)
|
|
|
|
}
|
|
|
|
a.BuildWithSdks(sdkRefs)
|
|
|
|
}
|
2018-10-10 07:01:00 +02:00
|
|
|
}
|
|
|
|
|
2019-06-06 23:33:29 +02:00
|
|
|
func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string {
|
2019-02-11 03:38:15 +01:00
|
|
|
certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(ctx.ModuleName())
|
|
|
|
if overridden {
|
2019-02-28 17:22:30 +01:00
|
|
|
return ":" + certificate
|
2019-02-11 03:38:15 +01:00
|
|
|
}
|
|
|
|
return String(a.properties.Certificate)
|
|
|
|
}
|
|
|
|
|
2019-05-29 23:40:35 +02:00
|
|
|
func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) {
|
|
|
|
switch tag {
|
|
|
|
case "":
|
|
|
|
if file, ok := a.outputFiles[imageApex]; ok {
|
|
|
|
return android.Paths{file}, nil
|
|
|
|
} else {
|
|
|
|
return nil, nil
|
|
|
|
}
|
2019-08-13 15:55:28 +02:00
|
|
|
case ".flattened":
|
2019-09-06 10:37:42 +02:00
|
|
|
if a.properties.Flattened {
|
2019-08-13 15:55:28 +02:00
|
|
|
flattenedApexPath := a.flattenedOutput
|
|
|
|
return android.Paths{flattenedApexPath}, nil
|
|
|
|
} else {
|
|
|
|
return nil, nil
|
|
|
|
}
|
2019-05-29 23:40:35 +02:00
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("unsupported module reference tag %q", tag)
|
2018-12-20 01:54:35 +01:00
|
|
|
}
|
2018-11-27 13:27:08 +01:00
|
|
|
}
|
|
|
|
|
2018-12-13 15:14:57 +01:00
|
|
|
func (a *apexBundle) installable() bool {
|
2019-08-09 07:44:36 +02:00
|
|
|
return !a.properties.PreventInstall && (a.properties.Installable == nil || proptools.Bool(a.properties.Installable))
|
2018-12-13 15:14:57 +01:00
|
|
|
}
|
|
|
|
|
2019-01-05 03:15:24 +01:00
|
|
|
func (a *apexBundle) getImageVariation(config android.DeviceConfig) string {
|
2019-10-07 08:34:50 +02:00
|
|
|
if a.vndkApex {
|
|
|
|
return "vendor." + a.vndkVersion(config)
|
|
|
|
}
|
2019-01-05 03:15:24 +01:00
|
|
|
if config.VndkVersion() != "" && proptools.Bool(a.properties.Use_vendor) {
|
2019-08-26 09:52:35 +02:00
|
|
|
return "vendor." + config.PlatformVndkVersion()
|
2018-12-19 09:12:36 +01:00
|
|
|
} else {
|
|
|
|
return "core"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-13 12:28:58 +01:00
|
|
|
func (a *apexBundle) EnableSanitizer(sanitizerName string) {
|
|
|
|
if !android.InList(sanitizerName, a.properties.SanitizerNames) {
|
|
|
|
a.properties.SanitizerNames = append(a.properties.SanitizerNames, sanitizerName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-28 11:47:32 +01:00
|
|
|
func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool {
|
2019-02-13 12:28:58 +01:00
|
|
|
if android.InList(sanitizerName, a.properties.SanitizerNames) {
|
|
|
|
return true
|
2019-02-09 03:50:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Then follow the global setting
|
2019-01-28 11:47:32 +01:00
|
|
|
globalSanitizerNames := []string{}
|
|
|
|
if a.Host() {
|
|
|
|
globalSanitizerNames = ctx.Config().SanitizeHost()
|
|
|
|
} else {
|
|
|
|
arches := ctx.Config().SanitizeDeviceArch()
|
|
|
|
if len(arches) == 0 || android.InList(a.Arch().ArchType.Name, arches) {
|
|
|
|
globalSanitizerNames = ctx.Config().SanitizeDevice()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return android.InList(sanitizerName, globalSanitizerNames)
|
2018-12-18 18:47:14 +01:00
|
|
|
}
|
|
|
|
|
2019-08-09 07:44:36 +02:00
|
|
|
func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
|
|
|
|
return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *apexBundle) PreventInstall() {
|
|
|
|
a.properties.PreventInstall = true
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *apexBundle) HideFromMake() {
|
|
|
|
a.properties.HideFromMake = true
|
|
|
|
}
|
|
|
|
|
2019-09-06 10:37:42 +02:00
|
|
|
func (a *apexBundle) SetFlattened(flattened bool) {
|
|
|
|
a.properties.Flattened = flattened
|
|
|
|
}
|
|
|
|
|
2019-09-17 06:50:45 +02:00
|
|
|
func (a *apexBundle) SetFlattenedConfigValue() {
|
|
|
|
a.properties.FlattenedConfigValue = true
|
|
|
|
}
|
|
|
|
|
|
|
|
// isFlattenedVariant returns true when the current module is the flattened
|
|
|
|
// variant of an apex that has both a flattened and an unflattened variant.
|
|
|
|
// It returns false when the current module is flattened but there is no
|
|
|
|
// unflattened variant, which occurs when ctx.Config().FlattenedApex() returns
|
|
|
|
// true. It can be used to avoid collisions between the install paths of the
|
|
|
|
// flattened and unflattened variants.
|
|
|
|
func (a *apexBundle) isFlattenedVariant() bool {
|
|
|
|
return a.properties.Flattened && !a.properties.FlattenedConfigValue
|
|
|
|
}
|
|
|
|
|
2019-09-11 00:18:20 +02:00
|
|
|
func getCopyManifestForNativeLibrary(ccMod *cc.Module, config android.Config, handleSpecialLibs bool) (fileToCopy android.Path, dirInApex string) {
|
2018-10-10 07:01:00 +02:00
|
|
|
// Decide the APEX-local directory by the multilib of the library
|
|
|
|
// In the future, we may query this to the module.
|
2019-09-11 00:18:20 +02:00
|
|
|
switch ccMod.Arch().ArchType.Multilib {
|
2018-10-10 07:01:00 +02:00
|
|
|
case "lib32":
|
|
|
|
dirInApex = "lib"
|
|
|
|
case "lib64":
|
|
|
|
dirInApex = "lib64"
|
|
|
|
}
|
2019-09-11 00:18:20 +02:00
|
|
|
dirInApex = filepath.Join(dirInApex, ccMod.RelativeInstallPath())
|
2019-09-17 23:45:31 +02:00
|
|
|
if ccMod.Target().NativeBridge == android.NativeBridgeEnabled {
|
2019-09-11 00:18:20 +02:00
|
|
|
dirInApex = filepath.Join(dirInApex, ccMod.Target().NativeBridgeRelativePath)
|
2018-10-10 07:01:00 +02:00
|
|
|
}
|
2019-09-11 00:18:20 +02:00
|
|
|
if handleSpecialLibs && cc.InstallToBootstrap(ccMod.BaseModuleName(), config) {
|
|
|
|
// Special case for Bionic libs and other libs installed with them. This is
|
|
|
|
// to prevent those libs from being included in the search path
|
|
|
|
// /apex/com.android.runtime/${LIB}. This exclusion is required because
|
|
|
|
// those libs in the Runtime APEX are available via the legacy paths in
|
|
|
|
// /system/lib/. By the init process, the libs in the APEX are bind-mounted
|
|
|
|
// to the legacy paths and thus will be loaded into the default linker
|
|
|
|
// namespace (aka "platform" namespace). If the libs are directly in
|
|
|
|
// /apex/com.android.runtime/${LIB} then the same libs will be loaded again
|
|
|
|
// into the runtime linker namespace, which will result in double loading of
|
|
|
|
// them, which isn't supported.
|
|
|
|
dirInApex = filepath.Join(dirInApex, "bionic")
|
2018-12-20 14:10:17 +01:00
|
|
|
}
|
2018-10-10 07:01:00 +02:00
|
|
|
|
2019-09-11 00:18:20 +02:00
|
|
|
fileToCopy = ccMod.OutputFile().Path()
|
2018-10-10 07:01:00 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func getCopyManifestForExecutable(cc *cc.Module) (fileToCopy android.Path, dirInApex string) {
|
2019-03-15 10:10:35 +01:00
|
|
|
dirInApex = filepath.Join("bin", cc.RelativeInstallPath())
|
2019-09-17 23:45:31 +02:00
|
|
|
if cc.Target().NativeBridge == android.NativeBridgeEnabled {
|
2019-07-11 10:23:53 +02:00
|
|
|
dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath)
|
2019-07-09 09:19:16 +02:00
|
|
|
}
|
2018-10-10 07:01:00 +02:00
|
|
|
fileToCopy = cc.OutputFile().Path()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-02-27 23:19:50 +01:00
|
|
|
func getCopyManifestForPyBinary(py *python.Module) (fileToCopy android.Path, dirInApex string) {
|
|
|
|
dirInApex = "bin"
|
|
|
|
fileToCopy = py.HostToolPath().Path()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
func getCopyManifestForGoBinary(ctx android.ModuleContext, gb bootstrap.GoBinaryTool) (fileToCopy android.Path, dirInApex string) {
|
|
|
|
dirInApex = "bin"
|
|
|
|
s, err := filepath.Rel(android.PathForOutput(ctx).String(), gb.InstallPath())
|
|
|
|
if err != nil {
|
|
|
|
ctx.ModuleErrorf("Unable to use compiled binary at %s", gb.InstallPath())
|
|
|
|
return
|
|
|
|
}
|
|
|
|
fileToCopy = android.PathForOutput(ctx, s)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-02-05 16:16:29 +01:00
|
|
|
func getCopyManifestForShBinary(sh *android.ShBinary) (fileToCopy android.Path, dirInApex string) {
|
|
|
|
dirInApex = filepath.Join("bin", sh.SubDir())
|
|
|
|
fileToCopy = sh.OutputFile()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-10-10 07:01:00 +02:00
|
|
|
func getCopyManifestForJavaLibrary(java *java.Library) (fileToCopy android.Path, dirInApex string) {
|
|
|
|
dirInApex = "javalib"
|
2018-11-07 18:50:25 +01:00
|
|
|
fileToCopy = java.DexJarFile()
|
2018-10-10 07:01:00 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-08-09 13:39:45 +02:00
|
|
|
func getCopyManifestForPrebuiltJavaLibrary(java *java.Import) (fileToCopy android.Path, dirInApex string) {
|
|
|
|
dirInApex = "javalib"
|
|
|
|
// The output is only one, but for some reason, ImplementationJars returns Paths, not Path
|
|
|
|
implJars := java.ImplementationJars()
|
|
|
|
if len(implJars) != 1 {
|
|
|
|
panic(fmt.Errorf("java.ImplementationJars() must return single Path, but got: %s",
|
|
|
|
strings.Join(implJars.Strings(), ", ")))
|
|
|
|
}
|
|
|
|
fileToCopy = implJars[0]
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-10-10 07:01:00 +02:00
|
|
|
func getCopyManifestForPrebuiltEtc(prebuilt *android.PrebuiltEtc) (fileToCopy android.Path, dirInApex string) {
|
|
|
|
dirInApex = filepath.Join("etc", prebuilt.SubDir())
|
|
|
|
fileToCopy = prebuilt.OutputFile()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-08-27 06:55:42 +02:00
|
|
|
func getCopyManifestForAndroidApp(app *java.AndroidApp, pkgName string) (fileToCopy android.Path, dirInApex string) {
|
|
|
|
dirInApex = filepath.Join("app", pkgName)
|
|
|
|
fileToCopy = app.OutputFile()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-08-13 15:55:28 +02:00
|
|
|
// Context "decorator", overriding the InstallBypassMake method to always reply `true`.
|
|
|
|
type flattenedApexContext struct {
|
|
|
|
android.ModuleContext
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *flattenedApexContext) InstallBypassMake() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2018-10-10 07:01:00 +02:00
|
|
|
func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
2018-11-07 18:50:25 +01:00
|
|
|
filesInfo := []apexFile{}
|
2018-10-10 07:01:00 +02:00
|
|
|
|
2018-11-30 02:12:15 +01:00
|
|
|
if a.properties.Payload_type == nil || *a.properties.Payload_type == "image" {
|
|
|
|
a.apexTypes = imageApex
|
|
|
|
} else if *a.properties.Payload_type == "zip" {
|
|
|
|
a.apexTypes = zipApex
|
|
|
|
} else if *a.properties.Payload_type == "both" {
|
|
|
|
a.apexTypes = both
|
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("type", "%q is not one of \"image\", \"zip\", or \"both\".", *a.properties.Payload_type)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-06-26 13:48:34 +02:00
|
|
|
if len(a.properties.Tests) > 0 && !a.testApex {
|
|
|
|
ctx.PropertyErrorf("tests", "property not allowed in apex module type")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-01-30 03:31:59 +01:00
|
|
|
handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case)
|
|
|
|
|
2019-08-01 10:41:43 +02:00
|
|
|
// native lib dependencies
|
|
|
|
var provideNativeLibs []string
|
|
|
|
var requireNativeLibs []string
|
|
|
|
|
2019-06-27 04:30:33 +02:00
|
|
|
// Check if "uses" requirements are met with dependent apexBundles
|
|
|
|
var providedNativeSharedLibs []string
|
|
|
|
useVendor := proptools.Bool(a.properties.Use_vendor)
|
|
|
|
ctx.VisitDirectDepsBlueprint(func(m blueprint.Module) {
|
|
|
|
if ctx.OtherModuleDependencyTag(m) != usesTag {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
otherName := ctx.OtherModuleName(m)
|
|
|
|
other, ok := m.(*apexBundle)
|
|
|
|
if !ok {
|
|
|
|
ctx.PropertyErrorf("uses", "%q is not a provider", otherName)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if proptools.Bool(other.properties.Use_vendor) != useVendor {
|
|
|
|
ctx.PropertyErrorf("use_vendor", "%q has different value of use_vendor", otherName)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if !proptools.Bool(other.properties.Provide_cpp_shared_libs) {
|
|
|
|
ctx.PropertyErrorf("uses", "%q does not provide native_shared_libs", otherName)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
providedNativeSharedLibs = append(providedNativeSharedLibs, other.properties.Native_shared_libs...)
|
|
|
|
})
|
|
|
|
|
2019-02-27 23:19:50 +01:00
|
|
|
ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool {
|
2019-07-29 17:22:59 +02:00
|
|
|
depTag := ctx.OtherModuleDependencyTag(child)
|
|
|
|
depName := ctx.OtherModuleName(child)
|
2018-10-10 07:01:00 +02:00
|
|
|
if _, ok := parent.(*apexBundle); ok {
|
|
|
|
// direct dependencies
|
|
|
|
switch depTag {
|
|
|
|
case sharedLibTag:
|
|
|
|
if cc, ok := child.(*cc.Module); ok {
|
2019-08-01 10:41:43 +02:00
|
|
|
if cc.HasStubsVariants() {
|
|
|
|
provideNativeLibs = append(provideNativeLibs, cc.OutputFile().Path().Base())
|
|
|
|
}
|
2019-09-11 00:18:20 +02:00
|
|
|
fileToCopy, dirInApex := getCopyManifestForNativeLibrary(cc, ctx.Config(), handleSpecialLibs)
|
2019-01-12 16:39:51 +01:00
|
|
|
filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, nativeSharedLib, cc, nil})
|
2018-10-10 07:01:00 +02:00
|
|
|
return true
|
2018-10-12 14:49:38 +02:00
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("native_shared_libs", "%q is not a cc_library or cc_library_shared module", depName)
|
2018-10-10 07:01:00 +02:00
|
|
|
}
|
|
|
|
case executableTag:
|
|
|
|
if cc, ok := child.(*cc.Module); ok {
|
|
|
|
fileToCopy, dirInApex := getCopyManifestForExecutable(cc)
|
2019-01-12 16:39:51 +01:00
|
|
|
filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, nativeExecutable, cc, cc.Symlinks()})
|
2018-10-10 07:01:00 +02:00
|
|
|
return true
|
2019-02-05 16:16:29 +01:00
|
|
|
} else if sh, ok := child.(*android.ShBinary); ok {
|
|
|
|
fileToCopy, dirInApex := getCopyManifestForShBinary(sh)
|
2019-10-05 05:38:01 +02:00
|
|
|
filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, shBinary, sh, sh.Symlinks()})
|
2019-02-27 23:19:50 +01:00
|
|
|
} else if py, ok := child.(*python.Module); ok && py.HostToolPath().Valid() {
|
|
|
|
fileToCopy, dirInApex := getCopyManifestForPyBinary(py)
|
|
|
|
filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, pyBinary, py, nil})
|
|
|
|
} else if gb, ok := child.(bootstrap.GoBinaryTool); ok && a.Host() {
|
|
|
|
fileToCopy, dirInApex := getCopyManifestForGoBinary(ctx, gb)
|
|
|
|
// NB: Since go binaries are static we don't need the module for anything here, which is
|
|
|
|
// good since the go tool is a blueprint.Module not an android.Module like we would
|
|
|
|
// normally use.
|
|
|
|
filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, goBinary, nil, nil})
|
2018-10-12 14:49:38 +02:00
|
|
|
} else {
|
2019-02-27 23:19:50 +01:00
|
|
|
ctx.PropertyErrorf("binaries", "%q is neither cc_binary, (embedded) py_binary, (host) blueprint_go_binary, (host) bootstrap_go_binary, nor sh_binary", depName)
|
2018-10-10 07:01:00 +02:00
|
|
|
}
|
|
|
|
case javaLibTag:
|
2019-08-09 13:39:45 +02:00
|
|
|
if javaLib, ok := child.(*java.Library); ok {
|
|
|
|
fileToCopy, dirInApex := getCopyManifestForJavaLibrary(javaLib)
|
2018-11-07 18:50:25 +01:00
|
|
|
if fileToCopy == nil {
|
|
|
|
ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
|
|
|
|
} else {
|
2019-08-09 13:39:45 +02:00
|
|
|
filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, javaSharedLib, javaLib, nil})
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
} else if javaLib, ok := child.(*java.Import); ok {
|
|
|
|
fileToCopy, dirInApex := getCopyManifestForPrebuiltJavaLibrary(javaLib)
|
|
|
|
if fileToCopy == nil {
|
|
|
|
ctx.PropertyErrorf("java_libs", "%q does not have a jar output", depName)
|
|
|
|
} else {
|
|
|
|
filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, javaSharedLib, javaLib, nil})
|
2018-11-07 18:50:25 +01:00
|
|
|
}
|
2018-10-10 07:01:00 +02:00
|
|
|
return true
|
2018-10-12 14:49:38 +02:00
|
|
|
} else {
|
2019-08-09 13:39:45 +02:00
|
|
|
ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
|
2018-10-10 07:01:00 +02:00
|
|
|
}
|
|
|
|
case prebuiltTag:
|
|
|
|
if prebuilt, ok := child.(*android.PrebuiltEtc); ok {
|
|
|
|
fileToCopy, dirInApex := getCopyManifestForPrebuiltEtc(prebuilt)
|
2019-01-12 16:39:51 +01:00
|
|
|
filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, etc, prebuilt, nil})
|
2018-10-10 07:01:00 +02:00
|
|
|
return true
|
2018-10-12 14:49:38 +02:00
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc module", depName)
|
|
|
|
}
|
2019-06-26 13:48:34 +02:00
|
|
|
case testTag:
|
2019-07-29 17:22:59 +02:00
|
|
|
if ccTest, ok := child.(*cc.Module); ok {
|
|
|
|
if ccTest.IsTestPerSrcAllTestsVariation() {
|
|
|
|
// Multiple-output test module (where `test_per_src: true`).
|
|
|
|
//
|
|
|
|
// `ccTest` is the "" ("all tests") variation of a `test_per_src` module.
|
|
|
|
// We do not add this variation to `filesInfo`, as it has no output;
|
|
|
|
// however, we do add the other variations of this module as indirect
|
|
|
|
// dependencies (see below).
|
|
|
|
return true
|
2019-06-28 16:41:19 +02:00
|
|
|
} else {
|
2019-07-29 17:22:59 +02:00
|
|
|
// Single-output test module (where `test_per_src: false`).
|
|
|
|
fileToCopy, dirInApex := getCopyManifestForExecutable(ccTest)
|
|
|
|
filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, nativeTest, ccTest, nil})
|
2019-06-28 16:41:19 +02:00
|
|
|
}
|
2019-06-26 13:48:34 +02:00
|
|
|
return true
|
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("tests", "%q is not a cc module", depName)
|
|
|
|
}
|
2018-10-12 14:49:38 +02:00
|
|
|
case keyTag:
|
|
|
|
if key, ok := child.(*apexKey); ok {
|
2019-02-18 07:25:04 +01:00
|
|
|
a.private_key_file = key.private_key_file
|
|
|
|
a.public_key_file = key.public_key_file
|
2018-10-12 14:49:38 +02:00
|
|
|
return false
|
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("key", "%q is not an apex_key module", depName)
|
2018-10-10 07:01:00 +02:00
|
|
|
}
|
2018-10-30 13:20:05 +01:00
|
|
|
case certificateTag:
|
|
|
|
if dep, ok := child.(*java.AndroidAppCertificate); ok {
|
2019-02-18 07:25:04 +01:00
|
|
|
a.container_certificate_file = dep.Certificate.Pem
|
|
|
|
a.container_private_key_file = dep.Certificate.Key
|
2018-10-30 13:20:05 +01:00
|
|
|
return false
|
|
|
|
} else {
|
|
|
|
ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName)
|
|
|
|
}
|
2019-07-26 16:20:40 +02:00
|
|
|
case android.PrebuiltDepTag:
|
|
|
|
// If the prebuilt is force disabled, remember to delete the prebuilt file
|
|
|
|
// that might have been installed in the previous builds
|
|
|
|
if prebuilt, ok := child.(*Prebuilt); ok && prebuilt.isForceDisabled() {
|
|
|
|
a.prebuiltFileToDelete = prebuilt.InstallFilename()
|
|
|
|
}
|
2019-08-27 06:55:42 +02:00
|
|
|
case androidAppTag:
|
|
|
|
if ap, ok := child.(*java.AndroidApp); ok {
|
|
|
|
fileToCopy, dirInApex := getCopyManifestForAndroidApp(ap, ctx.DeviceConfig().OverridePackageNameFor(depName))
|
|
|
|
filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, app, ap, nil})
|
|
|
|
return true
|
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("apps", "%q is not an android_app module", depName)
|
|
|
|
}
|
2018-10-10 07:01:00 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// indirect dependencies
|
2019-08-20 10:30:57 +02:00
|
|
|
if am, ok := child.(android.ApexModule); ok {
|
2019-07-29 17:22:59 +02:00
|
|
|
// We cannot use a switch statement on `depTag` here as the checked
|
|
|
|
// tags used below are private (e.g. `cc.sharedDepTag`).
|
|
|
|
if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) {
|
|
|
|
if cc, ok := child.(*cc.Module); ok {
|
|
|
|
if android.InList(cc.Name(), providedNativeSharedLibs) {
|
|
|
|
// If we're using a shared library which is provided from other APEX,
|
|
|
|
// don't include it in this APEX
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if !a.Host() && (cc.IsStubs() || cc.HasStubsVariants()) {
|
|
|
|
// If the dependency is a stubs lib, don't include it in this APEX,
|
|
|
|
// but make sure that the lib is installed on the device.
|
|
|
|
// In case no APEX is having the lib, the lib is installed to the system
|
|
|
|
// partition.
|
|
|
|
//
|
|
|
|
// Always include if we are a host-apex however since those won't have any
|
|
|
|
// system libraries.
|
|
|
|
if !android.DirectlyInAnyApex(ctx, cc.Name()) && !android.InList(cc.Name(), a.externalDeps) {
|
|
|
|
a.externalDeps = append(a.externalDeps, cc.Name())
|
|
|
|
}
|
2019-08-01 10:41:43 +02:00
|
|
|
requireNativeLibs = append(requireNativeLibs, cc.OutputFile().Path().Base())
|
2019-07-29 17:22:59 +02:00
|
|
|
// Don't track further
|
|
|
|
return false
|
2019-02-20 13:49:26 +01:00
|
|
|
}
|
2019-09-11 00:18:20 +02:00
|
|
|
fileToCopy, dirInApex := getCopyManifestForNativeLibrary(cc, ctx.Config(), handleSpecialLibs)
|
2019-07-29 17:22:59 +02:00
|
|
|
filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, nativeSharedLib, cc, nil})
|
|
|
|
return true
|
Stubs variant is used when building for APEX
When a native module is built for an APEX and is depending on a native
library having stubs (i.e. stubs.versions property is set), the stubs
variant is used unless the dependent lib is directly included in the
same APEX with the depending module.
Example:
apex {
name: "myapex",
native_shared_libs: ["libX", "libY"],
}
cc_library {
name: "libX",
shared_libs: ["libY", "libZ"],
}
cc_library {
name: "libY",
stubs: { versions: ["1", "2"], },
}
cc_library {
name: "libZ",
stubs: { versions: ["1", "2"], },
}
In this case, libX is linking to the impl variant of libY (that provides
private APIs) while libY is linking to the version 2 stubs of libZ. This is
because libY is directly included in the same apex via
native_shared_libs property, but libZ isn't.
Bug: 112672359
Test: apex_test added
Change-Id: If9871b70dc74a06bd828dd4cd1aeebd2e68b837c
2018-11-18 10:02:45 +01:00
|
|
|
}
|
2019-07-29 17:22:59 +02:00
|
|
|
} else if cc.IsTestPerSrcDepTag(depTag) {
|
|
|
|
if cc, ok := child.(*cc.Module); ok {
|
|
|
|
fileToCopy, dirInApex := getCopyManifestForExecutable(cc)
|
|
|
|
// Handle modules created as `test_per_src` variations of a single test module:
|
|
|
|
// use the name of the generated test binary (`fileToCopy`) instead of the name
|
|
|
|
// of the original test module (`depName`, shared by all `test_per_src`
|
|
|
|
// variations of that module).
|
|
|
|
moduleName := filepath.Base(fileToCopy.String())
|
|
|
|
filesInfo = append(filesInfo, apexFile{fileToCopy, moduleName, dirInApex, nativeTest, cc, nil})
|
|
|
|
return true
|
|
|
|
}
|
2019-08-20 10:30:57 +02:00
|
|
|
} else if am.CanHaveApexVariants() && am.IsInstallableToApex() {
|
2019-07-29 17:22:59 +02:00
|
|
|
ctx.ModuleErrorf("unexpected tag %q for indirect dependency %q", depTag, depName)
|
2018-10-10 07:01:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
})
|
|
|
|
|
2019-02-18 07:25:04 +01:00
|
|
|
if a.private_key_file == nil {
|
2018-11-08 21:52:26 +01:00
|
|
|
ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-11-07 18:50:25 +01:00
|
|
|
// remove duplicates in filesInfo
|
|
|
|
removeDup := func(filesInfo []apexFile) []apexFile {
|
2019-08-23 04:17:39 +02:00
|
|
|
encountered := make(map[string]bool)
|
2018-11-07 18:50:25 +01:00
|
|
|
result := []apexFile{}
|
|
|
|
for _, f := range filesInfo {
|
2019-08-23 04:17:39 +02:00
|
|
|
dest := filepath.Join(f.installDir, f.builtFile.Base())
|
|
|
|
if !encountered[dest] {
|
|
|
|
encountered[dest] = true
|
2018-11-07 18:50:25 +01:00
|
|
|
result = append(result, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
filesInfo = removeDup(filesInfo)
|
|
|
|
|
|
|
|
// to have consistent build rules
|
|
|
|
sort.Slice(filesInfo, func(i, j int) bool {
|
|
|
|
return filesInfo[i].builtFile.String() < filesInfo[j].builtFile.String()
|
|
|
|
})
|
|
|
|
|
Add apex_available to control the availablity of a module to APEXes
apex_available property controls the availability of a module to APEXes.
For example, `apex_available: ["myapex", "otherapex"]` makes the module
available only to the two APEXes: myapex and otherapex, and nothing
else, even to the platform.
If the module is intended to be available to any APEX, then a pseudo
name "//apex_available:anyapex" can be used.
If the module is intended to be available to the platform, then another
pseudo name "//apex_available:platform" is used.
For now, if unspecified, this property defaults to ["//apex_available:platform",
"//apex_available:anyapex"], which means the module is available to everybody.
This will be reduced to ["//apex_available:platform"], when marking for
apex_available for existing modules are finished.
Bug: 139870423
Bug: 128708192
Test: m
Change-Id: Id4b233c3056c7858f984cbf9427cfac4118b2682
2019-09-30 09:04:35 +02:00
|
|
|
// check apex_available requirements
|
2019-10-08 13:55:38 +02:00
|
|
|
if !ctx.Host() {
|
|
|
|
for _, fi := range filesInfo {
|
|
|
|
if am, ok := fi.module.(android.ApexModule); ok {
|
|
|
|
if !am.AvailableFor(ctx.ModuleName()) {
|
|
|
|
ctx.ModuleErrorf("requires %q that is not available for the APEX", fi.module.Name())
|
|
|
|
return
|
|
|
|
}
|
Add apex_available to control the availablity of a module to APEXes
apex_available property controls the availability of a module to APEXes.
For example, `apex_available: ["myapex", "otherapex"]` makes the module
available only to the two APEXes: myapex and otherapex, and nothing
else, even to the platform.
If the module is intended to be available to any APEX, then a pseudo
name "//apex_available:anyapex" can be used.
If the module is intended to be available to the platform, then another
pseudo name "//apex_available:platform" is used.
For now, if unspecified, this property defaults to ["//apex_available:platform",
"//apex_available:anyapex"], which means the module is available to everybody.
This will be reduced to ["//apex_available:platform"], when marking for
apex_available for existing modules are finished.
Bug: 139870423
Bug: 128708192
Test: m
Change-Id: Id4b233c3056c7858f984cbf9427cfac4118b2682
2019-09-30 09:04:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-07 18:50:25 +01:00
|
|
|
// prepend the name of this APEX to the module names. These names will be the names of
|
|
|
|
// modules that will be defined if the APEX is flattened.
|
|
|
|
for i := range filesInfo {
|
2019-10-07 08:34:50 +02:00
|
|
|
filesInfo[i].moduleName = filesInfo[i].moduleName + "." + ctx.ModuleName()
|
2018-11-07 18:50:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
a.installDir = android.PathForModuleInstall(ctx, "apex")
|
|
|
|
a.filesInfo = filesInfo
|
2018-11-30 02:12:15 +01:00
|
|
|
|
2019-09-26 17:38:03 +02:00
|
|
|
// prepare apex_manifest.json
|
2019-08-01 10:41:43 +02:00
|
|
|
a.manifestOut = android.PathForModuleOut(ctx, "apex_manifest.json")
|
|
|
|
manifestSrc := android.PathForModuleSrc(ctx, proptools.StringDefault(a.properties.Manifest, "apex_manifest.json"))
|
2019-09-26 17:38:03 +02:00
|
|
|
|
|
|
|
// put dependency({provide|require}NativeLibs) in apex_manifest.json
|
2019-08-01 10:41:43 +02:00
|
|
|
provideNativeLibs = android.SortedUniqueStrings(provideNativeLibs)
|
|
|
|
requireNativeLibs = android.SortedUniqueStrings(android.RemoveListFromList(requireNativeLibs, provideNativeLibs))
|
2019-09-26 17:38:03 +02:00
|
|
|
|
|
|
|
// apex name can be overridden
|
|
|
|
optCommands := []string{}
|
|
|
|
if a.properties.Apex_name != nil {
|
|
|
|
optCommands = append(optCommands, "-v name "+*a.properties.Apex_name)
|
|
|
|
}
|
|
|
|
|
2019-08-01 10:41:43 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
2019-09-26 17:38:03 +02:00
|
|
|
Rule: apexManifestRule,
|
2019-08-01 10:41:43 +02:00
|
|
|
Input: manifestSrc,
|
|
|
|
Output: a.manifestOut,
|
|
|
|
Args: map[string]string{
|
|
|
|
"provideNativeLibs": strings.Join(provideNativeLibs, " "),
|
|
|
|
"requireNativeLibs": strings.Join(requireNativeLibs, " "),
|
2019-09-26 17:38:03 +02:00
|
|
|
"opt": strings.Join(optCommands, " "),
|
2019-08-01 10:41:43 +02:00
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2019-08-13 15:55:28 +02:00
|
|
|
// Temporarily wrap the original `ctx` into a `flattenedApexContext` to have it
|
|
|
|
// reply true to `InstallBypassMake()` (thus making the call
|
|
|
|
// `android.PathForModuleInstall` below use `android.pathForInstallInMakeDir`
|
|
|
|
// instead of `android.PathForOutput`) to return the correct path to the flattened
|
|
|
|
// APEX (as its contents is installed by Make, not Soong).
|
|
|
|
factx := flattenedApexContext{ctx}
|
2019-10-08 14:59:58 +02:00
|
|
|
apexName := proptools.StringDefault(a.properties.Apex_name, ctx.ModuleName())
|
|
|
|
a.flattenedOutput = android.PathForModuleInstall(&factx, "apex", apexName)
|
2019-08-13 15:55:28 +02:00
|
|
|
|
2018-11-30 02:12:15 +01:00
|
|
|
if a.apexTypes.zip() {
|
2019-02-18 07:25:04 +01:00
|
|
|
a.buildUnflattenedApex(ctx, zipApex)
|
2018-11-30 02:12:15 +01:00
|
|
|
}
|
|
|
|
if a.apexTypes.image() {
|
2019-02-02 05:13:47 +01:00
|
|
|
// Build rule for unflattened APEX is created even when ctx.Config().FlattenApex()
|
2019-07-23 17:53:32 +02:00
|
|
|
// is true. This is to support referencing APEX via ":<module_name>" syntax
|
2019-02-02 05:13:47 +01:00
|
|
|
// in other modules. It is in AndroidMk where the selection of flattened
|
|
|
|
// or unflattened APEX is made.
|
2019-02-18 07:25:04 +01:00
|
|
|
a.buildUnflattenedApex(ctx, imageApex)
|
2019-02-02 05:13:47 +01:00
|
|
|
a.buildFlattenedApex(ctx)
|
2018-11-07 18:50:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-18 22:09:13 +02:00
|
|
|
func (a *apexBundle) buildNoticeFile(ctx android.ModuleContext, apexFileName string) android.OptionalPath {
|
2019-03-18 04:01:38 +01:00
|
|
|
noticeFiles := []android.Path{}
|
|
|
|
for _, f := range a.filesInfo {
|
|
|
|
if f.module != nil {
|
|
|
|
notice := f.module.NoticeFile()
|
|
|
|
if notice.Valid() {
|
|
|
|
noticeFiles = append(noticeFiles, notice.Path())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// append the notice file specified in the apex module itself
|
|
|
|
if a.NoticeFile().Valid() {
|
|
|
|
noticeFiles = append(noticeFiles, a.NoticeFile().Path())
|
|
|
|
}
|
|
|
|
|
2019-06-18 22:09:13 +02:00
|
|
|
if len(noticeFiles) == 0 {
|
|
|
|
return android.OptionalPath{}
|
2019-03-18 04:01:38 +01:00
|
|
|
}
|
2019-06-18 22:09:13 +02:00
|
|
|
|
2019-07-02 02:15:13 +02:00
|
|
|
return android.BuildNoticeOutput(ctx, a.installDir, apexFileName, android.FirstUniquePaths(noticeFiles)).HtmlGzOutput
|
2019-03-18 04:01:38 +01:00
|
|
|
}
|
|
|
|
|
2019-02-18 07:25:04 +01:00
|
|
|
func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext, apexType apexPackaging) {
|
2018-10-30 13:20:05 +01:00
|
|
|
cert := String(a.properties.Certificate)
|
|
|
|
if cert != "" && android.SrcIsModule(cert) == "" {
|
|
|
|
defaultDir := ctx.Config().DefaultAppCertificateDir(ctx)
|
2019-02-18 07:25:04 +01:00
|
|
|
a.container_certificate_file = defaultDir.Join(ctx, cert+".x509.pem")
|
|
|
|
a.container_private_key_file = defaultDir.Join(ctx, cert+".pk8")
|
2018-10-30 13:20:05 +01:00
|
|
|
} else if cert == "" {
|
|
|
|
pem, key := ctx.Config().DefaultAppCertificate(ctx)
|
2019-02-18 07:25:04 +01:00
|
|
|
a.container_certificate_file = pem
|
|
|
|
a.container_private_key_file = key
|
2018-10-30 13:20:05 +01:00
|
|
|
}
|
|
|
|
|
2018-11-30 02:12:15 +01:00
|
|
|
var abis []string
|
|
|
|
for _, target := range ctx.MultiTargets() {
|
|
|
|
if len(target.Arch.Abi) > 0 {
|
|
|
|
abis = append(abis, target.Arch.Abi[0])
|
|
|
|
}
|
2018-11-09 22:37:15 +01:00
|
|
|
}
|
2018-10-10 07:01:00 +02:00
|
|
|
|
2018-11-30 02:12:15 +01:00
|
|
|
abis = android.FirstUniqueStrings(abis)
|
|
|
|
|
|
|
|
suffix := apexType.suffix()
|
|
|
|
unsignedOutputFile := android.PathForModuleOut(ctx, ctx.ModuleName()+suffix+".unsigned")
|
2018-10-10 07:01:00 +02:00
|
|
|
|
2018-10-10 07:05:29 +02:00
|
|
|
filesToCopy := []android.Path{}
|
2018-11-07 18:50:25 +01:00
|
|
|
for _, f := range a.filesInfo {
|
|
|
|
filesToCopy = append(filesToCopy, f.builtFile)
|
2018-10-10 07:01:00 +02:00
|
|
|
}
|
2018-10-10 07:05:29 +02:00
|
|
|
|
2018-10-10 07:01:00 +02:00
|
|
|
copyCommands := []string{}
|
2019-08-31 15:38:05 +02:00
|
|
|
emitCommands := []string{}
|
|
|
|
imageContentFile := android.PathForModuleOut(ctx, ctx.ModuleName()+"-content.txt")
|
|
|
|
emitCommands = append(emitCommands, "echo ./apex_manifest.json >> "+imageContentFile.String())
|
2018-11-07 18:50:25 +01:00
|
|
|
for i, src := range filesToCopy {
|
|
|
|
dest := filepath.Join(a.filesInfo[i].installDir, src.Base())
|
2019-08-31 15:38:05 +02:00
|
|
|
emitCommands = append(emitCommands, "echo './"+dest+"' >> "+imageContentFile.String())
|
2018-11-30 02:12:15 +01:00
|
|
|
dest_path := filepath.Join(android.PathForModuleOut(ctx, "image"+suffix).String(), dest)
|
2018-10-10 07:01:00 +02:00
|
|
|
copyCommands = append(copyCommands, "mkdir -p "+filepath.Dir(dest_path))
|
|
|
|
copyCommands = append(copyCommands, "cp "+src.String()+" "+dest_path)
|
2019-01-18 23:37:31 +01:00
|
|
|
for _, sym := range a.filesInfo[i].symlinks {
|
|
|
|
symlinkDest := filepath.Join(filepath.Dir(dest_path), sym)
|
|
|
|
copyCommands = append(copyCommands, "ln -s "+filepath.Base(dest)+" "+symlinkDest)
|
|
|
|
}
|
2018-10-10 07:01:00 +02:00
|
|
|
}
|
2018-10-10 07:05:29 +02:00
|
|
|
implicitInputs := append(android.Paths(nil), filesToCopy...)
|
2019-08-01 10:41:43 +02:00
|
|
|
implicitInputs = append(implicitInputs, a.manifestOut)
|
2018-11-30 02:12:15 +01:00
|
|
|
|
2019-08-31 15:38:05 +02:00
|
|
|
if a.properties.Whitelisted_files != nil {
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: emitApexContentRule,
|
|
|
|
Implicits: implicitInputs,
|
|
|
|
Output: imageContentFile,
|
|
|
|
Description: "emit apex image content",
|
|
|
|
Args: map[string]string{
|
|
|
|
"emit_commands": strings.Join(emitCommands, " && "),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
implicitInputs = append(implicitInputs, imageContentFile)
|
|
|
|
whitelistedFilesFile := android.PathForModuleSrc(ctx, proptools.String(a.properties.Whitelisted_files))
|
|
|
|
|
2019-09-04 12:53:14 +02:00
|
|
|
phonyOutput := android.PathForModuleOut(ctx, ctx.ModuleName()+"-diff-phony-output")
|
2019-08-31 15:38:05 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: diffApexContentRule,
|
|
|
|
Implicits: implicitInputs,
|
|
|
|
Output: phonyOutput,
|
|
|
|
Description: "diff apex image content",
|
|
|
|
Args: map[string]string{
|
|
|
|
"whitelisted_files_file": whitelistedFilesFile.String(),
|
|
|
|
"image_content_file": imageContentFile.String(),
|
|
|
|
"apex_module_name": ctx.ModuleName(),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
implicitInputs = append(implicitInputs, phonyOutput)
|
|
|
|
}
|
|
|
|
|
2018-10-10 07:01:00 +02:00
|
|
|
outHostBinDir := android.PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "bin").String()
|
|
|
|
prebuiltSdkToolsBinDir := filepath.Join("prebuilts", "sdk", "tools", runtime.GOOS, "bin")
|
|
|
|
|
2018-11-30 02:12:15 +01:00
|
|
|
if apexType.image() {
|
|
|
|
// files and dirs that will be created in APEX
|
|
|
|
var readOnlyPaths []string
|
|
|
|
var executablePaths []string // this also includes dirs
|
|
|
|
for _, f := range a.filesInfo {
|
|
|
|
pathInApex := filepath.Join(f.installDir, f.builtFile.Base())
|
2019-06-26 13:48:34 +02:00
|
|
|
if f.installDir == "bin" || strings.HasPrefix(f.installDir, "bin/") {
|
2018-11-30 02:12:15 +01:00
|
|
|
executablePaths = append(executablePaths, pathInApex)
|
2019-01-18 23:37:31 +01:00
|
|
|
for _, s := range f.symlinks {
|
2019-07-20 07:24:33 +02:00
|
|
|
executablePaths = append(executablePaths, filepath.Join(f.installDir, s))
|
2019-01-18 23:37:31 +01:00
|
|
|
}
|
2018-11-30 02:12:15 +01:00
|
|
|
} else {
|
|
|
|
readOnlyPaths = append(readOnlyPaths, pathInApex)
|
|
|
|
}
|
2018-12-06 16:42:25 +01:00
|
|
|
dir := f.installDir
|
|
|
|
for !android.InList(dir, executablePaths) && dir != "" {
|
|
|
|
executablePaths = append(executablePaths, dir)
|
|
|
|
dir, _ = filepath.Split(dir) // move up to the parent
|
|
|
|
if len(dir) > 0 {
|
|
|
|
// remove trailing slash
|
|
|
|
dir = dir[:len(dir)-1]
|
|
|
|
}
|
2018-11-30 02:12:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
sort.Strings(readOnlyPaths)
|
|
|
|
sort.Strings(executablePaths)
|
|
|
|
cannedFsConfig := android.PathForModuleOut(ctx, "canned_fs_config")
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: generateFsConfig,
|
|
|
|
Output: cannedFsConfig,
|
|
|
|
Description: "generate fs config",
|
|
|
|
Args: map[string]string{
|
|
|
|
"ro_paths": strings.Join(readOnlyPaths, " "),
|
|
|
|
"exec_paths": strings.Join(executablePaths, " "),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
fcName := proptools.StringDefault(a.properties.File_contexts, ctx.ModuleName())
|
|
|
|
fileContextsPath := "system/sepolicy/apex/" + fcName + "-file_contexts"
|
|
|
|
fileContextsOptionalPath := android.ExistentPathForSource(ctx, fileContextsPath)
|
|
|
|
if !fileContextsOptionalPath.Valid() {
|
|
|
|
ctx.ModuleErrorf("Cannot find file_contexts file: %q", fileContextsPath)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
fileContexts := fileContextsOptionalPath.Path()
|
|
|
|
|
2018-12-27 08:04:18 +01:00
|
|
|
optFlags := []string{}
|
|
|
|
|
2018-11-30 02:12:15 +01:00
|
|
|
// Additional implicit inputs.
|
2019-04-01 04:15:50 +02:00
|
|
|
implicitInputs = append(implicitInputs, cannedFsConfig, fileContexts, a.private_key_file, a.public_key_file)
|
|
|
|
optFlags = append(optFlags, "--pubkey "+a.public_key_file.String())
|
2018-11-30 02:12:15 +01:00
|
|
|
|
2019-01-05 04:57:48 +01:00
|
|
|
manifestPackageName, overridden := ctx.DeviceConfig().OverrideManifestPackageNameFor(ctx.ModuleName())
|
|
|
|
if overridden {
|
|
|
|
optFlags = append(optFlags, "--override_apk_package_name "+manifestPackageName)
|
|
|
|
}
|
|
|
|
|
2019-02-07 18:53:06 +01:00
|
|
|
if a.properties.AndroidManifest != nil {
|
2019-03-06 07:25:09 +01:00
|
|
|
androidManifestFile := android.PathForModuleSrc(ctx, proptools.String(a.properties.AndroidManifest))
|
2019-02-07 18:53:06 +01:00
|
|
|
implicitInputs = append(implicitInputs, androidManifestFile)
|
|
|
|
optFlags = append(optFlags, "--android_manifest "+androidManifestFile.String())
|
|
|
|
}
|
|
|
|
|
2019-04-18 10:25:49 +02:00
|
|
|
targetSdkVersion := ctx.Config().DefaultAppTargetSdk()
|
|
|
|
if targetSdkVersion == ctx.Config().PlatformSdkCodename() &&
|
|
|
|
ctx.Config().UnbundledBuild() &&
|
|
|
|
!ctx.Config().UnbundledBuildUsePrebuiltSdks() &&
|
|
|
|
ctx.Config().IsEnvTrue("UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT") {
|
|
|
|
apiFingerprint := java.ApiFingerprintPath(ctx)
|
|
|
|
targetSdkVersion += fmt.Sprintf(".$$(cat %s)", apiFingerprint.String())
|
|
|
|
implicitInputs = append(implicitInputs, apiFingerprint)
|
|
|
|
}
|
|
|
|
optFlags = append(optFlags, "--target_sdk_version "+targetSdkVersion)
|
|
|
|
|
2019-06-18 22:09:13 +02:00
|
|
|
noticeFile := a.buildNoticeFile(ctx, ctx.ModuleName()+suffix)
|
|
|
|
if noticeFile.Valid() {
|
|
|
|
// If there's a NOTICE file, embed it as an asset file in the APEX.
|
|
|
|
implicitInputs = append(implicitInputs, noticeFile.Path())
|
|
|
|
optFlags = append(optFlags, "--assets_dir "+filepath.Dir(noticeFile.String()))
|
|
|
|
}
|
|
|
|
|
2019-08-27 17:27:35 +02:00
|
|
|
if !ctx.Config().UnbundledBuild() && a.installable() {
|
|
|
|
// Apexes which are supposed to be installed in builtin dirs(/system, etc)
|
|
|
|
// don't need hashtree for activation. Therefore, by removing hashtree from
|
|
|
|
// apex bundle (filesystem image in it, to be specific), we can save storage.
|
|
|
|
optFlags = append(optFlags, "--no_hashtree")
|
|
|
|
}
|
|
|
|
|
2019-09-26 17:38:03 +02:00
|
|
|
if a.properties.Apex_name != nil {
|
|
|
|
// If apex_name is set, apexer can skip checking if key name matches with apex name.
|
|
|
|
// Note that apex_manifest is also mended.
|
|
|
|
optFlags = append(optFlags, "--do_not_check_keyname")
|
|
|
|
}
|
|
|
|
|
2018-11-30 02:12:15 +01:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: apexRule,
|
|
|
|
Implicits: implicitInputs,
|
|
|
|
Output: unsignedOutputFile,
|
|
|
|
Description: "apex (" + apexType.name() + ")",
|
|
|
|
Args: map[string]string{
|
|
|
|
"tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir,
|
|
|
|
"image_dir": android.PathForModuleOut(ctx, "image"+suffix).String(),
|
|
|
|
"copy_commands": strings.Join(copyCommands, " && "),
|
2019-08-01 10:41:43 +02:00
|
|
|
"manifest": a.manifestOut.String(),
|
2018-11-30 02:12:15 +01:00
|
|
|
"file_contexts": fileContexts.String(),
|
|
|
|
"canned_fs_config": cannedFsConfig.String(),
|
2019-02-18 07:25:04 +01:00
|
|
|
"key": a.private_key_file.String(),
|
2018-12-27 08:04:18 +01:00
|
|
|
"opt_flags": strings.Join(optFlags, " "),
|
2018-11-30 02:12:15 +01:00
|
|
|
},
|
|
|
|
})
|
2018-11-16 20:36:28 +01:00
|
|
|
|
2018-11-30 02:12:15 +01:00
|
|
|
apexProtoFile := android.PathForModuleOut(ctx, ctx.ModuleName()+".pb"+suffix)
|
|
|
|
bundleModuleFile := android.PathForModuleOut(ctx, ctx.ModuleName()+suffix+"-base.zip")
|
|
|
|
a.bundleModuleFile = bundleModuleFile
|
2018-11-16 20:36:28 +01:00
|
|
|
|
2018-11-30 02:12:15 +01:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: apexProtoConvertRule,
|
|
|
|
Input: unsignedOutputFile,
|
|
|
|
Output: apexProtoFile,
|
|
|
|
Description: "apex proto convert",
|
|
|
|
})
|
2018-11-16 20:36:28 +01:00
|
|
|
|
2018-11-30 02:12:15 +01:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: apexBundleRule,
|
|
|
|
Input: apexProtoFile,
|
|
|
|
Output: a.bundleModuleFile,
|
|
|
|
Description: "apex bundle module",
|
|
|
|
Args: map[string]string{
|
|
|
|
"abi": strings.Join(abis, "."),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: zipApexRule,
|
|
|
|
Implicits: implicitInputs,
|
|
|
|
Output: unsignedOutputFile,
|
|
|
|
Description: "apex (" + apexType.name() + ")",
|
|
|
|
Args: map[string]string{
|
|
|
|
"tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir,
|
|
|
|
"image_dir": android.PathForModuleOut(ctx, "image"+suffix).String(),
|
|
|
|
"copy_commands": strings.Join(copyCommands, " && "),
|
2019-08-01 10:41:43 +02:00
|
|
|
"manifest": a.manifestOut.String(),
|
2018-11-30 02:12:15 +01:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
2018-11-16 20:36:28 +01:00
|
|
|
|
2018-11-30 02:12:15 +01:00
|
|
|
a.outputFiles[apexType] = android.PathForModuleOut(ctx, ctx.ModuleName()+suffix)
|
2018-10-30 13:20:05 +01:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: java.Signapk,
|
|
|
|
Description: "signapk",
|
2018-11-30 02:12:15 +01:00
|
|
|
Output: a.outputFiles[apexType],
|
2018-10-30 13:20:05 +01:00
|
|
|
Input: unsignedOutputFile,
|
2019-06-13 06:48:54 +02:00
|
|
|
Implicits: []android.Path{
|
|
|
|
a.container_certificate_file,
|
|
|
|
a.container_private_key_file,
|
|
|
|
},
|
2018-10-30 13:20:05 +01:00
|
|
|
Args: map[string]string{
|
2019-02-18 07:25:04 +01:00
|
|
|
"certificates": a.container_certificate_file.String() + " " + a.container_private_key_file.String(),
|
2018-11-21 18:51:54 +01:00
|
|
|
"flags": "-a 4096", //alignment
|
2018-10-30 13:20:05 +01:00
|
|
|
},
|
|
|
|
})
|
2018-11-30 02:12:15 +01:00
|
|
|
|
|
|
|
// Install to $OUT/soong/{target,host}/.../apex
|
2019-09-17 06:50:45 +02:00
|
|
|
if a.installable() && (!ctx.Config().FlattenApex() || apexType.zip()) && !a.isFlattenedVariant() {
|
2019-02-18 07:25:04 +01:00
|
|
|
ctx.InstallFile(a.installDir, ctx.ModuleName()+suffix, a.outputFiles[apexType])
|
2018-12-13 15:14:57 +01:00
|
|
|
}
|
2018-11-07 18:50:25 +01:00
|
|
|
}
|
2018-10-30 13:20:05 +01:00
|
|
|
|
2018-11-07 18:50:25 +01:00
|
|
|
func (a *apexBundle) buildFlattenedApex(ctx android.ModuleContext) {
|
2018-12-13 15:14:57 +01:00
|
|
|
if a.installable() {
|
2019-04-01 04:15:50 +02:00
|
|
|
// For flattened APEX, do nothing but make sure that apex_manifest.json and apex_pubkey are also copied along
|
2018-12-13 15:14:57 +01:00
|
|
|
// with other ordinary files.
|
2019-10-07 08:34:50 +02:00
|
|
|
a.filesInfo = append(a.filesInfo, apexFile{a.manifestOut, "apex_manifest.json." + ctx.ModuleName(), ".", etc, nil, nil})
|
2018-12-13 15:14:57 +01:00
|
|
|
|
2019-04-01 04:15:50 +02:00
|
|
|
// rename to apex_pubkey
|
|
|
|
copiedPubkey := android.PathForModuleOut(ctx, "apex_pubkey")
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: android.Cp,
|
|
|
|
Input: a.public_key_file,
|
|
|
|
Output: copiedPubkey,
|
|
|
|
})
|
2019-10-07 08:34:50 +02:00
|
|
|
a.filesInfo = append(a.filesInfo, apexFile{copiedPubkey, "apex_pubkey." + ctx.ModuleName(), ".", etc, nil, nil})
|
2019-04-01 04:15:50 +02:00
|
|
|
|
2019-02-02 05:13:47 +01:00
|
|
|
if ctx.Config().FlattenApex() {
|
2019-10-08 14:59:58 +02:00
|
|
|
apexName := proptools.StringDefault(a.properties.Apex_name, ctx.ModuleName())
|
2019-02-02 05:13:47 +01:00
|
|
|
for _, fi := range a.filesInfo {
|
2019-10-08 14:59:58 +02:00
|
|
|
dir := filepath.Join("apex", apexName, fi.installDir)
|
2019-02-22 22:00:04 +01:00
|
|
|
target := ctx.InstallFile(android.PathForModuleInstall(ctx, dir), fi.builtFile.Base(), fi.builtFile)
|
|
|
|
for _, sym := range fi.symlinks {
|
|
|
|
ctx.InstallSymlink(android.PathForModuleInstall(ctx, dir), sym, target)
|
|
|
|
}
|
2019-02-02 05:13:47 +01:00
|
|
|
}
|
2018-12-13 15:14:57 +01:00
|
|
|
}
|
2018-11-07 18:50:25 +01:00
|
|
|
}
|
2018-10-10 07:01:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *apexBundle) AndroidMk() android.AndroidMkData {
|
2019-08-09 07:44:36 +02:00
|
|
|
if a.properties.HideFromMake {
|
|
|
|
return android.AndroidMkData{
|
|
|
|
Disabled: true,
|
|
|
|
}
|
|
|
|
}
|
2018-11-30 02:12:15 +01:00
|
|
|
writers := []android.AndroidMkData{}
|
|
|
|
if a.apexTypes.image() {
|
|
|
|
writers = append(writers, a.androidMkForType(imageApex))
|
|
|
|
}
|
|
|
|
if a.apexTypes.zip() {
|
|
|
|
writers = append(writers, a.androidMkForType(zipApex))
|
|
|
|
}
|
|
|
|
return android.AndroidMkData{
|
|
|
|
Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
|
|
|
|
for _, data := range writers {
|
|
|
|
data.Custom(w, name, prefix, moduleDir, data)
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
2019-10-08 14:59:58 +02:00
|
|
|
func (a *apexBundle) androidMkForFiles(w io.Writer, apexName, moduleDir string, apexType apexPackaging) []string {
|
2019-02-05 15:18:47 +01:00
|
|
|
moduleNames := []string{}
|
2019-01-12 16:39:51 +01:00
|
|
|
|
2019-02-05 15:18:47 +01:00
|
|
|
for _, fi := range a.filesInfo {
|
|
|
|
if cc, ok := fi.module.(*cc.Module); ok && cc.Properties.HideFromMake {
|
|
|
|
continue
|
|
|
|
}
|
2019-09-06 10:37:42 +02:00
|
|
|
if a.properties.Flattened && !apexType.image() {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
var suffix string
|
2019-09-17 06:50:45 +02:00
|
|
|
if a.isFlattenedVariant() {
|
2019-09-06 10:37:42 +02:00
|
|
|
suffix = ".flattened"
|
|
|
|
}
|
|
|
|
|
2019-02-05 15:18:47 +01:00
|
|
|
if !android.InList(fi.moduleName, moduleNames) {
|
2019-09-06 10:37:42 +02:00
|
|
|
moduleNames = append(moduleNames, fi.moduleName+suffix)
|
2019-02-05 15:18:47 +01:00
|
|
|
}
|
2019-09-06 10:37:42 +02:00
|
|
|
|
2019-02-05 15:18:47 +01:00
|
|
|
fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
|
|
|
|
fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
|
2019-09-06 10:37:42 +02:00
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE :=", fi.moduleName+suffix)
|
2019-09-19 17:37:20 +02:00
|
|
|
// /apex/<apex_name>/{lib|framework|...}
|
2019-10-08 14:59:58 +02:00
|
|
|
pathWhenActivated := filepath.Join("$(PRODUCT_OUT)", "apex", apexName, fi.installDir)
|
2019-09-06 10:37:42 +02:00
|
|
|
if a.properties.Flattened && apexType.image() {
|
2019-02-05 15:18:47 +01:00
|
|
|
// /system/apex/<name>/{lib|framework|...}
|
2019-10-03 01:01:35 +02:00
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join(a.installDir.ToMakePath().String(),
|
2019-10-08 14:59:58 +02:00
|
|
|
apexName, fi.installDir))
|
2019-09-17 06:50:45 +02:00
|
|
|
if !a.isFlattenedVariant() {
|
2019-09-06 10:37:42 +02:00
|
|
|
fmt.Fprintln(w, "LOCAL_SOONG_SYMBOL_PATH :=", pathWhenActivated)
|
|
|
|
}
|
2019-02-22 22:00:04 +01:00
|
|
|
if len(fi.symlinks) > 0 {
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_SYMLINKS :=", strings.Join(fi.symlinks, " "))
|
|
|
|
}
|
2019-03-18 04:01:38 +01:00
|
|
|
|
|
|
|
if fi.module != nil && fi.module.NoticeFile().Valid() {
|
|
|
|
fmt.Fprintln(w, "LOCAL_NOTICE_FILE :=", fi.module.NoticeFile().Path().String())
|
|
|
|
}
|
2019-02-05 15:18:47 +01:00
|
|
|
} else {
|
2019-03-18 06:26:32 +01:00
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", pathWhenActivated)
|
2019-02-05 15:18:47 +01:00
|
|
|
}
|
|
|
|
fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", fi.builtFile.String())
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_CLASS :=", fi.class.NameInMake())
|
|
|
|
if fi.module != nil {
|
|
|
|
archStr := fi.module.Target().Arch.ArchType.String()
|
|
|
|
host := false
|
|
|
|
switch fi.module.Target().Os.Class {
|
|
|
|
case android.Host:
|
|
|
|
if archStr != "common" {
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_HOST_ARCH :=", archStr)
|
2018-11-07 18:50:25 +01:00
|
|
|
}
|
2019-02-05 15:18:47 +01:00
|
|
|
host = true
|
|
|
|
case android.HostCross:
|
|
|
|
if archStr != "common" {
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_HOST_CROSS_ARCH :=", archStr)
|
2019-01-12 16:39:51 +01:00
|
|
|
}
|
2019-02-05 15:18:47 +01:00
|
|
|
host = true
|
|
|
|
case android.Device:
|
|
|
|
if archStr != "common" {
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_TARGET_ARCH :=", archStr)
|
2019-01-12 16:39:51 +01:00
|
|
|
}
|
2019-02-05 15:18:47 +01:00
|
|
|
}
|
|
|
|
if host {
|
|
|
|
makeOs := fi.module.Target().Os.String()
|
|
|
|
if fi.module.Target().Os == android.Linux || fi.module.Target().Os == android.LinuxBionic {
|
|
|
|
makeOs = "linux"
|
2019-01-11 21:23:36 +01:00
|
|
|
}
|
2019-02-05 15:18:47 +01:00
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_HOST_OS :=", makeOs)
|
|
|
|
fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if fi.class == javaSharedLib {
|
|
|
|
javaModule := fi.module.(*java.Library)
|
|
|
|
// soong_java_prebuilt.mk sets LOCAL_MODULE_SUFFIX := .jar Therefore
|
|
|
|
// we need to remove the suffix from LOCAL_MODULE_STEM, otherwise
|
|
|
|
// we will have foo.jar.jar
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", strings.TrimSuffix(fi.builtFile.Base(), ".jar"))
|
|
|
|
fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", javaModule.ImplementationAndResourcesJars()[0].String())
|
|
|
|
fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", javaModule.HeaderJars()[0].String())
|
|
|
|
fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", fi.builtFile.String())
|
|
|
|
fmt.Fprintln(w, "LOCAL_DEX_PREOPT := false")
|
|
|
|
fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
|
2019-09-10 18:08:24 +02:00
|
|
|
} else if fi.class == nativeSharedLib || fi.class == nativeExecutable || fi.class == nativeTest {
|
2019-02-05 15:18:47 +01:00
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", fi.builtFile.Base())
|
2019-04-10 07:33:58 +02:00
|
|
|
if cc, ok := fi.module.(*cc.Module); ok {
|
|
|
|
if cc.UnstrippedOutputFile() != nil {
|
|
|
|
fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", cc.UnstrippedOutputFile().String())
|
|
|
|
}
|
|
|
|
cc.AndroidMkWriteAdditionalDependenciesForSourceAbiDiff(w)
|
2019-08-09 07:44:36 +02:00
|
|
|
if cc.CoverageOutputFile().Valid() {
|
|
|
|
fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", cc.CoverageOutputFile().String())
|
|
|
|
}
|
2019-02-05 15:18:47 +01:00
|
|
|
}
|
|
|
|
fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_cc_prebuilt.mk")
|
|
|
|
} else {
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", fi.builtFile.Base())
|
|
|
|
fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return moduleNames
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *apexBundle) androidMkForType(apexType apexPackaging) android.AndroidMkData {
|
|
|
|
return android.AndroidMkData{
|
|
|
|
Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
|
|
|
|
moduleNames := []string{}
|
|
|
|
if a.installable() {
|
2019-10-08 14:59:58 +02:00
|
|
|
apexName := proptools.StringDefault(a.properties.Apex_name, name)
|
|
|
|
moduleNames = a.androidMkForFiles(w, apexName, moduleDir, apexType)
|
2019-01-12 16:39:51 +01:00
|
|
|
}
|
2019-02-05 15:18:47 +01:00
|
|
|
|
2019-09-17 06:50:45 +02:00
|
|
|
if a.isFlattenedVariant() {
|
2019-09-06 10:37:42 +02:00
|
|
|
name = name + ".flattened"
|
|
|
|
}
|
|
|
|
|
|
|
|
if a.properties.Flattened && apexType.image() {
|
2019-01-12 16:39:51 +01:00
|
|
|
// Only image APEXes can be flattened.
|
|
|
|
fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
|
|
|
|
fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE :=", name)
|
2019-02-05 15:18:47 +01:00
|
|
|
if len(moduleNames) > 0 {
|
|
|
|
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(moduleNames, " "))
|
|
|
|
}
|
2019-01-12 16:39:51 +01:00
|
|
|
fmt.Fprintln(w, "include $(BUILD_PHONY_PACKAGE)")
|
2019-08-13 15:55:28 +02:00
|
|
|
fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): .KATI_IMPLICIT_OUTPUTS :=", a.flattenedOutput.String())
|
|
|
|
|
2019-09-17 06:50:45 +02:00
|
|
|
} else if !a.isFlattenedVariant() {
|
2018-11-30 02:12:15 +01:00
|
|
|
// zip-apex is the less common type so have the name refer to the image-apex
|
|
|
|
// only and use {name}.zip if you want the zip-apex
|
|
|
|
if apexType == zipApex && a.apexTypes == both {
|
|
|
|
name = name + ".zip"
|
|
|
|
}
|
2018-11-07 18:50:25 +01:00
|
|
|
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") // do we need a new class?
|
2018-11-30 02:12:15 +01:00
|
|
|
fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", a.outputFiles[apexType].String())
|
2019-10-03 01:01:35 +02:00
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", a.installDir.ToMakePath().String())
|
2019-01-03 07:32:27 +01:00
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", name+apexType.suffix())
|
2018-12-13 15:14:57 +01:00
|
|
|
fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !a.installable())
|
2019-02-05 15:18:47 +01:00
|
|
|
if len(moduleNames) > 0 {
|
|
|
|
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(moduleNames, " "))
|
|
|
|
}
|
2019-02-20 13:49:26 +01:00
|
|
|
if len(a.externalDeps) > 0 {
|
|
|
|
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(a.externalDeps, " "))
|
|
|
|
}
|
2019-07-26 16:20:40 +02:00
|
|
|
if a.prebuiltFileToDelete != "" {
|
|
|
|
fmt.Fprintln(w, "LOCAL_POST_INSTALL_CMD :=", "rm -rf "+
|
2019-10-03 01:01:35 +02:00
|
|
|
filepath.Join(a.installDir.ToMakePath().String(), a.prebuiltFileToDelete))
|
2019-07-26 16:20:40 +02:00
|
|
|
}
|
2018-11-07 18:50:25 +01:00
|
|
|
fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
|
2018-11-16 20:36:28 +01:00
|
|
|
|
2018-11-30 02:12:15 +01:00
|
|
|
if apexType == imageApex {
|
|
|
|
fmt.Fprintln(w, "ALL_MODULES.$(LOCAL_MODULE).BUNDLE :=", a.bundleModuleFile.String())
|
|
|
|
}
|
2019-01-12 16:39:51 +01:00
|
|
|
}
|
|
|
|
}}
|
2018-10-10 07:01:00 +02:00
|
|
|
}
|
|
|
|
|
2019-08-23 04:17:39 +02:00
|
|
|
func newApexBundle() *apexBundle {
|
2018-11-30 02:12:15 +01:00
|
|
|
module := &apexBundle{
|
|
|
|
outputFiles: map[apexPackaging]android.WritablePath{},
|
|
|
|
}
|
2018-10-10 07:01:00 +02:00
|
|
|
module.AddProperties(&module.properties)
|
2019-01-30 03:07:33 +01:00
|
|
|
module.AddProperties(&module.targetProperties)
|
2018-11-30 02:12:15 +01:00
|
|
|
module.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool {
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
return class == android.Device && ctx.Config().DevicePrefer32BitExecutables()
|
|
|
|
})
|
2018-11-30 02:12:15 +01:00
|
|
|
android.InitAndroidMultiTargetsArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
|
2018-10-10 07:01:00 +02:00
|
|
|
android.InitDefaultableModule(module)
|
Introduce module type 'sdk'
This change introduces a new module type named 'sdk'. It is a logical
group of prebuilt modules that together provide a context (e.g. APIs)
in which Mainline modules (such as APEXes) are built.
A prebuilt module (e.g. java_import) can join an sdk by adding it to the
sdk module as shown below:
sdk {
name: "mysdk#20",
java_libs: ["myjavalib_mysdk_20"],
}
java_import {
name: "myjavalib_mysdk_20",
srcs: ["myjavalib-v20.jar"],
sdk_member_name: "myjavalib",
}
sdk {
name: "mysdk#21",
java_libs: ["myjavalib_mysdk_21"],
}
java_import {
name: "myjavalib_mysdk_21",
srcs: ["myjavalib-v21.jar"],
sdk_member_name: "myjavalib",
}
java_library {
name: "myjavalib",
srcs: ["**/*/*.java"],
}
An APEX can specify the SDK(s) that it wants to build with via the new
'uses_sdks' property.
apex {
name: "myapex",
java_libs: ["libX", "libY"],
uses_sdks: ["mysdk#20"],
}
With this, libX, libY, and their transitive dependencies are all built
with the version 20 of myjavalib (the first java_import module) instead
of the other one (which is for version 21) and java_library having the
same name (which is for ToT).
Bug: 138182343
Test: m (sdk_test.go added)
Change-Id: I7e14c524a7d6a0d9f575fb20822080f39818c01e
2019-07-17 13:08:41 +02:00
|
|
|
android.InitSdkAwareModule(module)
|
2018-10-10 07:01:00 +02:00
|
|
|
return module
|
|
|
|
}
|
2019-02-07 08:27:23 +01:00
|
|
|
|
2019-08-23 04:17:39 +02:00
|
|
|
func ApexBundleFactory(testApex bool) android.Module {
|
|
|
|
bundle := newApexBundle()
|
|
|
|
bundle.testApex = testApex
|
|
|
|
return bundle
|
|
|
|
}
|
|
|
|
|
|
|
|
func testApexBundleFactory() android.Module {
|
|
|
|
bundle := newApexBundle()
|
|
|
|
bundle.testApex = true
|
|
|
|
return bundle
|
|
|
|
}
|
|
|
|
|
Introduce module type 'sdk'
This change introduces a new module type named 'sdk'. It is a logical
group of prebuilt modules that together provide a context (e.g. APIs)
in which Mainline modules (such as APEXes) are built.
A prebuilt module (e.g. java_import) can join an sdk by adding it to the
sdk module as shown below:
sdk {
name: "mysdk#20",
java_libs: ["myjavalib_mysdk_20"],
}
java_import {
name: "myjavalib_mysdk_20",
srcs: ["myjavalib-v20.jar"],
sdk_member_name: "myjavalib",
}
sdk {
name: "mysdk#21",
java_libs: ["myjavalib_mysdk_21"],
}
java_import {
name: "myjavalib_mysdk_21",
srcs: ["myjavalib-v21.jar"],
sdk_member_name: "myjavalib",
}
java_library {
name: "myjavalib",
srcs: ["**/*/*.java"],
}
An APEX can specify the SDK(s) that it wants to build with via the new
'uses_sdks' property.
apex {
name: "myapex",
java_libs: ["libX", "libY"],
uses_sdks: ["mysdk#20"],
}
With this, libX, libY, and their transitive dependencies are all built
with the version 20 of myjavalib (the first java_import module) instead
of the other one (which is for version 21) and java_library having the
same name (which is for ToT).
Bug: 138182343
Test: m (sdk_test.go added)
Change-Id: I7e14c524a7d6a0d9f575fb20822080f39818c01e
2019-07-17 13:08:41 +02:00
|
|
|
func BundleFactory() android.Module {
|
2019-08-23 04:17:39 +02:00
|
|
|
return newApexBundle()
|
|
|
|
}
|
|
|
|
|
|
|
|
// apex_vndk creates a special variant of apex modules which contains only VNDK libraries.
|
|
|
|
// If `vndk_version` is specified, the VNDK libraries of the specified VNDK version are gathered automatically.
|
|
|
|
// If not specified, then the "current" versions are gathered.
|
|
|
|
func vndkApexBundleFactory() android.Module {
|
|
|
|
bundle := newApexBundle()
|
|
|
|
bundle.vndkApex = true
|
|
|
|
bundle.AddProperties(&bundle.vndkProperties)
|
|
|
|
android.AddLoadHook(bundle, func(ctx android.LoadHookContext) {
|
|
|
|
ctx.AppendProperties(&struct {
|
|
|
|
Compile_multilib *string
|
|
|
|
}{
|
|
|
|
proptools.StringPtr("both"),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return bundle
|
|
|
|
}
|
|
|
|
|
2019-10-07 08:34:50 +02:00
|
|
|
func (a *apexBundle) vndkVersion(config android.DeviceConfig) string {
|
|
|
|
vndkVersion := proptools.StringDefault(a.vndkProperties.Vndk_version, "current")
|
|
|
|
if vndkVersion == "current" {
|
|
|
|
vndkVersion = config.PlatformVndkVersion()
|
|
|
|
}
|
|
|
|
return vndkVersion
|
|
|
|
}
|
|
|
|
|
2019-02-07 08:27:23 +01:00
|
|
|
//
|
|
|
|
// Defaults
|
|
|
|
//
|
|
|
|
type Defaults struct {
|
|
|
|
android.ModuleBase
|
|
|
|
android.DefaultsModuleBase
|
|
|
|
}
|
|
|
|
|
|
|
|
func defaultsFactory() android.Module {
|
|
|
|
return DefaultsFactory()
|
|
|
|
}
|
|
|
|
|
|
|
|
func DefaultsFactory(props ...interface{}) android.Module {
|
|
|
|
module := &Defaults{}
|
|
|
|
|
|
|
|
module.AddProperties(props...)
|
|
|
|
module.AddProperties(
|
|
|
|
&apexBundleProperties{},
|
|
|
|
&apexTargetBundleProperties{},
|
|
|
|
)
|
|
|
|
|
|
|
|
android.InitDefaultsModule(module)
|
|
|
|
return module
|
|
|
|
}
|
2019-03-26 23:07:36 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Prebuilt APEX
|
|
|
|
//
|
|
|
|
type Prebuilt struct {
|
|
|
|
android.ModuleBase
|
|
|
|
prebuilt android.Prebuilt
|
|
|
|
|
|
|
|
properties PrebuiltProperties
|
|
|
|
|
2019-04-04 19:09:48 +02:00
|
|
|
inputApex android.Path
|
2019-10-02 07:05:35 +02:00
|
|
|
installDir android.InstallPath
|
2019-04-04 19:09:48 +02:00
|
|
|
installFilename string
|
2019-04-05 03:10:45 +02:00
|
|
|
outputApex android.WritablePath
|
2019-03-26 23:07:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type PrebuiltProperties struct {
|
|
|
|
// the path to the prebuilt .apex file to import.
|
2019-07-07 05:39:16 +02:00
|
|
|
Source string `blueprint:"mutated"`
|
|
|
|
ForceDisable bool `blueprint:"mutated"`
|
2019-03-29 06:23:10 +01:00
|
|
|
|
|
|
|
Src *string
|
|
|
|
Arch struct {
|
|
|
|
Arm struct {
|
|
|
|
Src *string
|
|
|
|
}
|
|
|
|
Arm64 struct {
|
|
|
|
Src *string
|
|
|
|
}
|
|
|
|
X86 struct {
|
|
|
|
Src *string
|
|
|
|
}
|
|
|
|
X86_64 struct {
|
|
|
|
Src *string
|
|
|
|
}
|
|
|
|
}
|
2019-04-04 14:42:00 +02:00
|
|
|
|
|
|
|
Installable *bool
|
2019-04-04 19:09:48 +02:00
|
|
|
// Optional name for the installed apex. If unspecified, name of the
|
|
|
|
// module is used as the file name
|
|
|
|
Filename *string
|
2019-07-17 03:25:41 +02:00
|
|
|
|
|
|
|
// Names of modules to be overridden. Listed modules can only be other binaries
|
|
|
|
// (in Make or Soong).
|
|
|
|
// This does not completely prevent installation of the overridden binaries, but if both
|
|
|
|
// binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed
|
|
|
|
// from PRODUCT_PACKAGES.
|
|
|
|
Overrides []string
|
2019-04-04 14:42:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Prebuilt) installable() bool {
|
|
|
|
return p.properties.Installable == nil || proptools.Bool(p.properties.Installable)
|
2019-03-26 23:07:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Prebuilt) DepsMutator(ctx android.BottomUpMutatorContext) {
|
2019-07-15 08:31:16 +02:00
|
|
|
// If the device is configured to use flattened APEX, force disable the prebuilt because
|
|
|
|
// the prebuilt is a non-flattened one.
|
|
|
|
forceDisable := ctx.Config().FlattenApex()
|
|
|
|
|
|
|
|
// Force disable the prebuilts when we are doing unbundled build. We do unbundled build
|
|
|
|
// to build the prebuilts themselves.
|
2019-07-17 01:21:36 +02:00
|
|
|
forceDisable = forceDisable || ctx.Config().UnbundledBuild()
|
2019-07-11 04:24:41 +02:00
|
|
|
|
2019-07-30 01:28:57 +02:00
|
|
|
// Force disable the prebuilts when coverage is enabled.
|
|
|
|
forceDisable = forceDisable || ctx.DeviceConfig().NativeCoverageEnabled()
|
|
|
|
forceDisable = forceDisable || ctx.Config().IsEnvTrue("EMMA_INSTRUMENT")
|
|
|
|
|
2019-07-11 04:24:41 +02:00
|
|
|
// b/137216042 don't use prebuilts when address sanitizer is on
|
|
|
|
forceDisable = forceDisable || android.InList("address", ctx.Config().SanitizeDevice()) ||
|
|
|
|
android.InList("hwaddress", ctx.Config().SanitizeDevice())
|
|
|
|
|
|
|
|
if forceDisable && p.prebuilt.SourceExists() {
|
2019-07-07 05:39:16 +02:00
|
|
|
p.properties.ForceDisable = true
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-03-29 06:23:10 +01:00
|
|
|
// This is called before prebuilt_select and prebuilt_postdeps mutators
|
|
|
|
// The mutators requires that src to be set correctly for each arch so that
|
|
|
|
// arch variants are disabled when src is not provided for the arch.
|
|
|
|
if len(ctx.MultiTargets()) != 1 {
|
|
|
|
ctx.ModuleErrorf("compile_multilib shouldn't be \"both\" for prebuilt_apex")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var src string
|
|
|
|
switch ctx.MultiTargets()[0].Arch.ArchType {
|
|
|
|
case android.Arm:
|
|
|
|
src = String(p.properties.Arch.Arm.Src)
|
|
|
|
case android.Arm64:
|
|
|
|
src = String(p.properties.Arch.Arm64.Src)
|
|
|
|
case android.X86:
|
|
|
|
src = String(p.properties.Arch.X86.Src)
|
|
|
|
case android.X86_64:
|
|
|
|
src = String(p.properties.Arch.X86_64.Src)
|
|
|
|
default:
|
|
|
|
ctx.ModuleErrorf("prebuilt_apex does not support %q", ctx.MultiTargets()[0].Arch.String())
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if src == "" {
|
|
|
|
src = String(p.properties.Src)
|
|
|
|
}
|
|
|
|
p.properties.Source = src
|
2019-03-26 23:07:36 +01:00
|
|
|
}
|
|
|
|
|
2019-07-26 16:20:40 +02:00
|
|
|
func (p *Prebuilt) isForceDisabled() bool {
|
|
|
|
return p.properties.ForceDisable
|
|
|
|
}
|
|
|
|
|
2019-05-29 23:40:35 +02:00
|
|
|
func (p *Prebuilt) OutputFiles(tag string) (android.Paths, error) {
|
|
|
|
switch tag {
|
|
|
|
case "":
|
|
|
|
return android.Paths{p.outputApex}, nil
|
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("unsupported module reference tag %q", tag)
|
|
|
|
}
|
2019-04-05 03:10:45 +02:00
|
|
|
}
|
|
|
|
|
2019-04-23 11:00:10 +02:00
|
|
|
func (p *Prebuilt) InstallFilename() string {
|
|
|
|
return proptools.StringDefault(p.properties.Filename, p.BaseModuleName()+imageApexSuffix)
|
|
|
|
}
|
|
|
|
|
2019-03-26 23:07:36 +01:00
|
|
|
func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
2019-07-07 05:39:16 +02:00
|
|
|
if p.properties.ForceDisable {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-03-26 23:07:36 +01:00
|
|
|
// TODO(jungjw): Check the key validity.
|
2019-03-29 06:23:10 +01:00
|
|
|
p.inputApex = p.Prebuilt().SingleSourcePath(ctx)
|
2019-03-26 23:07:36 +01:00
|
|
|
p.installDir = android.PathForModuleInstall(ctx, "apex")
|
2019-04-23 11:00:10 +02:00
|
|
|
p.installFilename = p.InstallFilename()
|
2019-04-04 19:09:48 +02:00
|
|
|
if !strings.HasSuffix(p.installFilename, imageApexSuffix) {
|
|
|
|
ctx.ModuleErrorf("filename should end in %s for prebuilt_apex", imageApexSuffix)
|
|
|
|
}
|
2019-04-05 03:10:45 +02:00
|
|
|
p.outputApex = android.PathForModuleOut(ctx, p.installFilename)
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: android.Cp,
|
|
|
|
Input: p.inputApex,
|
|
|
|
Output: p.outputApex,
|
|
|
|
})
|
2019-04-04 14:42:00 +02:00
|
|
|
if p.installable() {
|
2019-04-04 19:09:48 +02:00
|
|
|
ctx.InstallFile(p.installDir, p.installFilename, p.inputApex)
|
2019-04-04 14:42:00 +02:00
|
|
|
}
|
2019-03-26 23:07:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Prebuilt) Prebuilt() *android.Prebuilt {
|
|
|
|
return &p.prebuilt
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Prebuilt) Name() string {
|
|
|
|
return p.prebuilt.Name(p.ModuleBase.Name())
|
|
|
|
}
|
|
|
|
|
2019-07-17 03:25:41 +02:00
|
|
|
func (p *Prebuilt) AndroidMkEntries() android.AndroidMkEntries {
|
|
|
|
return android.AndroidMkEntries{
|
2019-03-26 23:07:36 +01:00
|
|
|
Class: "ETC",
|
|
|
|
OutputFile: android.OptionalPathForPath(p.inputApex),
|
|
|
|
Include: "$(BUILD_PREBUILT)",
|
2019-08-28 02:33:16 +02:00
|
|
|
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
|
|
|
|
func(entries *android.AndroidMkEntries) {
|
2019-10-03 01:01:35 +02:00
|
|
|
entries.SetString("LOCAL_MODULE_PATH", p.installDir.ToMakePath().String())
|
2019-08-28 02:33:16 +02:00
|
|
|
entries.SetString("LOCAL_MODULE_STEM", p.installFilename)
|
|
|
|
entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.installable())
|
|
|
|
entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", p.properties.Overrides...)
|
|
|
|
},
|
2019-03-26 23:07:36 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// prebuilt_apex imports an `.apex` file into the build graph as if it was built with apex.
|
|
|
|
func PrebuiltFactory() android.Module {
|
|
|
|
module := &Prebuilt{}
|
|
|
|
module.AddProperties(&module.properties)
|
2019-06-11 21:25:34 +02:00
|
|
|
android.InitSingleSourcePrebuiltModule(module, &module.properties, "Source")
|
2019-03-29 06:23:10 +01:00
|
|
|
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
|
2019-03-26 23:07:36 +01:00
|
|
|
return module
|
|
|
|
}
|