blob: e45bd49a80ecda55822d190f867d2e90931f2ae1 [file] [log] [blame]
Jiyong Park9b409bc2019-10-11 14:59:13 +09001// Copyright (C) 2019 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 sdk
16
17import (
18 "fmt"
Jiyong Park9b409bc2019-10-11 14:59:13 +090019 "path/filepath"
Jiyong Park9b409bc2019-10-11 14:59:13 +090020 "strings"
21
22 "github.com/google/blueprint/proptools"
23
24 "android/soong/android"
Jiyong Park73c54ee2019-10-22 20:31:18 +090025 "android/soong/cc"
Jiyong Park9b409bc2019-10-11 14:59:13 +090026 "android/soong/java"
27)
28
29var pctx = android.NewPackageContext("android/soong/sdk")
30
31// generatedFile abstracts operations for writing contents into a file and emit a build rule
32// for the file.
33type generatedFile struct {
Jiyong Park73c54ee2019-10-22 20:31:18 +090034 path android.OutputPath
35 content strings.Builder
36 indentLevel int
Jiyong Park9b409bc2019-10-11 14:59:13 +090037}
38
Jiyong Park232e7852019-11-04 12:23:40 +090039func newGeneratedFile(ctx android.ModuleContext, path ...string) *generatedFile {
Jiyong Park9b409bc2019-10-11 14:59:13 +090040 return &generatedFile{
Jiyong Park232e7852019-11-04 12:23:40 +090041 path: android.PathForModuleOut(ctx, path...).OutputPath,
Jiyong Park73c54ee2019-10-22 20:31:18 +090042 indentLevel: 0,
Jiyong Park9b409bc2019-10-11 14:59:13 +090043 }
44}
45
Paul Duffin0e0cf1d2019-11-12 19:39:25 +000046func (gf *generatedFile) Indent() {
Jiyong Park73c54ee2019-10-22 20:31:18 +090047 gf.indentLevel++
48}
49
Paul Duffin0e0cf1d2019-11-12 19:39:25 +000050func (gf *generatedFile) Dedent() {
Jiyong Park73c54ee2019-10-22 20:31:18 +090051 gf.indentLevel--
52}
53
Paul Duffin0e0cf1d2019-11-12 19:39:25 +000054func (gf *generatedFile) Printfln(format string, args ...interface{}) {
Jiyong Park9b409bc2019-10-11 14:59:13 +090055 // ninja consumes newline characters in rspfile_content. Prevent it by
Paul Duffin0e0cf1d2019-11-12 19:39:25 +000056 // escaping the backslash in the newline character. The extra backslash
Jiyong Park9b409bc2019-10-11 14:59:13 +090057 // is removed when the rspfile is written to the actual script file
Jiyong Park73c54ee2019-10-22 20:31:18 +090058 fmt.Fprintf(&(gf.content), strings.Repeat(" ", gf.indentLevel)+format+"\\n", args...)
Jiyong Park9b409bc2019-10-11 14:59:13 +090059}
60
61func (gf *generatedFile) build(pctx android.PackageContext, ctx android.BuilderContext, implicits android.Paths) {
62 rb := android.NewRuleBuilder()
63 // convert \\n to \n
64 rb.Command().
65 Implicits(implicits).
66 Text("echo").Text(proptools.ShellEscape(gf.content.String())).
67 Text("| sed 's/\\\\n/\\n/g' >").Output(gf.path)
68 rb.Command().
69 Text("chmod a+x").Output(gf.path)
70 rb.Build(pctx, ctx, gf.path.Base(), "Build "+gf.path.Base())
71}
72
Paul Duffin0e0cf1d2019-11-12 19:39:25 +000073func (s *sdk) javaLibs(ctx android.ModuleContext) []android.SdkAware {
74 result := []android.SdkAware{}
Jiyong Park9b409bc2019-10-11 14:59:13 +090075 ctx.VisitDirectDeps(func(m android.Module) {
Jiyong Park73c54ee2019-10-22 20:31:18 +090076 if j, ok := m.(*java.Library); ok {
77 result = append(result, j)
Jiyong Park9b409bc2019-10-11 14:59:13 +090078 }
79 })
80 return result
81}
82
Paul Duffin91547182019-11-12 19:39:36 +000083func (s *sdk) stubsSources(ctx android.ModuleContext) []android.SdkAware {
84 result := []android.SdkAware{}
85 ctx.VisitDirectDeps(func(m android.Module) {
86 if j, ok := m.(*java.Droidstubs); ok {
87 result = append(result, j)
88 }
89 })
90 return result
91}
92
Jiyong Park73c54ee2019-10-22 20:31:18 +090093// archSpecificNativeLibInfo represents an arch-specific variant of a native lib
94type archSpecificNativeLibInfo struct {
95 name string
96 archType string
97 exportedIncludeDirs android.Paths
98 exportedSystemIncludeDirs android.Paths
99 exportedFlags []string
Jiyong Park232e7852019-11-04 12:23:40 +0900100 exportedDeps android.Paths
Jiyong Park73c54ee2019-10-22 20:31:18 +0900101 outputFile android.Path
102}
Jiyong Park9b409bc2019-10-11 14:59:13 +0900103
Jiyong Park73c54ee2019-10-22 20:31:18 +0900104func (lib *archSpecificNativeLibInfo) signature() string {
105 return fmt.Sprintf("%v %v %v %v",
106 lib.name,
107 lib.exportedIncludeDirs.Strings(),
108 lib.exportedSystemIncludeDirs.Strings(),
109 lib.exportedFlags)
110}
111
112// nativeLibInfo represents a collection of arch-specific modules having the same name
113type nativeLibInfo struct {
114 name string
115 archVariants []archSpecificNativeLibInfo
116 // hasArchSpecificFlags is set to true if modules for each architecture all have the same
117 // include dirs, flags, etc, in which case only those of the first arch is selected.
118 hasArchSpecificFlags bool
119}
120
121// nativeMemberInfos collects all cc.Modules that are member of an SDK.
122func (s *sdk) nativeMemberInfos(ctx android.ModuleContext) []*nativeLibInfo {
123 infoMap := make(map[string]*nativeLibInfo)
124
125 // Collect cc.Modules
126 ctx.VisitDirectDeps(func(m android.Module) {
127 ccModule, ok := m.(*cc.Module)
128 if !ok {
129 return
130 }
131 depName := ctx.OtherModuleName(m)
132
133 if _, ok := infoMap[depName]; !ok {
134 infoMap[depName] = &nativeLibInfo{name: depName}
135 }
136
137 info := infoMap[depName]
138 info.archVariants = append(info.archVariants, archSpecificNativeLibInfo{
139 name: ccModule.BaseModuleName(),
140 archType: ccModule.Target().Arch.ArchType.String(),
141 exportedIncludeDirs: ccModule.ExportedIncludeDirs(),
142 exportedSystemIncludeDirs: ccModule.ExportedSystemIncludeDirs(),
143 exportedFlags: ccModule.ExportedFlags(),
Jiyong Park232e7852019-11-04 12:23:40 +0900144 exportedDeps: ccModule.ExportedDeps(),
Jiyong Park73c54ee2019-10-22 20:31:18 +0900145 outputFile: ccModule.OutputFile().Path(),
146 })
147 })
148
149 // Determine if include dirs and flags for each module are different across arch-specific
150 // modules or not. And set hasArchSpecificFlags accordingly
151 for _, info := range infoMap {
152 // by default, include paths and flags are assumed to be the same across arches
153 info.hasArchSpecificFlags = false
154 oldSignature := ""
155 for _, av := range info.archVariants {
156 newSignature := av.signature()
157 if oldSignature == "" {
158 oldSignature = newSignature
159 }
160 if oldSignature != newSignature {
161 info.hasArchSpecificFlags = true
162 break
163 }
164 }
Jiyong Park9b409bc2019-10-11 14:59:13 +0900165 }
166
Jiyong Park73c54ee2019-10-22 20:31:18 +0900167 var list []*nativeLibInfo
168 for _, v := range infoMap {
169 list = append(list, v)
170 }
171 return list
172}
Jiyong Park9b409bc2019-10-11 14:59:13 +0900173
Jiyong Park73c54ee2019-10-22 20:31:18 +0900174// SDK directory structure
175// <sdk_root>/
176// Android.bp : definition of a 'sdk' module is here. This is a hand-made one.
177// <api_ver>/ : below this directory are all auto-generated
178// Android.bp : definition of 'sdk_snapshot' module is here
179// aidl/
180// frameworks/base/core/..../IFoo.aidl : an exported AIDL file
181// java/
Jiyong Park232e7852019-11-04 12:23:40 +0900182// <module_name>.jar : the stub jar for a java library 'module_name'
Jiyong Park73c54ee2019-10-22 20:31:18 +0900183// include/
184// bionic/libc/include/stdlib.h : an exported header file
185// include_gen/
Jiyong Park232e7852019-11-04 12:23:40 +0900186// <module_name>/com/android/.../IFoo.h : a generated header file
Jiyong Park73c54ee2019-10-22 20:31:18 +0900187// <arch>/include/ : arch-specific exported headers
188// <arch>/include_gen/ : arch-specific generated headers
189// <arch>/lib/
190// libFoo.so : a stub library
191
192const (
Jiyong Park73c54ee2019-10-22 20:31:18 +0900193 nativeIncludeDir = "include"
194 nativeGeneratedIncludeDir = "include_gen"
195 nativeStubDir = "lib"
196 nativeStubFileSuffix = ".so"
197)
198
Jiyong Park73c54ee2019-10-22 20:31:18 +0900199// path to the stub file of a native shared library. Relative to <sdk_root>/<api_dir>
200func nativeStubFilePathFor(lib archSpecificNativeLibInfo) string {
201 return filepath.Join(lib.archType,
202 nativeStubDir, lib.name+nativeStubFileSuffix)
203}
204
205// paths to the include dirs of a native shared library. Relative to <sdk_root>/<api_dir>
206func nativeIncludeDirPathsFor(ctx android.ModuleContext, lib archSpecificNativeLibInfo,
207 systemInclude bool, archSpecific bool) []string {
208 var result []string
Jiyong Park73c54ee2019-10-22 20:31:18 +0900209 var includeDirs []android.Path
210 if !systemInclude {
211 includeDirs = lib.exportedIncludeDirs
212 } else {
213 includeDirs = lib.exportedSystemIncludeDirs
214 }
215 for _, dir := range includeDirs {
216 var path string
Jiyong Park232e7852019-11-04 12:23:40 +0900217 if _, gen := dir.(android.WritablePath); gen {
218 path = filepath.Join(nativeGeneratedIncludeDir, lib.name)
Jiyong Park73c54ee2019-10-22 20:31:18 +0900219 } else {
220 path = filepath.Join(nativeIncludeDir, dir.String())
221 }
222 if archSpecific {
223 path = filepath.Join(lib.archType, path)
224 }
225 result = append(result, path)
226 }
227 return result
228}
229
Jiyong Park232e7852019-11-04 12:23:40 +0900230// A name that uniquely identifies a prebuilt SDK member for a version of SDK snapshot
Jiyong Park73c54ee2019-10-22 20:31:18 +0900231// This isn't visible to users, so could be changed in future.
232func versionedSdkMemberName(ctx android.ModuleContext, memberName string, version string) string {
233 return ctx.ModuleName() + "_" + memberName + string(android.SdkVersionSeparator) + version
234}
235
Jiyong Park232e7852019-11-04 12:23:40 +0900236// buildSnapshot is the main function in this source file. It creates rules to copy
237// the contents (header files, stub libraries, etc) into the zip file.
238func (s *sdk) buildSnapshot(ctx android.ModuleContext) android.OutputPath {
Paul Duffin0e0cf1d2019-11-12 19:39:25 +0000239 snapshotDir := android.PathForModuleOut(ctx, "snapshot")
Jiyong Park9b409bc2019-10-11 14:59:13 +0900240
Paul Duffin0e0cf1d2019-11-12 19:39:25 +0000241 bp := newGeneratedFile(ctx, "snapshot", "Android.bp")
242 bp.Printfln("// This is auto-generated. DO NOT EDIT.")
243 bp.Printfln("")
244
245 builder := &snapshotBuilder{
246 ctx: ctx,
247 version: "current",
248 snapshotDir: snapshotDir.OutputPath,
Paul Duffin0e0cf1d2019-11-12 19:39:25 +0000249 filesToZip: []android.Path{bp.path},
Paul Duffin91547182019-11-12 19:39:36 +0000250 androidBpFile: bp,
Jiyong Park73c54ee2019-10-22 20:31:18 +0900251 }
Paul Duffinac37c502019-11-26 18:02:20 +0000252 s.builderForTests = builder
Jiyong Park9b409bc2019-10-11 14:59:13 +0900253
Jiyong Park232e7852019-11-04 12:23:40 +0900254 // copy exported AIDL files and stub jar files
Paul Duffin0e0cf1d2019-11-12 19:39:25 +0000255 javaLibs := s.javaLibs(ctx)
256 for _, m := range javaLibs {
257 m.BuildSnapshot(ctx, builder)
Jiyong Park73c54ee2019-10-22 20:31:18 +0900258 }
259
Paul Duffin91547182019-11-12 19:39:36 +0000260 // copy stubs sources
261 stubsSources := s.stubsSources(ctx)
262 for _, m := range stubsSources {
263 m.BuildSnapshot(ctx, builder)
264 }
265
Jiyong Park232e7852019-11-04 12:23:40 +0900266 // copy exported header files and stub *.so files
Jiyong Park73c54ee2019-10-22 20:31:18 +0900267 nativeLibInfos := s.nativeMemberInfos(ctx)
268 for _, info := range nativeLibInfos {
Paul Duffin0e0cf1d2019-11-12 19:39:25 +0000269 buildSharedNativeLibSnapshot(ctx, info, builder)
Jiyong Park73c54ee2019-10-22 20:31:18 +0900270 }
Jiyong Park9b409bc2019-10-11 14:59:13 +0900271
Jiyong Park232e7852019-11-04 12:23:40 +0900272 // generate Android.bp
Paul Duffin0e0cf1d2019-11-12 19:39:25 +0000273
274 bp.Printfln("sdk_snapshot {")
275 bp.Indent()
276 bp.Printfln("name: %q,", ctx.ModuleName()+string(android.SdkVersionSeparator)+builder.version)
277 if len(javaLibs) > 0 {
278 bp.Printfln("java_libs: [")
279 bp.Indent()
280 for _, m := range javaLibs {
281 bp.Printfln("%q,", builder.VersionedSdkMemberName(m.Name()))
282 }
283 bp.Dedent()
284 bp.Printfln("],") // java_libs
285 }
Paul Duffin91547182019-11-12 19:39:36 +0000286 if len(stubsSources) > 0 {
287 bp.Printfln("stubs_sources: [")
288 bp.Indent()
289 for _, m := range stubsSources {
290 bp.Printfln("%q,", builder.VersionedSdkMemberName(m.Name()))
291 }
292 bp.Dedent()
293 bp.Printfln("],") // stubs_sources
294 }
Paul Duffin0e0cf1d2019-11-12 19:39:25 +0000295 if len(nativeLibInfos) > 0 {
296 bp.Printfln("native_shared_libs: [")
297 bp.Indent()
298 for _, info := range nativeLibInfos {
299 bp.Printfln("%q,", builder.VersionedSdkMemberName(info.name))
300 }
301 bp.Dedent()
302 bp.Printfln("],") // native_shared_libs
303 }
304 bp.Dedent()
305 bp.Printfln("}") // sdk_snapshot
306 bp.Printfln("")
307
308 bp.build(pctx, ctx, nil)
309
310 filesToZip := builder.filesToZip
Jiyong Park9b409bc2019-10-11 14:59:13 +0900311
Jiyong Park232e7852019-11-04 12:23:40 +0900312 // zip them all
Paul Duffin91547182019-11-12 19:39:36 +0000313 outputZipFile := android.PathForModuleOut(ctx, ctx.ModuleName()+"-current.zip").OutputPath
314 outputRuleName := "snapshot"
315 outputDesc := "Building snapshot for " + ctx.ModuleName()
316
317 // If there are no zips to merge then generate the output zip directly.
318 // Otherwise, generate an intermediate zip file into which other zips can be
319 // merged.
320 var zipFile android.OutputPath
321 var ruleName string
322 var desc string
323 if len(builder.zipsToMerge) == 0 {
324 zipFile = outputZipFile
325 ruleName = outputRuleName
326 desc = outputDesc
327 } else {
328 zipFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"-current.unmerged.zip").OutputPath
329 ruleName = "intermediate snapshot"
330 desc = "Building intermediate snapshot for " + ctx.ModuleName()
331 }
332
Jiyong Park232e7852019-11-04 12:23:40 +0900333 rb := android.NewRuleBuilder()
334 rb.Command().
335 BuiltTool(ctx, "soong_zip").
Paul Duffin0e0cf1d2019-11-12 19:39:25 +0000336 FlagWithArg("-C ", builder.snapshotDir.String()).
Jiyong Park232e7852019-11-04 12:23:40 +0900337 FlagWithRspFileInputList("-l ", filesToZip).
338 FlagWithOutput("-o ", zipFile)
Paul Duffin91547182019-11-12 19:39:36 +0000339 rb.Build(pctx, ctx, ruleName, desc)
Jiyong Park9b409bc2019-10-11 14:59:13 +0900340
Paul Duffin91547182019-11-12 19:39:36 +0000341 if len(builder.zipsToMerge) != 0 {
342 rb := android.NewRuleBuilder()
343 rb.Command().
344 BuiltTool(ctx, "merge_zips").
345 Output(outputZipFile).
346 Input(zipFile).
347 Inputs(builder.zipsToMerge)
348 rb.Build(pctx, ctx, outputRuleName, outputDesc)
349 }
350
351 return outputZipFile
Jiyong Park9b409bc2019-10-11 14:59:13 +0900352}
Paul Duffin0e0cf1d2019-11-12 19:39:25 +0000353
Paul Duffinac37c502019-11-26 18:02:20 +0000354func (s *sdk) GetAndroidBpContentsForTests() string {
355 return s.builderForTests.androidBpFile.content.String()
356}
357
Paul Duffin0e0cf1d2019-11-12 19:39:25 +0000358func buildSharedNativeLibSnapshot(ctx android.ModuleContext, info *nativeLibInfo, builder android.SnapshotBuilder) {
359 // a function for emitting include dirs
360 printExportedDirCopyCommandsForNativeLibs := func(lib archSpecificNativeLibInfo) {
361 includeDirs := lib.exportedIncludeDirs
362 includeDirs = append(includeDirs, lib.exportedSystemIncludeDirs...)
363 if len(includeDirs) == 0 {
364 return
365 }
366 for _, dir := range includeDirs {
367 if _, gen := dir.(android.WritablePath); gen {
368 // generated headers are copied via exportedDeps. See below.
369 continue
370 }
371 targetDir := nativeIncludeDir
372 if info.hasArchSpecificFlags {
373 targetDir = filepath.Join(lib.archType, targetDir)
374 }
375
376 // TODO(jiyong) copy headers having other suffixes
377 headers, _ := ctx.GlobWithDeps(dir.String()+"/**/*.h", nil)
378 for _, file := range headers {
379 src := android.PathForSource(ctx, file)
380 dest := filepath.Join(targetDir, file)
381 builder.CopyToSnapshot(src, dest)
382 }
383 }
384
385 genHeaders := lib.exportedDeps
386 for _, file := range genHeaders {
387 targetDir := nativeGeneratedIncludeDir
388 if info.hasArchSpecificFlags {
389 targetDir = filepath.Join(lib.archType, targetDir)
390 }
391 dest := filepath.Join(targetDir, lib.name, file.Rel())
392 builder.CopyToSnapshot(file, dest)
393 }
394 }
395
396 if !info.hasArchSpecificFlags {
397 printExportedDirCopyCommandsForNativeLibs(info.archVariants[0])
398 }
399
400 // for each architecture
401 for _, av := range info.archVariants {
402 builder.CopyToSnapshot(av.outputFile, nativeStubFilePathFor(av))
403
404 if info.hasArchSpecificFlags {
405 printExportedDirCopyCommandsForNativeLibs(av)
406 }
407 }
408
Paul Duffin90102502019-11-25 19:49:33 +0000409 info.generatePrebuiltLibrary(ctx, builder, true)
410
411 // This module is for the case when the source tree for the unversioned module
412 // doesn't exist (i.e. building in an unbundled tree). "prefer:" is set to false
413 // so that this module does not eclipse the unversioned module if it exists.
414 info.generatePrebuiltLibrary(ctx, builder, false)
415}
416
417func (info *nativeLibInfo) generatePrebuiltLibrary(ctx android.ModuleContext, builder android.SnapshotBuilder, versioned bool) {
Paul Duffin0e0cf1d2019-11-12 19:39:25 +0000418 bp := builder.AndroidBpFile()
419 bp.Printfln("cc_prebuilt_library_shared {")
420 bp.Indent()
Paul Duffin90102502019-11-25 19:49:33 +0000421 name := info.name
422 if versioned {
423 bp.Printfln("name: %q,", builder.VersionedSdkMemberName(name))
424 bp.Printfln("sdk_member_name: %q,", name)
425 } else {
426 bp.Printfln("name: %q,", name)
427 bp.Printfln("prefer: false,")
428 }
Paul Duffin0e0cf1d2019-11-12 19:39:25 +0000429
430 // a function for emitting include dirs
431 printExportedDirsForNativeLibs := func(lib archSpecificNativeLibInfo, systemInclude bool) {
432 includeDirs := nativeIncludeDirPathsFor(ctx, lib, systemInclude, info.hasArchSpecificFlags)
433 if len(includeDirs) == 0 {
434 return
435 }
436 if !systemInclude {
437 bp.Printfln("export_include_dirs: [")
438 } else {
439 bp.Printfln("export_system_include_dirs: [")
440 }
441 bp.Indent()
442 for _, dir := range includeDirs {
443 bp.Printfln("%q,", dir)
444 }
445 bp.Dedent()
446 bp.Printfln("],")
447 }
448
449 if !info.hasArchSpecificFlags {
450 printExportedDirsForNativeLibs(info.archVariants[0], false /*systemInclude*/)
451 printExportedDirsForNativeLibs(info.archVariants[0], true /*systemInclude*/)
452 }
453
454 bp.Printfln("arch: {")
455 bp.Indent()
456 for _, av := range info.archVariants {
457 bp.Printfln("%s: {", av.archType)
458 bp.Indent()
459 bp.Printfln("srcs: [%q],", nativeStubFilePathFor(av))
460 if info.hasArchSpecificFlags {
461 // export_* properties are added inside the arch: {<arch>: {...}} block
462 printExportedDirsForNativeLibs(av, false /*systemInclude*/)
463 printExportedDirsForNativeLibs(av, true /*systemInclude*/)
464 }
465 bp.Dedent()
466 bp.Printfln("},") // <arch>
467 }
468 bp.Dedent()
469 bp.Printfln("},") // arch
470 bp.Printfln("stl: \"none\",")
471 bp.Printfln("system_shared_libs: [],")
472 bp.Dedent()
473 bp.Printfln("}") // cc_prebuilt_library_shared
474 bp.Printfln("")
475}
476
477type snapshotBuilder struct {
478 ctx android.ModuleContext
479 version string
480 snapshotDir android.OutputPath
Paul Duffin0e0cf1d2019-11-12 19:39:25 +0000481 androidBpFile *generatedFile
Paul Duffin91547182019-11-12 19:39:36 +0000482 filesToZip android.Paths
483 zipsToMerge android.Paths
Paul Duffin0e0cf1d2019-11-12 19:39:25 +0000484}
485
486func (s *snapshotBuilder) CopyToSnapshot(src android.Path, dest string) {
487 path := s.snapshotDir.Join(s.ctx, dest)
488 s.ctx.Build(pctx, android.BuildParams{
489 Rule: android.Cp,
490 Input: src,
491 Output: path,
492 })
493 s.filesToZip = append(s.filesToZip, path)
494}
495
Paul Duffin91547182019-11-12 19:39:36 +0000496func (s *snapshotBuilder) UnzipToSnapshot(zipPath android.Path, destDir string) {
497 ctx := s.ctx
498
499 // Repackage the zip file so that the entries are in the destDir directory.
500 // This will allow the zip file to be merged into the snapshot.
501 tmpZipPath := android.PathForModuleOut(ctx, "tmp", destDir+".zip").OutputPath
502 rb := android.NewRuleBuilder()
503 rb.Command().
504 BuiltTool(ctx, "zip2zip").
505 FlagWithInput("-i ", zipPath).
506 FlagWithOutput("-o ", tmpZipPath).
507 Flag("**/*:" + destDir)
508 rb.Build(pctx, ctx, "repackaging "+destDir,
509 "Repackaging zip file "+destDir+" for snapshot "+ctx.ModuleName())
510
511 // Add the repackaged zip file to the files to merge.
512 s.zipsToMerge = append(s.zipsToMerge, tmpZipPath)
513}
514
Paul Duffin0e0cf1d2019-11-12 19:39:25 +0000515func (s *snapshotBuilder) AndroidBpFile() android.GeneratedSnapshotFile {
516 return s.androidBpFile
517}
518
519func (s *snapshotBuilder) VersionedSdkMemberName(unversionedName string) interface{} {
520 return versionedSdkMemberName(s.ctx, unversionedName, s.version)
521}