blob: ccf9e9d3b6bdc010578e729a116e648b41c42207 [file] [log] [blame]
Jiyong Park6f0f6882020-11-12 13:14:30 +09001// Copyright (C) 2020 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 filesystem
16
17import (
18 "fmt"
Inseob Kim14199b02021-02-09 21:18:31 +090019 "path/filepath"
20 "strings"
Jiyong Park6f0f6882020-11-12 13:14:30 +090021
22 "android/soong/android"
Jiyong Park65b62242020-11-25 12:44:59 +090023
24 "github.com/google/blueprint"
Jiyong Park71baa762021-01-18 21:11:03 +090025 "github.com/google/blueprint/proptools"
Jiyong Park6f0f6882020-11-12 13:14:30 +090026)
27
28func init() {
Jooyung Han9706cbc2021-04-15 22:43:48 +090029 registerBuildComponents(android.InitRegistrationContext)
30}
31
32func registerBuildComponents(ctx android.RegistrationContext) {
33 ctx.RegisterModuleType("android_filesystem", filesystemFactory)
Jiyong Parkfa616132021-04-20 11:36:40 +090034 ctx.RegisterModuleType("android_system_image", systemImageFactory)
Jiyong Park6f0f6882020-11-12 13:14:30 +090035}
36
37type filesystem struct {
38 android.ModuleBase
39 android.PackagingBase
Jiyong Park65c49f52020-11-24 14:23:26 +090040
Jiyong Park71baa762021-01-18 21:11:03 +090041 properties filesystemProperties
42
Jiyong Parkfa616132021-04-20 11:36:40 +090043 // Function that builds extra files under the root directory and returns the files
44 buildExtraFiles func(ctx android.ModuleContext, root android.OutputPath) android.OutputPaths
45
Jooyung Han0fbbc2b2022-03-25 12:35:46 +090046 // Function that filters PackagingSpecs returned by PackagingBase.GatherPackagingSpecs()
47 filterPackagingSpecs func(specs map[string]android.PackagingSpec)
48
Jiyong Park65c49f52020-11-24 14:23:26 +090049 output android.OutputPath
50 installDir android.InstallPath
Jooyung Han0fbbc2b2022-03-25 12:35:46 +090051
52 // For testing. Keeps the result of CopyDepsToZip()
53 entries []string
Jiyong Park6f0f6882020-11-12 13:14:30 +090054}
55
Inseob Kim14199b02021-02-09 21:18:31 +090056type symlinkDefinition struct {
57 Target *string
58 Name *string
59}
60
Jiyong Park71baa762021-01-18 21:11:03 +090061type filesystemProperties struct {
62 // When set to true, sign the image with avbtool. Default is false.
63 Use_avb *bool
64
65 // Path to the private key that avbtool will use to sign this filesystem image.
66 // TODO(jiyong): allow apex_key to be specified here
67 Avb_private_key *string `android:"path"`
68
69 // Hash and signing algorithm for avbtool. Default is SHA256_RSA4096.
70 Avb_algorithm *string
Jiyong Park11a65972021-02-01 21:09:38 +090071
Jiyong Parkac4076d2021-03-15 23:21:30 +090072 // Name of the partition stored in vbmeta desc. Defaults to the name of this module.
73 Partition_name *string
74
Jiyong Park837cdb22021-02-05 00:17:14 +090075 // Type of the filesystem. Currently, ext4, cpio, and compressed_cpio are supported. Default
76 // is ext4.
Jiyong Park11a65972021-02-01 21:09:38 +090077 Type *string
Inseob Kimcc8e5362021-02-03 14:05:24 +090078
79 // file_contexts file to make image. Currently, only ext4 is supported.
80 File_contexts *string `android:"path"`
Inseob Kim2ce1b5d2021-02-15 17:01:04 +090081
82 // Base directory relative to root, to which deps are installed, e.g. "system". Default is "."
83 // (root).
84 Base_dir *string
Inseob Kim14199b02021-02-09 21:18:31 +090085
86 // Directories to be created under root. e.g. /dev, /proc, etc.
87 Dirs []string
88
89 // Symbolic links to be created under root with "ln -sf <target> <name>".
90 Symlinks []symlinkDefinition
Jiyong Park71baa762021-01-18 21:11:03 +090091}
92
Jiyong Park65c49f52020-11-24 14:23:26 +090093// android_filesystem packages a set of modules and their transitive dependencies into a filesystem
94// image. The filesystem images are expected to be mounted in the target device, which means the
95// modules in the filesystem image are built for the target device (i.e. Android, not Linux host).
96// The modules are placed in the filesystem image just like they are installed to the ordinary
97// partitions like system.img. For example, cc_library modules are placed under ./lib[64] directory.
Jiyong Park6f0f6882020-11-12 13:14:30 +090098func filesystemFactory() android.Module {
99 module := &filesystem{}
Jiyong Parkfa616132021-04-20 11:36:40 +0900100 initFilesystemModule(module)
101 return module
102}
103
104func initFilesystemModule(module *filesystem) {
Jiyong Park71baa762021-01-18 21:11:03 +0900105 module.AddProperties(&module.properties)
Jiyong Park6f0f6882020-11-12 13:14:30 +0900106 android.InitPackageModule(module)
107 android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
Jiyong Park6f0f6882020-11-12 13:14:30 +0900108}
109
Jiyong Park12a719c2021-01-07 15:31:24 +0900110var dependencyTag = struct {
111 blueprint.BaseDependencyTag
Jooyung Han092ef812021-03-10 15:40:34 +0900112 android.PackagingItemAlwaysDepTag
Jiyong Park12a719c2021-01-07 15:31:24 +0900113}{}
Jiyong Park65b62242020-11-25 12:44:59 +0900114
Jiyong Park6f0f6882020-11-12 13:14:30 +0900115func (f *filesystem) DepsMutator(ctx android.BottomUpMutatorContext) {
Jiyong Park65b62242020-11-25 12:44:59 +0900116 f.AddDeps(ctx, dependencyTag)
Jiyong Park6f0f6882020-11-12 13:14:30 +0900117}
118
Jiyong Park11a65972021-02-01 21:09:38 +0900119type fsType int
120
121const (
122 ext4Type fsType = iota
123 compressedCpioType
Jiyong Park837cdb22021-02-05 00:17:14 +0900124 cpioType // uncompressed
Jiyong Park11a65972021-02-01 21:09:38 +0900125 unknown
126)
127
128func (f *filesystem) fsType(ctx android.ModuleContext) fsType {
129 typeStr := proptools.StringDefault(f.properties.Type, "ext4")
130 switch typeStr {
131 case "ext4":
132 return ext4Type
133 case "compressed_cpio":
134 return compressedCpioType
Jiyong Park837cdb22021-02-05 00:17:14 +0900135 case "cpio":
136 return cpioType
Jiyong Park11a65972021-02-01 21:09:38 +0900137 default:
138 ctx.PropertyErrorf("type", "%q not supported", typeStr)
139 return unknown
140 }
141}
142
Jiyong Park65c49f52020-11-24 14:23:26 +0900143func (f *filesystem) installFileName() string {
144 return f.BaseModuleName() + ".img"
145}
146
Jiyong Park6f0f6882020-11-12 13:14:30 +0900147var pctx = android.NewPackageContext("android/soong/filesystem")
148
149func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Jiyong Park11a65972021-02-01 21:09:38 +0900150 switch f.fsType(ctx) {
151 case ext4Type:
152 f.output = f.buildImageUsingBuildImage(ctx)
153 case compressedCpioType:
Jiyong Park837cdb22021-02-05 00:17:14 +0900154 f.output = f.buildCpioImage(ctx, true)
155 case cpioType:
156 f.output = f.buildCpioImage(ctx, false)
Jiyong Park11a65972021-02-01 21:09:38 +0900157 default:
158 return
159 }
160
161 f.installDir = android.PathForModuleInstall(ctx, "etc")
162 ctx.InstallFile(f.installDir, f.installFileName(), f.output)
163}
164
Jiyong Parkfa616132021-04-20 11:36:40 +0900165// root zip will contain extra files/dirs that are not from the `deps` property.
Inseob Kim2ce1b5d2021-02-15 17:01:04 +0900166func (f *filesystem) buildRootZip(ctx android.ModuleContext) android.OutputPath {
167 rootDir := android.PathForModuleGen(ctx, "root").OutputPath
168 builder := android.NewRuleBuilder(pctx, ctx)
169 builder.Command().Text("rm -rf").Text(rootDir.String())
170 builder.Command().Text("mkdir -p").Text(rootDir.String())
171
Inseob Kim14199b02021-02-09 21:18:31 +0900172 // create dirs and symlinks
173 for _, dir := range f.properties.Dirs {
174 // OutputPath.Join verifies dir
175 builder.Command().Text("mkdir -p").Text(rootDir.Join(ctx, dir).String())
176 }
177
178 for _, symlink := range f.properties.Symlinks {
179 name := strings.TrimSpace(proptools.String(symlink.Name))
180 target := strings.TrimSpace(proptools.String(symlink.Target))
181
182 if name == "" {
183 ctx.PropertyErrorf("symlinks", "Name can't be empty")
184 continue
185 }
186
187 if target == "" {
188 ctx.PropertyErrorf("symlinks", "Target can't be empty")
189 continue
190 }
191
192 // OutputPath.Join verifies name. don't need to verify target.
193 dst := rootDir.Join(ctx, name)
194
195 builder.Command().Text("mkdir -p").Text(filepath.Dir(dst.String()))
196 builder.Command().Text("ln -sf").Text(proptools.ShellEscape(target)).Text(dst.String())
197 }
Inseob Kim2ce1b5d2021-02-15 17:01:04 +0900198
Jiyong Parkfa616132021-04-20 11:36:40 +0900199 // create extra files if there's any
200 rootForExtraFiles := android.PathForModuleGen(ctx, "root-extra").OutputPath
201 var extraFiles android.OutputPaths
202 if f.buildExtraFiles != nil {
203 extraFiles = f.buildExtraFiles(ctx, rootForExtraFiles)
204 for _, f := range extraFiles {
205 rel, _ := filepath.Rel(rootForExtraFiles.String(), f.String())
206 if strings.HasPrefix(rel, "..") {
207 panic(fmt.Errorf("%q is not under %q\n", f, rootForExtraFiles))
208 }
209 }
210 }
Inseob Kim2ce1b5d2021-02-15 17:01:04 +0900211
Jiyong Parkfa616132021-04-20 11:36:40 +0900212 // Zip them all
213 zipOut := android.PathForModuleGen(ctx, "root.zip").OutputPath
214 zipCommand := builder.Command().BuiltTool("soong_zip")
215 zipCommand.FlagWithOutput("-o ", zipOut).
Inseob Kim2ce1b5d2021-02-15 17:01:04 +0900216 FlagWithArg("-C ", rootDir.String()).
217 Flag("-L 0"). // no compression because this will be unzipped soon
218 FlagWithArg("-D ", rootDir.String()).
219 Flag("-d") // include empty directories
Jiyong Parkfa616132021-04-20 11:36:40 +0900220 if len(extraFiles) > 0 {
221 zipCommand.FlagWithArg("-C ", rootForExtraFiles.String())
222 for _, f := range extraFiles {
223 zipCommand.FlagWithInput("-f ", f)
224 }
225 }
226
Inseob Kim2ce1b5d2021-02-15 17:01:04 +0900227 builder.Command().Text("rm -rf").Text(rootDir.String())
228
229 builder.Build("zip_root", fmt.Sprintf("zipping root contents for %s", ctx.ModuleName()))
230 return zipOut
231}
232
Jiyong Park11a65972021-02-01 21:09:38 +0900233func (f *filesystem) buildImageUsingBuildImage(ctx android.ModuleContext) android.OutputPath {
Inseob Kim2ce1b5d2021-02-15 17:01:04 +0900234 depsZipFile := android.PathForModuleOut(ctx, "deps.zip").OutputPath
Jooyung Han0fbbc2b2022-03-25 12:35:46 +0900235 f.entries = f.CopyDepsToZip(ctx, f.gatherFilteredPackagingSpecs(ctx), depsZipFile)
Inseob Kim2ce1b5d2021-02-15 17:01:04 +0900236
237 builder := android.NewRuleBuilder(pctx, ctx)
238 depsBase := proptools.StringDefault(f.properties.Base_dir, ".")
239 rebasedDepsZip := android.PathForModuleOut(ctx, "rebased_deps.zip").OutputPath
240 builder.Command().
241 BuiltTool("zip2zip").
242 FlagWithInput("-i ", depsZipFile).
243 FlagWithOutput("-o ", rebasedDepsZip).
244 Text("**/*:" + proptools.ShellEscape(depsBase)) // zip2zip verifies depsBase
Jiyong Park6f0f6882020-11-12 13:14:30 +0900245
246 rootDir := android.PathForModuleOut(ctx, "root").OutputPath
Inseob Kim2ce1b5d2021-02-15 17:01:04 +0900247 rootZip := f.buildRootZip(ctx)
Jiyong Park6f0f6882020-11-12 13:14:30 +0900248 builder.Command().
Colin Crossf1a035e2020-11-16 17:32:30 -0800249 BuiltTool("zipsync").
Jiyong Park6f0f6882020-11-12 13:14:30 +0900250 FlagWithArg("-d ", rootDir.String()). // zipsync wipes this. No need to clear.
Inseob Kim2ce1b5d2021-02-15 17:01:04 +0900251 Input(rootZip).
252 Input(rebasedDepsZip)
Jiyong Park6f0f6882020-11-12 13:14:30 +0900253
Jiyong Park72678312021-01-18 17:29:49 +0900254 propFile, toolDeps := f.buildPropFile(ctx)
Jiyong Park11a65972021-02-01 21:09:38 +0900255 output := android.PathForModuleOut(ctx, f.installFileName()).OutputPath
Colin Crossf1a035e2020-11-16 17:32:30 -0800256 builder.Command().BuiltTool("build_image").
Jiyong Park6f0f6882020-11-12 13:14:30 +0900257 Text(rootDir.String()). // input directory
258 Input(propFile).
Jiyong Park72678312021-01-18 17:29:49 +0900259 Implicits(toolDeps).
Jiyong Park11a65972021-02-01 21:09:38 +0900260 Output(output).
Jiyong Park6f0f6882020-11-12 13:14:30 +0900261 Text(rootDir.String()) // directory where to find fs_config_files|dirs
262
263 // rootDir is not deleted. Might be useful for quick inspection.
Colin Crossf1a035e2020-11-16 17:32:30 -0800264 builder.Build("build_filesystem_image", fmt.Sprintf("Creating filesystem %s", f.BaseModuleName()))
Jiyong Park65c49f52020-11-24 14:23:26 +0900265
Jiyong Park11a65972021-02-01 21:09:38 +0900266 return output
Jiyong Park65c49f52020-11-24 14:23:26 +0900267}
268
Inseob Kimcc8e5362021-02-03 14:05:24 +0900269func (f *filesystem) buildFileContexts(ctx android.ModuleContext) android.OutputPath {
270 builder := android.NewRuleBuilder(pctx, ctx)
271 fcBin := android.PathForModuleOut(ctx, "file_contexts.bin")
272 builder.Command().BuiltTool("sefcontext_compile").
273 FlagWithOutput("-o ", fcBin).
274 Input(android.PathForModuleSrc(ctx, proptools.String(f.properties.File_contexts)))
275 builder.Build("build_filesystem_file_contexts", fmt.Sprintf("Creating filesystem file contexts for %s", f.BaseModuleName()))
276 return fcBin.OutputPath
277}
278
Jiyong Park72678312021-01-18 17:29:49 +0900279func (f *filesystem) buildPropFile(ctx android.ModuleContext) (propFile android.OutputPath, toolDeps android.Paths) {
280 type prop struct {
281 name string
282 value string
283 }
284
285 var props []prop
286 var deps android.Paths
287 addStr := func(name string, value string) {
288 props = append(props, prop{name, value})
289 }
290 addPath := func(name string, path android.Path) {
291 props = append(props, prop{name, path.String()})
292 deps = append(deps, path)
293 }
294
Jiyong Park11a65972021-02-01 21:09:38 +0900295 // Type string that build_image.py accepts.
296 fsTypeStr := func(t fsType) string {
297 switch t {
298 // TODO(jiyong): add more types like f2fs, erofs, etc.
299 case ext4Type:
300 return "ext4"
301 }
302 panic(fmt.Errorf("unsupported fs type %v", t))
303 }
304
305 addStr("fs_type", fsTypeStr(f.fsType(ctx)))
Inseob Kim2ce1b5d2021-02-15 17:01:04 +0900306 addStr("mount_point", "/")
Jiyong Park72678312021-01-18 17:29:49 +0900307 addStr("use_dynamic_partition_size", "true")
308 addPath("ext_mkuserimg", ctx.Config().HostToolPath(ctx, "mkuserimg_mke2fs"))
309 // b/177813163 deps of the host tools have to be added. Remove this.
310 for _, t := range []string{"mke2fs", "e2fsdroid", "tune2fs"} {
311 deps = append(deps, ctx.Config().HostToolPath(ctx, t))
312 }
313
Jiyong Park71baa762021-01-18 21:11:03 +0900314 if proptools.Bool(f.properties.Use_avb) {
315 addStr("avb_hashtree_enable", "true")
316 addPath("avb_avbtool", ctx.Config().HostToolPath(ctx, "avbtool"))
317 algorithm := proptools.StringDefault(f.properties.Avb_algorithm, "SHA256_RSA4096")
318 addStr("avb_algorithm", algorithm)
319 key := android.PathForModuleSrc(ctx, proptools.String(f.properties.Avb_private_key))
320 addPath("avb_key_path", key)
321 addStr("avb_add_hashtree_footer_args", "--do_not_generate_fec")
Jiyong Parkac4076d2021-03-15 23:21:30 +0900322 partitionName := proptools.StringDefault(f.properties.Partition_name, f.Name())
323 addStr("partition_name", partitionName)
Jiyong Park71baa762021-01-18 21:11:03 +0900324 }
325
Inseob Kimcc8e5362021-02-03 14:05:24 +0900326 if proptools.String(f.properties.File_contexts) != "" {
327 addPath("selinux_fc", f.buildFileContexts(ctx))
328 }
329
Jiyong Park72678312021-01-18 17:29:49 +0900330 propFile = android.PathForModuleOut(ctx, "prop").OutputPath
331 builder := android.NewRuleBuilder(pctx, ctx)
332 builder.Command().Text("rm").Flag("-rf").Output(propFile)
333 for _, p := range props {
334 builder.Command().
Jiyong Park3db465d2021-01-26 14:08:16 +0900335 Text("echo").
Jiyong Park72678312021-01-18 17:29:49 +0900336 Flag(`"` + p.name + "=" + p.value + `"`).
337 Text(">>").Output(propFile)
338 }
339 builder.Build("build_filesystem_prop", fmt.Sprintf("Creating filesystem props for %s", f.BaseModuleName()))
340 return propFile, deps
341}
342
Jiyong Park837cdb22021-02-05 00:17:14 +0900343func (f *filesystem) buildCpioImage(ctx android.ModuleContext, compressed bool) android.OutputPath {
Jiyong Park11a65972021-02-01 21:09:38 +0900344 if proptools.Bool(f.properties.Use_avb) {
345 ctx.PropertyErrorf("use_avb", "signing compresed cpio image using avbtool is not supported."+
346 "Consider adding this to bootimg module and signing the entire boot image.")
347 }
348
Inseob Kimcc8e5362021-02-03 14:05:24 +0900349 if proptools.String(f.properties.File_contexts) != "" {
350 ctx.PropertyErrorf("file_contexts", "file_contexts is not supported for compressed cpio image.")
351 }
352
Inseob Kim2ce1b5d2021-02-15 17:01:04 +0900353 depsZipFile := android.PathForModuleOut(ctx, "deps.zip").OutputPath
Jooyung Han0fbbc2b2022-03-25 12:35:46 +0900354 f.entries = f.CopyDepsToZip(ctx, f.gatherFilteredPackagingSpecs(ctx), depsZipFile)
Inseob Kim2ce1b5d2021-02-15 17:01:04 +0900355
356 builder := android.NewRuleBuilder(pctx, ctx)
357 depsBase := proptools.StringDefault(f.properties.Base_dir, ".")
358 rebasedDepsZip := android.PathForModuleOut(ctx, "rebased_deps.zip").OutputPath
359 builder.Command().
360 BuiltTool("zip2zip").
361 FlagWithInput("-i ", depsZipFile).
362 FlagWithOutput("-o ", rebasedDepsZip).
363 Text("**/*:" + proptools.ShellEscape(depsBase)) // zip2zip verifies depsBase
Jiyong Park11a65972021-02-01 21:09:38 +0900364
365 rootDir := android.PathForModuleOut(ctx, "root").OutputPath
Inseob Kim2ce1b5d2021-02-15 17:01:04 +0900366 rootZip := f.buildRootZip(ctx)
Jiyong Park11a65972021-02-01 21:09:38 +0900367 builder.Command().
368 BuiltTool("zipsync").
369 FlagWithArg("-d ", rootDir.String()). // zipsync wipes this. No need to clear.
Inseob Kim2ce1b5d2021-02-15 17:01:04 +0900370 Input(rootZip).
371 Input(rebasedDepsZip)
Jiyong Park11a65972021-02-01 21:09:38 +0900372
373 output := android.PathForModuleOut(ctx, f.installFileName()).OutputPath
Jiyong Park837cdb22021-02-05 00:17:14 +0900374 cmd := builder.Command().
Jiyong Park11a65972021-02-01 21:09:38 +0900375 BuiltTool("mkbootfs").
Jiyong Park837cdb22021-02-05 00:17:14 +0900376 Text(rootDir.String()) // input directory
377 if compressed {
378 cmd.Text("|").
379 BuiltTool("lz4").
380 Flag("--favor-decSpeed"). // for faster boot
381 Flag("-12"). // maximum compression level
382 Flag("-l"). // legacy format for kernel
383 Text(">").Output(output)
384 } else {
385 cmd.Text(">").Output(output)
386 }
Jiyong Park11a65972021-02-01 21:09:38 +0900387
388 // rootDir is not deleted. Might be useful for quick inspection.
Jiyong Park837cdb22021-02-05 00:17:14 +0900389 builder.Build("build_cpio_image", fmt.Sprintf("Creating filesystem %s", f.BaseModuleName()))
Jiyong Park11a65972021-02-01 21:09:38 +0900390
391 return output
392}
393
Jiyong Park65c49f52020-11-24 14:23:26 +0900394var _ android.AndroidMkEntriesProvider = (*filesystem)(nil)
395
396// Implements android.AndroidMkEntriesProvider
397func (f *filesystem) AndroidMkEntries() []android.AndroidMkEntries {
398 return []android.AndroidMkEntries{android.AndroidMkEntries{
399 Class: "ETC",
400 OutputFile: android.OptionalPathForPath(f.output),
401 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700402 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crossc68db4b2021-11-11 18:59:15 -0800403 entries.SetString("LOCAL_MODULE_PATH", f.installDir.String())
Jiyong Park65c49f52020-11-24 14:23:26 +0900404 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", f.installFileName())
405 },
406 },
407 }}
Jiyong Park6f0f6882020-11-12 13:14:30 +0900408}
Jiyong Park12a719c2021-01-07 15:31:24 +0900409
Jiyong Park940dfd42021-02-04 15:37:34 +0900410var _ android.OutputFileProducer = (*filesystem)(nil)
411
412// Implements android.OutputFileProducer
413func (f *filesystem) OutputFiles(tag string) (android.Paths, error) {
414 if tag == "" {
415 return []android.Path{f.output}, nil
416 }
417 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
418}
419
Jiyong Park12a719c2021-01-07 15:31:24 +0900420// Filesystem is the public interface for the filesystem struct. Currently, it's only for the apex
421// package to have access to the output file.
422type Filesystem interface {
423 android.Module
424 OutputPath() android.Path
Jiyong Park972e06c2021-03-15 23:32:49 +0900425
426 // Returns the output file that is signed by avbtool. If this module is not signed, returns
427 // nil.
428 SignedOutputPath() android.Path
Jiyong Park12a719c2021-01-07 15:31:24 +0900429}
430
431var _ Filesystem = (*filesystem)(nil)
432
433func (f *filesystem) OutputPath() android.Path {
434 return f.output
435}
Jiyong Park972e06c2021-03-15 23:32:49 +0900436
437func (f *filesystem) SignedOutputPath() android.Path {
438 if proptools.Bool(f.properties.Use_avb) {
439 return f.OutputPath()
440 }
441 return nil
442}
Jooyung Han0fbbc2b2022-03-25 12:35:46 +0900443
444// Filter the result of GatherPackagingSpecs to discard items targeting outside "system" partition.
445// Note that "apex" module installs its contents to "apex"(fake partition) as well
446// for symbol lookup by imitating "activated" paths.
447func (f *filesystem) gatherFilteredPackagingSpecs(ctx android.ModuleContext) map[string]android.PackagingSpec {
448 specs := f.PackagingBase.GatherPackagingSpecs(ctx)
449 if f.filterPackagingSpecs != nil {
450 f.filterPackagingSpecs(specs)
451 }
452 return specs
453}