blob: 07a53b3660f3bda2c80ce50726c6cc516d03cad1 [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{
40 Command: `echo '/ 1000 1000 0644' > ${out} && ` +
41 `echo '/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} ` +
55 `${apexer} --verbose --force --manifest ${manifest} ` +
56 `--file_contexts ${file_contexts} ` +
57 `--canned_fs_config ${canned_fs_config} ` +
58 `--key ${key} ${image_dir} ${out} `,
59 CommandDeps: []string{"${apexer}", "${avbtool}", "${e2fsdroid}", "${merge_zips}",
60 "${mke2fs}", "${resize2fs}", "${sefcontext_compile}",
61 "${soong_zip}", "${zipalign}", "${aapt2}"},
62 Description: "APEX ${image_dir} => ${out}",
63 }, "tool_path", "image_dir", "copy_commands", "manifest", "file_contexts", "canned_fs_config", "key")
64)
65
66var apexSuffix = ".apex"
67
68type dependencyTag struct {
69 blueprint.BaseDependencyTag
70 name string
71}
72
73var (
74 sharedLibTag = dependencyTag{name: "sharedLib"}
75 executableTag = dependencyTag{name: "executable"}
76 javaLibTag = dependencyTag{name: "javaLib"}
77 prebuiltTag = dependencyTag{name: "prebuilt"}
Jiyong Parkff1458f2018-10-12 21:49:38 +090078 keyTag = dependencyTag{name: "key"}
Jiyong Park48ca7dc2018-10-10 14:01:00 +090079)
80
81func init() {
82 pctx.Import("android/soong/common")
83 pctx.HostBinToolVariable("apexer", "apexer")
84 pctx.HostBinToolVariable("aapt2", "aapt2")
85 pctx.HostBinToolVariable("avbtool", "avbtool")
86 pctx.HostBinToolVariable("e2fsdroid", "e2fsdroid")
87 pctx.HostBinToolVariable("merge_zips", "merge_zips")
88 pctx.HostBinToolVariable("mke2fs", "mke2fs")
89 pctx.HostBinToolVariable("resize2fs", "resize2fs")
90 pctx.HostBinToolVariable("sefcontext_compile", "sefcontext_compile")
91 pctx.HostBinToolVariable("soong_zip", "soong_zip")
92 pctx.HostBinToolVariable("zipalign", "zipalign")
93
94 android.RegisterModuleType("apex", apexBundleFactory)
95
96 android.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
97 ctx.TopDown("apex_deps", apexDepsMutator)
98 ctx.BottomUp("apex", apexMutator)
99 })
100}
101
102// maps a module name to set of apex bundle names that the module should be built for
103func apexBundleNamesFor(config android.Config) map[string]map[string]bool {
104 return config.Once("apexBundleNames", func() interface{} {
105 return make(map[string]map[string]bool)
106 }).(map[string]map[string]bool)
107}
108
109// Mark the direct and transitive dependencies of apex bundles so that they
110// can be built for the apex bundles.
111func apexDepsMutator(mctx android.TopDownMutatorContext) {
112 if _, ok := mctx.Module().(*apexBundle); ok {
113 apexBundleName := mctx.Module().Name()
114 mctx.WalkDeps(func(child, parent android.Module) bool {
115 if am, ok := child.(android.ApexModule); ok && am.CanHaveApexVariants() {
Jiyong Park678529e2018-10-23 23:58:01 +0900116 moduleName := am.Name() + "-" + am.Target().String()
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900117 bundleNames, ok := apexBundleNamesFor(mctx.Config())[moduleName]
118 if !ok {
119 bundleNames = make(map[string]bool)
120 apexBundleNamesFor(mctx.Config())[moduleName] = bundleNames
121 }
122 bundleNames[apexBundleName] = true
123 return true
124 } else {
125 return false
126 }
127 })
128 }
129}
130
131// Create apex variations if a module is included in APEX(s).
132func apexMutator(mctx android.BottomUpMutatorContext) {
133 if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() {
Jiyong Park678529e2018-10-23 23:58:01 +0900134 moduleName := am.Name() + "-" + am.Target().String()
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900135 if bundleNames, ok := apexBundleNamesFor(mctx.Config())[moduleName]; ok {
136 variations := []string{"platform"}
137 for bn := range bundleNames {
138 variations = append(variations, bn)
139 }
140 modules := mctx.CreateVariations(variations...)
141 for i, m := range modules {
142 if i == 0 {
143 continue // platform
144 }
145 m.(android.ApexModule).BuildForApex(variations[i])
146 }
147 }
148 } else if _, ok := mctx.Module().(*apexBundle); ok {
149 // apex bundle itself is mutated so that it and its modules have same
150 // apex variant.
151 apexBundleName := mctx.ModuleName()
152 mctx.CreateVariations(apexBundleName)
153 }
154}
155
156type apexBundleProperties struct {
157 // Json manifest file describing meta info of this APEX bundle. Default:
158 // "manifest.json"
159 Manifest *string
160
161 // File contexts file for setting security context to each file in this APEX bundle
162 // Default: "file_contexts".
163 File_contexts *string
164
165 // List of native shared libs that are embedded inside this APEX bundle
166 Native_shared_libs []string
167
168 // List of native executables that are embedded inside this APEX bundle
169 Binaries []string
170
171 // List of java libraries that are embedded inside this APEX bundle
172 Java_libs []string
173
174 // List of prebuilt files that are embedded inside this APEX bundle
175 Prebuilts []string
Jiyong Parkff1458f2018-10-12 21:49:38 +0900176
177 // Name of the apex_key module that provides the private key to sign APEX
178 Key *string
Jiyong Park397e55e2018-10-24 21:09:55 +0900179
180 Multilib struct {
181 First struct {
182 // List of native libraries whose compile_multilib is "first"
183 Native_shared_libs []string
184 // List of native executables whose compile_multilib is "first"
185 Binaries []string
186 }
187 Both struct {
188 // List of native libraries whose compile_multilib is "both"
189 Native_shared_libs []string
190 // List of native executables whose compile_multilib is "both"
191 Binaries []string
192 }
193 Prefer32 struct {
194 // List of native libraries whose compile_multilib is "prefer32"
195 Native_shared_libs []string
196 // List of native executables whose compile_multilib is "prefer32"
197 Binaries []string
198 }
199 Lib32 struct {
200 // List of native libraries whose compile_multilib is "32"
201 Native_shared_libs []string
202 // List of native executables whose compile_multilib is "32"
203 Binaries []string
204 }
205 Lib64 struct {
206 // List of native libraries whose compile_multilib is "64"
207 Native_shared_libs []string
208 // List of native executables whose compile_multilib is "64"
209 Binaries []string
210 }
211 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900212}
213
214type apexBundle struct {
215 android.ModuleBase
216 android.DefaultableModuleBase
217
218 properties apexBundleProperties
219
220 outputFile android.WritablePath
221 installDir android.OutputPath
222}
223
Jiyong Park397e55e2018-10-24 21:09:55 +0900224func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,
225 native_shared_libs []string, binaries []string, arch string) {
226 // Use *FarVariation* to be able to depend on modules having
227 // conflicting variations with this module. This is required since
228 // arch variant of an APEX bundle is 'common' but it is 'arm' or 'arm64'
229 // for native shared libs.
230 ctx.AddFarVariationDependencies([]blueprint.Variation{
231 {Mutator: "arch", Variation: arch},
232 {Mutator: "image", Variation: "core"},
233 {Mutator: "link", Variation: "shared"},
234 }, sharedLibTag, native_shared_libs...)
235
236 ctx.AddFarVariationDependencies([]blueprint.Variation{
237 {Mutator: "arch", Variation: arch},
238 {Mutator: "image", Variation: "core"},
239 }, executableTag, binaries...)
240}
241
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900242func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
Jiyong Park397e55e2018-10-24 21:09:55 +0900243 targets := ctx.MultiTargets()
244 has32BitTarget := false
245 for _, target := range targets {
246 if target.Arch.ArchType.Multilib == "lib32" {
247 has32BitTarget = true
248 }
249 }
250 for i, target := range targets {
251 // When multilib.* is omitted for native_shared_libs, it implies
252 // multilib.both.
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900253 ctx.AddFarVariationDependencies([]blueprint.Variation{
Jiyong Park397e55e2018-10-24 21:09:55 +0900254 {Mutator: "arch", Variation: target.String()},
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900255 {Mutator: "image", Variation: "core"},
256 {Mutator: "link", Variation: "shared"},
257 }, sharedLibTag, a.properties.Native_shared_libs...)
258
Jiyong Park397e55e2018-10-24 21:09:55 +0900259 // Add native modules targetting both ABIs
260 addDependenciesForNativeModules(ctx,
261 a.properties.Multilib.Both.Native_shared_libs,
262 a.properties.Multilib.Both.Binaries, target.String())
263
264 if i == 0 {
265 // When multilib.* is omitted for binaries, it implies
266 // multilib.first.
267 ctx.AddFarVariationDependencies([]blueprint.Variation{
268 {Mutator: "arch", Variation: target.String()},
269 {Mutator: "image", Variation: "core"},
270 }, executableTag, a.properties.Binaries...)
271
272 // Add native modules targetting the first ABI
273 addDependenciesForNativeModules(ctx,
274 a.properties.Multilib.First.Native_shared_libs,
275 a.properties.Multilib.First.Binaries, target.String())
276 }
277
278 switch target.Arch.ArchType.Multilib {
279 case "lib32":
280 // Add native modules targetting 32-bit ABI
281 addDependenciesForNativeModules(ctx,
282 a.properties.Multilib.Lib32.Native_shared_libs,
283 a.properties.Multilib.Lib32.Binaries, target.String())
284
285 addDependenciesForNativeModules(ctx,
286 a.properties.Multilib.Prefer32.Native_shared_libs,
287 a.properties.Multilib.Prefer32.Binaries, target.String())
288 case "lib64":
289 // Add native modules targetting 64-bit ABI
290 addDependenciesForNativeModules(ctx,
291 a.properties.Multilib.Lib64.Native_shared_libs,
292 a.properties.Multilib.Lib64.Binaries, target.String())
293
294 if !has32BitTarget {
295 addDependenciesForNativeModules(ctx,
296 a.properties.Multilib.Prefer32.Native_shared_libs,
297 a.properties.Multilib.Prefer32.Binaries, target.String())
298 }
299 }
300
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900301 }
302
Jiyong Parkff1458f2018-10-12 21:49:38 +0900303 ctx.AddFarVariationDependencies([]blueprint.Variation{
304 {Mutator: "arch", Variation: "android_common"},
305 }, javaLibTag, a.properties.Java_libs...)
306
307 ctx.AddFarVariationDependencies([]blueprint.Variation{
308 {Mutator: "arch", Variation: "android_common"},
309 }, prebuiltTag, a.properties.Prebuilts...)
310
311 if String(a.properties.Key) == "" {
312 ctx.ModuleErrorf("key is missing")
313 return
314 }
315 ctx.AddDependency(ctx.Module(), keyTag, String(a.properties.Key))
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900316}
317
318func getCopyManifestForNativeLibrary(cc *cc.Module) (fileToCopy android.Path, dirInApex string) {
319 // Decide the APEX-local directory by the multilib of the library
320 // In the future, we may query this to the module.
321 switch cc.Arch().ArchType.Multilib {
322 case "lib32":
323 dirInApex = "lib"
324 case "lib64":
325 dirInApex = "lib64"
326 }
327 if !cc.Arch().Native {
328 dirInApex = filepath.Join(dirInApex, cc.Arch().ArchType.String())
329 }
330
331 fileToCopy = cc.OutputFile().Path()
332 return
333}
334
335func getCopyManifestForExecutable(cc *cc.Module) (fileToCopy android.Path, dirInApex string) {
336 dirInApex = "bin"
337 fileToCopy = cc.OutputFile().Path()
338 return
339}
340
341func getCopyManifestForJavaLibrary(java *java.Library) (fileToCopy android.Path, dirInApex string) {
342 dirInApex = "javalib"
343 fileToCopy = java.Srcs()[0]
344 return
345}
346
347func getCopyManifestForPrebuiltEtc(prebuilt *android.PrebuiltEtc) (fileToCopy android.Path, dirInApex string) {
348 dirInApex = filepath.Join("etc", prebuilt.SubDir())
349 fileToCopy = prebuilt.OutputFile()
350 return
351}
352
353func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
354 // files to copy -> dir in apex
355 copyManifest := make(map[android.Path]string)
356
Jiyong Parkff1458f2018-10-12 21:49:38 +0900357 var keyFile android.Path
358
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900359 ctx.WalkDeps(func(child, parent android.Module) bool {
360 if _, ok := parent.(*apexBundle); ok {
361 // direct dependencies
362 depTag := ctx.OtherModuleDependencyTag(child)
Jiyong Parkff1458f2018-10-12 21:49:38 +0900363 depName := ctx.OtherModuleName(child)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900364 switch depTag {
365 case sharedLibTag:
366 if cc, ok := child.(*cc.Module); ok {
367 fileToCopy, dirInApex := getCopyManifestForNativeLibrary(cc)
368 copyManifest[fileToCopy] = dirInApex
369 return true
Jiyong Parkff1458f2018-10-12 21:49:38 +0900370 } else {
371 ctx.PropertyErrorf("native_shared_libs", "%q is not a cc_library or cc_library_shared module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900372 }
373 case executableTag:
374 if cc, ok := child.(*cc.Module); ok {
375 fileToCopy, dirInApex := getCopyManifestForExecutable(cc)
376 copyManifest[fileToCopy] = dirInApex
377 return true
Jiyong Parkff1458f2018-10-12 21:49:38 +0900378 } else {
379 ctx.PropertyErrorf("binaries", "%q is not a cc_binary module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900380 }
381 case javaLibTag:
382 if java, ok := child.(*java.Library); ok {
383 fileToCopy, dirInApex := getCopyManifestForJavaLibrary(java)
384 copyManifest[fileToCopy] = dirInApex
385 return true
Jiyong Parkff1458f2018-10-12 21:49:38 +0900386 } else {
387 ctx.PropertyErrorf("java_libs", "%q is not a java_library module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900388 }
389 case prebuiltTag:
390 if prebuilt, ok := child.(*android.PrebuiltEtc); ok {
391 fileToCopy, dirInApex := getCopyManifestForPrebuiltEtc(prebuilt)
392 copyManifest[fileToCopy] = dirInApex
393 return true
Jiyong Parkff1458f2018-10-12 21:49:38 +0900394 } else {
395 ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc module", depName)
396 }
397 case keyTag:
398 if key, ok := child.(*apexKey); ok {
399 keyFile = key.private_key_file
400 return false
401 } else {
402 ctx.PropertyErrorf("key", "%q is not an apex_key module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900403 }
404 }
405 } else {
406 // indirect dependencies
407 if am, ok := child.(android.ApexModule); ok && am.CanHaveApexVariants() && am.IsInstallableToApex() {
408 if cc, ok := child.(*cc.Module); ok {
409 fileToCopy, dirInApex := getCopyManifestForNativeLibrary(cc)
410 copyManifest[fileToCopy] = dirInApex
411 return true
412 }
413 }
414 }
415 return false
416 })
417
418 // files and dirs that will be created in apex
Jiyong Park92905d62018-10-11 13:23:09 +0900419 var readOnlyPaths []string
420 var executablePaths []string // this also includes dirs
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900421 for fileToCopy, dirInApex := range copyManifest {
422 pathInApex := filepath.Join(dirInApex, fileToCopy.Base())
Jiyong Park92905d62018-10-11 13:23:09 +0900423 if dirInApex == "bin" {
424 executablePaths = append(executablePaths, pathInApex)
425 } else {
426 readOnlyPaths = append(readOnlyPaths, pathInApex)
427 }
428 if !android.InList(dirInApex, executablePaths) {
429 executablePaths = append(executablePaths, dirInApex)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900430 }
431 }
Jiyong Park92905d62018-10-11 13:23:09 +0900432 sort.Strings(readOnlyPaths)
433 sort.Strings(executablePaths)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900434 cannedFsConfig := android.PathForModuleOut(ctx, "canned_fs_config")
435 ctx.ModuleBuild(pctx, android.ModuleBuildParams{
436 Rule: generateFsConfig,
437 Output: cannedFsConfig,
438 Args: map[string]string{
Jiyong Park92905d62018-10-11 13:23:09 +0900439 "ro_paths": strings.Join(readOnlyPaths, " "),
440 "exec_paths": strings.Join(executablePaths, " "),
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900441 },
442 })
443
444 manifest := android.PathForModuleSrc(ctx, proptools.StringDefault(a.properties.Manifest, "manifest.json"))
445 fileContexts := android.PathForModuleSrc(ctx, proptools.StringDefault(a.properties.File_contexts, "file_contexts"))
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900446
447 a.outputFile = android.PathForModuleOut(ctx, a.ModuleBase.Name()+apexSuffix)
448
Jiyong Parkab3ceb32018-10-10 14:05:29 +0900449 filesToCopy := []android.Path{}
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900450 for file := range copyManifest {
Jiyong Parkab3ceb32018-10-10 14:05:29 +0900451 filesToCopy = append(filesToCopy, file)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900452 }
Jiyong Parkab3ceb32018-10-10 14:05:29 +0900453 sort.Slice(filesToCopy, func(i, j int) bool {
454 return filesToCopy[i].String() < filesToCopy[j].String()
455 })
456
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900457 copyCommands := []string{}
Jiyong Parkab3ceb32018-10-10 14:05:29 +0900458 for _, src := range filesToCopy {
459 dest := filepath.Join(copyManifest[src], src.Base())
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900460 dest_path := filepath.Join(android.PathForModuleOut(ctx, "image").String(), dest)
461 copyCommands = append(copyCommands, "mkdir -p "+filepath.Dir(dest_path))
462 copyCommands = append(copyCommands, "cp "+src.String()+" "+dest_path)
463 }
Jiyong Parkab3ceb32018-10-10 14:05:29 +0900464 implicitInputs := append(android.Paths(nil), filesToCopy...)
Jiyong Parkff1458f2018-10-12 21:49:38 +0900465 implicitInputs = append(implicitInputs, cannedFsConfig, manifest, fileContexts, keyFile)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900466 outHostBinDir := android.PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "bin").String()
467 prebuiltSdkToolsBinDir := filepath.Join("prebuilts", "sdk", "tools", runtime.GOOS, "bin")
468 ctx.ModuleBuild(pctx, android.ModuleBuildParams{
469 Rule: apexRule,
470 Implicits: implicitInputs,
471 Output: a.outputFile,
472 Args: map[string]string{
473 "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir,
474 "image_dir": android.PathForModuleOut(ctx, "image").String(),
475 "copy_commands": strings.Join(copyCommands, " && "),
476 "manifest": manifest.String(),
477 "file_contexts": fileContexts.String(),
478 "canned_fs_config": cannedFsConfig.String(),
Jiyong Parkff1458f2018-10-12 21:49:38 +0900479 "key": keyFile.String(),
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900480 },
481 })
482
483 a.installDir = android.PathForModuleInstall(ctx, "apex")
484}
485
486func (a *apexBundle) AndroidMk() android.AndroidMkData {
487 return android.AndroidMkData{
488 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
489 fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
490 fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
491 fmt.Fprintln(w, "LOCAL_MODULE :=", name)
492 fmt.Fprintln(w, "LOCAL_MODULE_CLASS := ETC") // do we need a new class?
493 fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", a.outputFile.String())
494 fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join("$(OUT_DIR)", a.installDir.RelPathString()))
495 fmt.Fprintln(w, "LOCAL_INSTALLED_MODULE_STEM :=", name+apexSuffix)
Jiyong Parkff1458f2018-10-12 21:49:38 +0900496 fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", String(a.properties.Key))
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900497 fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
498 }}
499}
500
501func apexBundleFactory() android.Module {
502 module := &apexBundle{}
503 module.AddProperties(&module.properties)
Jiyong Park397e55e2018-10-24 21:09:55 +0900504 module.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase,
505 class android.OsClass) bool {
506 return class == android.Device && ctx.Config().DevicePrefer32BitExecutables()
507 })
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900508 android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
509 android.InitDefaultableModule(module)
510 return module
511}