Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 1 | // Copyright 2015 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 | |
| 15 | package cc |
| 16 | |
| 17 | import ( |
Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 18 | "fmt" |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 19 | "io" |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 20 | "path/filepath" |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 21 | "strings" |
| 22 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 23 | "android/soong/android" |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 24 | ) |
| 25 | |
Jiyong Park | 27b188b | 2017-07-18 13:23:39 +0900 | [diff] [blame] | 26 | var ( |
dimitry | 4320449 | 2019-05-23 13:24:38 +0200 | [diff] [blame] | 27 | nativeBridgeSuffix = ".native_bridge" |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 28 | productSuffix = ".product" |
dimitry | 4320449 | 2019-05-23 13:24:38 +0200 | [diff] [blame] | 29 | vendorSuffix = ".vendor" |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 30 | ramdiskSuffix = ".ramdisk" |
dimitry | 4320449 | 2019-05-23 13:24:38 +0200 | [diff] [blame] | 31 | recoverySuffix = ".recovery" |
Jiyong Park | 27b188b | 2017-07-18 13:23:39 +0900 | [diff] [blame] | 32 | ) |
| 33 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 34 | type AndroidMkContext interface { |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 35 | Name() string |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 36 | Target() android.Target |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 37 | subAndroidMk(*android.AndroidMkData, interface{}) |
Nicolas Geoffray | c22c1bf | 2019-01-15 19:53:23 +0000 | [diff] [blame] | 38 | Arch() android.Arch |
| 39 | Os() android.OsType |
| 40 | Host() bool |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 41 | UseVndk() bool |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 42 | VndkVersion() string |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 43 | static() bool |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 44 | InRamdisk() bool |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 45 | InRecovery() bool |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | type subAndroidMkProvider interface { |
| 49 | AndroidMk(AndroidMkContext, *android.AndroidMkData) |
| 50 | } |
| 51 | |
| 52 | func (c *Module) subAndroidMk(data *android.AndroidMkData, obj interface{}) { |
| 53 | if c.subAndroidMkOnce == nil { |
| 54 | c.subAndroidMkOnce = make(map[subAndroidMkProvider]bool) |
| 55 | } |
| 56 | if androidmk, ok := obj.(subAndroidMkProvider); ok { |
| 57 | if !c.subAndroidMkOnce[androidmk] { |
| 58 | c.subAndroidMkOnce[androidmk] = true |
| 59 | androidmk.AndroidMk(c, data) |
| 60 | } |
| 61 | } |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 62 | } |
| 63 | |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 64 | func (c *Module) AndroidMk() android.AndroidMkData { |
Jiyong Park | 9d45299 | 2018-10-03 00:38:19 +0900 | [diff] [blame] | 65 | if c.Properties.HideFromMake || !c.IsForPlatform() { |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 66 | return android.AndroidMkData{ |
| 67 | Disabled: true, |
| 68 | } |
Colin Cross | bc6fb16 | 2016-05-24 15:39:04 -0700 | [diff] [blame] | 69 | } |
| 70 | |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 71 | ret := android.AndroidMkData{ |
| 72 | OutputFile: c.outputFile, |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 73 | // TODO(jiyong): add the APEXes providing shared libs to the required modules |
| 74 | // Currently, adding c.Properties.ApexesProvidingSharedLibs is causing multiple |
Martin Stjernholm | cc4b0ad | 2019-07-05 22:38:25 +0100 | [diff] [blame] | 75 | // ART APEXes (com.android.art.debug|release) to be installed. And this |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 76 | // is breaking some older devices (like marlin) where system.img is small. |
| 77 | Required: c.Properties.AndroidMkRuntimeLibs, |
| 78 | Include: "$(BUILD_SYSTEM)/soong_cc_prebuilt.mk", |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 79 | |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 80 | Extra: []android.AndroidMkExtraFunc{ |
| 81 | func(w io.Writer, outputFile android.Path) { |
Colin Cross | 5beccee | 2017-12-07 15:28:59 -0800 | [diff] [blame] | 82 | if len(c.Properties.Logtags) > 0 { |
| 83 | fmt.Fprintln(w, "LOCAL_LOGTAGS_FILES :=", strings.Join(c.Properties.Logtags, " ")) |
| 84 | } |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 85 | if len(c.Properties.AndroidMkSharedLibs) > 0 { |
| 86 | fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " ")) |
| 87 | } |
Jaewoong Jung | 16c7d3d | 2018-11-16 01:19:56 +0000 | [diff] [blame] | 88 | if len(c.Properties.AndroidMkStaticLibs) > 0 { |
| 89 | fmt.Fprintln(w, "LOCAL_STATIC_LIBRARIES := "+strings.Join(c.Properties.AndroidMkStaticLibs, " ")) |
| 90 | } |
| 91 | if len(c.Properties.AndroidMkWholeStaticLibs) > 0 { |
| 92 | fmt.Fprintln(w, "LOCAL_WHOLE_STATIC_LIBRARIES := "+strings.Join(c.Properties.AndroidMkWholeStaticLibs, " ")) |
| 93 | } |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 94 | fmt.Fprintln(w, "LOCAL_SOONG_LINK_TYPE :=", c.makeLinkType) |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 95 | if c.UseVndk() { |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 96 | fmt.Fprintln(w, "LOCAL_USE_VNDK := true") |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 97 | if c.IsVndk() && !c.static() { |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 98 | fmt.Fprintln(w, "LOCAL_SOONG_VNDK_VERSION := "+c.VndkVersion()) |
Jooyung Han | b01c114 | 2019-10-29 05:24:42 +0900 | [diff] [blame] | 99 | // VNDK libraries available to vendor are not installed because |
| 100 | // they are packaged in VNDK APEX and installed by APEX packages (apex/apex.go) |
| 101 | if !c.isVndkExt() { |
| 102 | fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true") |
| 103 | } |
Jooyung Han | 76106d9 | 2019-05-20 18:49:10 +0900 | [diff] [blame] | 104 | } |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 105 | } |
| 106 | }, |
| 107 | }, |
| 108 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 109 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 110 | for _, feature := range c.features { |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 111 | c.subAndroidMk(&ret, feature) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 112 | } |
| 113 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 114 | c.subAndroidMk(&ret, c.compiler) |
| 115 | c.subAndroidMk(&ret, c.linker) |
Colin Cross | 8ff9ef4 | 2017-05-08 13:44:11 -0700 | [diff] [blame] | 116 | if c.sanitize != nil { |
| 117 | c.subAndroidMk(&ret, c.sanitize) |
| 118 | } |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 119 | c.subAndroidMk(&ret, c.installer) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 120 | |
Inseob Kim | 64c4395 | 2019-08-26 16:52:35 +0900 | [diff] [blame] | 121 | ret.SubName += c.Properties.SubName |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 122 | |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 123 | return ret |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 124 | } |
| 125 | |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 126 | func androidMkWriteTestData(data android.Paths, ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 127 | var testFiles []string |
| 128 | for _, d := range data { |
| 129 | rel := d.Rel() |
| 130 | path := d.String() |
| 131 | if !strings.HasSuffix(path, rel) { |
| 132 | panic(fmt.Errorf("path %q does not end with %q", path, rel)) |
| 133 | } |
| 134 | path = strings.TrimSuffix(path, rel) |
| 135 | testFiles = append(testFiles, path+":"+rel) |
| 136 | } |
| 137 | if len(testFiles) > 0 { |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 138 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 139 | fmt.Fprintln(w, "LOCAL_TEST_DATA := "+strings.Join(testFiles, " ")) |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 140 | }) |
| 141 | } |
| 142 | } |
| 143 | |
dimitry | db41747 | 2019-05-20 16:16:47 +0200 | [diff] [blame] | 144 | func makeOverrideModuleNames(ctx AndroidMkContext, overrides []string) []string { |
| 145 | if ctx.Target().NativeBridge == android.NativeBridgeEnabled { |
| 146 | var result []string |
| 147 | for _, override := range overrides { |
| 148 | result = append(result, override+nativeBridgeSuffix) |
| 149 | } |
| 150 | return result |
| 151 | } |
| 152 | |
| 153 | return overrides |
| 154 | } |
| 155 | |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 156 | func (library *libraryDecorator) androidMkWriteExportedFlags(w io.Writer) { |
| 157 | exportedFlags := library.exportedFlags() |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 158 | for _, dir := range library.exportedDirs() { |
Jiyong Park | 7495504 | 2019-10-22 20:19:51 +0900 | [diff] [blame] | 159 | exportedFlags = append(exportedFlags, "-I"+dir.String()) |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 160 | } |
| 161 | for _, dir := range library.exportedSystemDirs() { |
Jiyong Park | 7495504 | 2019-10-22 20:19:51 +0900 | [diff] [blame] | 162 | exportedFlags = append(exportedFlags, "-isystem "+dir.String()) |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 163 | } |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 164 | if len(exportedFlags) > 0 { |
| 165 | fmt.Fprintln(w, "LOCAL_EXPORT_CFLAGS :=", strings.Join(exportedFlags, " ")) |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 166 | } |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 167 | exportedDeps := library.exportedDeps() |
| 168 | if len(exportedDeps) > 0 { |
| 169 | fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DEPS :=", strings.Join(exportedDeps.Strings(), " ")) |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 170 | } |
| 171 | } |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 172 | |
Logan Chien | 41eabe6 | 2019-04-10 13:33:58 +0800 | [diff] [blame] | 173 | func (library *libraryDecorator) androidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Writer) { |
| 174 | if library.sAbiOutputFile.Valid() { |
| 175 | fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES +=", library.sAbiOutputFile.String()) |
| 176 | if library.sAbiDiff.Valid() && !library.static() { |
| 177 | fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES +=", library.sAbiDiff.String()) |
| 178 | fmt.Fprintln(w, "HEADER_ABI_DIFFS +=", library.sAbiDiff.String()) |
| 179 | } |
| 180 | } |
| 181 | } |
| 182 | |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 183 | func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 184 | if library.static() { |
| 185 | ret.Class = "STATIC_LIBRARIES" |
| 186 | } else if library.shared() { |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 187 | ret.Class = "SHARED_LIBRARIES" |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 188 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
| 189 | fmt.Fprintln(w, "LOCAL_SOONG_TOC :=", library.toc().String()) |
Jiyong Park | 47e4fcb | 2019-02-05 22:33:10 +0900 | [diff] [blame] | 190 | if !library.buildStubs() { |
| 191 | fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", library.unstrippedOutputFile.String()) |
| 192 | } |
dimitry | d95964a | 2018-11-07 13:43:34 +0100 | [diff] [blame] | 193 | if len(library.Properties.Overrides) > 0 { |
dimitry | db41747 | 2019-05-20 16:16:47 +0200 | [diff] [blame] | 194 | fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES := "+strings.Join(makeOverrideModuleNames(ctx, library.Properties.Overrides), " ")) |
dimitry | d95964a | 2018-11-07 13:43:34 +0100 | [diff] [blame] | 195 | } |
Jiyong Park | f119435 | 2019-02-25 11:05:47 +0900 | [diff] [blame] | 196 | if len(library.post_install_cmds) > 0 { |
| 197 | fmt.Fprintln(w, "LOCAL_POST_INSTALL_CMD := "+strings.Join(library.post_install_cmds, "&& ")) |
| 198 | } |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 199 | }) |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 200 | } else if library.header() { |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 201 | ret.Class = "HEADER_LIBRARIES" |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 202 | } |
| 203 | |
Dan Willemsen | 569edc5 | 2018-11-19 09:33:29 -0800 | [diff] [blame] | 204 | ret.DistFile = library.distFile |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 205 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 206 | library.androidMkWriteExportedFlags(w) |
Logan Chien | 41eabe6 | 2019-04-10 13:33:58 +0800 | [diff] [blame] | 207 | library.androidMkWriteAdditionalDependenciesForSourceAbiDiff(w) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 208 | |
Ivan Lozano | 022a73b | 2019-09-09 20:29:31 -0700 | [diff] [blame] | 209 | _, _, ext := android.SplitFileExt(outputFile.Base()) |
Logan Chien | 031d2b3 | 2018-07-26 00:19:50 +0800 | [diff] [blame] | 210 | |
| 211 | fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+ext) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 212 | |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 213 | if library.coverageOutputFile.Valid() { |
| 214 | fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", library.coverageOutputFile.String()) |
| 215 | } |
Vic Yang | efd249e | 2018-11-12 20:19:56 -0800 | [diff] [blame] | 216 | |
| 217 | if library.useCoreVariant { |
| 218 | fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true") |
| 219 | fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true") |
| 220 | fmt.Fprintln(w, "LOCAL_VNDK_DEPEND_ON_CORE_VARIANT := true") |
| 221 | } |
Vic Yang | d92090f | 2020-01-08 14:32:28 -0800 | [diff] [blame] | 222 | if library.checkSameCoreVariant { |
| 223 | fmt.Fprintln(w, "LOCAL_CHECK_SAME_VNDK_VARIANTS := true") |
| 224 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 225 | }) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 226 | |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 227 | if library.shared() && !library.buildStubs() { |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 228 | ctx.subAndroidMk(ret, library.baseInstaller) |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 229 | } else { |
| 230 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
| 231 | fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true") |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 232 | if library.buildStubs() { |
| 233 | fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true") |
| 234 | } |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 235 | }) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 236 | } |
Nicolas Geoffray | c22c1bf | 2019-01-15 19:53:23 +0000 | [diff] [blame] | 237 | if len(library.Properties.Stubs.Versions) > 0 && |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 238 | android.DirectlyInAnyApex(ctx, ctx.Name()) && !ctx.InRamdisk() && !ctx.InRecovery() && !ctx.UseVndk() && |
Nicolas Geoffray | c22c1bf | 2019-01-15 19:53:23 +0000 | [diff] [blame] | 239 | !ctx.static() { |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 240 | if !library.buildStubs() { |
| 241 | ret.SubName = ".bootstrap" |
| 242 | } |
| 243 | } |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 244 | } |
| 245 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 246 | func (object *objectLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Colin Cross | 0f86d18 | 2017-08-10 17:07:28 -0700 | [diff] [blame] | 247 | ret.Custom = func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) { |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 248 | out := ret.OutputFile.Path() |
Dan Willemsen | 2e224ca | 2018-09-06 00:26:20 -0700 | [diff] [blame] | 249 | varname := fmt.Sprintf("SOONG_%sOBJECT_%s%s", prefix, name, data.SubName) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 250 | |
Dan Willemsen | 2e224ca | 2018-09-06 00:26:20 -0700 | [diff] [blame] | 251 | fmt.Fprintf(w, "\n%s := %s\n", varname, out.String()) |
| 252 | fmt.Fprintln(w, ".KATI_READONLY: "+varname) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 253 | } |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 254 | } |
| 255 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 256 | func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Colin Cross | 1e7d370 | 2016-08-24 15:25:47 -0700 | [diff] [blame] | 257 | ctx.subAndroidMk(ret, binary.baseInstaller) |
Dan Willemsen | 7517ed0 | 2016-06-10 17:20:30 -0700 | [diff] [blame] | 258 | |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 259 | ret.Class = "EXECUTABLES" |
Dan Willemsen | 569edc5 | 2018-11-19 09:33:29 -0800 | [diff] [blame] | 260 | ret.DistFile = binary.distFile |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 261 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 262 | fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", binary.unstrippedOutputFile.String()) |
Colin Cross | 9b09f24 | 2016-12-07 13:37:42 -0800 | [diff] [blame] | 263 | if len(binary.symlinks) > 0 { |
| 264 | fmt.Fprintln(w, "LOCAL_MODULE_SYMLINKS := "+strings.Join(binary.symlinks, " ")) |
| 265 | } |
| 266 | |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 267 | if binary.coverageOutputFile.Valid() { |
| 268 | fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", binary.coverageOutputFile.String()) |
| 269 | } |
Yifan Hong | 946e32e | 2018-04-03 13:22:50 -0700 | [diff] [blame] | 270 | |
| 271 | if len(binary.Properties.Overrides) > 0 { |
dimitry | db41747 | 2019-05-20 16:16:47 +0200 | [diff] [blame] | 272 | fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES := "+strings.Join(makeOverrideModuleNames(ctx, binary.Properties.Overrides), " ")) |
Yifan Hong | 946e32e | 2018-04-03 13:22:50 -0700 | [diff] [blame] | 273 | } |
Jiyong Park | f119435 | 2019-02-25 11:05:47 +0900 | [diff] [blame] | 274 | if len(binary.post_install_cmds) > 0 { |
| 275 | fmt.Fprintln(w, "LOCAL_POST_INSTALL_CMD := "+strings.Join(binary.post_install_cmds, "&& ")) |
| 276 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 277 | }) |
| 278 | } |
| 279 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 280 | func (benchmark *benchmarkDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 281 | ctx.subAndroidMk(ret, benchmark.binaryDecorator) |
Dan Willemsen | 58a5c8b | 2017-05-23 15:10:37 -0700 | [diff] [blame] | 282 | ret.Class = "NATIVE_TESTS" |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 283 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Colin Cross | e28f4e2 | 2017-04-24 18:10:29 -0700 | [diff] [blame] | 284 | if len(benchmark.Properties.Test_suites) > 0 { |
| 285 | fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", |
| 286 | strings.Join(benchmark.Properties.Test_suites, " ")) |
| 287 | } |
Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 288 | if benchmark.testConfig != nil { |
| 289 | fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", benchmark.testConfig.String()) |
Julien Desprez | e146e39 | 2018-08-02 15:00:46 -0700 | [diff] [blame] | 290 | } |
Nelson Li | 1f6b14e | 2018-04-18 16:55:21 +0000 | [diff] [blame] | 291 | fmt.Fprintln(w, "LOCAL_NATIVE_BENCHMARK := true") |
Dan Shi | 2468d01 | 2020-01-06 15:47:57 -0800 | [diff] [blame] | 292 | if !BoolDefault(benchmark.Properties.Auto_gen_config, true) { |
| 293 | fmt.Fprintln(w, "LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG := true") |
| 294 | } |
Colin Cross | e28f4e2 | 2017-04-24 18:10:29 -0700 | [diff] [blame] | 295 | }) |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 296 | |
| 297 | androidMkWriteTestData(benchmark.data, ctx, ret) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | func (test *testBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 301 | ctx.subAndroidMk(ret, test.binaryDecorator) |
Dan Willemsen | 0fe7253 | 2017-01-17 13:25:49 -0800 | [diff] [blame] | 302 | ret.Class = "NATIVE_TESTS" |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 303 | if Bool(test.Properties.Test_per_src) { |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 304 | ret.SubName = "_" + String(test.binaryDecorator.Properties.Stem) |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 305 | } |
Colin Cross | faeb7aa | 2017-02-01 14:12:44 -0800 | [diff] [blame] | 306 | |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 307 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Colin Cross | a929db0 | 2017-03-27 16:27:50 -0700 | [diff] [blame] | 308 | if len(test.Properties.Test_suites) > 0 { |
Dan Shi | 4df566d | 2017-04-03 12:29:25 -0700 | [diff] [blame] | 309 | fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", |
Colin Cross | a929db0 | 2017-03-27 16:27:50 -0700 | [diff] [blame] | 310 | strings.Join(test.Properties.Test_suites, " ")) |
| 311 | } |
Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 312 | if test.testConfig != nil { |
| 313 | fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", test.testConfig.String()) |
Julien Desprez | e146e39 | 2018-08-02 15:00:46 -0700 | [diff] [blame] | 314 | } |
Dan Shi | 2468d01 | 2020-01-06 15:47:57 -0800 | [diff] [blame] | 315 | if !BoolDefault(test.Properties.Auto_gen_config, true) { |
| 316 | fmt.Fprintln(w, "LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG := true") |
| 317 | } |
Colin Cross | a929db0 | 2017-03-27 16:27:50 -0700 | [diff] [blame] | 318 | }) |
| 319 | |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 320 | androidMkWriteTestData(test.data, ctx, ret) |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 321 | } |
| 322 | |
Mitch Phillips | 4e4ab8a | 2019-09-13 17:32:50 -0700 | [diff] [blame] | 323 | func (fuzz *fuzzBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 324 | ctx.subAndroidMk(ret, fuzz.binaryDecorator) |
| 325 | |
| 326 | var fuzzFiles []string |
| 327 | for _, d := range fuzz.corpus { |
Mitch Phillips | 8a2bc0b | 2019-10-17 15:04:01 -0700 | [diff] [blame] | 328 | fuzzFiles = append(fuzzFiles, |
| 329 | filepath.Dir(fuzz.corpusIntermediateDir.String())+":corpus/"+d.Base()) |
Mitch Phillips | 4e4ab8a | 2019-09-13 17:32:50 -0700 | [diff] [blame] | 330 | } |
| 331 | |
Tri Vo | ad172d8 | 2019-11-27 13:45:45 -0800 | [diff] [blame] | 332 | for _, d := range fuzz.data { |
| 333 | fuzzFiles = append(fuzzFiles, |
| 334 | filepath.Dir(fuzz.dataIntermediateDir.String())+":data/"+d.Rel()) |
| 335 | } |
| 336 | |
Mitch Phillips | 4e4ab8a | 2019-09-13 17:32:50 -0700 | [diff] [blame] | 337 | if fuzz.dictionary != nil { |
Mitch Phillips | 8a2bc0b | 2019-10-17 15:04:01 -0700 | [diff] [blame] | 338 | fuzzFiles = append(fuzzFiles, |
| 339 | filepath.Dir(fuzz.dictionary.String())+":"+fuzz.dictionary.Base()) |
Mitch Phillips | 4e4ab8a | 2019-09-13 17:32:50 -0700 | [diff] [blame] | 340 | } |
| 341 | |
Kris Alder | f979ee3 | 2019-10-22 10:52:01 -0700 | [diff] [blame] | 342 | if fuzz.config != nil { |
| 343 | fuzzFiles = append(fuzzFiles, |
| 344 | filepath.Dir(fuzz.config.String())+":config.json") |
| 345 | } |
| 346 | |
Mitch Phillips | 4e4ab8a | 2019-09-13 17:32:50 -0700 | [diff] [blame] | 347 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
| 348 | fmt.Fprintln(w, "LOCAL_IS_FUZZ_TARGET := true") |
Mitch Phillips | e1ee1a1 | 2019-10-17 19:20:41 -0700 | [diff] [blame] | 349 | if len(fuzzFiles) > 0 { |
| 350 | fmt.Fprintln(w, "LOCAL_TEST_DATA := "+strings.Join(fuzzFiles, " ")) |
| 351 | } |
| 352 | if fuzz.installedSharedDeps != nil { |
| 353 | fmt.Fprintln(w, "LOCAL_FUZZ_INSTALLED_SHARED_DEPS :="+ |
| 354 | strings.Join(fuzz.installedSharedDeps, " ")) |
| 355 | } |
Mitch Phillips | 4e4ab8a | 2019-09-13 17:32:50 -0700 | [diff] [blame] | 356 | }) |
| 357 | } |
| 358 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 359 | func (test *testLibrary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 360 | ctx.subAndroidMk(ret, test.libraryDecorator) |
| 361 | } |
Dan Willemsen | e7932e8 | 2016-05-16 15:56:53 -0700 | [diff] [blame] | 362 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 363 | func (library *toolchainLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 364 | ret.Class = "STATIC_LIBRARIES" |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 365 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Ivan Lozano | 022a73b | 2019-09-09 20:29:31 -0700 | [diff] [blame] | 366 | _, suffix, _ := android.SplitFileExt(outputFile.Base()) |
Logan Chien | 031d2b3 | 2018-07-26 00:19:50 +0800 | [diff] [blame] | 367 | fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+suffix) |
Dan Willemsen | 7517ed0 | 2016-06-10 17:20:30 -0700 | [diff] [blame] | 368 | }) |
| 369 | } |
| 370 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 371 | func (installer *baseInstaller) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Dan Willemsen | 03ce63e | 2016-09-29 12:17:49 -0700 | [diff] [blame] | 372 | // Soong installation is only supported for host modules. Have Make |
| 373 | // installation trigger Soong installation. |
| 374 | if ctx.Target().Os.Class == android.Host { |
| 375 | ret.OutputFile = android.OptionalPathForPath(installer.path) |
| 376 | } |
| 377 | |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 378 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Colin Cross | ff6c33d | 2019-10-02 16:01:35 -0700 | [diff] [blame] | 379 | path, file := filepath.Split(installer.path.ToMakePath().String()) |
Ivan Lozano | 022a73b | 2019-09-09 20:29:31 -0700 | [diff] [blame] | 380 | stem, suffix, _ := android.SplitFileExt(file) |
Logan Chien | 031d2b3 | 2018-07-26 00:19:50 +0800 | [diff] [blame] | 381 | fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+suffix) |
Colin Cross | ff6c33d | 2019-10-02 16:01:35 -0700 | [diff] [blame] | 382 | fmt.Fprintln(w, "LOCAL_MODULE_PATH := "+path) |
Colin Cross | bf305de | 2016-03-29 17:32:06 -0700 | [diff] [blame] | 383 | fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem) |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 384 | }) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 385 | } |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 386 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 387 | func (c *stubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Dan Willemsen | 01a9059 | 2017-04-07 15:21:13 -0700 | [diff] [blame] | 388 | ret.SubName = ndkLibrarySuffix + "." + c.properties.ApiLevel |
Dan Albert | 705c84b | 2016-08-08 10:45:03 -0700 | [diff] [blame] | 389 | ret.Class = "SHARED_LIBRARIES" |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 390 | |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 391 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 392 | path, file := filepath.Split(c.installPath.String()) |
Ivan Lozano | 022a73b | 2019-09-09 20:29:31 -0700 | [diff] [blame] | 393 | stem, suffix, _ := android.SplitFileExt(file) |
Logan Chien | 031d2b3 | 2018-07-26 00:19:50 +0800 | [diff] [blame] | 394 | fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+suffix) |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 395 | fmt.Fprintln(w, "LOCAL_MODULE_PATH := "+path) |
| 396 | fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem) |
Dan Willemsen | 866810d | 2017-04-04 14:13:45 -0700 | [diff] [blame] | 397 | fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true") |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 398 | }) |
| 399 | } |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 400 | |
| 401 | func (c *llndkStubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 402 | ret.Class = "SHARED_LIBRARIES" |
| 403 | |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 404 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 405 | c.libraryDecorator.androidMkWriteExportedFlags(w) |
Ivan Lozano | 022a73b | 2019-09-09 20:29:31 -0700 | [diff] [blame] | 406 | _, _, ext := android.SplitFileExt(outputFile.Base()) |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 407 | |
Logan Chien | 031d2b3 | 2018-07-26 00:19:50 +0800 | [diff] [blame] | 408 | fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+ext) |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 409 | fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true") |
| 410 | fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true") |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 411 | fmt.Fprintln(w, "LOCAL_SOONG_TOC :=", c.toc().String()) |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 412 | }) |
| 413 | } |
Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 414 | |
| 415 | func (c *vndkPrebuiltLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 416 | ret.Class = "SHARED_LIBRARIES" |
| 417 | |
Inseob Kim | 2b96bf5 | 2020-02-17 18:00:39 +0900 | [diff] [blame] | 418 | ret.SubName = c.androidMkSuffix |
Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 419 | |
| 420 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
| 421 | c.libraryDecorator.androidMkWriteExportedFlags(w) |
| 422 | |
Colin Cross | ff6c33d | 2019-10-02 16:01:35 -0700 | [diff] [blame] | 423 | path, file := filepath.Split(c.path.ToMakePath().String()) |
Ivan Lozano | 022a73b | 2019-09-09 20:29:31 -0700 | [diff] [blame] | 424 | stem, suffix, ext := android.SplitFileExt(file) |
Logan Chien | 031d2b3 | 2018-07-26 00:19:50 +0800 | [diff] [blame] | 425 | fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+ext) |
| 426 | fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+suffix) |
Colin Cross | ff6c33d | 2019-10-02 16:01:35 -0700 | [diff] [blame] | 427 | fmt.Fprintln(w, "LOCAL_MODULE_PATH := "+path) |
Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 428 | fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem) |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 429 | if c.tocFile.Valid() { |
| 430 | fmt.Fprintln(w, "LOCAL_SOONG_TOC := "+c.tocFile.String()) |
| 431 | } |
| 432 | }) |
| 433 | } |
| 434 | |
| 435 | func (c *vendorSnapshotLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 436 | // Each vendor snapshot is exported to androidMk only when BOARD_VNDK_VERSION != current |
| 437 | // and the version of the prebuilt is same as BOARD_VNDK_VERSION. |
| 438 | if c.shared() { |
| 439 | ret.Class = "SHARED_LIBRARIES" |
| 440 | } else if c.static() { |
| 441 | ret.Class = "STATIC_LIBRARIES" |
| 442 | } else if c.header() { |
| 443 | ret.Class = "HEADER_LIBRARIES" |
| 444 | } |
| 445 | |
| 446 | if c.androidMkVendorSuffix { |
| 447 | ret.SubName = vendorSuffix |
| 448 | } else { |
| 449 | ret.SubName = "" |
| 450 | } |
| 451 | |
| 452 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
| 453 | c.libraryDecorator.androidMkWriteExportedFlags(w) |
| 454 | |
Inseob Kim | c3b1a16 | 2020-02-18 12:42:54 +0900 | [diff] [blame] | 455 | if c.shared() || c.static() { |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 456 | path, file := filepath.Split(c.path.ToMakePath().String()) |
| 457 | stem, suffix, ext := android.SplitFileExt(file) |
| 458 | fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+ext) |
| 459 | fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+suffix) |
Inseob Kim | c3b1a16 | 2020-02-18 12:42:54 +0900 | [diff] [blame] | 460 | fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem) |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 461 | if c.shared() { |
| 462 | fmt.Fprintln(w, "LOCAL_MODULE_PATH := "+path) |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 463 | } |
| 464 | if c.tocFile.Valid() { |
| 465 | fmt.Fprintln(w, "LOCAL_SOONG_TOC := "+c.tocFile.String()) |
| 466 | } |
Inseob Kim | c3b1a16 | 2020-02-18 12:42:54 +0900 | [diff] [blame] | 467 | } |
| 468 | |
| 469 | if !c.shared() { // static or header |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 470 | fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true") |
| 471 | } |
| 472 | }) |
| 473 | } |
| 474 | |
| 475 | func (c *vendorSnapshotBinaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 476 | ret.Class = "EXECUTABLES" |
| 477 | |
| 478 | if c.androidMkVendorSuffix { |
| 479 | ret.SubName = vendorSuffix |
| 480 | } else { |
| 481 | ret.SubName = "" |
| 482 | } |
| 483 | |
| 484 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
| 485 | fmt.Fprintln(w, "LOCAL_MODULE_SYMLINKS := "+strings.Join(c.Properties.Symlinks, " ")) |
Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 486 | }) |
Colin Cross | 7a6fcbe | 2017-12-06 13:08:00 -0800 | [diff] [blame] | 487 | } |
Dan Albert | 8ba131b | 2017-12-14 13:23:15 -0800 | [diff] [blame] | 488 | |
| 489 | func (c *ndkPrebuiltStlLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 490 | ret.Class = "SHARED_LIBRARIES" |
Dan Albert | 8ba131b | 2017-12-14 13:23:15 -0800 | [diff] [blame] | 491 | } |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 492 | |
| 493 | func (c *vendorPublicLibraryStubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 494 | ret.Class = "SHARED_LIBRARIES" |
| 495 | ret.SubName = vendorPublicLibrarySuffix |
| 496 | |
| 497 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
| 498 | c.libraryDecorator.androidMkWriteExportedFlags(w) |
Ivan Lozano | 022a73b | 2019-09-09 20:29:31 -0700 | [diff] [blame] | 499 | _, _, ext := android.SplitFileExt(outputFile.Base()) |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 500 | |
Logan Chien | 031d2b3 | 2018-07-26 00:19:50 +0800 | [diff] [blame] | 501 | fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+ext) |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 502 | fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true") |
| 503 | fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true") |
| 504 | }) |
| 505 | } |
Logan Chien | 4fcea3d | 2018-11-20 11:59:08 +0800 | [diff] [blame] | 506 | |
| 507 | func (p *prebuiltLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 508 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
| 509 | if p.properties.Check_elf_files != nil { |
| 510 | fmt.Fprintln(w, "LOCAL_CHECK_ELF_FILES :=", *p.properties.Check_elf_files) |
| 511 | } else { |
| 512 | // soong_cc_prebuilt.mk does not include check_elf_file.mk by default |
| 513 | // because cc_library_shared and cc_binary use soong_cc_prebuilt.mk as well. |
| 514 | // In order to turn on prebuilt ABI checker, set `LOCAL_CHECK_ELF_FILES` to |
| 515 | // true if `p.properties.Check_elf_files` is not specified. |
| 516 | fmt.Fprintln(w, "LOCAL_CHECK_ELF_FILES := true") |
| 517 | } |
| 518 | }) |
| 519 | } |
| 520 | |
| 521 | func (p *prebuiltLibraryLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 522 | ctx.subAndroidMk(ret, p.libraryDecorator) |
| 523 | if p.shared() { |
| 524 | ctx.subAndroidMk(ret, &p.prebuiltLinker) |
| 525 | androidMkWriteAllowUndefinedSymbols(p.baseLinker, ret) |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | func (p *prebuiltBinaryLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 530 | ctx.subAndroidMk(ret, p.binaryDecorator) |
| 531 | ctx.subAndroidMk(ret, &p.prebuiltLinker) |
| 532 | androidMkWriteAllowUndefinedSymbols(p.baseLinker, ret) |
| 533 | } |
| 534 | |
| 535 | func androidMkWriteAllowUndefinedSymbols(linker *baseLinker, ret *android.AndroidMkData) { |
| 536 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
| 537 | allow := linker.Properties.Allow_undefined_symbols |
| 538 | if allow != nil { |
| 539 | fmt.Fprintln(w, "LOCAL_ALLOW_UNDEFINED_SYMBOLS :=", *allow) |
| 540 | } |
| 541 | }) |
| 542 | } |