blob: 672458c532acce137cbf8b0ba44513954b6579ee [file] [log] [blame]
Jiyong Parkfa616132021-04-20 11:36:40 +09001// Copyright (C) 2021 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 "android/soong/android"
19 "android/soong/linkerconfig"
Kiyoung Kim67118212024-11-07 13:23:44 +090020
21 "github.com/google/blueprint/proptools"
Jiyong Parkfa616132021-04-20 11:36:40 +090022)
23
24type systemImage struct {
25 filesystem
Jiyong Parkfa616132021-04-20 11:36:40 +090026}
27
Kiyoung Kim67118212024-11-07 13:23:44 +090028var _ filesystemBuilder = (*systemImage)(nil)
Jiyong Parkfa616132021-04-20 11:36:40 +090029
30// android_system_image is a specialization of android_filesystem for the 'system' partition.
31// Currently, the only difference is the inclusion of linker.config.pb file which specifies
32// the provided and the required libraries to and from APEXes.
Jihoon Kang98047cf2024-10-02 17:13:54 +000033func SystemImageFactory() android.Module {
Jiyong Parkfa616132021-04-20 11:36:40 +090034 module := &systemImage{}
Kiyoung Kim67118212024-11-07 13:23:44 +090035 module.filesystemBuilder = module
Cole Faust2cfe6962024-09-17 11:31:14 -070036 initFilesystemModule(module, &module.filesystem)
Jiyong Parkfa616132021-04-20 11:36:40 +090037 return module
38}
39
Jihoon Kang98047cf2024-10-02 17:13:54 +000040func (s systemImage) FsProps() FilesystemProperties {
41 return s.filesystem.properties
42}
43
Kiyoung Kim67118212024-11-07 13:23:44 +090044func (s *systemImage) BuildLinkerConfigFile(ctx android.ModuleContext, builder *android.RuleBuilder, rebasedDir android.OutputPath) {
Spandan Das2047a4c2024-11-11 21:24:58 +000045 if !proptools.Bool(s.filesystem.properties.Linker_config.Gen_linker_config) {
Kiyoung Kim67118212024-11-07 13:23:44 +090046 return
Cole Faust9a24d902024-03-18 15:38:12 -070047 }
Jooyung Handf09d172021-05-11 11:13:30 +090048
Spandan Das918191e2024-10-31 18:27:23 +000049 provideModules, requireModules := s.getLibsForLinkerConfig(ctx)
Kiyoung Kim67118212024-11-07 13:23:44 +090050 output := rebasedDir.Join(ctx, "etc", "linker.config.pb")
Spandan Das2047a4c2024-11-11 21:24:58 +000051 linkerconfig.BuildLinkerConfig(ctx, builder, android.PathsForModuleSrc(ctx, s.filesystem.properties.Linker_config.Linker_config_srcs), provideModules, requireModules, output)
Kiyoung Kim67118212024-11-07 13:23:44 +090052
53 s.appendToEntry(ctx, output)
Jiyong Parkfa616132021-04-20 11:36:40 +090054}
Jooyung Han0fbbc2b2022-03-25 12:35:46 +090055
Inseob Kim33f95a92024-07-11 15:44:49 +090056// Filter the result of GatherPackagingSpecs to discard items targeting outside "system" / "root"
57// partition. Note that "apex" module installs its contents to "apex"(fake partition) as well
Jooyung Han0fbbc2b2022-03-25 12:35:46 +090058// for symbol lookup by imitating "activated" paths.
Kiyoung Kim67118212024-11-07 13:23:44 +090059func (s *systemImage) FilterPackagingSpec(ps android.PackagingSpec) bool {
Hugo Drumond Jacob69d829a2024-10-21 09:55:45 +000060 return !ps.SkipInstall() &&
Inseob Kim33f95a92024-07-11 15:44:49 +090061 (ps.Partition() == "system" || ps.Partition() == "root")
Jooyung Han0fbbc2b2022-03-25 12:35:46 +090062}