2018-10-10 13:01:00 +08: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 13:05:29 +08:00
|
|
|
"sort"
|
2018-10-10 13:01:00 +08:00
|
|
|
"strings"
|
|
|
|
|
|
|
|
"android/soong/android"
|
|
|
|
"android/soong/cc"
|
|
|
|
"android/soong/java"
|
|
|
|
|
|
|
|
"github.com/google/blueprint"
|
|
|
|
"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 19:50:42 +08:00
|
|
|
Command: `echo '/ 1000 1000 0755' > ${out} && ` +
|
2018-10-10 13:01:00 +08:00
|
|
|
`echo '/manifest.json 1000 1000 0644' >> ${out} && ` +
|
2018-10-11 12:23:09 +08:00
|
|
|
`echo ${ro_paths} | tr ' ' '\n' | awk '{print "/"$$1 " 1000 1000 0644"}' >> ${out} && ` +
|
|
|
|
`echo ${exec_paths} | tr ' ' '\n' | awk '{print "/"$$1 " 1000 1000 0755"}' >> ${out}`,
|
2018-10-10 13:01:00 +08:00
|
|
|
Description: "fs_config ${out}",
|
2018-10-11 12:23:09 +08:00
|
|
|
}, "ro_paths", "exec_paths")
|
2018-10-10 13:01:00 +08: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} && ` +
|
|
|
|
`(${copy_commands}) && ` +
|
|
|
|
`APEXER_TOOL_PATH=${tool_path} ` +
|
|
|
|
`${apexer} --verbose --force --manifest ${manifest} ` +
|
|
|
|
`--file_contexts ${file_contexts} ` +
|
|
|
|
`--canned_fs_config ${canned_fs_config} ` +
|
|
|
|
`--key ${key} ${image_dir} ${out} `,
|
|
|
|
CommandDeps: []string{"${apexer}", "${avbtool}", "${e2fsdroid}", "${merge_zips}",
|
|
|
|
"${mke2fs}", "${resize2fs}", "${sefcontext_compile}",
|
|
|
|
"${soong_zip}", "${zipalign}", "${aapt2}"},
|
|
|
|
Description: "APEX ${image_dir} => ${out}",
|
|
|
|
}, "tool_path", "image_dir", "copy_commands", "manifest", "file_contexts", "canned_fs_config", "key")
|
|
|
|
)
|
|
|
|
|
|
|
|
var apexSuffix = ".apex"
|
|
|
|
|
|
|
|
type dependencyTag struct {
|
|
|
|
blueprint.BaseDependencyTag
|
|
|
|
name string
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
2018-10-30 20:20:05 +08:00
|
|
|
sharedLibTag = dependencyTag{name: "sharedLib"}
|
|
|
|
executableTag = dependencyTag{name: "executable"}
|
|
|
|
javaLibTag = dependencyTag{name: "javaLib"}
|
|
|
|
prebuiltTag = dependencyTag{name: "prebuilt"}
|
|
|
|
keyTag = dependencyTag{name: "key"}
|
|
|
|
certificateTag = dependencyTag{name: "certificate"}
|
2018-10-10 13:01:00 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
pctx.Import("android/soong/common")
|
2018-10-30 20:20:05 +08:00
|
|
|
pctx.Import("android/soong/java")
|
2018-10-10 13:01:00 +08:00
|
|
|
pctx.HostBinToolVariable("apexer", "apexer")
|
2018-10-06 02:34:32 +08: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 {
|
|
|
|
if !android.ExistentPathForSource(ctx, "frameworks/base").Valid() {
|
|
|
|
return filepath.Join(prebuiltDir, runtime.GOOS, "bin", tool)
|
|
|
|
} else {
|
|
|
|
return pctx.HostBinToolPath(ctx, tool).String()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
hostBinToolVariableWithPrebuilt("aapt2", "prebuilts/sdk/tools", "aapt2")
|
2018-10-10 13:01:00 +08: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")
|
|
|
|
pctx.HostBinToolVariable("zipalign", "zipalign")
|
|
|
|
|
|
|
|
android.RegisterModuleType("apex", apexBundleFactory)
|
|
|
|
|
|
|
|
android.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
|
|
|
ctx.TopDown("apex_deps", apexDepsMutator)
|
|
|
|
ctx.BottomUp("apex", apexMutator)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// maps a module name to set of apex bundle names that the module should be built for
|
|
|
|
func apexBundleNamesFor(config android.Config) map[string]map[string]bool {
|
|
|
|
return config.Once("apexBundleNames", func() interface{} {
|
|
|
|
return make(map[string]map[string]bool)
|
|
|
|
}).(map[string]map[string]bool)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mark the direct and transitive dependencies of apex bundles so that they
|
|
|
|
// can be built for the apex bundles.
|
|
|
|
func apexDepsMutator(mctx android.TopDownMutatorContext) {
|
|
|
|
if _, ok := mctx.Module().(*apexBundle); ok {
|
|
|
|
apexBundleName := mctx.Module().Name()
|
|
|
|
mctx.WalkDeps(func(child, parent android.Module) bool {
|
|
|
|
if am, ok := child.(android.ApexModule); ok && am.CanHaveApexVariants() {
|
arch-specific dependencies are correctly handled in apex
The change fixes the problem that multiple APEXs having native component
(shared lib or executable) can't be built with an error similar to this:
error: bionic/linker/Android.bp:298:1: failed to find variation "com.android.art" for module "libclang_rt.builtins-aarch64-android" needed by "ld-android"
This is happening because the dependency to the built-in library is
arch-specific but apex.go ignores it. Specifically, let's assume that
32-bit variant of libFoo depends on libX while 64-bit variant of libFoo
depends on libY. Also assume that libFoo is included in two APEXs: apex1
(which is 64-bit) and apex2 (which is 32-bit). Then apexDepsMutator
records that libFoo shall be split into apex1 and apex2, while libX will
be only split into apex1 and libY will be split into apex2.
The problem is that, during apexMutator, both 32 and 64-bit varants of
libFoo are split into apex1 and apex2. As a result, a dependency to
apex2 variant of libX and a dependency to apex1 variant of libY are
requested, which don't exist.
Fixing this issue by using module's name AND target string as the key.
So, only the 32-bit variant of libFoo is split into apex1 and 64-bit
variant of libFoo is split into apex2.
Test: have following module somewhere. `m` is successful.
apex {
name: "com.android.art",
manifest: "manifest.json",
file_contexts: "file_contexts",
binaries: ["dex2oat"],
key: "apex.test.key",
target: {
android: {
// Prefer the 32-bit versions of these binaries.
compile_multilib: "prefer32",
},
},
}
Change-Id: I562b7be8e7c0325bd8d728dbee2ddcae608c181a
2018-10-23 22:58:01 +08:00
|
|
|
moduleName := am.Name() + "-" + am.Target().String()
|
2018-10-10 13:01:00 +08:00
|
|
|
bundleNames, ok := apexBundleNamesFor(mctx.Config())[moduleName]
|
|
|
|
if !ok {
|
|
|
|
bundleNames = make(map[string]bool)
|
|
|
|
apexBundleNamesFor(mctx.Config())[moduleName] = bundleNames
|
|
|
|
}
|
|
|
|
bundleNames[apexBundleName] = true
|
|
|
|
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() {
|
arch-specific dependencies are correctly handled in apex
The change fixes the problem that multiple APEXs having native component
(shared lib or executable) can't be built with an error similar to this:
error: bionic/linker/Android.bp:298:1: failed to find variation "com.android.art" for module "libclang_rt.builtins-aarch64-android" needed by "ld-android"
This is happening because the dependency to the built-in library is
arch-specific but apex.go ignores it. Specifically, let's assume that
32-bit variant of libFoo depends on libX while 64-bit variant of libFoo
depends on libY. Also assume that libFoo is included in two APEXs: apex1
(which is 64-bit) and apex2 (which is 32-bit). Then apexDepsMutator
records that libFoo shall be split into apex1 and apex2, while libX will
be only split into apex1 and libY will be split into apex2.
The problem is that, during apexMutator, both 32 and 64-bit varants of
libFoo are split into apex1 and apex2. As a result, a dependency to
apex2 variant of libX and a dependency to apex1 variant of libY are
requested, which don't exist.
Fixing this issue by using module's name AND target string as the key.
So, only the 32-bit variant of libFoo is split into apex1 and 64-bit
variant of libFoo is split into apex2.
Test: have following module somewhere. `m` is successful.
apex {
name: "com.android.art",
manifest: "manifest.json",
file_contexts: "file_contexts",
binaries: ["dex2oat"],
key: "apex.test.key",
target: {
android: {
// Prefer the 32-bit versions of these binaries.
compile_multilib: "prefer32",
},
},
}
Change-Id: I562b7be8e7c0325bd8d728dbee2ddcae608c181a
2018-10-23 22:58:01 +08:00
|
|
|
moduleName := am.Name() + "-" + am.Target().String()
|
2018-10-10 13:01:00 +08:00
|
|
|
if bundleNames, ok := apexBundleNamesFor(mctx.Config())[moduleName]; ok {
|
|
|
|
variations := []string{"platform"}
|
|
|
|
for bn := range bundleNames {
|
|
|
|
variations = append(variations, bn)
|
|
|
|
}
|
|
|
|
modules := mctx.CreateVariations(variations...)
|
|
|
|
for i, m := range modules {
|
|
|
|
if i == 0 {
|
|
|
|
continue // platform
|
|
|
|
}
|
|
|
|
m.(android.ApexModule).BuildForApex(variations[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if _, ok := mctx.Module().(*apexBundle); ok {
|
|
|
|
// apex bundle itself is mutated so that it and its modules have same
|
|
|
|
// apex variant.
|
|
|
|
apexBundleName := mctx.ModuleName()
|
|
|
|
mctx.CreateVariations(apexBundleName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type apexBundleProperties struct {
|
|
|
|
// Json manifest file describing meta info of this APEX bundle. Default:
|
|
|
|
// "manifest.json"
|
|
|
|
Manifest *string
|
|
|
|
|
2018-11-10 05:37:15 +08: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 13:01:00 +08:00
|
|
|
File_contexts *string
|
|
|
|
|
|
|
|
// List of native shared libs that are embedded inside this APEX bundle
|
|
|
|
Native_shared_libs []string
|
|
|
|
|
|
|
|
// List of native executables that are embedded inside this APEX bundle
|
|
|
|
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 20:49:38 +08: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 20:09:55 +08:00
|
|
|
|
2018-10-30 20:20:05 +08: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
|
|
|
|
|
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 20:09:55 +08:00
|
|
|
Multilib struct {
|
|
|
|
First struct {
|
|
|
|
// List of native libraries whose compile_multilib is "first"
|
|
|
|
Native_shared_libs []string
|
|
|
|
// List of native executables whose compile_multilib is "first"
|
|
|
|
Binaries []string
|
|
|
|
}
|
|
|
|
Both struct {
|
|
|
|
// List of native libraries whose compile_multilib is "both"
|
|
|
|
Native_shared_libs []string
|
|
|
|
// List of native executables whose compile_multilib is "both"
|
|
|
|
Binaries []string
|
|
|
|
}
|
|
|
|
Prefer32 struct {
|
|
|
|
// List of native libraries whose compile_multilib is "prefer32"
|
|
|
|
Native_shared_libs []string
|
|
|
|
// List of native executables whose compile_multilib is "prefer32"
|
|
|
|
Binaries []string
|
|
|
|
}
|
|
|
|
Lib32 struct {
|
|
|
|
// List of native libraries whose compile_multilib is "32"
|
|
|
|
Native_shared_libs []string
|
|
|
|
// List of native executables whose compile_multilib is "32"
|
|
|
|
Binaries []string
|
|
|
|
}
|
|
|
|
Lib64 struct {
|
|
|
|
// List of native libraries whose compile_multilib is "64"
|
|
|
|
Native_shared_libs []string
|
|
|
|
// List of native executables whose compile_multilib is "64"
|
|
|
|
Binaries []string
|
|
|
|
}
|
|
|
|
}
|
2018-10-10 13:01:00 +08:00
|
|
|
}
|
|
|
|
|
2018-11-08 01:50:25 +08:00
|
|
|
type apexFileClass int
|
|
|
|
|
|
|
|
const (
|
|
|
|
etc apexFileClass = iota
|
|
|
|
nativeSharedLib
|
|
|
|
nativeExecutable
|
|
|
|
javaSharedLib
|
|
|
|
)
|
|
|
|
|
|
|
|
func (class apexFileClass) NameInMake() string {
|
|
|
|
switch class {
|
|
|
|
case etc:
|
|
|
|
return "ETC"
|
|
|
|
case nativeSharedLib:
|
|
|
|
return "SHARED_LIBRARIES"
|
|
|
|
case nativeExecutable:
|
|
|
|
return "EXECUTABLES"
|
|
|
|
case javaSharedLib:
|
|
|
|
return "JAVA_LIBRARIES"
|
|
|
|
default:
|
|
|
|
panic(fmt.Errorf("unkonwn class %d", class))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type apexFile struct {
|
|
|
|
builtFile android.Path
|
|
|
|
moduleName string
|
|
|
|
archType android.ArchType
|
|
|
|
installDir string
|
|
|
|
class apexFileClass
|
|
|
|
}
|
|
|
|
|
2018-10-10 13:01:00 +08:00
|
|
|
type apexBundle struct {
|
|
|
|
android.ModuleBase
|
|
|
|
android.DefaultableModuleBase
|
|
|
|
|
|
|
|
properties apexBundleProperties
|
|
|
|
|
|
|
|
outputFile android.WritablePath
|
|
|
|
installDir android.OutputPath
|
2018-11-08 01:50:25 +08:00
|
|
|
|
|
|
|
// list of files to be included in this apex
|
|
|
|
filesInfo []apexFile
|
|
|
|
|
|
|
|
flattened bool
|
2018-10-10 13:01:00 +08: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 20:09:55 +08:00
|
|
|
func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,
|
|
|
|
native_shared_libs []string, binaries []string, arch string) {
|
|
|
|
// 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},
|
|
|
|
{Mutator: "image", Variation: "core"},
|
|
|
|
{Mutator: "link", Variation: "shared"},
|
|
|
|
}, sharedLibTag, native_shared_libs...)
|
|
|
|
|
|
|
|
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "arch", Variation: arch},
|
|
|
|
{Mutator: "image", Variation: "core"},
|
|
|
|
}, executableTag, binaries...)
|
|
|
|
}
|
|
|
|
|
2018-10-10 13:01:00 +08: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 20:09:55 +08:00
|
|
|
targets := ctx.MultiTargets()
|
|
|
|
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 13:01:00 +08: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 20:09:55 +08:00
|
|
|
{Mutator: "arch", Variation: target.String()},
|
2018-10-10 13:01:00 +08:00
|
|
|
{Mutator: "image", Variation: "core"},
|
|
|
|
{Mutator: "link", Variation: "shared"},
|
|
|
|
}, sharedLibTag, a.properties.Native_shared_libs...)
|
|
|
|
|
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 20:09:55 +08:00
|
|
|
// Add native modules targetting both ABIs
|
|
|
|
addDependenciesForNativeModules(ctx,
|
|
|
|
a.properties.Multilib.Both.Native_shared_libs,
|
|
|
|
a.properties.Multilib.Both.Binaries, target.String())
|
|
|
|
|
|
|
|
if i == 0 {
|
|
|
|
// When multilib.* is omitted for binaries, it implies
|
|
|
|
// multilib.first.
|
|
|
|
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "arch", Variation: target.String()},
|
|
|
|
{Mutator: "image", Variation: "core"},
|
|
|
|
}, executableTag, a.properties.Binaries...)
|
|
|
|
|
|
|
|
// Add native modules targetting the first ABI
|
|
|
|
addDependenciesForNativeModules(ctx,
|
|
|
|
a.properties.Multilib.First.Native_shared_libs,
|
|
|
|
a.properties.Multilib.First.Binaries, target.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
switch target.Arch.ArchType.Multilib {
|
|
|
|
case "lib32":
|
|
|
|
// Add native modules targetting 32-bit ABI
|
|
|
|
addDependenciesForNativeModules(ctx,
|
|
|
|
a.properties.Multilib.Lib32.Native_shared_libs,
|
|
|
|
a.properties.Multilib.Lib32.Binaries, target.String())
|
|
|
|
|
|
|
|
addDependenciesForNativeModules(ctx,
|
|
|
|
a.properties.Multilib.Prefer32.Native_shared_libs,
|
|
|
|
a.properties.Multilib.Prefer32.Binaries, target.String())
|
|
|
|
case "lib64":
|
|
|
|
// Add native modules targetting 64-bit ABI
|
|
|
|
addDependenciesForNativeModules(ctx,
|
|
|
|
a.properties.Multilib.Lib64.Native_shared_libs,
|
|
|
|
a.properties.Multilib.Lib64.Binaries, target.String())
|
|
|
|
|
|
|
|
if !has32BitTarget {
|
|
|
|
addDependenciesForNativeModules(ctx,
|
|
|
|
a.properties.Multilib.Prefer32.Native_shared_libs,
|
|
|
|
a.properties.Multilib.Prefer32.Binaries, target.String())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-12 20:49:38 +08:00
|
|
|
}
|
2018-10-10 13:01:00 +08:00
|
|
|
|
2018-10-12 20:49:38 +08:00
|
|
|
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "arch", Variation: "android_common"},
|
|
|
|
}, javaLibTag, a.properties.Java_libs...)
|
2018-10-10 13:01:00 +08:00
|
|
|
|
2018-10-12 20:49:38 +08:00
|
|
|
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "arch", Variation: "android_common"},
|
|
|
|
}, prebuiltTag, a.properties.Prebuilts...)
|
2018-10-10 13:01:00 +08:00
|
|
|
|
2018-10-12 20:49:38 +08:00
|
|
|
if String(a.properties.Key) == "" {
|
|
|
|
ctx.ModuleErrorf("key is missing")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
ctx.AddDependency(ctx.Module(), keyTag, String(a.properties.Key))
|
2018-10-30 20:20:05 +08:00
|
|
|
|
|
|
|
cert := android.SrcIsModule(String(a.properties.Certificate))
|
|
|
|
if cert != "" {
|
|
|
|
ctx.AddDependency(ctx.Module(), certificateTag, cert)
|
|
|
|
}
|
2018-10-10 13:01:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func getCopyManifestForNativeLibrary(cc *cc.Module) (fileToCopy android.Path, dirInApex string) {
|
|
|
|
// Decide the APEX-local directory by the multilib of the library
|
|
|
|
// In the future, we may query this to the module.
|
|
|
|
switch cc.Arch().ArchType.Multilib {
|
|
|
|
case "lib32":
|
|
|
|
dirInApex = "lib"
|
|
|
|
case "lib64":
|
|
|
|
dirInApex = "lib64"
|
|
|
|
}
|
|
|
|
if !cc.Arch().Native {
|
|
|
|
dirInApex = filepath.Join(dirInApex, cc.Arch().ArchType.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
fileToCopy = cc.OutputFile().Path()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func getCopyManifestForExecutable(cc *cc.Module) (fileToCopy android.Path, dirInApex string) {
|
|
|
|
dirInApex = "bin"
|
|
|
|
fileToCopy = cc.OutputFile().Path()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func getCopyManifestForJavaLibrary(java *java.Library) (fileToCopy android.Path, dirInApex string) {
|
|
|
|
dirInApex = "javalib"
|
2018-11-08 01:50:25 +08:00
|
|
|
fileToCopy = java.DexJarFile()
|
2018-10-10 13:01:00 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func getCopyManifestForPrebuiltEtc(prebuilt *android.PrebuiltEtc) (fileToCopy android.Path, dirInApex string) {
|
|
|
|
dirInApex = filepath.Join("etc", prebuilt.SubDir())
|
|
|
|
fileToCopy = prebuilt.OutputFile()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
2018-11-08 01:50:25 +08:00
|
|
|
filesInfo := []apexFile{}
|
2018-10-10 13:01:00 +08:00
|
|
|
|
2018-10-12 20:49:38 +08:00
|
|
|
var keyFile android.Path
|
2018-10-30 20:20:05 +08:00
|
|
|
var certificate java.Certificate
|
2018-10-12 20:49:38 +08:00
|
|
|
|
2018-10-10 13:01:00 +08:00
|
|
|
ctx.WalkDeps(func(child, parent android.Module) bool {
|
|
|
|
if _, ok := parent.(*apexBundle); ok {
|
|
|
|
// direct dependencies
|
|
|
|
depTag := ctx.OtherModuleDependencyTag(child)
|
2018-10-12 20:49:38 +08:00
|
|
|
depName := ctx.OtherModuleName(child)
|
2018-10-10 13:01:00 +08:00
|
|
|
switch depTag {
|
|
|
|
case sharedLibTag:
|
|
|
|
if cc, ok := child.(*cc.Module); ok {
|
|
|
|
fileToCopy, dirInApex := getCopyManifestForNativeLibrary(cc)
|
2018-11-08 01:50:25 +08:00
|
|
|
filesInfo = append(filesInfo, apexFile{fileToCopy, depName, cc.Arch().ArchType, dirInApex, nativeSharedLib})
|
2018-10-10 13:01:00 +08:00
|
|
|
return true
|
2018-10-12 20:49:38 +08:00
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("native_shared_libs", "%q is not a cc_library or cc_library_shared module", depName)
|
2018-10-10 13:01:00 +08:00
|
|
|
}
|
|
|
|
case executableTag:
|
|
|
|
if cc, ok := child.(*cc.Module); ok {
|
|
|
|
fileToCopy, dirInApex := getCopyManifestForExecutable(cc)
|
2018-11-08 01:50:25 +08:00
|
|
|
filesInfo = append(filesInfo, apexFile{fileToCopy, depName, cc.Arch().ArchType, dirInApex, nativeExecutable})
|
2018-10-10 13:01:00 +08:00
|
|
|
return true
|
2018-10-12 20:49:38 +08:00
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("binaries", "%q is not a cc_binary module", depName)
|
2018-10-10 13:01:00 +08:00
|
|
|
}
|
|
|
|
case javaLibTag:
|
|
|
|
if java, ok := child.(*java.Library); ok {
|
|
|
|
fileToCopy, dirInApex := getCopyManifestForJavaLibrary(java)
|
2018-11-08 01:50:25 +08:00
|
|
|
if fileToCopy == nil {
|
|
|
|
ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
|
|
|
|
} else {
|
|
|
|
filesInfo = append(filesInfo, apexFile{fileToCopy, depName, java.Arch().ArchType, dirInApex, javaSharedLib})
|
|
|
|
}
|
2018-10-10 13:01:00 +08:00
|
|
|
return true
|
2018-10-12 20:49:38 +08:00
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("java_libs", "%q is not a java_library module", depName)
|
2018-10-10 13:01:00 +08:00
|
|
|
}
|
|
|
|
case prebuiltTag:
|
|
|
|
if prebuilt, ok := child.(*android.PrebuiltEtc); ok {
|
|
|
|
fileToCopy, dirInApex := getCopyManifestForPrebuiltEtc(prebuilt)
|
2018-11-08 01:50:25 +08:00
|
|
|
filesInfo = append(filesInfo, apexFile{fileToCopy, depName, prebuilt.Arch().ArchType, dirInApex, etc})
|
2018-10-10 13:01:00 +08:00
|
|
|
return true
|
2018-10-12 20:49:38 +08:00
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc module", depName)
|
|
|
|
}
|
|
|
|
case keyTag:
|
|
|
|
if key, ok := child.(*apexKey); ok {
|
|
|
|
keyFile = key.private_key_file
|
|
|
|
return false
|
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("key", "%q is not an apex_key module", depName)
|
2018-10-10 13:01:00 +08:00
|
|
|
}
|
2018-10-30 20:20:05 +08:00
|
|
|
case certificateTag:
|
|
|
|
if dep, ok := child.(*java.AndroidAppCertificate); ok {
|
|
|
|
certificate = dep.Certificate
|
|
|
|
return false
|
|
|
|
} else {
|
|
|
|
ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName)
|
|
|
|
}
|
2018-10-10 13:01:00 +08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// indirect dependencies
|
|
|
|
if am, ok := child.(android.ApexModule); ok && am.CanHaveApexVariants() && am.IsInstallableToApex() {
|
|
|
|
if cc, ok := child.(*cc.Module); ok {
|
2018-11-08 01:50:25 +08:00
|
|
|
depName := ctx.OtherModuleName(child)
|
2018-10-10 13:01:00 +08:00
|
|
|
fileToCopy, dirInApex := getCopyManifestForNativeLibrary(cc)
|
2018-11-08 01:50:25 +08:00
|
|
|
filesInfo = append(filesInfo, apexFile{fileToCopy, depName, cc.Arch().ArchType, dirInApex, nativeSharedLib})
|
2018-10-10 13:01:00 +08:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
})
|
|
|
|
|
2018-11-09 04:52:26 +08:00
|
|
|
if keyFile == nil {
|
|
|
|
ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-11-08 01:50:25 +08:00
|
|
|
// remove duplicates in filesInfo
|
|
|
|
removeDup := func(filesInfo []apexFile) []apexFile {
|
|
|
|
encountered := make(map[android.Path]bool)
|
|
|
|
result := []apexFile{}
|
|
|
|
for _, f := range filesInfo {
|
|
|
|
if !encountered[f.builtFile] {
|
|
|
|
encountered[f.builtFile] = true
|
|
|
|
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()
|
|
|
|
})
|
|
|
|
|
|
|
|
// 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 {
|
|
|
|
filesInfo[i].moduleName = ctx.ModuleName() + "." + filesInfo[i].moduleName
|
|
|
|
}
|
|
|
|
|
|
|
|
a.flattened = ctx.Config().FlattenApex()
|
|
|
|
a.installDir = android.PathForModuleInstall(ctx, "apex")
|
|
|
|
a.filesInfo = filesInfo
|
|
|
|
if ctx.Config().FlattenApex() {
|
|
|
|
a.buildFlattenedApex(ctx)
|
|
|
|
} else {
|
|
|
|
a.buildUnflattenedApex(ctx, keyFile, certificate)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext, keyFile android.Path, certificate java.Certificate) {
|
2018-10-30 20:20:05 +08:00
|
|
|
cert := String(a.properties.Certificate)
|
|
|
|
if cert != "" && android.SrcIsModule(cert) == "" {
|
|
|
|
defaultDir := ctx.Config().DefaultAppCertificateDir(ctx)
|
|
|
|
certificate = java.Certificate{
|
|
|
|
defaultDir.Join(ctx, cert+".x509.pem"),
|
|
|
|
defaultDir.Join(ctx, cert+".pk8"),
|
|
|
|
}
|
|
|
|
} else if cert == "" {
|
|
|
|
pem, key := ctx.Config().DefaultAppCertificate(ctx)
|
|
|
|
certificate = java.Certificate{pem, key}
|
|
|
|
}
|
|
|
|
|
2018-10-10 13:01:00 +08:00
|
|
|
// files and dirs that will be created in apex
|
2018-10-11 12:23:09 +08:00
|
|
|
var readOnlyPaths []string
|
|
|
|
var executablePaths []string // this also includes dirs
|
2018-11-08 01:50:25 +08:00
|
|
|
for _, f := range a.filesInfo {
|
|
|
|
pathInApex := filepath.Join(f.installDir, f.builtFile.Base())
|
|
|
|
if f.installDir == "bin" {
|
2018-10-11 12:23:09 +08:00
|
|
|
executablePaths = append(executablePaths, pathInApex)
|
|
|
|
} else {
|
|
|
|
readOnlyPaths = append(readOnlyPaths, pathInApex)
|
|
|
|
}
|
2018-11-08 01:50:25 +08:00
|
|
|
if !android.InList(f.installDir, executablePaths) {
|
|
|
|
executablePaths = append(executablePaths, f.installDir)
|
2018-10-10 13:01:00 +08:00
|
|
|
}
|
|
|
|
}
|
2018-10-11 12:23:09 +08:00
|
|
|
sort.Strings(readOnlyPaths)
|
|
|
|
sort.Strings(executablePaths)
|
2018-10-10 13:01:00 +08:00
|
|
|
cannedFsConfig := android.PathForModuleOut(ctx, "canned_fs_config")
|
|
|
|
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
|
|
|
Rule: generateFsConfig,
|
|
|
|
Output: cannedFsConfig,
|
|
|
|
Args: map[string]string{
|
2018-10-11 12:23:09 +08:00
|
|
|
"ro_paths": strings.Join(readOnlyPaths, " "),
|
|
|
|
"exec_paths": strings.Join(executablePaths, " "),
|
2018-10-10 13:01:00 +08:00
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
manifest := android.PathForModuleSrc(ctx, proptools.StringDefault(a.properties.Manifest, "manifest.json"))
|
2018-11-10 05:37:15 +08:00
|
|
|
|
|
|
|
fcName := proptools.StringDefault(a.properties.File_contexts, a.ModuleBase.Name())
|
2018-11-14 12:54:14 +08:00
|
|
|
fileContextsPath := "system/sepolicy/apex/" + fcName + "-file_contexts"
|
2018-11-10 05:37:15 +08:00
|
|
|
fileContextsOptionalPath := android.ExistentPathForSource(ctx, fileContextsPath)
|
|
|
|
if !fileContextsOptionalPath.Valid() {
|
|
|
|
ctx.ModuleErrorf("Cannot find file_contexts file: %q", fileContextsPath)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
fileContexts := fileContextsOptionalPath.Path()
|
2018-10-10 13:01:00 +08:00
|
|
|
|
2018-10-30 20:20:05 +08:00
|
|
|
unsignedOutputFile := android.PathForModuleOut(ctx, a.ModuleBase.Name()+apexSuffix+".unsigned")
|
2018-10-10 13:01:00 +08:00
|
|
|
|
2018-10-10 13:05:29 +08:00
|
|
|
filesToCopy := []android.Path{}
|
2018-11-08 01:50:25 +08:00
|
|
|
for _, f := range a.filesInfo {
|
|
|
|
filesToCopy = append(filesToCopy, f.builtFile)
|
2018-10-10 13:01:00 +08:00
|
|
|
}
|
2018-10-10 13:05:29 +08:00
|
|
|
|
2018-10-10 13:01:00 +08:00
|
|
|
copyCommands := []string{}
|
2018-11-08 01:50:25 +08:00
|
|
|
for i, src := range filesToCopy {
|
|
|
|
dest := filepath.Join(a.filesInfo[i].installDir, src.Base())
|
2018-10-10 13:01:00 +08:00
|
|
|
dest_path := filepath.Join(android.PathForModuleOut(ctx, "image").String(), dest)
|
|
|
|
copyCommands = append(copyCommands, "mkdir -p "+filepath.Dir(dest_path))
|
|
|
|
copyCommands = append(copyCommands, "cp "+src.String()+" "+dest_path)
|
|
|
|
}
|
2018-10-10 13:05:29 +08:00
|
|
|
implicitInputs := append(android.Paths(nil), filesToCopy...)
|
2018-10-12 20:49:38 +08:00
|
|
|
implicitInputs = append(implicitInputs, cannedFsConfig, manifest, fileContexts, keyFile)
|
2018-10-10 13:01:00 +08:00
|
|
|
outHostBinDir := android.PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "bin").String()
|
|
|
|
prebuiltSdkToolsBinDir := filepath.Join("prebuilts", "sdk", "tools", runtime.GOOS, "bin")
|
|
|
|
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
|
|
|
Rule: apexRule,
|
|
|
|
Implicits: implicitInputs,
|
2018-10-30 20:20:05 +08:00
|
|
|
Output: unsignedOutputFile,
|
2018-10-10 13:01:00 +08:00
|
|
|
Args: map[string]string{
|
|
|
|
"tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir,
|
|
|
|
"image_dir": android.PathForModuleOut(ctx, "image").String(),
|
|
|
|
"copy_commands": strings.Join(copyCommands, " && "),
|
|
|
|
"manifest": manifest.String(),
|
|
|
|
"file_contexts": fileContexts.String(),
|
|
|
|
"canned_fs_config": cannedFsConfig.String(),
|
2018-10-12 20:49:38 +08:00
|
|
|
"key": keyFile.String(),
|
2018-10-10 13:01:00 +08:00
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2018-10-30 20:20:05 +08:00
|
|
|
a.outputFile = android.PathForModuleOut(ctx, a.ModuleBase.Name()+apexSuffix)
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: java.Signapk,
|
|
|
|
Description: "signapk",
|
|
|
|
Output: a.outputFile,
|
|
|
|
Input: unsignedOutputFile,
|
|
|
|
Args: map[string]string{
|
|
|
|
"certificates": strings.Join([]string{certificate.Pem.String(), certificate.Key.String()}, " "),
|
|
|
|
},
|
|
|
|
})
|
2018-11-08 01:50:25 +08:00
|
|
|
}
|
2018-10-30 20:20:05 +08:00
|
|
|
|
2018-11-08 01:50:25 +08:00
|
|
|
func (a *apexBundle) buildFlattenedApex(ctx android.ModuleContext) {
|
|
|
|
// For flattened APEX, do nothing but make sure that manifest.json file is also copied along
|
|
|
|
// with other ordinary files.
|
|
|
|
manifest := android.PathForModuleSrc(ctx, proptools.StringDefault(a.properties.Manifest, "manifest.json"))
|
|
|
|
a.filesInfo = append(a.filesInfo, apexFile{manifest, a.Name() + ".manifest.json", android.Common, ".", etc})
|
|
|
|
|
|
|
|
for _, fi := range a.filesInfo {
|
|
|
|
dir := filepath.Join("apex", a.Name(), fi.installDir)
|
|
|
|
ctx.InstallFile(android.PathForModuleInstall(ctx, dir), fi.builtFile.Base(), fi.builtFile)
|
|
|
|
}
|
2018-10-10 13:01:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *apexBundle) AndroidMk() android.AndroidMkData {
|
2018-11-08 01:50:25 +08:00
|
|
|
if a.flattened {
|
|
|
|
return android.AndroidMkData{
|
|
|
|
Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
|
|
|
|
moduleNames := []string{}
|
|
|
|
for _, fi := range a.filesInfo {
|
|
|
|
if !android.InList(fi.moduleName, moduleNames) {
|
|
|
|
moduleNames = append(moduleNames, fi.moduleName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
|
|
|
|
fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE :=", name)
|
|
|
|
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(moduleNames, " "))
|
|
|
|
fmt.Fprintln(w, "include $(BUILD_PHONY_PACKAGE)")
|
|
|
|
|
|
|
|
for _, fi := range a.filesInfo {
|
|
|
|
fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
|
|
|
|
fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE :=", fi.moduleName)
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join("$(OUT_DIR)", a.installDir.RelPathString(), name, fi.installDir))
|
|
|
|
fmt.Fprintln(w, "LOCAL_INSTALLED_MODULE_STEM :=", fi.builtFile.Base())
|
|
|
|
fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", fi.builtFile.String())
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_CLASS :=", fi.class.NameInMake())
|
|
|
|
archStr := fi.archType.String()
|
|
|
|
if archStr != "common" {
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_TARGET_ARCH :=", archStr)
|
|
|
|
}
|
|
|
|
if fi.class == javaSharedLib {
|
|
|
|
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")
|
|
|
|
} else {
|
|
|
|
fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
} else {
|
|
|
|
return android.AndroidMkData{
|
|
|
|
Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
|
|
|
|
fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
|
|
|
|
fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE :=", name)
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_CLASS := ETC") // do we need a new class?
|
|
|
|
fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", a.outputFile.String())
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join("$(OUT_DIR)", a.installDir.RelPathString()))
|
|
|
|
fmt.Fprintln(w, "LOCAL_INSTALLED_MODULE_STEM :=", name+apexSuffix)
|
|
|
|
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", String(a.properties.Key))
|
|
|
|
fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
|
|
|
|
}}
|
|
|
|
}
|
2018-10-10 13:01:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func apexBundleFactory() android.Module {
|
|
|
|
module := &apexBundle{}
|
|
|
|
module.AddProperties(&module.properties)
|
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 20:09:55 +08:00
|
|
|
module.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase,
|
|
|
|
class android.OsClass) bool {
|
|
|
|
return class == android.Device && ctx.Config().DevicePrefer32BitExecutables()
|
|
|
|
})
|
2018-10-10 13:01:00 +08:00
|
|
|
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
|
|
|
|
android.InitDefaultableModule(module)
|
|
|
|
return module
|
|
|
|
}
|