blob: cdd8e92018368b650a4666f3f157670b32cb0363 [file] [log] [blame]
Dan Willemsen218f6562015-07-08 18:13:11 -07001// 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
15package cc
16
17import (
Dan Willemsen97750522016-02-09 17:43:51 -080018 "fmt"
Dan Willemsen218f6562015-07-08 18:13:11 -070019 "io"
Colin Crossa2344662016-03-24 13:14:12 -070020 "path/filepath"
Dan Willemsen218f6562015-07-08 18:13:11 -070021 "strings"
22
Colin Cross635c3b02016-05-18 15:37:25 -070023 "android/soong/android"
Dan Willemsen218f6562015-07-08 18:13:11 -070024)
25
Jiyong Park27b188b2017-07-18 13:23:39 +090026var (
dimitry43204492019-05-23 13:24:38 +020027 nativeBridgeSuffix = ".native_bridge"
28 vendorSuffix = ".vendor"
29 recoverySuffix = ".recovery"
Jiyong Park27b188b2017-07-18 13:23:39 +090030)
31
Dan Willemsenf2c27d72016-07-13 16:50:22 -070032type AndroidMkContext interface {
Jiyong Parkb0788572018-12-20 22:10:17 +090033 Name() string
Dan Willemsenf2c27d72016-07-13 16:50:22 -070034 Target() android.Target
Colin Crossb916a382016-07-29 17:28:03 -070035 subAndroidMk(*android.AndroidMkData, interface{})
Nicolas Geoffrayc22c1bf2019-01-15 19:53:23 +000036 Arch() android.Arch
37 Os() android.OsType
38 Host() bool
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -070039 useVndk() bool
Inseob Kim64c43952019-08-26 16:52:35 +090040 vndkVersion() string
Jiyong Parkb0788572018-12-20 22:10:17 +090041 static() bool
42 inRecovery() bool
Colin Crossb916a382016-07-29 17:28:03 -070043}
44
45type subAndroidMkProvider interface {
46 AndroidMk(AndroidMkContext, *android.AndroidMkData)
47}
48
49func (c *Module) subAndroidMk(data *android.AndroidMkData, obj interface{}) {
50 if c.subAndroidMkOnce == nil {
51 c.subAndroidMkOnce = make(map[subAndroidMkProvider]bool)
52 }
53 if androidmk, ok := obj.(subAndroidMkProvider); ok {
54 if !c.subAndroidMkOnce[androidmk] {
55 c.subAndroidMkOnce[androidmk] = true
56 androidmk.AndroidMk(c, data)
57 }
58 }
Dan Willemsenf2c27d72016-07-13 16:50:22 -070059}
60
Colin Crossa18e9cf2017-08-10 17:00:19 -070061func (c *Module) AndroidMk() android.AndroidMkData {
Jiyong Park9d452992018-10-03 00:38:19 +090062 if c.Properties.HideFromMake || !c.IsForPlatform() {
Colin Crossa18e9cf2017-08-10 17:00:19 -070063 return android.AndroidMkData{
64 Disabled: true,
65 }
Colin Crossbc6fb162016-05-24 15:39:04 -070066 }
67
Colin Crossa18e9cf2017-08-10 17:00:19 -070068 ret := android.AndroidMkData{
69 OutputFile: c.outputFile,
Jiyong Parkb0788572018-12-20 22:10:17 +090070 // TODO(jiyong): add the APEXes providing shared libs to the required modules
71 // Currently, adding c.Properties.ApexesProvidingSharedLibs is causing multiple
Martin Stjernholmcc4b0ad2019-07-05 22:38:25 +010072 // ART APEXes (com.android.art.debug|release) to be installed. And this
Jiyong Parkb0788572018-12-20 22:10:17 +090073 // is breaking some older devices (like marlin) where system.img is small.
74 Required: c.Properties.AndroidMkRuntimeLibs,
75 Include: "$(BUILD_SYSTEM)/soong_cc_prebuilt.mk",
Logan Chien43d34c32017-12-20 01:17:32 +080076
Colin Crossa18e9cf2017-08-10 17:00:19 -070077 Extra: []android.AndroidMkExtraFunc{
78 func(w io.Writer, outputFile android.Path) {
Colin Cross5beccee2017-12-07 15:28:59 -080079 if len(c.Properties.Logtags) > 0 {
80 fmt.Fprintln(w, "LOCAL_LOGTAGS_FILES :=", strings.Join(c.Properties.Logtags, " "))
81 }
Colin Crossa18e9cf2017-08-10 17:00:19 -070082 if len(c.Properties.AndroidMkSharedLibs) > 0 {
83 fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " "))
84 }
Jaewoong Jung16c7d3d2018-11-16 01:19:56 +000085 if len(c.Properties.AndroidMkStaticLibs) > 0 {
86 fmt.Fprintln(w, "LOCAL_STATIC_LIBRARIES := "+strings.Join(c.Properties.AndroidMkStaticLibs, " "))
87 }
88 if len(c.Properties.AndroidMkWholeStaticLibs) > 0 {
89 fmt.Fprintln(w, "LOCAL_WHOLE_STATIC_LIBRARIES := "+strings.Join(c.Properties.AndroidMkWholeStaticLibs, " "))
90 }
Inseob Kim9516ee92019-05-09 10:56:13 +090091 fmt.Fprintln(w, "LOCAL_SOONG_LINK_TYPE :=", c.makeLinkType)
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -070092 if c.useVndk() {
Colin Crossa18e9cf2017-08-10 17:00:19 -070093 fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
Jooyung Han76106d92019-05-20 18:49:10 +090094 if c.isVndk() && !c.static() {
95 fmt.Fprintln(w, "LOCAL_SOONG_VNDK_VERSION := "+c.vndkVersion())
96 }
Colin Crossa18e9cf2017-08-10 17:00:19 -070097 }
98 },
99 },
100 }
Colin Crossca860ac2016-01-04 14:34:37 -0800101
Colin Crossca860ac2016-01-04 14:34:37 -0800102 for _, feature := range c.features {
Colin Crossb916a382016-07-29 17:28:03 -0700103 c.subAndroidMk(&ret, feature)
Colin Crossca860ac2016-01-04 14:34:37 -0800104 }
105
Colin Crossb916a382016-07-29 17:28:03 -0700106 c.subAndroidMk(&ret, c.compiler)
107 c.subAndroidMk(&ret, c.linker)
Colin Cross8ff9ef42017-05-08 13:44:11 -0700108 if c.sanitize != nil {
109 c.subAndroidMk(&ret, c.sanitize)
110 }
Colin Crossb916a382016-07-29 17:28:03 -0700111 c.subAndroidMk(&ret, c.installer)
Colin Crossca860ac2016-01-04 14:34:37 -0800112
Inseob Kim64c43952019-08-26 16:52:35 +0900113 ret.SubName += c.Properties.SubName
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700114
Colin Crossa18e9cf2017-08-10 17:00:19 -0700115 return ret
Colin Crossca860ac2016-01-04 14:34:37 -0800116}
117
Anders Lewisb97e8182017-07-14 15:20:13 -0700118func androidMkWriteTestData(data android.Paths, ctx AndroidMkContext, ret *android.AndroidMkData) {
119 var testFiles []string
120 for _, d := range data {
121 rel := d.Rel()
122 path := d.String()
123 if !strings.HasSuffix(path, rel) {
124 panic(fmt.Errorf("path %q does not end with %q", path, rel))
125 }
126 path = strings.TrimSuffix(path, rel)
127 testFiles = append(testFiles, path+":"+rel)
128 }
129 if len(testFiles) > 0 {
Colin Cross27a4b052017-08-10 16:32:23 -0700130 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Anders Lewisb97e8182017-07-14 15:20:13 -0700131 fmt.Fprintln(w, "LOCAL_TEST_DATA := "+strings.Join(testFiles, " "))
Anders Lewisb97e8182017-07-14 15:20:13 -0700132 })
133 }
134}
135
dimitrydb417472019-05-20 16:16:47 +0200136func makeOverrideModuleNames(ctx AndroidMkContext, overrides []string) []string {
137 if ctx.Target().NativeBridge == android.NativeBridgeEnabled {
138 var result []string
139 for _, override := range overrides {
140 result = append(result, override+nativeBridgeSuffix)
141 }
142 return result
143 }
144
145 return overrides
146}
147
Dan Willemsen58539402017-03-19 13:44:32 -0700148func (library *libraryDecorator) androidMkWriteExportedFlags(w io.Writer) {
149 exportedFlags := library.exportedFlags()
Inseob Kim69378442019-06-03 19:10:47 +0900150 for _, dir := range library.exportedDirs() {
Jiyong Park74955042019-10-22 20:19:51 +0900151 exportedFlags = append(exportedFlags, "-I"+dir.String())
Inseob Kim69378442019-06-03 19:10:47 +0900152 }
153 for _, dir := range library.exportedSystemDirs() {
Jiyong Park74955042019-10-22 20:19:51 +0900154 exportedFlags = append(exportedFlags, "-isystem "+dir.String())
Inseob Kim69378442019-06-03 19:10:47 +0900155 }
Dan Willemsen58539402017-03-19 13:44:32 -0700156 if len(exportedFlags) > 0 {
157 fmt.Fprintln(w, "LOCAL_EXPORT_CFLAGS :=", strings.Join(exportedFlags, " "))
Dan Willemsend5781342017-02-15 16:15:21 -0800158 }
Inseob Kim69378442019-06-03 19:10:47 +0900159 exportedDeps := library.exportedDeps()
160 if len(exportedDeps) > 0 {
161 fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DEPS :=", strings.Join(exportedDeps.Strings(), " "))
Dan Willemsen58539402017-03-19 13:44:32 -0700162 }
163}
Dan Willemsend5781342017-02-15 16:15:21 -0800164
Logan Chien41eabe62019-04-10 13:33:58 +0800165func (library *libraryDecorator) androidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Writer) {
166 if library.sAbiOutputFile.Valid() {
167 fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES +=", library.sAbiOutputFile.String())
168 if library.sAbiDiff.Valid() && !library.static() {
169 fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES +=", library.sAbiDiff.String())
170 fmt.Fprintln(w, "HEADER_ABI_DIFFS +=", library.sAbiDiff.String())
171 }
172 }
173}
174
Dan Willemsen58539402017-03-19 13:44:32 -0700175func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Dan Willemsend5781342017-02-15 16:15:21 -0800176 if library.static() {
177 ret.Class = "STATIC_LIBRARIES"
178 } else if library.shared() {
Dan Willemsend5781342017-02-15 16:15:21 -0800179 ret.Class = "SHARED_LIBRARIES"
Colin Crossb60190a2018-09-04 16:28:17 -0700180 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
181 fmt.Fprintln(w, "LOCAL_SOONG_TOC :=", library.toc().String())
Jiyong Park47e4fcb2019-02-05 22:33:10 +0900182 if !library.buildStubs() {
183 fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", library.unstrippedOutputFile.String())
184 }
dimitryd95964a2018-11-07 13:43:34 +0100185 if len(library.Properties.Overrides) > 0 {
dimitrydb417472019-05-20 16:16:47 +0200186 fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES := "+strings.Join(makeOverrideModuleNames(ctx, library.Properties.Overrides), " "))
dimitryd95964a2018-11-07 13:43:34 +0100187 }
Jiyong Parkf1194352019-02-25 11:05:47 +0900188 if len(library.post_install_cmds) > 0 {
189 fmt.Fprintln(w, "LOCAL_POST_INSTALL_CMD := "+strings.Join(library.post_install_cmds, "&& "))
190 }
Colin Crossb60190a2018-09-04 16:28:17 -0700191 })
Dan Willemsend5781342017-02-15 16:15:21 -0800192 } else if library.header() {
Colin Crossb60190a2018-09-04 16:28:17 -0700193 ret.Class = "HEADER_LIBRARIES"
Dan Willemsend5781342017-02-15 16:15:21 -0800194 }
195
Dan Willemsen569edc52018-11-19 09:33:29 -0800196 ret.DistFile = library.distFile
Colin Cross27a4b052017-08-10 16:32:23 -0700197 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsen58539402017-03-19 13:44:32 -0700198 library.androidMkWriteExportedFlags(w)
Logan Chien41eabe62019-04-10 13:33:58 +0800199 library.androidMkWriteAdditionalDependenciesForSourceAbiDiff(w)
Dan Willemsen218f6562015-07-08 18:13:11 -0700200
Ivan Lozano022a73b2019-09-09 20:29:31 -0700201 _, _, ext := android.SplitFileExt(outputFile.Base())
Logan Chien031d2b32018-07-26 00:19:50 +0800202
203 fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+ext)
Dan Willemsen218f6562015-07-08 18:13:11 -0700204
Dan Willemsen581341d2017-02-09 16:16:31 -0800205 if library.coverageOutputFile.Valid() {
206 fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", library.coverageOutputFile.String())
207 }
Vic Yangefd249e2018-11-12 20:19:56 -0800208
209 if library.useCoreVariant {
210 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
211 fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
212 fmt.Fprintln(w, "LOCAL_VNDK_DEPEND_ON_CORE_VARIANT := true")
213 }
Colin Crossca860ac2016-01-04 14:34:37 -0800214 })
Colin Crossb916a382016-07-29 17:28:03 -0700215
Jiyong Parkb0788572018-12-20 22:10:17 +0900216 if library.shared() && !library.buildStubs() {
Colin Crossb916a382016-07-29 17:28:03 -0700217 ctx.subAndroidMk(ret, library.baseInstaller)
Colin Crossb60190a2018-09-04 16:28:17 -0700218 } else {
219 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
220 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
Jiyong Parkb0788572018-12-20 22:10:17 +0900221 if library.buildStubs() {
222 fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
223 }
Colin Crossb60190a2018-09-04 16:28:17 -0700224 })
Colin Crossb916a382016-07-29 17:28:03 -0700225 }
Nicolas Geoffrayc22c1bf2019-01-15 19:53:23 +0000226 if len(library.Properties.Stubs.Versions) > 0 &&
227 android.DirectlyInAnyApex(ctx, ctx.Name()) && !ctx.inRecovery() && !ctx.useVndk() &&
228 !ctx.static() {
Jiyong Parkb0788572018-12-20 22:10:17 +0900229 if !library.buildStubs() {
230 ret.SubName = ".bootstrap"
231 }
232 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700233}
234
Dan Willemsenf2c27d72016-07-13 16:50:22 -0700235func (object *objectLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Colin Cross0f86d182017-08-10 17:07:28 -0700236 ret.Custom = func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
Colin Crossca860ac2016-01-04 14:34:37 -0800237 out := ret.OutputFile.Path()
Dan Willemsen2e224ca2018-09-06 00:26:20 -0700238 varname := fmt.Sprintf("SOONG_%sOBJECT_%s%s", prefix, name, data.SubName)
Dan Willemsen218f6562015-07-08 18:13:11 -0700239
Dan Willemsen2e224ca2018-09-06 00:26:20 -0700240 fmt.Fprintf(w, "\n%s := %s\n", varname, out.String())
241 fmt.Fprintln(w, ".KATI_READONLY: "+varname)
Dan Willemsen218f6562015-07-08 18:13:11 -0700242 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700243}
244
Colin Crossb916a382016-07-29 17:28:03 -0700245func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Colin Cross1e7d3702016-08-24 15:25:47 -0700246 ctx.subAndroidMk(ret, binary.baseInstaller)
Dan Willemsen7517ed02016-06-10 17:20:30 -0700247
Dan Willemsen218f6562015-07-08 18:13:11 -0700248 ret.Class = "EXECUTABLES"
Dan Willemsen569edc52018-11-19 09:33:29 -0800249 ret.DistFile = binary.distFile
Colin Cross27a4b052017-08-10 16:32:23 -0700250 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossb60190a2018-09-04 16:28:17 -0700251 fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", binary.unstrippedOutputFile.String())
Colin Cross9b09f242016-12-07 13:37:42 -0800252 if len(binary.symlinks) > 0 {
253 fmt.Fprintln(w, "LOCAL_MODULE_SYMLINKS := "+strings.Join(binary.symlinks, " "))
254 }
255
Dan Willemsen581341d2017-02-09 16:16:31 -0800256 if binary.coverageOutputFile.Valid() {
257 fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", binary.coverageOutputFile.String())
258 }
Yifan Hong946e32e2018-04-03 13:22:50 -0700259
260 if len(binary.Properties.Overrides) > 0 {
dimitrydb417472019-05-20 16:16:47 +0200261 fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES := "+strings.Join(makeOverrideModuleNames(ctx, binary.Properties.Overrides), " "))
Yifan Hong946e32e2018-04-03 13:22:50 -0700262 }
Jiyong Parkf1194352019-02-25 11:05:47 +0900263 if len(binary.post_install_cmds) > 0 {
264 fmt.Fprintln(w, "LOCAL_POST_INSTALL_CMD := "+strings.Join(binary.post_install_cmds, "&& "))
265 }
Colin Crossca860ac2016-01-04 14:34:37 -0800266 })
267}
268
Colin Crossb916a382016-07-29 17:28:03 -0700269func (benchmark *benchmarkDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
270 ctx.subAndroidMk(ret, benchmark.binaryDecorator)
Dan Willemsen58a5c8b2017-05-23 15:10:37 -0700271 ret.Class = "NATIVE_TESTS"
Colin Cross27a4b052017-08-10 16:32:23 -0700272 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crosse28f4e22017-04-24 18:10:29 -0700273 if len(benchmark.Properties.Test_suites) > 0 {
274 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
275 strings.Join(benchmark.Properties.Test_suites, " "))
276 }
Colin Cross303e21f2018-08-07 16:49:25 -0700277 if benchmark.testConfig != nil {
278 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", benchmark.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700279 }
Nelson Li1f6b14e2018-04-18 16:55:21 +0000280 fmt.Fprintln(w, "LOCAL_NATIVE_BENCHMARK := true")
Colin Crosse28f4e22017-04-24 18:10:29 -0700281 })
Anders Lewisb97e8182017-07-14 15:20:13 -0700282
283 androidMkWriteTestData(benchmark.data, ctx, ret)
Colin Crossb916a382016-07-29 17:28:03 -0700284}
285
286func (test *testBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
287 ctx.subAndroidMk(ret, test.binaryDecorator)
Dan Willemsen0fe72532017-01-17 13:25:49 -0800288 ret.Class = "NATIVE_TESTS"
Colin Crossb916a382016-07-29 17:28:03 -0700289 if Bool(test.Properties.Test_per_src) {
Nan Zhang0007d812017-11-07 10:57:05 -0800290 ret.SubName = "_" + String(test.binaryDecorator.Properties.Stem)
Colin Crossa2344662016-03-24 13:14:12 -0700291 }
Colin Crossfaeb7aa2017-02-01 14:12:44 -0800292
Colin Cross27a4b052017-08-10 16:32:23 -0700293 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossa929db02017-03-27 16:27:50 -0700294 if len(test.Properties.Test_suites) > 0 {
Dan Shi4df566d2017-04-03 12:29:25 -0700295 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
Colin Crossa929db02017-03-27 16:27:50 -0700296 strings.Join(test.Properties.Test_suites, " "))
297 }
Colin Cross303e21f2018-08-07 16:49:25 -0700298 if test.testConfig != nil {
299 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", test.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700300 }
Colin Crossa929db02017-03-27 16:27:50 -0700301 })
302
Anders Lewisb97e8182017-07-14 15:20:13 -0700303 androidMkWriteTestData(test.data, ctx, ret)
Colin Crossa2344662016-03-24 13:14:12 -0700304}
305
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -0700306func (fuzz *fuzzBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
307 ctx.subAndroidMk(ret, fuzz.binaryDecorator)
308
309 var fuzzFiles []string
310 for _, d := range fuzz.corpus {
Mitch Phillips8a2bc0b2019-10-17 15:04:01 -0700311 fuzzFiles = append(fuzzFiles,
312 filepath.Dir(fuzz.corpusIntermediateDir.String())+":corpus/"+d.Base())
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -0700313 }
314
315 if fuzz.dictionary != nil {
Mitch Phillips8a2bc0b2019-10-17 15:04:01 -0700316 fuzzFiles = append(fuzzFiles,
317 filepath.Dir(fuzz.dictionary.String())+":"+fuzz.dictionary.Base())
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -0700318 }
319
320 if len(fuzzFiles) > 0 {
321 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
322 fmt.Fprintln(w, "LOCAL_TEST_DATA := "+strings.Join(fuzzFiles, " "))
323 })
324 }
325
326 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
327 fmt.Fprintln(w, "LOCAL_IS_FUZZ_TARGET := true")
328 })
329}
330
Colin Crossb916a382016-07-29 17:28:03 -0700331func (test *testLibrary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
332 ctx.subAndroidMk(ret, test.libraryDecorator)
333}
Dan Willemsene7932e82016-05-16 15:56:53 -0700334
Colin Crossb916a382016-07-29 17:28:03 -0700335func (library *toolchainLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
336 ret.Class = "STATIC_LIBRARIES"
Colin Cross27a4b052017-08-10 16:32:23 -0700337 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Ivan Lozano022a73b2019-09-09 20:29:31 -0700338 _, suffix, _ := android.SplitFileExt(outputFile.Base())
Logan Chien031d2b32018-07-26 00:19:50 +0800339 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+suffix)
Dan Willemsen7517ed02016-06-10 17:20:30 -0700340 })
341}
342
Dan Willemsenf2c27d72016-07-13 16:50:22 -0700343func (installer *baseInstaller) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Dan Willemsen03ce63e2016-09-29 12:17:49 -0700344 // Soong installation is only supported for host modules. Have Make
345 // installation trigger Soong installation.
346 if ctx.Target().Os.Class == android.Host {
347 ret.OutputFile = android.OptionalPathForPath(installer.path)
348 }
349
Colin Cross27a4b052017-08-10 16:32:23 -0700350 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossff6c33d2019-10-02 16:01:35 -0700351 path, file := filepath.Split(installer.path.ToMakePath().String())
Ivan Lozano022a73b2019-09-09 20:29:31 -0700352 stem, suffix, _ := android.SplitFileExt(file)
Logan Chien031d2b32018-07-26 00:19:50 +0800353 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+suffix)
Colin Crossff6c33d2019-10-02 16:01:35 -0700354 fmt.Fprintln(w, "LOCAL_MODULE_PATH := "+path)
Colin Crossbf305de2016-03-29 17:32:06 -0700355 fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
Colin Crossa2344662016-03-24 13:14:12 -0700356 })
Dan Willemsen218f6562015-07-08 18:13:11 -0700357}
Dan Albert914449f2016-06-17 16:45:24 -0700358
Colin Crossb916a382016-07-29 17:28:03 -0700359func (c *stubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Dan Willemsen01a90592017-04-07 15:21:13 -0700360 ret.SubName = ndkLibrarySuffix + "." + c.properties.ApiLevel
Dan Albert705c84b2016-08-08 10:45:03 -0700361 ret.Class = "SHARED_LIBRARIES"
Dan Albert914449f2016-06-17 16:45:24 -0700362
Colin Cross27a4b052017-08-10 16:32:23 -0700363 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Cross0875c522017-11-28 17:34:01 -0800364 path, file := filepath.Split(c.installPath.String())
Ivan Lozano022a73b2019-09-09 20:29:31 -0700365 stem, suffix, _ := android.SplitFileExt(file)
Logan Chien031d2b32018-07-26 00:19:50 +0800366 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+suffix)
Dan Albert914449f2016-06-17 16:45:24 -0700367 fmt.Fprintln(w, "LOCAL_MODULE_PATH := "+path)
368 fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
Dan Willemsen866810d2017-04-04 14:13:45 -0700369 fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
Dan Albert914449f2016-06-17 16:45:24 -0700370 })
371}
Dan Willemsenb916b802017-03-19 13:44:32 -0700372
373func (c *llndkStubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
374 ret.Class = "SHARED_LIBRARIES"
375
Colin Cross27a4b052017-08-10 16:32:23 -0700376 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsenb916b802017-03-19 13:44:32 -0700377 c.libraryDecorator.androidMkWriteExportedFlags(w)
Ivan Lozano022a73b2019-09-09 20:29:31 -0700378 _, _, ext := android.SplitFileExt(outputFile.Base())
Dan Willemsenb916b802017-03-19 13:44:32 -0700379
Logan Chien031d2b32018-07-26 00:19:50 +0800380 fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+ext)
Dan Willemsenb916b802017-03-19 13:44:32 -0700381 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
382 fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
Colin Crossb60190a2018-09-04 16:28:17 -0700383 fmt.Fprintln(w, "LOCAL_SOONG_TOC :=", c.toc().String())
Dan Willemsenb916b802017-03-19 13:44:32 -0700384 })
385}
Justin Yun71549282017-11-17 12:10:28 +0900386
387func (c *vndkPrebuiltLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
388 ret.Class = "SHARED_LIBRARIES"
389
Jae Shin43ef2642017-12-29 16:20:21 +0900390 ret.SubName = c.NameSuffix()
Justin Yun71549282017-11-17 12:10:28 +0900391
392 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
393 c.libraryDecorator.androidMkWriteExportedFlags(w)
394
Colin Crossff6c33d2019-10-02 16:01:35 -0700395 path, file := filepath.Split(c.path.ToMakePath().String())
Ivan Lozano022a73b2019-09-09 20:29:31 -0700396 stem, suffix, ext := android.SplitFileExt(file)
Logan Chien031d2b32018-07-26 00:19:50 +0800397 fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+ext)
398 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+suffix)
Colin Crossff6c33d2019-10-02 16:01:35 -0700399 fmt.Fprintln(w, "LOCAL_MODULE_PATH := "+path)
Justin Yun71549282017-11-17 12:10:28 +0900400 fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
401 })
Colin Cross7a6fcbe2017-12-06 13:08:00 -0800402}
Dan Albert8ba131b2017-12-14 13:23:15 -0800403
404func (c *ndkPrebuiltStlLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
405 ret.Class = "SHARED_LIBRARIES"
Dan Albert8ba131b2017-12-14 13:23:15 -0800406}
Jiyong Park374510b2018-03-19 18:23:01 +0900407
408func (c *vendorPublicLibraryStubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
409 ret.Class = "SHARED_LIBRARIES"
410 ret.SubName = vendorPublicLibrarySuffix
411
412 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
413 c.libraryDecorator.androidMkWriteExportedFlags(w)
Ivan Lozano022a73b2019-09-09 20:29:31 -0700414 _, _, ext := android.SplitFileExt(outputFile.Base())
Jiyong Park374510b2018-03-19 18:23:01 +0900415
Logan Chien031d2b32018-07-26 00:19:50 +0800416 fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+ext)
Jiyong Park374510b2018-03-19 18:23:01 +0900417 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
418 fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
419 })
420}
Logan Chien4fcea3d2018-11-20 11:59:08 +0800421
422func (p *prebuiltLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
423 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
424 if p.properties.Check_elf_files != nil {
425 fmt.Fprintln(w, "LOCAL_CHECK_ELF_FILES :=", *p.properties.Check_elf_files)
426 } else {
427 // soong_cc_prebuilt.mk does not include check_elf_file.mk by default
428 // because cc_library_shared and cc_binary use soong_cc_prebuilt.mk as well.
429 // In order to turn on prebuilt ABI checker, set `LOCAL_CHECK_ELF_FILES` to
430 // true if `p.properties.Check_elf_files` is not specified.
431 fmt.Fprintln(w, "LOCAL_CHECK_ELF_FILES := true")
432 }
433 })
434}
435
436func (p *prebuiltLibraryLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
437 ctx.subAndroidMk(ret, p.libraryDecorator)
438 if p.shared() {
439 ctx.subAndroidMk(ret, &p.prebuiltLinker)
440 androidMkWriteAllowUndefinedSymbols(p.baseLinker, ret)
441 }
442}
443
444func (p *prebuiltBinaryLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
445 ctx.subAndroidMk(ret, p.binaryDecorator)
446 ctx.subAndroidMk(ret, &p.prebuiltLinker)
447 androidMkWriteAllowUndefinedSymbols(p.baseLinker, ret)
448}
449
450func androidMkWriteAllowUndefinedSymbols(linker *baseLinker, ret *android.AndroidMkData) {
451 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
452 allow := linker.Properties.Allow_undefined_symbols
453 if allow != nil {
454 fmt.Fprintln(w, "LOCAL_ALLOW_UNDEFINED_SYMBOLS :=", *allow)
455 }
456 })
457}