Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 1 | // Copyright 2016 Google Inc. All rights reserved. |
| 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 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 15 | package etc |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 16 | |
Yo Chiang | 803c40d | 2020-11-16 20:32:51 +0800 | [diff] [blame] | 17 | // This file implements module types that install prebuilt artifacts. |
| 18 | // |
| 19 | // There exist two classes of prebuilt modules in the Android tree. The first class are the ones |
| 20 | // based on `android.Prebuilt`, such as `cc_prebuilt_library` and `java_import`. This kind of |
| 21 | // modules may exist both as prebuilts and source at the same time, though only one would be |
| 22 | // installed and the other would be marked disabled. The `prebuilt_postdeps` mutator would select |
| 23 | // the actual modules to be installed. More details in android/prebuilt.go. |
| 24 | // |
| 25 | // The second class is described in this file. Unlike `android.Prebuilt` based module types, |
| 26 | // `prebuilt_etc` exist only as prebuilts and cannot have a same-named source module counterpart. |
| 27 | // This makes the logic of `prebuilt_etc` to be much simpler as they don't need to go through the |
| 28 | // various `prebuilt_*` mutators. |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 29 | |
Yo Chiang | 803c40d | 2020-11-16 20:32:51 +0800 | [diff] [blame] | 30 | import ( |
Jiyong Park | 76a42f5 | 2021-02-16 06:50:37 +0900 | [diff] [blame] | 31 | "fmt" |
Kiyoung Kim | ae11c23 | 2021-07-19 11:38:04 +0900 | [diff] [blame] | 32 | "path/filepath" |
Inseob Kim | 27408bf | 2021-04-06 21:00:17 +0900 | [diff] [blame] | 33 | "strings" |
Jiyong Park | 76a42f5 | 2021-02-16 06:50:37 +0900 | [diff] [blame] | 34 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 35 | "github.com/google/blueprint/proptools" |
| 36 | |
| 37 | "android/soong/android" |
| 38 | ) |
| 39 | |
| 40 | var pctx = android.NewPackageContext("android/soong/etc") |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 41 | |
Jaewoong Jung | c3fcdb4 | 2019-02-13 05:50:33 -0800 | [diff] [blame] | 42 | // TODO(jungw): Now that it handles more than the ones in etc/, consider renaming this file. |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 43 | |
| 44 | func init() { |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 45 | pctx.Import("android/soong/android") |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 46 | RegisterPrebuiltEtcBuildComponents(android.InitRegistrationContext) |
| 47 | } |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 48 | |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 49 | func RegisterPrebuiltEtcBuildComponents(ctx android.RegistrationContext) { |
| 50 | ctx.RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory) |
| 51 | ctx.RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory) |
Miguel | 32b0280 | 2022-12-01 18:38:26 +0000 | [diff] [blame] | 52 | ctx.RegisterModuleType("prebuilt_etc_cacerts", PrebuiltEtcCaCertsFactory) |
Nelson Li | 1fb94b2 | 2024-07-09 17:04:52 +0800 | [diff] [blame] | 53 | ctx.RegisterModuleType("prebuilt_avb", PrebuiltAvbFactory) |
Inseob Kim | 27408bf | 2021-04-06 21:00:17 +0900 | [diff] [blame] | 54 | ctx.RegisterModuleType("prebuilt_root", PrebuiltRootFactory) |
Liz Kammer | e9ecddc | 2022-01-04 17:27:52 -0500 | [diff] [blame] | 55 | ctx.RegisterModuleType("prebuilt_root_host", PrebuiltRootHostFactory) |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 56 | ctx.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory) |
| 57 | ctx.RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory) |
yangbill | 63c5e19 | 2024-03-27 09:02:12 +0000 | [diff] [blame] | 58 | ctx.RegisterModuleType("prebuilt_usr_hyphendata", PrebuiltUserHyphenDataFactory) |
yangbill | 85527e6 | 2024-04-30 08:24:50 +0000 | [diff] [blame] | 59 | ctx.RegisterModuleType("prebuilt_usr_keylayout", PrebuiltUserKeyLayoutFactory) |
| 60 | ctx.RegisterModuleType("prebuilt_usr_keychars", PrebuiltUserKeyCharsFactory) |
| 61 | ctx.RegisterModuleType("prebuilt_usr_idc", PrebuiltUserIdcFactory) |
Jihoon Kang | 0da5ae9 | 2024-10-29 23:24:17 +0000 | [diff] [blame] | 62 | ctx.RegisterModuleType("prebuilt_usr_srec", PrebuiltUserSrecFactory) |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 63 | ctx.RegisterModuleType("prebuilt_font", PrebuiltFontFactory) |
Kevin | 93f7cd8 | 2024-05-02 12:37:59 +0200 | [diff] [blame] | 64 | ctx.RegisterModuleType("prebuilt_overlay", PrebuiltOverlayFactory) |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 65 | ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory) |
| 66 | ctx.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory) |
Colin Cross | 83ebf23 | 2021-04-09 09:41:23 -0700 | [diff] [blame] | 67 | ctx.RegisterModuleType("prebuilt_rfsa", PrebuiltRFSAFactory) |
Colin Cross | f17e2b5 | 2023-10-30 15:17:25 -0700 | [diff] [blame] | 68 | ctx.RegisterModuleType("prebuilt_renderscript_bitcode", PrebuiltRenderScriptBitcodeFactory) |
Jihoon Kang | 0da5ae9 | 2024-10-29 23:24:17 +0000 | [diff] [blame] | 69 | ctx.RegisterModuleType("prebuilt_media", PrebuiltMediaFactory) |
Jihoon Kang | ec62d84 | 2024-10-25 20:27:18 +0000 | [diff] [blame] | 70 | ctx.RegisterModuleType("prebuilt_voicepack", PrebuiltVoicepackFactory) |
| 71 | ctx.RegisterModuleType("prebuilt_bin", PrebuiltBinaryFactory) |
| 72 | ctx.RegisterModuleType("prebuilt_wallpaper", PrebuiltWallpaperFactory) |
Jihoon Kang | 0da5ae9 | 2024-10-29 23:24:17 +0000 | [diff] [blame] | 73 | ctx.RegisterModuleType("prebuilt_priv_app", PrebuiltPrivAppFactory) |
| 74 | ctx.RegisterModuleType("prebuilt_rfs", PrebuiltRfsFactory) |
| 75 | ctx.RegisterModuleType("prebuilt_framework", PrebuiltFrameworkFactory) |
| 76 | ctx.RegisterModuleType("prebuilt_res", PrebuiltResFactory) |
| 77 | ctx.RegisterModuleType("prebuilt_wlc_upt", PrebuiltWlcUptFactory) |
| 78 | ctx.RegisterModuleType("prebuilt_odm", PrebuiltOdmFactory) |
Jihoon Kang | 2e2b744 | 2024-11-05 00:26:20 +0000 | [diff] [blame] | 79 | ctx.RegisterModuleType("prebuilt_vendor_dlkm", PrebuiltVendorDlkmFactory) |
| 80 | ctx.RegisterModuleType("prebuilt_bt_firmware", PrebuiltBtFirmwareFactory) |
Jihoon Kang | dca2f2b | 2024-11-06 18:43:19 +0000 | [diff] [blame] | 81 | ctx.RegisterModuleType("prebuilt_tvservice", PrebuiltTvServiceFactory) |
| 82 | ctx.RegisterModuleType("prebuilt_optee", PrebuiltOpteeFactory) |
Jihoon Kang | ecf76dd | 2024-11-12 05:24:46 +0000 | [diff] [blame] | 83 | ctx.RegisterModuleType("prebuilt_tvconfig", PrebuiltTvConfigFactory) |
Jihoon Kang | 3ca07a1 | 2024-12-02 19:14:30 +0000 | [diff] [blame] | 84 | ctx.RegisterModuleType("prebuilt_vendor", PrebuiltVendorFactory) |
Jihoon Kang | 320ca7c | 2024-12-03 18:14:50 +0000 | [diff] [blame] | 85 | ctx.RegisterModuleType("prebuilt_sbin", PrebuiltSbinFactory) |
| 86 | ctx.RegisterModuleType("prebuilt_system", PrebuiltSystemFactory) |
| 87 | ctx.RegisterModuleType("prebuilt_first_stage_ramdisk", PrebuiltFirstStageRamdiskFactory) |
Jihoon Kang | 3e14966 | 2025-03-12 22:14:39 +0000 | [diff] [blame] | 88 | ctx.RegisterModuleType("prebuilt_any", PrebuiltAnyFactory) |
Inseob Kim | 1e27a14 | 2021-05-06 11:46:11 +0000 | [diff] [blame] | 89 | |
| 90 | ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory) |
Rupert Shuttleworth | 378fc1b | 2021-07-28 08:03:16 -0400 | [diff] [blame] | 91 | |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 92 | } |
| 93 | |
Paul Duffin | 1172fed | 2021-03-08 11:28:18 +0000 | [diff] [blame] | 94 | var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents) |
| 95 | |
Jihoon Kang | 69725b3 | 2024-11-12 03:08:49 +0000 | [diff] [blame] | 96 | type PrebuiltEtcProperties struct { |
Yo Chiang | 803c40d | 2020-11-16 20:32:51 +0800 | [diff] [blame] | 97 | // Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax. |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 98 | // Mutually exclusive with srcs. |
Cole Faust | fdec872 | 2024-05-22 11:38:29 -0700 | [diff] [blame] | 99 | Src proptools.Configurable[string] `android:"path,arch_variant,replace_instead_of_append"` |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 100 | |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 101 | // Source files of this prebuilt. Can reference a genrule type module with the ":module" syntax. |
Douglas Anderson | 79688ff | 2024-09-27 15:08:33 -0700 | [diff] [blame] | 102 | // Mutually exclusive with src. When used, filename_from_src is set to true unless dsts is also |
| 103 | // set. May use globs in filenames. |
Cole Faust | fdec872 | 2024-05-22 11:38:29 -0700 | [diff] [blame] | 104 | Srcs proptools.Configurable[[]string] `android:"path,arch_variant"` |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 105 | |
Yo Chiang | f0e19fe | 2020-11-18 15:28:42 +0800 | [diff] [blame] | 106 | // Optional name for the installed file. If unspecified, name of the module is used as the file |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 107 | // name. Only available when using a single source (src). |
Jiyong Park | 139a2e6 | 2018-10-26 21:49:39 +0900 | [diff] [blame] | 108 | Filename *string `android:"arch_variant"` |
| 109 | |
Yo Chiang | f0e19fe | 2020-11-18 15:28:42 +0800 | [diff] [blame] | 110 | // When set to true, and filename property is not set, the name for the installed file |
Jiyong Park | 1a7cf08 | 2018-11-13 11:59:12 +0900 | [diff] [blame] | 111 | // is the same as the file name of the source file. |
| 112 | Filename_from_src *bool `android:"arch_variant"` |
| 113 | |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 114 | // Make this module available when building for ramdisk. |
Yifan Hong | 39143a9 | 2020-10-26 12:43:12 -0700 | [diff] [blame] | 115 | // On device without a dedicated recovery partition, the module is only |
| 116 | // available after switching root into |
| 117 | // /first_stage_ramdisk. To expose the module before switching root, install |
| 118 | // the recovery variant instead. |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 119 | Ramdisk_available *bool |
| 120 | |
Yifan Hong | 60e0cfb | 2020-10-21 15:17:56 -0700 | [diff] [blame] | 121 | // Make this module available when building for vendor ramdisk. |
Yifan Hong | 39143a9 | 2020-10-26 12:43:12 -0700 | [diff] [blame] | 122 | // On device without a dedicated recovery partition, the module is only |
| 123 | // available after switching root into |
| 124 | // /first_stage_ramdisk. To expose the module before switching root, install |
| 125 | // the recovery variant instead. |
Yifan Hong | 60e0cfb | 2020-10-21 15:17:56 -0700 | [diff] [blame] | 126 | Vendor_ramdisk_available *bool |
| 127 | |
Inseob Kim | 08758f0 | 2021-04-08 21:13:22 +0900 | [diff] [blame] | 128 | // Make this module available when building for debug ramdisk. |
| 129 | Debug_ramdisk_available *bool |
| 130 | |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 131 | // Make this module available when building for recovery. |
| 132 | Recovery_available *bool |
| 133 | |
Jiyong Park | ad9ce04 | 2018-10-31 22:49:57 +0900 | [diff] [blame] | 134 | // Whether this module is directly installable to one of the partitions. Default: true. |
| 135 | Installable *bool |
Yo Chiang | 3d64d49 | 2020-05-27 17:56:39 +0800 | [diff] [blame] | 136 | |
| 137 | // Install symlinks to the installed file. |
| 138 | Symlinks []string `android:"arch_variant"` |
Wei Li | 5958625 | 2024-11-04 09:25:54 -0800 | [diff] [blame] | 139 | |
Wei Li | 5958625 | 2024-11-04 09:25:54 -0800 | [diff] [blame] | 140 | // Install to partition oem when set to true. |
| 141 | Oem_specific *bool `android:"arch_variant"` |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 142 | } |
| 143 | |
Jihoon Kang | 723f122 | 2025-03-12 22:24:52 +0000 | [diff] [blame] | 144 | // Dsts is useful in that it allows prebuilt_* modules to easily map the source files to the |
| 145 | // install path within the partition. Dsts values are allowed to contain filepath separator |
| 146 | // so that the source files can be installed in subdirectories within the partition. |
| 147 | // However, this functionality should not be supported for prebuilt_root module type, as it |
| 148 | // allows the module to install to any arbitrary location. Thus, this property is defined in |
| 149 | // a separate struct so that it's not available to be set in prebuilt_root module type. |
| 150 | type PrebuiltDstsProperties struct { |
| 151 | // Destination files of this prebuilt. Requires srcs to be used and causes srcs not to implicitly |
| 152 | // set filename_from_src. This can be used to install each source file to a different directory |
| 153 | // and/or change filenames when files are installed. Must be exactly one entry per source file, |
| 154 | // which means care must be taken if srcs has globs. |
| 155 | Dsts proptools.Configurable[[]string] `android:"path,arch_variant"` |
| 156 | } |
| 157 | |
Inseob Kim | 27408bf | 2021-04-06 21:00:17 +0900 | [diff] [blame] | 158 | type prebuiltSubdirProperties struct { |
| 159 | // Optional subdirectory under which this file is installed into, cannot be specified with |
| 160 | // relative_install_path, prefer relative_install_path. |
| 161 | Sub_dir *string `android:"arch_variant"` |
| 162 | |
| 163 | // Optional subdirectory under which this file is installed into, cannot be specified with |
| 164 | // sub_dir. |
| 165 | Relative_install_path *string `android:"arch_variant"` |
| 166 | } |
| 167 | |
Inseob Kim | be6a66d | 2024-07-11 15:43:44 +0900 | [diff] [blame] | 168 | type prebuiltRootProperties struct { |
| 169 | // Install this module to the root directory, without partition subdirs. When this module is |
| 170 | // added to PRODUCT_PACKAGES, this module will be installed to $PRODUCT_OUT/root, which will |
| 171 | // then be copied to the root of system.img. When this module is packaged by other modules like |
| 172 | // android_filesystem, this module will be installed to the root ("/"), unlike normal |
| 173 | // prebuilt_root modules which are installed to the partition subdir (e.g. "/system/"). |
| 174 | Install_in_root *bool |
| 175 | } |
| 176 | |
Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 177 | type PrebuiltEtcModule interface { |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 178 | android.Module |
Yo Chiang | f0e19fe | 2020-11-18 15:28:42 +0800 | [diff] [blame] | 179 | |
| 180 | // Returns the base install directory, such as "etc", "usr/share". |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 181 | BaseDir() string |
Yo Chiang | f0e19fe | 2020-11-18 15:28:42 +0800 | [diff] [blame] | 182 | |
| 183 | // Returns the sub install directory relative to BaseDir(). |
Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 184 | SubDir() string |
Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 185 | } |
| 186 | |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 187 | type PrebuiltEtc struct { |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 188 | android.ModuleBase |
Inseob Kim | 1e27a14 | 2021-05-06 11:46:11 +0000 | [diff] [blame] | 189 | android.DefaultableModuleBase |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 190 | |
Jihoon Kang | 69725b3 | 2024-11-12 03:08:49 +0000 | [diff] [blame] | 191 | properties PrebuiltEtcProperties |
Inseob Kim | be6a66d | 2024-07-11 15:43:44 +0900 | [diff] [blame] | 192 | |
Jihoon Kang | 723f122 | 2025-03-12 22:24:52 +0000 | [diff] [blame] | 193 | dstsProperties PrebuiltDstsProperties |
| 194 | |
Inseob Kim | be6a66d | 2024-07-11 15:43:44 +0900 | [diff] [blame] | 195 | // rootProperties is used to return the value of the InstallInRoot() method. Currently, only |
| 196 | // prebuilt_avb and prebuilt_root modules use this. |
| 197 | rootProperties prebuiltRootProperties |
| 198 | |
Inseob Kim | 27408bf | 2021-04-06 21:00:17 +0900 | [diff] [blame] | 199 | subdirProperties prebuiltSubdirProperties |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 200 | |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 201 | sourceFilePaths android.Paths |
Cole Faust | 4e9f592 | 2024-11-13 16:09:23 -0800 | [diff] [blame] | 202 | outputFilePaths android.WritablePaths |
Jaewoong Jung | c3fcdb4 | 2019-02-13 05:50:33 -0800 | [diff] [blame] | 203 | // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share. |
Colin Cross | 2f63457 | 2023-11-13 12:12:06 -0800 | [diff] [blame] | 204 | installDirBase string |
| 205 | installDirBase64 string |
| 206 | installAvoidMultilibConflict bool |
Yo Chiang | f0e19fe | 2020-11-18 15:28:42 +0800 | [diff] [blame] | 207 | // The base install location when soc_specific property is set to true, e.g. "firmware" for |
| 208 | // prebuilt_firmware. |
Patrice Arruda | 057a8b1 | 2019-06-03 15:29:27 -0700 | [diff] [blame] | 209 | socInstallDirBase string |
Douglas Anderson | 79688ff | 2024-09-27 15:08:33 -0700 | [diff] [blame] | 210 | installDirPaths []android.InstallPath |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 211 | additionalDependencies *android.Paths |
Colin Cross | f17e2b5 | 2023-10-30 15:17:25 -0700 | [diff] [blame] | 212 | |
Cole Faust | fdec872 | 2024-05-22 11:38:29 -0700 | [diff] [blame] | 213 | usedSrcsProperty bool |
| 214 | |
Colin Cross | f17e2b5 | 2023-10-30 15:17:25 -0700 | [diff] [blame] | 215 | makeClass string |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 216 | } |
| 217 | |
Inseob Kim | 1e27a14 | 2021-05-06 11:46:11 +0000 | [diff] [blame] | 218 | type Defaults struct { |
| 219 | android.ModuleBase |
| 220 | android.DefaultsModuleBase |
| 221 | } |
| 222 | |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 223 | func (p *PrebuiltEtc) inRamdisk() bool { |
| 224 | return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk() |
| 225 | } |
| 226 | |
| 227 | func (p *PrebuiltEtc) onlyInRamdisk() bool { |
| 228 | return p.ModuleBase.InstallInRamdisk() |
| 229 | } |
| 230 | |
| 231 | func (p *PrebuiltEtc) InstallInRamdisk() bool { |
| 232 | return p.inRamdisk() |
| 233 | } |
| 234 | |
Yifan Hong | 60e0cfb | 2020-10-21 15:17:56 -0700 | [diff] [blame] | 235 | func (p *PrebuiltEtc) inVendorRamdisk() bool { |
| 236 | return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk() |
| 237 | } |
| 238 | |
| 239 | func (p *PrebuiltEtc) onlyInVendorRamdisk() bool { |
| 240 | return p.ModuleBase.InstallInVendorRamdisk() |
| 241 | } |
| 242 | |
| 243 | func (p *PrebuiltEtc) InstallInVendorRamdisk() bool { |
| 244 | return p.inVendorRamdisk() |
| 245 | } |
| 246 | |
Inseob Kim | 08758f0 | 2021-04-08 21:13:22 +0900 | [diff] [blame] | 247 | func (p *PrebuiltEtc) inDebugRamdisk() bool { |
| 248 | return p.ModuleBase.InDebugRamdisk() || p.ModuleBase.InstallInDebugRamdisk() |
| 249 | } |
| 250 | |
| 251 | func (p *PrebuiltEtc) onlyInDebugRamdisk() bool { |
| 252 | return p.ModuleBase.InstallInDebugRamdisk() |
| 253 | } |
| 254 | |
| 255 | func (p *PrebuiltEtc) InstallInDebugRamdisk() bool { |
| 256 | return p.inDebugRamdisk() |
| 257 | } |
| 258 | |
Kiyoung Kim | ae11c23 | 2021-07-19 11:38:04 +0900 | [diff] [blame] | 259 | func (p *PrebuiltEtc) InRecovery() bool { |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 260 | return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery() |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | func (p *PrebuiltEtc) onlyInRecovery() bool { |
| 264 | return p.ModuleBase.InstallInRecovery() |
| 265 | } |
| 266 | |
| 267 | func (p *PrebuiltEtc) InstallInRecovery() bool { |
Kiyoung Kim | ae11c23 | 2021-07-19 11:38:04 +0900 | [diff] [blame] | 268 | return p.InRecovery() |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 269 | } |
| 270 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 271 | var _ android.ImageInterface = (*PrebuiltEtc)(nil) |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 272 | |
Cole Faust | fa6e0fd | 2024-10-15 15:22:57 -0700 | [diff] [blame] | 273 | func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.ImageInterfaceContext) {} |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 274 | |
Cole Faust | fa6e0fd | 2024-10-15 15:22:57 -0700 | [diff] [blame] | 275 | func (p *PrebuiltEtc) VendorVariantNeeded(ctx android.ImageInterfaceContext) bool { |
Jihoon Kang | 47e9184 | 2024-06-19 00:51:16 +0000 | [diff] [blame] | 276 | return false |
| 277 | } |
| 278 | |
Cole Faust | fa6e0fd | 2024-10-15 15:22:57 -0700 | [diff] [blame] | 279 | func (p *PrebuiltEtc) ProductVariantNeeded(ctx android.ImageInterfaceContext) bool { |
Jihoon Kang | 47e9184 | 2024-06-19 00:51:16 +0000 | [diff] [blame] | 280 | return false |
| 281 | } |
| 282 | |
Cole Faust | fa6e0fd | 2024-10-15 15:22:57 -0700 | [diff] [blame] | 283 | func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.ImageInterfaceContext) bool { |
Yifan Hong | 60e0cfb | 2020-10-21 15:17:56 -0700 | [diff] [blame] | 284 | return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() && |
Inseob Kim | 08758f0 | 2021-04-08 21:13:22 +0900 | [diff] [blame] | 285 | !p.ModuleBase.InstallInVendorRamdisk() && !p.ModuleBase.InstallInDebugRamdisk() |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 286 | } |
| 287 | |
Cole Faust | fa6e0fd | 2024-10-15 15:22:57 -0700 | [diff] [blame] | 288 | func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool { |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 289 | return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk() |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 290 | } |
| 291 | |
Cole Faust | fa6e0fd | 2024-10-15 15:22:57 -0700 | [diff] [blame] | 292 | func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool { |
Yifan Hong | 60e0cfb | 2020-10-21 15:17:56 -0700 | [diff] [blame] | 293 | return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk() |
| 294 | } |
| 295 | |
Cole Faust | fa6e0fd | 2024-10-15 15:22:57 -0700 | [diff] [blame] | 296 | func (p *PrebuiltEtc) DebugRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool { |
Inseob Kim | 08758f0 | 2021-04-08 21:13:22 +0900 | [diff] [blame] | 297 | return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk() |
| 298 | } |
| 299 | |
Nelson Li | 1fb94b2 | 2024-07-09 17:04:52 +0800 | [diff] [blame] | 300 | func (p *PrebuiltEtc) InstallInRoot() bool { |
Inseob Kim | be6a66d | 2024-07-11 15:43:44 +0900 | [diff] [blame] | 301 | return proptools.Bool(p.rootProperties.Install_in_root) |
Nelson Li | 1fb94b2 | 2024-07-09 17:04:52 +0800 | [diff] [blame] | 302 | } |
| 303 | |
Cole Faust | fa6e0fd | 2024-10-15 15:22:57 -0700 | [diff] [blame] | 304 | func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.ImageInterfaceContext) bool { |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 305 | return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery() |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 306 | } |
| 307 | |
Cole Faust | fa6e0fd | 2024-10-15 15:22:57 -0700 | [diff] [blame] | 308 | func (p *PrebuiltEtc) ExtraImageVariations(ctx android.ImageInterfaceContext) []string { |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 309 | return nil |
| 310 | } |
| 311 | |
Cole Faust | fa6e0fd | 2024-10-15 15:22:57 -0700 | [diff] [blame] | 312 | func (p *PrebuiltEtc) SetImageVariation(ctx android.ImageInterfaceContext, variation string) { |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 313 | } |
| 314 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 315 | func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path { |
Cole Faust | fdec872 | 2024-05-22 11:38:29 -0700 | [diff] [blame] | 316 | if len(p.properties.Srcs.GetOrDefault(ctx, nil)) > 0 { |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 317 | panic(fmt.Errorf("SourceFilePath not available on multi-source prebuilt %q", p.Name())) |
| 318 | } |
Cole Faust | fdec872 | 2024-05-22 11:38:29 -0700 | [diff] [blame] | 319 | return android.PathForModuleSrc(ctx, p.properties.Src.GetOrDefault(ctx, "")) |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 320 | } |
| 321 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 322 | func (p *PrebuiltEtc) InstallDirPath() android.InstallPath { |
Douglas Anderson | 79688ff | 2024-09-27 15:08:33 -0700 | [diff] [blame] | 323 | if len(p.installDirPaths) != 1 { |
| 324 | panic(fmt.Errorf("InstallDirPath not available on multi-source prebuilt %q", p.Name())) |
| 325 | } |
| 326 | return p.installDirPaths[0] |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 327 | } |
| 328 | |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 329 | // This allows other derivative modules (e.g. prebuilt_etc_xml) to perform |
| 330 | // additional steps (like validating the src) before the file is installed. |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 331 | func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) { |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 332 | p.additionalDependencies = &paths |
| 333 | } |
| 334 | |
Cole Faust | 4e9f592 | 2024-11-13 16:09:23 -0800 | [diff] [blame] | 335 | func (p *PrebuiltEtc) OutputFile() android.Path { |
Cole Faust | fdec872 | 2024-05-22 11:38:29 -0700 | [diff] [blame] | 336 | if p.usedSrcsProperty { |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 337 | panic(fmt.Errorf("OutputFile not available on multi-source prebuilt %q", p.Name())) |
| 338 | } |
| 339 | return p.outputFilePaths[0] |
Jiyong Park | c43e0ac | 2018-10-04 20:27:15 +0900 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | func (p *PrebuiltEtc) SubDir() string { |
Inseob Kim | 27408bf | 2021-04-06 21:00:17 +0900 | [diff] [blame] | 343 | if subDir := proptools.String(p.subdirProperties.Sub_dir); subDir != "" { |
Liz Kammer | 0449a63 | 2020-06-26 10:12:36 -0700 | [diff] [blame] | 344 | return subDir |
| 345 | } |
Inseob Kim | 27408bf | 2021-04-06 21:00:17 +0900 | [diff] [blame] | 346 | return proptools.String(p.subdirProperties.Relative_install_path) |
Jiyong Park | c43e0ac | 2018-10-04 20:27:15 +0900 | [diff] [blame] | 347 | } |
| 348 | |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 349 | func (p *PrebuiltEtc) BaseDir() string { |
Jooyung Han | 8e5685d | 2020-09-21 11:02:57 +0900 | [diff] [blame] | 350 | return p.installDirBase |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 351 | } |
| 352 | |
Jiyong Park | ad9ce04 | 2018-10-31 22:49:57 +0900 | [diff] [blame] | 353 | func (p *PrebuiltEtc) Installable() bool { |
Yo Chiang | f0e19fe | 2020-11-18 15:28:42 +0800 | [diff] [blame] | 354 | return p.properties.Installable == nil || proptools.Bool(p.properties.Installable) |
Jiyong Park | ad9ce04 | 2018-10-31 22:49:57 +0900 | [diff] [blame] | 355 | } |
| 356 | |
Kiyoung Kim | ae11c23 | 2021-07-19 11:38:04 +0900 | [diff] [blame] | 357 | func (p *PrebuiltEtc) InVendor() bool { |
| 358 | return p.ModuleBase.InstallInVendor() |
| 359 | } |
| 360 | |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 361 | func (p *PrebuiltEtc) installBaseDir(ctx android.ModuleContext) string { |
Yo Chiang | f0e19fe | 2020-11-18 15:28:42 +0800 | [diff] [blame] | 362 | // If soc install dir was specified and SOC specific is set, set the installDirPath to the |
| 363 | // specified socInstallDirBase. |
Jooyung Han | 8e5685d | 2020-09-21 11:02:57 +0900 | [diff] [blame] | 364 | installBaseDir := p.installDirBase |
Colin Cross | f17e2b5 | 2023-10-30 15:17:25 -0700 | [diff] [blame] | 365 | if p.Target().Arch.ArchType.Multilib == "lib64" && p.installDirBase64 != "" { |
| 366 | installBaseDir = p.installDirBase64 |
| 367 | } |
Jooyung Han | 8e5685d | 2020-09-21 11:02:57 +0900 | [diff] [blame] | 368 | if p.SocSpecific() && p.socInstallDirBase != "" { |
| 369 | installBaseDir = p.socInstallDirBase |
| 370 | } |
Colin Cross | 2f63457 | 2023-11-13 12:12:06 -0800 | [diff] [blame] | 371 | if p.installAvoidMultilibConflict && !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) { |
| 372 | installBaseDir = filepath.Join(installBaseDir, ctx.Arch().ArchType.String()) |
| 373 | } |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 374 | return installBaseDir |
| 375 | } |
Colin Cross | 2f63457 | 2023-11-13 12:12:06 -0800 | [diff] [blame] | 376 | |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 377 | func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 378 | var installs []installProperties |
Jiyong Park | c43e0ac | 2018-10-04 20:27:15 +0900 | [diff] [blame] | 379 | |
Cole Faust | fdec872 | 2024-05-22 11:38:29 -0700 | [diff] [blame] | 380 | srcProperty := p.properties.Src.Get(ctx) |
| 381 | srcsProperty := p.properties.Srcs.GetOrDefault(ctx, nil) |
| 382 | if srcProperty.IsPresent() && len(srcsProperty) > 0 { |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 383 | ctx.PropertyErrorf("src", "src is set. Cannot set srcs") |
Spandan Das | 756d340 | 2023-06-05 22:49:50 +0000 | [diff] [blame] | 384 | } |
Jihoon Kang | 723f122 | 2025-03-12 22:24:52 +0000 | [diff] [blame] | 385 | dstsProperty := p.dstsProperties.Dsts.GetOrDefault(ctx, nil) |
Douglas Anderson | 79688ff | 2024-09-27 15:08:33 -0700 | [diff] [blame] | 386 | if len(dstsProperty) > 0 && len(srcsProperty) == 0 { |
| 387 | ctx.PropertyErrorf("dsts", "dsts is set. Must use srcs") |
| 388 | } |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 389 | |
| 390 | // Check that `sub_dir` and `relative_install_path` are not set at the same time. |
| 391 | if p.subdirProperties.Sub_dir != nil && p.subdirProperties.Relative_install_path != nil { |
| 392 | ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir") |
| 393 | } |
Douglas Anderson | 79688ff | 2024-09-27 15:08:33 -0700 | [diff] [blame] | 394 | baseInstallDirPath := android.PathForModuleInstall(ctx, p.installBaseDir(ctx), p.SubDir()) |
Wei Li | 5958625 | 2024-11-04 09:25:54 -0800 | [diff] [blame] | 395 | // TODO(b/377304441) |
Spandan Das | 27ff767 | 2024-11-06 19:23:57 +0000 | [diff] [blame] | 396 | if android.Bool(p.properties.Oem_specific) { |
Wei Li | 5958625 | 2024-11-04 09:25:54 -0800 | [diff] [blame] | 397 | baseInstallDirPath = android.PathForModuleInPartitionInstall(ctx, ctx.DeviceConfig().OemPath(), p.installBaseDir(ctx), p.SubDir()) |
| 398 | } |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 399 | |
| 400 | filename := proptools.String(p.properties.Filename) |
| 401 | filenameFromSrc := proptools.Bool(p.properties.Filename_from_src) |
Cole Faust | fdec872 | 2024-05-22 11:38:29 -0700 | [diff] [blame] | 402 | if srcProperty.IsPresent() { |
| 403 | p.sourceFilePaths = android.PathsForModuleSrc(ctx, []string{srcProperty.Get()}) |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 404 | // If the source was not found, set a fake source path to |
| 405 | // support AllowMissingDependencies executions. |
| 406 | if len(p.sourceFilePaths) == 0 { |
| 407 | p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)} |
| 408 | } |
| 409 | |
| 410 | // Determine the output file basename. |
| 411 | // If Filename is set, use the name specified by the property. |
| 412 | // If Filename_from_src is set, use the source file name. |
| 413 | // Otherwise use the module name. |
| 414 | if filename != "" { |
| 415 | if filenameFromSrc { |
| 416 | ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true") |
| 417 | return |
| 418 | } |
| 419 | } else if filenameFromSrc { |
| 420 | filename = p.sourceFilePaths[0].Base() |
| 421 | } else { |
| 422 | filename = ctx.ModuleName() |
| 423 | } |
| 424 | if strings.Contains(filename, "/") { |
| 425 | ctx.PropertyErrorf("filename", "filename cannot contain separator '/'") |
| 426 | return |
| 427 | } |
Cole Faust | 4e9f592 | 2024-11-13 16:09:23 -0800 | [diff] [blame] | 428 | p.outputFilePaths = android.WritablePaths{android.PathForModuleOut(ctx, filename)} |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 429 | |
| 430 | ip := installProperties{ |
| 431 | filename: filename, |
| 432 | sourceFilePath: p.sourceFilePaths[0], |
| 433 | outputFilePath: p.outputFilePaths[0], |
Douglas Anderson | 79688ff | 2024-09-27 15:08:33 -0700 | [diff] [blame] | 434 | installDirPath: baseInstallDirPath, |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 435 | symlinks: p.properties.Symlinks, |
| 436 | } |
| 437 | installs = append(installs, ip) |
Douglas Anderson | 79688ff | 2024-09-27 15:08:33 -0700 | [diff] [blame] | 438 | p.installDirPaths = append(p.installDirPaths, baseInstallDirPath) |
Cole Faust | fdec872 | 2024-05-22 11:38:29 -0700 | [diff] [blame] | 439 | } else if len(srcsProperty) > 0 { |
| 440 | p.usedSrcsProperty = true |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 441 | if filename != "" { |
| 442 | ctx.PropertyErrorf("filename", "filename cannot be set when using srcs") |
| 443 | } |
| 444 | if len(p.properties.Symlinks) > 0 { |
| 445 | ctx.PropertyErrorf("symlinks", "symlinks cannot be set when using srcs") |
| 446 | } |
| 447 | if p.properties.Filename_from_src != nil { |
Douglas Anderson | 79688ff | 2024-09-27 15:08:33 -0700 | [diff] [blame] | 448 | if len(dstsProperty) > 0 { |
| 449 | ctx.PropertyErrorf("filename_from_src", "dsts is set. Cannot set filename_from_src") |
| 450 | } else { |
| 451 | ctx.PropertyErrorf("filename_from_src", "filename_from_src is implicitly set to true when using srcs") |
| 452 | } |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 453 | } |
Cole Faust | fdec872 | 2024-05-22 11:38:29 -0700 | [diff] [blame] | 454 | p.sourceFilePaths = android.PathsForModuleSrc(ctx, srcsProperty) |
Douglas Anderson | 79688ff | 2024-09-27 15:08:33 -0700 | [diff] [blame] | 455 | if len(dstsProperty) > 0 && len(p.sourceFilePaths) != len(dstsProperty) { |
| 456 | ctx.PropertyErrorf("dsts", "Must have one entry in dsts per source file") |
| 457 | } |
| 458 | for i, src := range p.sourceFilePaths { |
| 459 | var filename string |
| 460 | var installDirPath android.InstallPath |
| 461 | |
| 462 | if len(dstsProperty) > 0 { |
| 463 | var dstdir string |
| 464 | |
| 465 | dstdir, filename = filepath.Split(dstsProperty[i]) |
| 466 | installDirPath = baseInstallDirPath.Join(ctx, dstdir) |
| 467 | } else { |
| 468 | filename = src.Base() |
| 469 | installDirPath = baseInstallDirPath |
| 470 | } |
Cole Faust | 4e9f592 | 2024-11-13 16:09:23 -0800 | [diff] [blame] | 471 | output := android.PathForModuleOut(ctx, filename) |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 472 | ip := installProperties{ |
| 473 | filename: filename, |
| 474 | sourceFilePath: src, |
| 475 | outputFilePath: output, |
Douglas Anderson | 79688ff | 2024-09-27 15:08:33 -0700 | [diff] [blame] | 476 | installDirPath: installDirPath, |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 477 | } |
| 478 | p.outputFilePaths = append(p.outputFilePaths, output) |
| 479 | installs = append(installs, ip) |
Douglas Anderson | 79688ff | 2024-09-27 15:08:33 -0700 | [diff] [blame] | 480 | p.installDirPaths = append(p.installDirPaths, installDirPath) |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 481 | } |
| 482 | } else if ctx.Config().AllowMissingDependencies() { |
| 483 | // If no srcs was set and AllowMissingDependencies is enabled then |
| 484 | // mark the module as missing dependencies and set a fake source path |
| 485 | // and file name. |
| 486 | ctx.AddMissingDependencies([]string{"MISSING_PREBUILT_SRC_FILE"}) |
| 487 | p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)} |
| 488 | if filename == "" { |
| 489 | filename = ctx.ModuleName() |
| 490 | } |
Cole Faust | 4e9f592 | 2024-11-13 16:09:23 -0800 | [diff] [blame] | 491 | p.outputFilePaths = android.WritablePaths{android.PathForModuleOut(ctx, filename)} |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 492 | ip := installProperties{ |
| 493 | filename: filename, |
| 494 | sourceFilePath: p.sourceFilePaths[0], |
| 495 | outputFilePath: p.outputFilePaths[0], |
Douglas Anderson | 79688ff | 2024-09-27 15:08:33 -0700 | [diff] [blame] | 496 | installDirPath: baseInstallDirPath, |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 497 | } |
| 498 | installs = append(installs, ip) |
Douglas Anderson | 79688ff | 2024-09-27 15:08:33 -0700 | [diff] [blame] | 499 | p.installDirPaths = append(p.installDirPaths, baseInstallDirPath) |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 500 | } else { |
| 501 | ctx.PropertyErrorf("src", "missing prebuilt source file") |
| 502 | return |
| 503 | } |
| 504 | |
| 505 | // Call InstallFile even when uninstallable to make the module included in the package. |
| 506 | if !p.Installable() { |
| 507 | p.SkipInstall() |
| 508 | } |
| 509 | for _, ip := range installs { |
| 510 | ip.addInstallRules(ctx) |
| 511 | } |
mrziwang | 8937176 | 2024-06-11 12:42:24 -0700 | [diff] [blame] | 512 | |
| 513 | ctx.SetOutputFiles(p.outputFilePaths.Paths(), "") |
Spandan Das | 756d340 | 2023-06-05 22:49:50 +0000 | [diff] [blame] | 514 | } |
Jiyong Park | f9f6805 | 2020-09-29 20:15:08 +0900 | [diff] [blame] | 515 | |
Spandan Das | 756d340 | 2023-06-05 22:49:50 +0000 | [diff] [blame] | 516 | type installProperties struct { |
Spandan Das | 756d340 | 2023-06-05 22:49:50 +0000 | [diff] [blame] | 517 | filename string |
| 518 | sourceFilePath android.Path |
Cole Faust | 4e9f592 | 2024-11-13 16:09:23 -0800 | [diff] [blame] | 519 | outputFilePath android.WritablePath |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 520 | installDirPath android.InstallPath |
Spandan Das | 756d340 | 2023-06-05 22:49:50 +0000 | [diff] [blame] | 521 | symlinks []string |
| 522 | } |
| 523 | |
| 524 | // utility function to add install rules to the build graph. |
| 525 | // Reduces code duplication between Soong and Mixed build analysis |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 526 | func (ip *installProperties) addInstallRules(ctx android.ModuleContext) { |
Spandan Das | 756d340 | 2023-06-05 22:49:50 +0000 | [diff] [blame] | 527 | // Copy the file from src to a location in out/ with the correct `filename` |
| 528 | // This ensures that outputFilePath has the correct name for others to |
| 529 | // use, as the source file may have a different name. |
Spandan Das | 756d340 | 2023-06-05 22:49:50 +0000 | [diff] [blame] | 530 | ctx.Build(pctx, android.BuildParams{ |
| 531 | Rule: android.Cp, |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 532 | Output: ip.outputFilePath, |
Spandan Das | 756d340 | 2023-06-05 22:49:50 +0000 | [diff] [blame] | 533 | Input: ip.sourceFilePath, |
| 534 | }) |
| 535 | |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 536 | installPath := ctx.InstallFile(ip.installDirPath, ip.filename, ip.outputFilePath) |
Spandan Das | 756d340 | 2023-06-05 22:49:50 +0000 | [diff] [blame] | 537 | for _, sl := range ip.symlinks { |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 538 | ctx.InstallSymlink(ip.installDirPath, sl, installPath) |
Jiyong Park | f9f6805 | 2020-09-29 20:15:08 +0900 | [diff] [blame] | 539 | } |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 540 | } |
| 541 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 542 | func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries { |
Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 543 | nameSuffix := "" |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 544 | if p.inRamdisk() && !p.onlyInRamdisk() { |
| 545 | nameSuffix = ".ramdisk" |
| 546 | } |
Yifan Hong | 60e0cfb | 2020-10-21 15:17:56 -0700 | [diff] [blame] | 547 | if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() { |
| 548 | nameSuffix = ".vendor_ramdisk" |
| 549 | } |
Inseob Kim | 08758f0 | 2021-04-08 21:13:22 +0900 | [diff] [blame] | 550 | if p.inDebugRamdisk() && !p.onlyInDebugRamdisk() { |
| 551 | nameSuffix = ".debug_ramdisk" |
| 552 | } |
Kiyoung Kim | ae11c23 | 2021-07-19 11:38:04 +0900 | [diff] [blame] | 553 | if p.InRecovery() && !p.onlyInRecovery() { |
Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 554 | nameSuffix = ".recovery" |
| 555 | } |
Colin Cross | f17e2b5 | 2023-10-30 15:17:25 -0700 | [diff] [blame] | 556 | |
| 557 | class := p.makeClass |
| 558 | if class == "" { |
| 559 | class = "ETC" |
| 560 | } |
| 561 | |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 562 | return []android.AndroidMkEntries{{ |
Colin Cross | f17e2b5 | 2023-10-30 15:17:25 -0700 | [diff] [blame] | 563 | Class: class, |
Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 564 | SubName: nameSuffix, |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 565 | OutputFile: android.OptionalPathForPath(p.outputFilePaths[0]), |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 566 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
Colin Cross | aa25553 | 2020-07-03 13:18:24 -0700 | [diff] [blame] | 567 | func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
Jaewoong Jung | e0dc8df | 2019-08-27 17:33:16 -0700 | [diff] [blame] | 568 | entries.SetString("LOCAL_MODULE_TAGS", "optional") |
Douglas Anderson | 79688ff | 2024-09-27 15:08:33 -0700 | [diff] [blame] | 569 | entries.SetString("LOCAL_MODULE_PATH", p.installDirPaths[0].String()) |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 570 | entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePaths[0].Base()) |
Yo Chiang | 3d64d49 | 2020-05-27 17:56:39 +0800 | [diff] [blame] | 571 | if len(p.properties.Symlinks) > 0 { |
| 572 | entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...) |
| 573 | } |
Yo Chiang | 803c40d | 2020-11-16 20:32:51 +0800 | [diff] [blame] | 574 | entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable()) |
Jaewoong Jung | e0dc8df | 2019-08-27 17:33:16 -0700 | [diff] [blame] | 575 | if p.additionalDependencies != nil { |
Yo Chiang | 803c40d | 2020-11-16 20:32:51 +0800 | [diff] [blame] | 576 | entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...) |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 577 | } |
Jaewoong Jung | e0dc8df | 2019-08-27 17:33:16 -0700 | [diff] [blame] | 578 | }, |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 579 | }, |
Jiyong Park | 0b0e1b9 | 2019-12-03 13:24:29 +0900 | [diff] [blame] | 580 | }} |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 581 | } |
| 582 | |
LaMont Jones | afe7baf | 2024-01-09 22:47:39 +0000 | [diff] [blame] | 583 | func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase { |
| 584 | return &p.ModuleBase |
| 585 | } |
| 586 | |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 587 | func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) { |
| 588 | p.installDirBase = dirBase |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 589 | p.AddProperties(&p.properties) |
Inseob Kim | 27408bf | 2021-04-06 21:00:17 +0900 | [diff] [blame] | 590 | p.AddProperties(&p.subdirProperties) |
Jihoon Kang | 320ca7c | 2024-12-03 18:14:50 +0000 | [diff] [blame] | 591 | p.AddProperties(&p.rootProperties) |
Jihoon Kang | 723f122 | 2025-03-12 22:24:52 +0000 | [diff] [blame] | 592 | p.AddProperties(&p.dstsProperties) |
Inseob Kim | 27408bf | 2021-04-06 21:00:17 +0900 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | func InitPrebuiltRootModule(p *PrebuiltEtc) { |
| 596 | p.installDirBase = "." |
Nelson Li | 1fb94b2 | 2024-07-09 17:04:52 +0800 | [diff] [blame] | 597 | p.AddProperties(&p.properties) |
Inseob Kim | be6a66d | 2024-07-11 15:43:44 +0900 | [diff] [blame] | 598 | p.AddProperties(&p.rootProperties) |
Nelson Li | 1fb94b2 | 2024-07-09 17:04:52 +0800 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | func InitPrebuiltAvbModule(p *PrebuiltEtc) { |
| 602 | p.installDirBase = "avb" |
Inseob Kim | 27408bf | 2021-04-06 21:00:17 +0900 | [diff] [blame] | 603 | p.AddProperties(&p.properties) |
Jihoon Kang | 723f122 | 2025-03-12 22:24:52 +0000 | [diff] [blame] | 604 | p.AddProperties(&p.dstsProperties) |
Inseob Kim | be6a66d | 2024-07-11 15:43:44 +0900 | [diff] [blame] | 605 | p.rootProperties.Install_in_root = proptools.BoolPtr(true) |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 606 | } |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 607 | |
Patrice Arruda | 9e14b96 | 2019-03-11 15:58:50 -0700 | [diff] [blame] | 608 | // prebuilt_etc is for a prebuilt artifact that is installed in |
| 609 | // <partition>/etc/<sub_dir> directory. |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 610 | func PrebuiltEtcFactory() android.Module { |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 611 | module := &PrebuiltEtc{} |
| 612 | InitPrebuiltEtcModule(module, "etc") |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 613 | // This module is device-only |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 614 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
Inseob Kim | 1e27a14 | 2021-05-06 11:46:11 +0000 | [diff] [blame] | 615 | android.InitDefaultableModule(module) |
| 616 | return module |
| 617 | } |
| 618 | |
| 619 | func defaultsFactory() android.Module { |
| 620 | return DefaultsFactory() |
| 621 | } |
| 622 | |
| 623 | func DefaultsFactory(props ...interface{}) android.Module { |
| 624 | module := &Defaults{} |
| 625 | |
| 626 | module.AddProperties(props...) |
| 627 | module.AddProperties( |
Jihoon Kang | 69725b3 | 2024-11-12 03:08:49 +0000 | [diff] [blame] | 628 | &PrebuiltEtcProperties{}, |
Inseob Kim | 1e27a14 | 2021-05-06 11:46:11 +0000 | [diff] [blame] | 629 | &prebuiltSubdirProperties{}, |
| 630 | ) |
| 631 | |
| 632 | android.InitDefaultsModule(module) |
| 633 | |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 634 | return module |
| 635 | } |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 636 | |
Patrice Arruda | 9e14b96 | 2019-03-11 15:58:50 -0700 | [diff] [blame] | 637 | // prebuilt_etc_host is for a host prebuilt artifact that is installed in |
| 638 | // $(HOST_OUT)/etc/<sub_dir> directory. |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 639 | func PrebuiltEtcHostFactory() android.Module { |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 640 | module := &PrebuiltEtc{} |
| 641 | InitPrebuiltEtcModule(module, "etc") |
Jaewoong Jung | 2478818 | 2019-02-04 14:34:10 -0800 | [diff] [blame] | 642 | // This module is host-only |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 643 | android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon) |
Martin Stjernholm | dc6525e | 2021-10-14 00:42:59 +0100 | [diff] [blame] | 644 | android.InitDefaultableModule(module) |
Jaewoong Jung | 2478818 | 2019-02-04 14:34:10 -0800 | [diff] [blame] | 645 | return module |
| 646 | } |
| 647 | |
Jihoon Kang | 3e14966 | 2025-03-12 22:14:39 +0000 | [diff] [blame] | 648 | // prebuilt_any is a special module where the module can define the subdirectory that the files |
| 649 | // are installed to. This is only used for converting the PRODUCT_COPY_FILES entries to Soong |
| 650 | // modules, and should never be defined in the bp files. If none of the existing prebuilt_* |
| 651 | // modules allow installing the file at the desired location, introduce a new prebuilt_* module |
| 652 | // type instead. |
| 653 | func PrebuiltAnyFactory() android.Module { |
| 654 | module := &PrebuiltEtc{} |
| 655 | InitPrebuiltEtcModule(module, ".") |
| 656 | // This module is device-only |
| 657 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) |
| 658 | android.InitDefaultableModule(module) |
| 659 | return module |
| 660 | } |
| 661 | |
Miguel | 32b0280 | 2022-12-01 18:38:26 +0000 | [diff] [blame] | 662 | // prebuilt_etc_host is for a host prebuilt artifact that is installed in |
| 663 | // <partition>/etc/<sub_dir> directory. |
| 664 | func PrebuiltEtcCaCertsFactory() android.Module { |
| 665 | module := &PrebuiltEtc{} |
| 666 | InitPrebuiltEtcModule(module, "cacerts") |
| 667 | // This module is device-only |
| 668 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
Miguel | 32b0280 | 2022-12-01 18:38:26 +0000 | [diff] [blame] | 669 | return module |
| 670 | } |
| 671 | |
Nelson Li | 1fb94b2 | 2024-07-09 17:04:52 +0800 | [diff] [blame] | 672 | // Generally, a <partition> directory will contain a `system` subdirectory, but the <partition> of |
| 673 | // `prebuilt_avb` will not have a `system` subdirectory. |
| 674 | // Ultimately, prebuilt_avb will install the prebuilt artifact to the `avb` subdirectory under the |
| 675 | // root directory of the partition: <partition_root>/avb. |
| 676 | // prebuilt_avb does not allow adding any other subdirectories. |
| 677 | func PrebuiltAvbFactory() android.Module { |
| 678 | module := &PrebuiltEtc{} |
| 679 | InitPrebuiltAvbModule(module) |
| 680 | // This module is device-only |
| 681 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
| 682 | android.InitDefaultableModule(module) |
| 683 | return module |
| 684 | } |
| 685 | |
Inseob Kim | 27408bf | 2021-04-06 21:00:17 +0900 | [diff] [blame] | 686 | // prebuilt_root is for a prebuilt artifact that is installed in |
| 687 | // <partition>/ directory. Can't have any sub directories. |
| 688 | func PrebuiltRootFactory() android.Module { |
| 689 | module := &PrebuiltEtc{} |
| 690 | InitPrebuiltRootModule(module) |
| 691 | // This module is device-only |
| 692 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
Martin Stjernholm | dc6525e | 2021-10-14 00:42:59 +0100 | [diff] [blame] | 693 | android.InitDefaultableModule(module) |
Inseob Kim | 27408bf | 2021-04-06 21:00:17 +0900 | [diff] [blame] | 694 | return module |
| 695 | } |
| 696 | |
Liz Kammer | e9ecddc | 2022-01-04 17:27:52 -0500 | [diff] [blame] | 697 | // prebuilt_root_host is for a host prebuilt artifact that is installed in $(HOST_OUT)/<sub_dir> |
| 698 | // directory. |
| 699 | func PrebuiltRootHostFactory() android.Module { |
| 700 | module := &PrebuiltEtc{} |
| 701 | InitPrebuiltEtcModule(module, ".") |
| 702 | // This module is host-only |
| 703 | android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon) |
| 704 | android.InitDefaultableModule(module) |
| 705 | return module |
| 706 | } |
| 707 | |
Patrice Arruda | 9e14b96 | 2019-03-11 15:58:50 -0700 | [diff] [blame] | 708 | // prebuilt_usr_share is for a prebuilt artifact that is installed in |
| 709 | // <partition>/usr/share/<sub_dir> directory. |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 710 | func PrebuiltUserShareFactory() android.Module { |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 711 | module := &PrebuiltEtc{} |
| 712 | InitPrebuiltEtcModule(module, "usr/share") |
Jaewoong Jung | c3fcdb4 | 2019-02-13 05:50:33 -0800 | [diff] [blame] | 713 | // This module is device-only |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 714 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
Martin Stjernholm | dc6525e | 2021-10-14 00:42:59 +0100 | [diff] [blame] | 715 | android.InitDefaultableModule(module) |
Jaewoong Jung | c3fcdb4 | 2019-02-13 05:50:33 -0800 | [diff] [blame] | 716 | return module |
| 717 | } |
| 718 | |
Patrice Arruda | 9e14b96 | 2019-03-11 15:58:50 -0700 | [diff] [blame] | 719 | // prebuild_usr_share_host is for a host prebuilt artifact that is installed in |
| 720 | // $(HOST_OUT)/usr/share/<sub_dir> directory. |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 721 | func PrebuiltUserShareHostFactory() android.Module { |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 722 | module := &PrebuiltEtc{} |
| 723 | InitPrebuiltEtcModule(module, "usr/share") |
Patrice Arruda | 300cef9 | 2019-02-22 15:47:57 -0800 | [diff] [blame] | 724 | // This module is host-only |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 725 | android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon) |
Martin Stjernholm | dc6525e | 2021-10-14 00:42:59 +0100 | [diff] [blame] | 726 | android.InitDefaultableModule(module) |
Patrice Arruda | 300cef9 | 2019-02-22 15:47:57 -0800 | [diff] [blame] | 727 | return module |
| 728 | } |
| 729 | |
yangbill | 63c5e19 | 2024-03-27 09:02:12 +0000 | [diff] [blame] | 730 | // prebuilt_usr_hyphendata is for a prebuilt artifact that is installed in |
| 731 | // <partition>/usr/hyphen-data/<sub_dir> directory. |
| 732 | func PrebuiltUserHyphenDataFactory() android.Module { |
| 733 | module := &PrebuiltEtc{} |
| 734 | InitPrebuiltEtcModule(module, "usr/hyphen-data") |
| 735 | // This module is device-only |
| 736 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
| 737 | android.InitDefaultableModule(module) |
| 738 | return module |
| 739 | } |
| 740 | |
yangbill | 85527e6 | 2024-04-30 08:24:50 +0000 | [diff] [blame] | 741 | // prebuilt_usr_keylayout is for a prebuilt artifact that is installed in |
| 742 | // <partition>/usr/keylayout/<sub_dir> directory. |
| 743 | func PrebuiltUserKeyLayoutFactory() android.Module { |
| 744 | module := &PrebuiltEtc{} |
| 745 | InitPrebuiltEtcModule(module, "usr/keylayout") |
| 746 | // This module is device-only |
| 747 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
| 748 | android.InitDefaultableModule(module) |
| 749 | return module |
| 750 | } |
| 751 | |
| 752 | // prebuilt_usr_keychars is for a prebuilt artifact that is installed in |
| 753 | // <partition>/usr/keychars/<sub_dir> directory. |
| 754 | func PrebuiltUserKeyCharsFactory() android.Module { |
| 755 | module := &PrebuiltEtc{} |
| 756 | InitPrebuiltEtcModule(module, "usr/keychars") |
| 757 | // This module is device-only |
| 758 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
| 759 | android.InitDefaultableModule(module) |
| 760 | return module |
| 761 | } |
| 762 | |
| 763 | // prebuilt_usr_idc is for a prebuilt artifact that is installed in |
| 764 | // <partition>/usr/idc/<sub_dir> directory. |
| 765 | func PrebuiltUserIdcFactory() android.Module { |
| 766 | module := &PrebuiltEtc{} |
| 767 | InitPrebuiltEtcModule(module, "usr/idc") |
| 768 | // This module is device-only |
| 769 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
| 770 | android.InitDefaultableModule(module) |
| 771 | return module |
| 772 | } |
| 773 | |
Jihoon Kang | 0da5ae9 | 2024-10-29 23:24:17 +0000 | [diff] [blame] | 774 | // prebuilt_usr_srec is for a prebuilt artifact that is installed in |
| 775 | // <partition>/usr/srec/<sub_dir> directory. |
| 776 | func PrebuiltUserSrecFactory() android.Module { |
| 777 | module := &PrebuiltEtc{} |
| 778 | InitPrebuiltEtcModule(module, "usr/srec") |
| 779 | // This module is device-only |
| 780 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
| 781 | android.InitDefaultableModule(module) |
| 782 | return module |
| 783 | } |
| 784 | |
Patrice Arruda | 61583eb | 2019-05-14 08:20:45 -0700 | [diff] [blame] | 785 | // prebuilt_font installs a font in <partition>/fonts directory. |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 786 | func PrebuiltFontFactory() android.Module { |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 787 | module := &PrebuiltEtc{} |
| 788 | InitPrebuiltEtcModule(module, "fonts") |
Patrice Arruda | 61583eb | 2019-05-14 08:20:45 -0700 | [diff] [blame] | 789 | // This module is device-only |
Cole Faust | c49443e | 2024-10-29 11:15:34 -0700 | [diff] [blame] | 790 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) |
Martin Stjernholm | dc6525e | 2021-10-14 00:42:59 +0100 | [diff] [blame] | 791 | android.InitDefaultableModule(module) |
Patrice Arruda | 61583eb | 2019-05-14 08:20:45 -0700 | [diff] [blame] | 792 | return module |
| 793 | } |
Patrice Arruda | 057a8b1 | 2019-06-03 15:29:27 -0700 | [diff] [blame] | 794 | |
Kevin | 93f7cd8 | 2024-05-02 12:37:59 +0200 | [diff] [blame] | 795 | // prebuilt_overlay is for a prebuilt artifact in <partition>/overlay directory. |
| 796 | func PrebuiltOverlayFactory() android.Module { |
| 797 | module := &PrebuiltEtc{} |
| 798 | InitPrebuiltEtcModule(module, "overlay") |
| 799 | // This module is device-only |
| 800 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
| 801 | return module |
| 802 | } |
| 803 | |
Yo Chiang | f0e19fe | 2020-11-18 15:28:42 +0800 | [diff] [blame] | 804 | // prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system |
| 805 | // image. |
| 806 | // If soc_specific property is set to true, the firmware file is installed to the |
| 807 | // vendor <partition>/firmware directory for vendor image. |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 808 | func PrebuiltFirmwareFactory() android.Module { |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 809 | module := &PrebuiltEtc{} |
| 810 | module.socInstallDirBase = "firmware" |
| 811 | InitPrebuiltEtcModule(module, "etc/firmware") |
Patrice Arruda | 057a8b1 | 2019-06-03 15:29:27 -0700 | [diff] [blame] | 812 | // This module is device-only |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 813 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
Martin Stjernholm | dc6525e | 2021-10-14 00:42:59 +0100 | [diff] [blame] | 814 | android.InitDefaultableModule(module) |
Patrice Arruda | 057a8b1 | 2019-06-03 15:29:27 -0700 | [diff] [blame] | 815 | return module |
| 816 | } |
Patrice Arruda | 0f68800 | 2020-06-08 21:40:25 +0000 | [diff] [blame] | 817 | |
| 818 | // prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image. |
Yo Chiang | f0e19fe | 2020-11-18 15:28:42 +0800 | [diff] [blame] | 819 | // If soc_specific property is set to true, the DSP related file is installed to the |
| 820 | // vendor <partition>/dsp directory for vendor image. |
Patrice Arruda | 0f68800 | 2020-06-08 21:40:25 +0000 | [diff] [blame] | 821 | func PrebuiltDSPFactory() android.Module { |
| 822 | module := &PrebuiltEtc{} |
| 823 | module.socInstallDirBase = "dsp" |
| 824 | InitPrebuiltEtcModule(module, "etc/dsp") |
| 825 | // This module is device-only |
| 826 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
Martin Stjernholm | dc6525e | 2021-10-14 00:42:59 +0100 | [diff] [blame] | 827 | android.InitDefaultableModule(module) |
Patrice Arruda | 0f68800 | 2020-06-08 21:40:25 +0000 | [diff] [blame] | 828 | return module |
| 829 | } |
Colin Cross | 83ebf23 | 2021-04-09 09:41:23 -0700 | [diff] [blame] | 830 | |
Colin Cross | f17e2b5 | 2023-10-30 15:17:25 -0700 | [diff] [blame] | 831 | // prebuilt_renderscript_bitcode installs a *.bc file into /system/lib or /system/lib64. |
| 832 | func PrebuiltRenderScriptBitcodeFactory() android.Module { |
| 833 | module := &PrebuiltEtc{} |
| 834 | module.makeClass = "RENDERSCRIPT_BITCODE" |
| 835 | module.installDirBase64 = "lib64" |
Colin Cross | 2f63457 | 2023-11-13 12:12:06 -0800 | [diff] [blame] | 836 | module.installAvoidMultilibConflict = true |
Colin Cross | f17e2b5 | 2023-10-30 15:17:25 -0700 | [diff] [blame] | 837 | InitPrebuiltEtcModule(module, "lib") |
| 838 | // This module is device-only |
| 839 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth) |
| 840 | android.InitDefaultableModule(module) |
| 841 | return module |
| 842 | } |
| 843 | |
Colin Cross | 83ebf23 | 2021-04-09 09:41:23 -0700 | [diff] [blame] | 844 | // prebuilt_rfsa installs a firmware file that will be available through Qualcomm's RFSA |
| 845 | // to the <partition>/lib/rfsa directory. |
| 846 | func PrebuiltRFSAFactory() android.Module { |
| 847 | module := &PrebuiltEtc{} |
| 848 | // Ideally these would go in /vendor/dsp, but the /vendor/lib/rfsa paths are hardcoded in too |
| 849 | // many places outside of the application processor. They could be moved to /vendor/dsp once |
| 850 | // that is cleaned up. |
| 851 | InitPrebuiltEtcModule(module, "lib/rfsa") |
| 852 | // This module is device-only |
| 853 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
Martin Stjernholm | dc6525e | 2021-10-14 00:42:59 +0100 | [diff] [blame] | 854 | android.InitDefaultableModule(module) |
Colin Cross | 83ebf23 | 2021-04-09 09:41:23 -0700 | [diff] [blame] | 855 | return module |
| 856 | } |
Jihoon Kang | 2ecf862 | 2024-10-23 21:20:30 +0000 | [diff] [blame] | 857 | |
Jihoon Kang | 0da5ae9 | 2024-10-29 23:24:17 +0000 | [diff] [blame] | 858 | // prebuilt_media installs media files in <partition>/media directory. |
| 859 | func PrebuiltMediaFactory() android.Module { |
Jihoon Kang | 2ecf862 | 2024-10-23 21:20:30 +0000 | [diff] [blame] | 860 | module := &PrebuiltEtc{} |
Jihoon Kang | 0da5ae9 | 2024-10-29 23:24:17 +0000 | [diff] [blame] | 861 | InitPrebuiltEtcModule(module, "media") |
Jihoon Kang | 2ecf862 | 2024-10-23 21:20:30 +0000 | [diff] [blame] | 862 | // This module is device-only |
| 863 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) |
| 864 | android.InitDefaultableModule(module) |
| 865 | return module |
| 866 | } |
Jihoon Kang | ec62d84 | 2024-10-25 20:27:18 +0000 | [diff] [blame] | 867 | |
| 868 | // prebuilt_voicepack installs voice pack files in <partition>/tts directory. |
| 869 | func PrebuiltVoicepackFactory() android.Module { |
| 870 | module := &PrebuiltEtc{} |
| 871 | InitPrebuiltEtcModule(module, "tts") |
| 872 | // This module is device-only |
| 873 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) |
| 874 | android.InitDefaultableModule(module) |
| 875 | return module |
| 876 | } |
| 877 | |
| 878 | // prebuilt_bin installs files in <partition>/bin directory. |
| 879 | func PrebuiltBinaryFactory() android.Module { |
| 880 | module := &PrebuiltEtc{} |
| 881 | InitPrebuiltEtcModule(module, "bin") |
| 882 | // This module is device-only |
| 883 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
| 884 | android.InitDefaultableModule(module) |
| 885 | return module |
| 886 | } |
| 887 | |
| 888 | // prebuilt_wallpaper installs image files in <partition>/wallpaper directory. |
| 889 | func PrebuiltWallpaperFactory() android.Module { |
| 890 | module := &PrebuiltEtc{} |
| 891 | InitPrebuiltEtcModule(module, "wallpaper") |
| 892 | // This module is device-only |
| 893 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) |
| 894 | android.InitDefaultableModule(module) |
| 895 | return module |
| 896 | } |
Jihoon Kang | 0da5ae9 | 2024-10-29 23:24:17 +0000 | [diff] [blame] | 897 | |
| 898 | // prebuilt_priv_app installs files in <partition>/priv-app directory. |
| 899 | func PrebuiltPrivAppFactory() android.Module { |
| 900 | module := &PrebuiltEtc{} |
| 901 | InitPrebuiltEtcModule(module, "priv-app") |
| 902 | // This module is device-only |
| 903 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) |
| 904 | android.InitDefaultableModule(module) |
| 905 | return module |
| 906 | } |
| 907 | |
| 908 | // prebuilt_rfs installs files in <partition>/rfs directory. |
| 909 | func PrebuiltRfsFactory() android.Module { |
| 910 | module := &PrebuiltEtc{} |
| 911 | InitPrebuiltEtcModule(module, "rfs") |
| 912 | // This module is device-only |
| 913 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) |
| 914 | android.InitDefaultableModule(module) |
| 915 | return module |
| 916 | } |
| 917 | |
| 918 | // prebuilt_framework installs files in <partition>/framework directory. |
| 919 | func PrebuiltFrameworkFactory() android.Module { |
| 920 | module := &PrebuiltEtc{} |
| 921 | InitPrebuiltEtcModule(module, "framework") |
| 922 | // This module is device-only |
| 923 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) |
| 924 | android.InitDefaultableModule(module) |
| 925 | return module |
| 926 | } |
| 927 | |
| 928 | // prebuilt_res installs files in <partition>/res directory. |
| 929 | func PrebuiltResFactory() android.Module { |
| 930 | module := &PrebuiltEtc{} |
| 931 | InitPrebuiltEtcModule(module, "res") |
| 932 | // This module is device-only |
| 933 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) |
| 934 | android.InitDefaultableModule(module) |
| 935 | return module |
| 936 | } |
| 937 | |
| 938 | // prebuilt_wlc_upt installs files in <partition>/wlc_upt directory. |
| 939 | func PrebuiltWlcUptFactory() android.Module { |
| 940 | module := &PrebuiltEtc{} |
| 941 | InitPrebuiltEtcModule(module, "wlc_upt") |
| 942 | // This module is device-only |
| 943 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) |
| 944 | android.InitDefaultableModule(module) |
| 945 | return module |
| 946 | } |
| 947 | |
| 948 | // prebuilt_odm installs files in <partition>/odm directory. |
| 949 | func PrebuiltOdmFactory() android.Module { |
| 950 | module := &PrebuiltEtc{} |
| 951 | InitPrebuiltEtcModule(module, "odm") |
| 952 | // This module is device-only |
| 953 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) |
| 954 | android.InitDefaultableModule(module) |
| 955 | return module |
| 956 | } |
Jihoon Kang | 2e2b744 | 2024-11-05 00:26:20 +0000 | [diff] [blame] | 957 | |
| 958 | // prebuilt_vendor_dlkm installs files in <partition>/vendor_dlkm directory. |
| 959 | func PrebuiltVendorDlkmFactory() android.Module { |
| 960 | module := &PrebuiltEtc{} |
| 961 | InitPrebuiltEtcModule(module, "vendor_dlkm") |
| 962 | // This module is device-only |
| 963 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) |
| 964 | android.InitDefaultableModule(module) |
| 965 | return module |
| 966 | } |
| 967 | |
| 968 | // prebuilt_bt_firmware installs files in <partition>/bt_firmware directory. |
| 969 | func PrebuiltBtFirmwareFactory() android.Module { |
| 970 | module := &PrebuiltEtc{} |
| 971 | InitPrebuiltEtcModule(module, "bt_firmware") |
| 972 | // This module is device-only |
| 973 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) |
| 974 | android.InitDefaultableModule(module) |
| 975 | return module |
| 976 | } |
Jihoon Kang | dca2f2b | 2024-11-06 18:43:19 +0000 | [diff] [blame] | 977 | |
| 978 | // prebuilt_tvservice installs files in <partition>/tvservice directory. |
| 979 | func PrebuiltTvServiceFactory() android.Module { |
| 980 | module := &PrebuiltEtc{} |
| 981 | InitPrebuiltEtcModule(module, "tvservice") |
| 982 | // This module is device-only |
| 983 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) |
| 984 | android.InitDefaultableModule(module) |
| 985 | return module |
| 986 | } |
| 987 | |
| 988 | // prebuilt_optee installs files in <partition>/optee directory. |
| 989 | func PrebuiltOpteeFactory() android.Module { |
| 990 | module := &PrebuiltEtc{} |
| 991 | InitPrebuiltEtcModule(module, "optee") |
| 992 | // This module is device-only |
| 993 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) |
| 994 | android.InitDefaultableModule(module) |
| 995 | return module |
| 996 | } |
Jihoon Kang | ecf76dd | 2024-11-12 05:24:46 +0000 | [diff] [blame] | 997 | |
| 998 | // prebuilt_tvconfig installs files in <partition>/tvconfig directory. |
| 999 | func PrebuiltTvConfigFactory() android.Module { |
| 1000 | module := &PrebuiltEtc{} |
| 1001 | InitPrebuiltEtcModule(module, "tvconfig") |
| 1002 | // This module is device-only |
| 1003 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) |
| 1004 | android.InitDefaultableModule(module) |
| 1005 | return module |
| 1006 | } |
Jihoon Kang | 3ca07a1 | 2024-12-02 19:14:30 +0000 | [diff] [blame] | 1007 | |
| 1008 | // prebuilt_vendor installs files in <partition>/vendor directory. |
| 1009 | func PrebuiltVendorFactory() android.Module { |
| 1010 | module := &PrebuiltEtc{} |
| 1011 | InitPrebuiltEtcModule(module, "vendor") |
| 1012 | // This module is device-only |
| 1013 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) |
| 1014 | android.InitDefaultableModule(module) |
| 1015 | return module |
| 1016 | } |
Jihoon Kang | 320ca7c | 2024-12-03 18:14:50 +0000 | [diff] [blame] | 1017 | |
| 1018 | // prebuilt_sbin installs files in <partition>/sbin directory. |
| 1019 | func PrebuiltSbinFactory() android.Module { |
| 1020 | module := &PrebuiltEtc{} |
| 1021 | InitPrebuiltEtcModule(module, "sbin") |
| 1022 | // This module is device-only |
| 1023 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) |
| 1024 | android.InitDefaultableModule(module) |
| 1025 | return module |
| 1026 | } |
| 1027 | |
| 1028 | // prebuilt_system installs files in <partition>/system directory. |
| 1029 | func PrebuiltSystemFactory() android.Module { |
| 1030 | module := &PrebuiltEtc{} |
| 1031 | InitPrebuiltEtcModule(module, "system") |
| 1032 | // This module is device-only |
| 1033 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) |
| 1034 | android.InitDefaultableModule(module) |
| 1035 | return module |
| 1036 | } |
| 1037 | |
| 1038 | // prebuilt_first_stage_ramdisk installs files in <partition>/first_stage_ramdisk directory. |
| 1039 | func PrebuiltFirstStageRamdiskFactory() android.Module { |
| 1040 | module := &PrebuiltEtc{} |
| 1041 | InitPrebuiltEtcModule(module, "first_stage_ramdisk") |
| 1042 | // This module is device-only |
| 1043 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) |
| 1044 | android.InitDefaultableModule(module) |
| 1045 | return module |
| 1046 | } |