blob: c7147711718237ed7cd74db649b7064027a56f6b [file] [log] [blame]
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001// Copyright (C) 2018 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package apex
16
17import (
18 "fmt"
19 "io"
20 "path/filepath"
21 "runtime"
Jiyong Parkab3ceb32018-10-10 14:05:29 +090022 "sort"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090023 "strings"
24
25 "android/soong/android"
26 "android/soong/cc"
27 "android/soong/java"
28
29 "github.com/google/blueprint"
30 "github.com/google/blueprint/proptools"
31)
32
33var (
34 pctx = android.NewPackageContext("android/apex")
35
36 // Create a canned fs config file where all files and directories are
37 // by default set to (uid/gid/mode) = (1000/1000/0644)
38 // TODO(b/113082813) make this configurable using config.fs syntax
39 generateFsConfig = pctx.StaticRule("generateFsConfig", blueprint.RuleParams{
Roland Levillain2b11f742018-11-02 11:50:42 +000040 Command: `echo '/ 1000 1000 0755' > ${out} && ` +
Dario Freni4abb1dc2018-11-20 18:04:58 +000041 `echo '/apex_manifest.json 1000 1000 0644' >> ${out} && ` +
Jiyong Park92905d62018-10-11 13:23:09 +090042 `echo ${ro_paths} | tr ' ' '\n' | awk '{print "/"$$1 " 1000 1000 0644"}' >> ${out} && ` +
43 `echo ${exec_paths} | tr ' ' '\n' | awk '{print "/"$$1 " 1000 1000 0755"}' >> ${out}`,
Jiyong Park48ca7dc2018-10-10 14:01:00 +090044 Description: "fs_config ${out}",
Jiyong Park92905d62018-10-11 13:23:09 +090045 }, "ro_paths", "exec_paths")
Jiyong Park48ca7dc2018-10-10 14:01:00 +090046
47 // TODO(b/113233103): make sure that file_contexts is sane, i.e., validate
48 // against the binary policy using sefcontext_compiler -p <policy>.
49
50 // TODO(b/114327326): automate the generation of file_contexts
51 apexRule = pctx.StaticRule("apexRule", blueprint.RuleParams{
52 Command: `rm -rf ${image_dir} && mkdir -p ${image_dir} && ` +
53 `(${copy_commands}) && ` +
54 `APEXER_TOOL_PATH=${tool_path} ` +
Jiyong Park25560152018-11-20 09:57:52 +090055 `${apexer} --force --manifest ${manifest} ` +
Jiyong Park48ca7dc2018-10-10 14:01:00 +090056 `--file_contexts ${file_contexts} ` +
57 `--canned_fs_config ${canned_fs_config} ` +
Alex Light5098a612018-11-29 17:12:15 -080058 `--payload_type image ` +
Jiyong Park48ca7dc2018-10-10 14:01:00 +090059 `--key ${key} ${image_dir} ${out} `,
60 CommandDeps: []string{"${apexer}", "${avbtool}", "${e2fsdroid}", "${merge_zips}",
61 "${mke2fs}", "${resize2fs}", "${sefcontext_compile}",
62 "${soong_zip}", "${zipalign}", "${aapt2}"},
63 Description: "APEX ${image_dir} => ${out}",
64 }, "tool_path", "image_dir", "copy_commands", "manifest", "file_contexts", "canned_fs_config", "key")
Colin Crossa4925902018-11-16 11:36:28 -080065
Alex Light5098a612018-11-29 17:12:15 -080066 zipApexRule = pctx.StaticRule("zipApexRule", blueprint.RuleParams{
67 Command: `rm -rf ${image_dir} && mkdir -p ${image_dir} && ` +
68 `(${copy_commands}) && ` +
69 `APEXER_TOOL_PATH=${tool_path} ` +
70 `${apexer} --force --manifest ${manifest} ` +
71 `--payload_type zip ` +
72 `${image_dir} ${out} `,
73 CommandDeps: []string{"${apexer}", "${merge_zips}", "${soong_zip}", "${zipalign}", "${aapt2}"},
74 Description: "ZipAPEX ${image_dir} => ${out}",
75 }, "tool_path", "image_dir", "copy_commands", "manifest")
76
Colin Crossa4925902018-11-16 11:36:28 -080077 apexProtoConvertRule = pctx.AndroidStaticRule("apexProtoConvertRule",
78 blueprint.RuleParams{
79 Command: `${aapt2} convert --output-format proto $in -o $out`,
80 CommandDeps: []string{"${aapt2}"},
81 })
82
83 apexBundleRule = pctx.StaticRule("apexBundleRule", blueprint.RuleParams{
Jiyong Park1ed0fc52018-11-23 13:22:21 +090084 Command: `${zip2zip} -i $in -o $out ` +
Dario Freni4abb1dc2018-11-20 18:04:58 +000085 `apex_payload.img:apex/${abi}.img ` +
86 `apex_manifest.json:root/apex_manifest.json ` +
Shahar Amitai328b0772018-11-26 14:12:02 +000087 `AndroidManifest.xml:manifest/AndroidManifest.xml`,
Colin Crossa4925902018-11-16 11:36:28 -080088 CommandDeps: []string{"${zip2zip}"},
89 Description: "app bundle",
90 }, "abi")
Jiyong Park48ca7dc2018-10-10 14:01:00 +090091)
92
Alex Light5098a612018-11-29 17:12:15 -080093var imageApexSuffix = ".apex"
94var zipApexSuffix = ".zipapex"
95
96var imageApexType = "image"
97var zipApexType = "zip"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090098
99type dependencyTag struct {
100 blueprint.BaseDependencyTag
101 name string
102}
103
104var (
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900105 sharedLibTag = dependencyTag{name: "sharedLib"}
106 executableTag = dependencyTag{name: "executable"}
107 javaLibTag = dependencyTag{name: "javaLib"}
108 prebuiltTag = dependencyTag{name: "prebuilt"}
109 keyTag = dependencyTag{name: "key"}
110 certificateTag = dependencyTag{name: "certificate"}
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900111)
112
113func init() {
114 pctx.Import("android/soong/common")
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900115 pctx.Import("android/soong/java")
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900116 pctx.HostBinToolVariable("apexer", "apexer")
Roland Levillain54bdfda2018-10-05 19:34:32 +0100117 // ART minimal builds (using the master-art manifest) do not have the "frameworks/base"
118 // projects, and hence cannot built 'aapt2'. Use the SDK prebuilt instead.
119 hostBinToolVariableWithPrebuilt := func(name, prebuiltDir, tool string) {
120 pctx.VariableFunc(name, func(ctx android.PackageVarContext) string {
121 if !android.ExistentPathForSource(ctx, "frameworks/base").Valid() {
122 return filepath.Join(prebuiltDir, runtime.GOOS, "bin", tool)
123 } else {
124 return pctx.HostBinToolPath(ctx, tool).String()
125 }
126 })
127 }
128 hostBinToolVariableWithPrebuilt("aapt2", "prebuilts/sdk/tools", "aapt2")
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900129 pctx.HostBinToolVariable("avbtool", "avbtool")
130 pctx.HostBinToolVariable("e2fsdroid", "e2fsdroid")
131 pctx.HostBinToolVariable("merge_zips", "merge_zips")
132 pctx.HostBinToolVariable("mke2fs", "mke2fs")
133 pctx.HostBinToolVariable("resize2fs", "resize2fs")
134 pctx.HostBinToolVariable("sefcontext_compile", "sefcontext_compile")
135 pctx.HostBinToolVariable("soong_zip", "soong_zip")
Colin Crossa4925902018-11-16 11:36:28 -0800136 pctx.HostBinToolVariable("zip2zip", "zip2zip")
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900137 pctx.HostBinToolVariable("zipalign", "zipalign")
138
Alex Lightee250722018-12-06 14:00:02 -0800139 android.RegisterModuleType("apex", ApexBundleFactory)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900140
141 android.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
142 ctx.TopDown("apex_deps", apexDepsMutator)
143 ctx.BottomUp("apex", apexMutator)
144 })
145}
146
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900147// Mark the direct and transitive dependencies of apex bundles so that they
148// can be built for the apex bundles.
149func apexDepsMutator(mctx android.TopDownMutatorContext) {
150 if _, ok := mctx.Module().(*apexBundle); ok {
Colin Crossa4925902018-11-16 11:36:28 -0800151 apexBundleName := mctx.ModuleName()
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900152 mctx.WalkDeps(func(child, parent android.Module) bool {
Jiyong Park0ddfcd12018-12-11 01:35:25 +0900153 depName := mctx.OtherModuleName(child)
154 // If the parent is apexBundle, this child is directly depended.
155 _, directDep := parent.(*apexBundle)
156 android.UpdateApexDependency(apexBundleName, depName, directDep)
157
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900158 if am, ok := child.(android.ApexModule); ok && am.CanHaveApexVariants() {
Jiyong Park0ddfcd12018-12-11 01:35:25 +0900159 am.BuildForApex(apexBundleName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900160 return true
161 } else {
162 return false
163 }
164 })
165 }
166}
167
168// Create apex variations if a module is included in APEX(s).
169func apexMutator(mctx android.BottomUpMutatorContext) {
170 if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() {
Jiyong Park0ddfcd12018-12-11 01:35:25 +0900171 am.CreateApexVariations(mctx)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900172 } else if _, ok := mctx.Module().(*apexBundle); ok {
173 // apex bundle itself is mutated so that it and its modules have same
174 // apex variant.
175 apexBundleName := mctx.ModuleName()
176 mctx.CreateVariations(apexBundleName)
177 }
178}
179
180type apexBundleProperties struct {
181 // Json manifest file describing meta info of this APEX bundle. Default:
Dario Freni4abb1dc2018-11-20 18:04:58 +0000182 // "apex_manifest.json"
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900183 Manifest *string
184
Jiyong Parkd0a65ba2018-11-10 06:37:15 +0900185 // Determines the file contexts file for setting security context to each file in this APEX bundle.
186 // Specifically, when this is set to <value>, /system/sepolicy/apex/<value>_file_contexts file is
187 // used.
188 // Default: <name_of_this_module>
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900189 File_contexts *string
190
191 // List of native shared libs that are embedded inside this APEX bundle
192 Native_shared_libs []string
193
194 // List of native executables that are embedded inside this APEX bundle
195 Binaries []string
196
197 // List of java libraries that are embedded inside this APEX bundle
198 Java_libs []string
199
200 // List of prebuilt files that are embedded inside this APEX bundle
201 Prebuilts []string
Jiyong Parkff1458f2018-10-12 21:49:38 +0900202
203 // Name of the apex_key module that provides the private key to sign APEX
204 Key *string
Jiyong Park397e55e2018-10-24 21:09:55 +0900205
Alex Light5098a612018-11-29 17:12:15 -0800206 // The type of APEX to build. Controls what the APEX payload is. Either
207 // 'image', 'zip' or 'both'. Default: 'image'.
208 Payload_type *string
209
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900210 // The name of a certificate in the default certificate directory, blank to use the default product certificate,
211 // or an android_app_certificate module name in the form ":module".
212 Certificate *string
213
Jiyong Park92c0f9c2018-12-13 23:14:57 +0900214 // Whether this APEX is installable to one of the partitions. Default: true.
215 Installable *bool
216
Jiyong Park397e55e2018-10-24 21:09:55 +0900217 Multilib struct {
218 First struct {
219 // List of native libraries whose compile_multilib is "first"
220 Native_shared_libs []string
221 // List of native executables whose compile_multilib is "first"
222 Binaries []string
223 }
224 Both struct {
225 // List of native libraries whose compile_multilib is "both"
226 Native_shared_libs []string
227 // List of native executables whose compile_multilib is "both"
228 Binaries []string
229 }
230 Prefer32 struct {
231 // List of native libraries whose compile_multilib is "prefer32"
232 Native_shared_libs []string
233 // List of native executables whose compile_multilib is "prefer32"
234 Binaries []string
235 }
236 Lib32 struct {
237 // List of native libraries whose compile_multilib is "32"
238 Native_shared_libs []string
239 // List of native executables whose compile_multilib is "32"
240 Binaries []string
241 }
242 Lib64 struct {
243 // List of native libraries whose compile_multilib is "64"
244 Native_shared_libs []string
245 // List of native executables whose compile_multilib is "64"
246 Binaries []string
247 }
248 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900249}
250
Jiyong Park8fd61922018-11-08 02:50:25 +0900251type apexFileClass int
252
253const (
254 etc apexFileClass = iota
255 nativeSharedLib
256 nativeExecutable
257 javaSharedLib
258)
259
Alex Light5098a612018-11-29 17:12:15 -0800260type apexPackaging int
261
262const (
263 imageApex apexPackaging = iota
264 zipApex
265 both
266)
267
268func (a apexPackaging) image() bool {
269 switch a {
270 case imageApex, both:
271 return true
272 }
273 return false
274}
275
276func (a apexPackaging) zip() bool {
277 switch a {
278 case zipApex, both:
279 return true
280 }
281 return false
282}
283
284func (a apexPackaging) suffix() string {
285 switch a {
286 case imageApex:
287 return imageApexSuffix
288 case zipApex:
289 return zipApexSuffix
290 case both:
291 panic(fmt.Errorf("must be either zip or image"))
292 default:
293 panic(fmt.Errorf("unkonwn APEX type %d", a))
294 }
295}
296
297func (a apexPackaging) name() string {
298 switch a {
299 case imageApex:
300 return imageApexType
301 case zipApex:
302 return zipApexType
303 case both:
304 panic(fmt.Errorf("must be either zip or image"))
305 default:
306 panic(fmt.Errorf("unkonwn APEX type %d", a))
307 }
308}
309
Jiyong Park8fd61922018-11-08 02:50:25 +0900310func (class apexFileClass) NameInMake() string {
311 switch class {
312 case etc:
313 return "ETC"
314 case nativeSharedLib:
315 return "SHARED_LIBRARIES"
316 case nativeExecutable:
317 return "EXECUTABLES"
318 case javaSharedLib:
319 return "JAVA_LIBRARIES"
320 default:
321 panic(fmt.Errorf("unkonwn class %d", class))
322 }
323}
324
325type apexFile struct {
326 builtFile android.Path
327 moduleName string
328 archType android.ArchType
329 installDir string
330 class apexFileClass
Jiyong Parka8894842018-12-19 17:36:39 +0900331 module android.Module
Jiyong Park8fd61922018-11-08 02:50:25 +0900332}
333
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900334type apexBundle struct {
335 android.ModuleBase
336 android.DefaultableModuleBase
337
338 properties apexBundleProperties
339
Alex Light5098a612018-11-29 17:12:15 -0800340 apexTypes apexPackaging
341
Colin Crossa4925902018-11-16 11:36:28 -0800342 bundleModuleFile android.WritablePath
Alex Light5098a612018-11-29 17:12:15 -0800343 outputFiles map[apexPackaging]android.WritablePath
Colin Crossa4925902018-11-16 11:36:28 -0800344 installDir android.OutputPath
Jiyong Park8fd61922018-11-08 02:50:25 +0900345
346 // list of files to be included in this apex
347 filesInfo []apexFile
348
349 flattened bool
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900350}
351
Jiyong Park397e55e2018-10-24 21:09:55 +0900352func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,
353 native_shared_libs []string, binaries []string, arch string) {
354 // Use *FarVariation* to be able to depend on modules having
355 // conflicting variations with this module. This is required since
356 // arch variant of an APEX bundle is 'common' but it is 'arm' or 'arm64'
357 // for native shared libs.
358 ctx.AddFarVariationDependencies([]blueprint.Variation{
359 {Mutator: "arch", Variation: arch},
360 {Mutator: "image", Variation: "core"},
361 {Mutator: "link", Variation: "shared"},
Jiyong Park28d395a2018-12-07 22:42:47 +0900362 {Mutator: "version", Variation: ""}, // "" is the non-stub variant
Jiyong Park397e55e2018-10-24 21:09:55 +0900363 }, sharedLibTag, native_shared_libs...)
364
365 ctx.AddFarVariationDependencies([]blueprint.Variation{
366 {Mutator: "arch", Variation: arch},
367 {Mutator: "image", Variation: "core"},
368 }, executableTag, binaries...)
369}
370
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900371func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
Jiyong Park397e55e2018-10-24 21:09:55 +0900372 targets := ctx.MultiTargets()
373 has32BitTarget := false
374 for _, target := range targets {
375 if target.Arch.ArchType.Multilib == "lib32" {
376 has32BitTarget = true
377 }
378 }
379 for i, target := range targets {
380 // When multilib.* is omitted for native_shared_libs, it implies
381 // multilib.both.
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900382 ctx.AddFarVariationDependencies([]blueprint.Variation{
Jiyong Park397e55e2018-10-24 21:09:55 +0900383 {Mutator: "arch", Variation: target.String()},
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900384 {Mutator: "image", Variation: "core"},
385 {Mutator: "link", Variation: "shared"},
386 }, sharedLibTag, a.properties.Native_shared_libs...)
387
Jiyong Park397e55e2018-10-24 21:09:55 +0900388 // Add native modules targetting both ABIs
389 addDependenciesForNativeModules(ctx,
390 a.properties.Multilib.Both.Native_shared_libs,
391 a.properties.Multilib.Both.Binaries, target.String())
392
393 if i == 0 {
394 // When multilib.* is omitted for binaries, it implies
395 // multilib.first.
396 ctx.AddFarVariationDependencies([]blueprint.Variation{
397 {Mutator: "arch", Variation: target.String()},
398 {Mutator: "image", Variation: "core"},
399 }, executableTag, a.properties.Binaries...)
400
401 // Add native modules targetting the first ABI
402 addDependenciesForNativeModules(ctx,
403 a.properties.Multilib.First.Native_shared_libs,
404 a.properties.Multilib.First.Binaries, target.String())
405 }
406
407 switch target.Arch.ArchType.Multilib {
408 case "lib32":
409 // Add native modules targetting 32-bit ABI
410 addDependenciesForNativeModules(ctx,
411 a.properties.Multilib.Lib32.Native_shared_libs,
412 a.properties.Multilib.Lib32.Binaries, target.String())
413
414 addDependenciesForNativeModules(ctx,
415 a.properties.Multilib.Prefer32.Native_shared_libs,
416 a.properties.Multilib.Prefer32.Binaries, target.String())
417 case "lib64":
418 // Add native modules targetting 64-bit ABI
419 addDependenciesForNativeModules(ctx,
420 a.properties.Multilib.Lib64.Native_shared_libs,
421 a.properties.Multilib.Lib64.Binaries, target.String())
422
423 if !has32BitTarget {
424 addDependenciesForNativeModules(ctx,
425 a.properties.Multilib.Prefer32.Native_shared_libs,
426 a.properties.Multilib.Prefer32.Binaries, target.String())
427 }
428 }
429
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900430 }
431
Jiyong Parkff1458f2018-10-12 21:49:38 +0900432 ctx.AddFarVariationDependencies([]blueprint.Variation{
433 {Mutator: "arch", Variation: "android_common"},
434 }, javaLibTag, a.properties.Java_libs...)
435
436 ctx.AddFarVariationDependencies([]blueprint.Variation{
437 {Mutator: "arch", Variation: "android_common"},
438 }, prebuiltTag, a.properties.Prebuilts...)
439
440 if String(a.properties.Key) == "" {
441 ctx.ModuleErrorf("key is missing")
442 return
443 }
444 ctx.AddDependency(ctx.Module(), keyTag, String(a.properties.Key))
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900445
446 cert := android.SrcIsModule(String(a.properties.Certificate))
447 if cert != "" {
448 ctx.AddDependency(ctx.Module(), certificateTag, cert)
449 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900450}
451
Jiyong Park74e240b2018-11-27 21:27:08 +0900452func (a *apexBundle) Srcs() android.Paths {
Jiyong Park5a832022018-12-20 09:54:35 +0900453 if file, ok := a.outputFiles[imageApex]; ok {
454 return android.Paths{file}
455 } else {
456 return nil
457 }
Jiyong Park74e240b2018-11-27 21:27:08 +0900458}
459
Jiyong Park92c0f9c2018-12-13 23:14:57 +0900460func (a *apexBundle) installable() bool {
461 return a.properties.Installable == nil || proptools.Bool(a.properties.Installable)
462}
463
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900464func getCopyManifestForNativeLibrary(cc *cc.Module) (fileToCopy android.Path, dirInApex string) {
465 // Decide the APEX-local directory by the multilib of the library
466 // In the future, we may query this to the module.
467 switch cc.Arch().ArchType.Multilib {
468 case "lib32":
469 dirInApex = "lib"
470 case "lib64":
471 dirInApex = "lib64"
472 }
473 if !cc.Arch().Native {
474 dirInApex = filepath.Join(dirInApex, cc.Arch().ArchType.String())
475 }
476
477 fileToCopy = cc.OutputFile().Path()
478 return
479}
480
481func getCopyManifestForExecutable(cc *cc.Module) (fileToCopy android.Path, dirInApex string) {
482 dirInApex = "bin"
483 fileToCopy = cc.OutputFile().Path()
484 return
485}
486
487func getCopyManifestForJavaLibrary(java *java.Library) (fileToCopy android.Path, dirInApex string) {
488 dirInApex = "javalib"
Jiyong Park8fd61922018-11-08 02:50:25 +0900489 fileToCopy = java.DexJarFile()
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900490 return
491}
492
493func getCopyManifestForPrebuiltEtc(prebuilt *android.PrebuiltEtc) (fileToCopy android.Path, dirInApex string) {
494 dirInApex = filepath.Join("etc", prebuilt.SubDir())
495 fileToCopy = prebuilt.OutputFile()
496 return
497}
498
499func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Jiyong Park8fd61922018-11-08 02:50:25 +0900500 filesInfo := []apexFile{}
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900501
Jiyong Parkff1458f2018-10-12 21:49:38 +0900502 var keyFile android.Path
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900503 var certificate java.Certificate
Jiyong Parkff1458f2018-10-12 21:49:38 +0900504
Alex Light5098a612018-11-29 17:12:15 -0800505 if a.properties.Payload_type == nil || *a.properties.Payload_type == "image" {
506 a.apexTypes = imageApex
507 } else if *a.properties.Payload_type == "zip" {
508 a.apexTypes = zipApex
509 } else if *a.properties.Payload_type == "both" {
510 a.apexTypes = both
511 } else {
512 ctx.PropertyErrorf("type", "%q is not one of \"image\", \"zip\", or \"both\".", *a.properties.Payload_type)
513 return
514 }
515
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900516 ctx.WalkDeps(func(child, parent android.Module) bool {
517 if _, ok := parent.(*apexBundle); ok {
518 // direct dependencies
519 depTag := ctx.OtherModuleDependencyTag(child)
Jiyong Parkff1458f2018-10-12 21:49:38 +0900520 depName := ctx.OtherModuleName(child)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900521 switch depTag {
522 case sharedLibTag:
523 if cc, ok := child.(*cc.Module); ok {
524 fileToCopy, dirInApex := getCopyManifestForNativeLibrary(cc)
Jiyong Parka8894842018-12-19 17:36:39 +0900525 filesInfo = append(filesInfo, apexFile{fileToCopy, depName, cc.Arch().ArchType, dirInApex, nativeSharedLib, cc})
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900526 return true
Jiyong Parkff1458f2018-10-12 21:49:38 +0900527 } else {
528 ctx.PropertyErrorf("native_shared_libs", "%q is not a cc_library or cc_library_shared module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900529 }
530 case executableTag:
531 if cc, ok := child.(*cc.Module); ok {
532 fileToCopy, dirInApex := getCopyManifestForExecutable(cc)
Jiyong Parka8894842018-12-19 17:36:39 +0900533 filesInfo = append(filesInfo, apexFile{fileToCopy, depName, cc.Arch().ArchType, dirInApex, nativeExecutable, cc})
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900534 return true
Jiyong Parkff1458f2018-10-12 21:49:38 +0900535 } else {
536 ctx.PropertyErrorf("binaries", "%q is not a cc_binary module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900537 }
538 case javaLibTag:
539 if java, ok := child.(*java.Library); ok {
540 fileToCopy, dirInApex := getCopyManifestForJavaLibrary(java)
Jiyong Park8fd61922018-11-08 02:50:25 +0900541 if fileToCopy == nil {
542 ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
543 } else {
Jiyong Parka8894842018-12-19 17:36:39 +0900544 filesInfo = append(filesInfo, apexFile{fileToCopy, depName, java.Arch().ArchType, dirInApex, javaSharedLib, java})
Jiyong Park8fd61922018-11-08 02:50:25 +0900545 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900546 return true
Jiyong Parkff1458f2018-10-12 21:49:38 +0900547 } else {
548 ctx.PropertyErrorf("java_libs", "%q is not a java_library module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900549 }
550 case prebuiltTag:
551 if prebuilt, ok := child.(*android.PrebuiltEtc); ok {
552 fileToCopy, dirInApex := getCopyManifestForPrebuiltEtc(prebuilt)
Jiyong Parka8894842018-12-19 17:36:39 +0900553 filesInfo = append(filesInfo, apexFile{fileToCopy, depName, prebuilt.Arch().ArchType, dirInApex, etc, prebuilt})
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900554 return true
Jiyong Parkff1458f2018-10-12 21:49:38 +0900555 } else {
556 ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc module", depName)
557 }
558 case keyTag:
559 if key, ok := child.(*apexKey); ok {
560 keyFile = key.private_key_file
561 return false
562 } else {
563 ctx.PropertyErrorf("key", "%q is not an apex_key module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900564 }
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900565 case certificateTag:
566 if dep, ok := child.(*java.AndroidAppCertificate); ok {
567 certificate = dep.Certificate
568 return false
569 } else {
570 ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName)
571 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900572 }
573 } else {
574 // indirect dependencies
575 if am, ok := child.(android.ApexModule); ok && am.CanHaveApexVariants() && am.IsInstallableToApex() {
576 if cc, ok := child.(*cc.Module); ok {
Jiyong Park25fc6a92018-11-18 18:02:45 +0900577 if cc.IsStubs() || cc.HasStubsVariants() {
578 return false
579 }
Jiyong Park8fd61922018-11-08 02:50:25 +0900580 depName := ctx.OtherModuleName(child)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900581 fileToCopy, dirInApex := getCopyManifestForNativeLibrary(cc)
Jiyong Parka8894842018-12-19 17:36:39 +0900582 filesInfo = append(filesInfo, apexFile{fileToCopy, depName, cc.Arch().ArchType, dirInApex, nativeSharedLib, cc})
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900583 return true
584 }
585 }
586 }
587 return false
588 })
589
Jiyong Parkfa0a3732018-11-09 05:52:26 +0900590 if keyFile == nil {
591 ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key))
592 return
593 }
594
Jiyong Park8fd61922018-11-08 02:50:25 +0900595 // remove duplicates in filesInfo
596 removeDup := func(filesInfo []apexFile) []apexFile {
597 encountered := make(map[android.Path]bool)
598 result := []apexFile{}
599 for _, f := range filesInfo {
600 if !encountered[f.builtFile] {
601 encountered[f.builtFile] = true
602 result = append(result, f)
603 }
604 }
605 return result
606 }
607 filesInfo = removeDup(filesInfo)
608
609 // to have consistent build rules
610 sort.Slice(filesInfo, func(i, j int) bool {
611 return filesInfo[i].builtFile.String() < filesInfo[j].builtFile.String()
612 })
613
614 // prepend the name of this APEX to the module names. These names will be the names of
615 // modules that will be defined if the APEX is flattened.
616 for i := range filesInfo {
617 filesInfo[i].moduleName = ctx.ModuleName() + "." + filesInfo[i].moduleName
618 }
619
Colin Crossa4925902018-11-16 11:36:28 -0800620 a.flattened = ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild()
Jiyong Park8fd61922018-11-08 02:50:25 +0900621 a.installDir = android.PathForModuleInstall(ctx, "apex")
622 a.filesInfo = filesInfo
Alex Light5098a612018-11-29 17:12:15 -0800623
624 if a.apexTypes.zip() {
625 a.buildUnflattenedApex(ctx, keyFile, certificate, zipApex)
626 }
627 if a.apexTypes.image() {
628 if ctx.Config().FlattenApex() {
629 a.buildFlattenedApex(ctx)
630 } else {
631 a.buildUnflattenedApex(ctx, keyFile, certificate, imageApex)
632 }
Jiyong Park8fd61922018-11-08 02:50:25 +0900633 }
634}
635
Alex Light5098a612018-11-29 17:12:15 -0800636func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext, keyFile android.Path, certificate java.Certificate, apexType apexPackaging) {
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900637 cert := String(a.properties.Certificate)
638 if cert != "" && android.SrcIsModule(cert) == "" {
639 defaultDir := ctx.Config().DefaultAppCertificateDir(ctx)
640 certificate = java.Certificate{
641 defaultDir.Join(ctx, cert+".x509.pem"),
642 defaultDir.Join(ctx, cert+".pk8"),
643 }
644 } else if cert == "" {
645 pem, key := ctx.Config().DefaultAppCertificate(ctx)
646 certificate = java.Certificate{pem, key}
647 }
648
Dario Freni4abb1dc2018-11-20 18:04:58 +0000649 manifest := android.PathForModuleSrc(ctx, proptools.StringDefault(a.properties.Manifest, "apex_manifest.json"))
Jiyong Parkd0a65ba2018-11-10 06:37:15 +0900650
Alex Light5098a612018-11-29 17:12:15 -0800651 var abis []string
652 for _, target := range ctx.MultiTargets() {
653 if len(target.Arch.Abi) > 0 {
654 abis = append(abis, target.Arch.Abi[0])
655 }
Jiyong Parkd0a65ba2018-11-10 06:37:15 +0900656 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900657
Alex Light5098a612018-11-29 17:12:15 -0800658 abis = android.FirstUniqueStrings(abis)
659
660 suffix := apexType.suffix()
661 unsignedOutputFile := android.PathForModuleOut(ctx, ctx.ModuleName()+suffix+".unsigned")
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900662
Jiyong Parkab3ceb32018-10-10 14:05:29 +0900663 filesToCopy := []android.Path{}
Jiyong Park8fd61922018-11-08 02:50:25 +0900664 for _, f := range a.filesInfo {
665 filesToCopy = append(filesToCopy, f.builtFile)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900666 }
Jiyong Parkab3ceb32018-10-10 14:05:29 +0900667
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900668 copyCommands := []string{}
Jiyong Park8fd61922018-11-08 02:50:25 +0900669 for i, src := range filesToCopy {
670 dest := filepath.Join(a.filesInfo[i].installDir, src.Base())
Alex Light5098a612018-11-29 17:12:15 -0800671 dest_path := filepath.Join(android.PathForModuleOut(ctx, "image"+suffix).String(), dest)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900672 copyCommands = append(copyCommands, "mkdir -p "+filepath.Dir(dest_path))
673 copyCommands = append(copyCommands, "cp "+src.String()+" "+dest_path)
674 }
Jiyong Parkab3ceb32018-10-10 14:05:29 +0900675 implicitInputs := append(android.Paths(nil), filesToCopy...)
Alex Light5098a612018-11-29 17:12:15 -0800676 implicitInputs = append(implicitInputs, manifest)
677
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900678 outHostBinDir := android.PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "bin").String()
679 prebuiltSdkToolsBinDir := filepath.Join("prebuilts", "sdk", "tools", runtime.GOOS, "bin")
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900680
Alex Light5098a612018-11-29 17:12:15 -0800681 if apexType.image() {
682 // files and dirs that will be created in APEX
683 var readOnlyPaths []string
684 var executablePaths []string // this also includes dirs
685 for _, f := range a.filesInfo {
686 pathInApex := filepath.Join(f.installDir, f.builtFile.Base())
687 if f.installDir == "bin" {
688 executablePaths = append(executablePaths, pathInApex)
689 } else {
690 readOnlyPaths = append(readOnlyPaths, pathInApex)
691 }
Jiyong Park7c2ee712018-12-07 00:42:25 +0900692 dir := f.installDir
693 for !android.InList(dir, executablePaths) && dir != "" {
694 executablePaths = append(executablePaths, dir)
695 dir, _ = filepath.Split(dir) // move up to the parent
696 if len(dir) > 0 {
697 // remove trailing slash
698 dir = dir[:len(dir)-1]
699 }
Alex Light5098a612018-11-29 17:12:15 -0800700 }
701 }
702 sort.Strings(readOnlyPaths)
703 sort.Strings(executablePaths)
704 cannedFsConfig := android.PathForModuleOut(ctx, "canned_fs_config")
705 ctx.Build(pctx, android.BuildParams{
706 Rule: generateFsConfig,
707 Output: cannedFsConfig,
708 Description: "generate fs config",
709 Args: map[string]string{
710 "ro_paths": strings.Join(readOnlyPaths, " "),
711 "exec_paths": strings.Join(executablePaths, " "),
712 },
713 })
714
715 fcName := proptools.StringDefault(a.properties.File_contexts, ctx.ModuleName())
716 fileContextsPath := "system/sepolicy/apex/" + fcName + "-file_contexts"
717 fileContextsOptionalPath := android.ExistentPathForSource(ctx, fileContextsPath)
718 if !fileContextsOptionalPath.Valid() {
719 ctx.ModuleErrorf("Cannot find file_contexts file: %q", fileContextsPath)
720 return
721 }
722 fileContexts := fileContextsOptionalPath.Path()
723
724 // Additional implicit inputs.
725 implicitInputs = append(implicitInputs, cannedFsConfig, fileContexts, keyFile)
726
727 ctx.Build(pctx, android.BuildParams{
728 Rule: apexRule,
729 Implicits: implicitInputs,
730 Output: unsignedOutputFile,
731 Description: "apex (" + apexType.name() + ")",
732 Args: map[string]string{
733 "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir,
734 "image_dir": android.PathForModuleOut(ctx, "image"+suffix).String(),
735 "copy_commands": strings.Join(copyCommands, " && "),
736 "manifest": manifest.String(),
737 "file_contexts": fileContexts.String(),
738 "canned_fs_config": cannedFsConfig.String(),
739 "key": keyFile.String(),
740 },
741 })
742
743 apexProtoFile := android.PathForModuleOut(ctx, ctx.ModuleName()+".pb"+suffix)
744 bundleModuleFile := android.PathForModuleOut(ctx, ctx.ModuleName()+suffix+"-base.zip")
745 a.bundleModuleFile = bundleModuleFile
746
747 ctx.Build(pctx, android.BuildParams{
748 Rule: apexProtoConvertRule,
749 Input: unsignedOutputFile,
750 Output: apexProtoFile,
751 Description: "apex proto convert",
752 })
753
754 ctx.Build(pctx, android.BuildParams{
755 Rule: apexBundleRule,
756 Input: apexProtoFile,
757 Output: a.bundleModuleFile,
758 Description: "apex bundle module",
759 Args: map[string]string{
760 "abi": strings.Join(abis, "."),
761 },
762 })
763 } else {
764 ctx.Build(pctx, android.BuildParams{
765 Rule: zipApexRule,
766 Implicits: implicitInputs,
767 Output: unsignedOutputFile,
768 Description: "apex (" + apexType.name() + ")",
769 Args: map[string]string{
770 "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir,
771 "image_dir": android.PathForModuleOut(ctx, "image"+suffix).String(),
772 "copy_commands": strings.Join(copyCommands, " && "),
773 "manifest": manifest.String(),
774 },
775 })
Colin Crossa4925902018-11-16 11:36:28 -0800776 }
Colin Crossa4925902018-11-16 11:36:28 -0800777
Alex Light5098a612018-11-29 17:12:15 -0800778 a.outputFiles[apexType] = android.PathForModuleOut(ctx, ctx.ModuleName()+suffix)
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900779 ctx.Build(pctx, android.BuildParams{
780 Rule: java.Signapk,
781 Description: "signapk",
Alex Light5098a612018-11-29 17:12:15 -0800782 Output: a.outputFiles[apexType],
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900783 Input: unsignedOutputFile,
784 Args: map[string]string{
785 "certificates": strings.Join([]string{certificate.Pem.String(), certificate.Key.String()}, " "),
Jiyong Parkbfe64a12018-11-22 02:51:54 +0900786 "flags": "-a 4096", //alignment
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900787 },
788 })
Alex Light5098a612018-11-29 17:12:15 -0800789
790 // Install to $OUT/soong/{target,host}/.../apex
Jiyong Park92c0f9c2018-12-13 23:14:57 +0900791 if a.installable() {
792 ctx.InstallFile(android.PathForModuleInstall(ctx, "apex"), ctx.ModuleName()+suffix, a.outputFiles[apexType])
793 }
Jiyong Park8fd61922018-11-08 02:50:25 +0900794}
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900795
Jiyong Park8fd61922018-11-08 02:50:25 +0900796func (a *apexBundle) buildFlattenedApex(ctx android.ModuleContext) {
Jiyong Park92c0f9c2018-12-13 23:14:57 +0900797 if a.installable() {
798 // For flattened APEX, do nothing but make sure that apex_manifest.json file is also copied along
799 // with other ordinary files.
800 manifest := android.PathForModuleSrc(ctx, proptools.StringDefault(a.properties.Manifest, "apex_manifest.json"))
Jiyong Parka8894842018-12-19 17:36:39 +0900801 a.filesInfo = append(a.filesInfo, apexFile{manifest, ctx.ModuleName() + ".apex_manifest.json", android.Common, ".", etc, nil})
Jiyong Park8fd61922018-11-08 02:50:25 +0900802
Jiyong Park92c0f9c2018-12-13 23:14:57 +0900803 for _, fi := range a.filesInfo {
804 dir := filepath.Join("apex", ctx.ModuleName(), fi.installDir)
805 ctx.InstallFile(android.PathForModuleInstall(ctx, dir), fi.builtFile.Base(), fi.builtFile)
806 }
Jiyong Park8fd61922018-11-08 02:50:25 +0900807 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900808}
809
810func (a *apexBundle) AndroidMk() android.AndroidMkData {
Alex Light5098a612018-11-29 17:12:15 -0800811 writers := []android.AndroidMkData{}
812 if a.apexTypes.image() {
813 writers = append(writers, a.androidMkForType(imageApex))
814 }
815 if a.apexTypes.zip() {
816 writers = append(writers, a.androidMkForType(zipApex))
817 }
818 return android.AndroidMkData{
819 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
820 for _, data := range writers {
821 data.Custom(w, name, prefix, moduleDir, data)
822 }
823 }}
824}
825
826func (a *apexBundle) androidMkForType(apexType apexPackaging) android.AndroidMkData {
827 // Only image APEXes can be flattened.
828 if a.flattened && apexType.image() {
Jiyong Park8fd61922018-11-08 02:50:25 +0900829 return android.AndroidMkData{
830 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
831 moduleNames := []string{}
832 for _, fi := range a.filesInfo {
833 if !android.InList(fi.moduleName, moduleNames) {
834 moduleNames = append(moduleNames, fi.moduleName)
835 }
836 }
837 fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
838 fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
839 fmt.Fprintln(w, "LOCAL_MODULE :=", name)
840 fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(moduleNames, " "))
841 fmt.Fprintln(w, "include $(BUILD_PHONY_PACKAGE)")
842
843 for _, fi := range a.filesInfo {
844 fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
845 fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
846 fmt.Fprintln(w, "LOCAL_MODULE :=", fi.moduleName)
847 fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join("$(OUT_DIR)", a.installDir.RelPathString(), name, fi.installDir))
848 fmt.Fprintln(w, "LOCAL_INSTALLED_MODULE_STEM :=", fi.builtFile.Base())
849 fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", fi.builtFile.String())
850 fmt.Fprintln(w, "LOCAL_MODULE_CLASS :=", fi.class.NameInMake())
Jiyong Park92c0f9c2018-12-13 23:14:57 +0900851 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !a.installable())
Jiyong Park8fd61922018-11-08 02:50:25 +0900852 archStr := fi.archType.String()
853 if archStr != "common" {
854 fmt.Fprintln(w, "LOCAL_MODULE_TARGET_ARCH :=", archStr)
855 }
856 if fi.class == javaSharedLib {
Jiyong Parka8894842018-12-19 17:36:39 +0900857 javaModule := fi.module.(*java.Library)
858 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", javaModule.ImplementationAndResourcesJars()[0].String())
859 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", javaModule.HeaderJars()[0].String())
Jiyong Park8fd61922018-11-08 02:50:25 +0900860 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", fi.builtFile.String())
861 fmt.Fprintln(w, "LOCAL_DEX_PREOPT := false")
862 fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
863 } else {
864 fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
865 }
866 }
867 }}
868 } else {
869 return android.AndroidMkData{
870 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
Alex Light5098a612018-11-29 17:12:15 -0800871 // zip-apex is the less common type so have the name refer to the image-apex
872 // only and use {name}.zip if you want the zip-apex
873 if apexType == zipApex && a.apexTypes == both {
874 name = name + ".zip"
875 }
Jiyong Park8fd61922018-11-08 02:50:25 +0900876 fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
877 fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
878 fmt.Fprintln(w, "LOCAL_MODULE :=", name)
879 fmt.Fprintln(w, "LOCAL_MODULE_CLASS := ETC") // do we need a new class?
Alex Light5098a612018-11-29 17:12:15 -0800880 fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", a.outputFiles[apexType].String())
Jiyong Park8fd61922018-11-08 02:50:25 +0900881 fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join("$(OUT_DIR)", a.installDir.RelPathString()))
Alex Light5098a612018-11-29 17:12:15 -0800882 fmt.Fprintln(w, "LOCAL_INSTALLED_MODULE_STEM :=", name+apexType.suffix())
Jiyong Park92c0f9c2018-12-13 23:14:57 +0900883 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !a.installable())
Jiyong Park8fd61922018-11-08 02:50:25 +0900884 fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", String(a.properties.Key))
885 fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
Colin Crossa4925902018-11-16 11:36:28 -0800886
Alex Light5098a612018-11-29 17:12:15 -0800887 if apexType == imageApex {
888 fmt.Fprintln(w, "ALL_MODULES.$(LOCAL_MODULE).BUNDLE :=", a.bundleModuleFile.String())
889 }
Jiyong Park8fd61922018-11-08 02:50:25 +0900890 }}
891 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900892}
893
Alex Lightee250722018-12-06 14:00:02 -0800894func ApexBundleFactory() android.Module {
Alex Light5098a612018-11-29 17:12:15 -0800895 module := &apexBundle{
896 outputFiles: map[apexPackaging]android.WritablePath{},
897 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900898 module.AddProperties(&module.properties)
Alex Light5098a612018-11-29 17:12:15 -0800899 module.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool {
Jiyong Park397e55e2018-10-24 21:09:55 +0900900 return class == android.Device && ctx.Config().DevicePrefer32BitExecutables()
901 })
Alex Light5098a612018-11-29 17:12:15 -0800902 android.InitAndroidMultiTargetsArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900903 android.InitDefaultableModule(module)
904 return module
905}