blob: 69ed77183ee8886297be6d46e3f5dd461c9107d1 [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 (
Jiyong Parkf9332f12018-02-01 00:54:12 +090027 vendorSuffix = ".vendor"
28 recoverySuffix = ".recovery"
Jiyong Park27b188b2017-07-18 13:23:39 +090029)
30
Dan Willemsenf2c27d72016-07-13 16:50:22 -070031type AndroidMkContext interface {
32 Target() android.Target
Colin Crossb916a382016-07-29 17:28:03 -070033 subAndroidMk(*android.AndroidMkData, interface{})
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -070034 useVndk() bool
Colin Crossb916a382016-07-29 17:28:03 -070035}
36
37type subAndroidMkProvider interface {
38 AndroidMk(AndroidMkContext, *android.AndroidMkData)
39}
40
41func (c *Module) subAndroidMk(data *android.AndroidMkData, obj interface{}) {
42 if c.subAndroidMkOnce == nil {
43 c.subAndroidMkOnce = make(map[subAndroidMkProvider]bool)
44 }
45 if androidmk, ok := obj.(subAndroidMkProvider); ok {
46 if !c.subAndroidMkOnce[androidmk] {
47 c.subAndroidMkOnce[androidmk] = true
48 androidmk.AndroidMk(c, data)
49 }
50 }
Dan Willemsenf2c27d72016-07-13 16:50:22 -070051}
52
Colin Crossa18e9cf2017-08-10 17:00:19 -070053func (c *Module) AndroidMk() android.AndroidMkData {
Jiyong Park9d452992018-10-03 00:38:19 +090054 if c.Properties.HideFromMake || !c.IsForPlatform() {
Colin Crossa18e9cf2017-08-10 17:00:19 -070055 return android.AndroidMkData{
56 Disabled: true,
57 }
Colin Crossbc6fb162016-05-24 15:39:04 -070058 }
59
Colin Crossa18e9cf2017-08-10 17:00:19 -070060 ret := android.AndroidMkData{
61 OutputFile: c.outputFile,
Logan Chien43d34c32017-12-20 01:17:32 +080062 Required: c.Properties.AndroidMkRuntimeLibs,
Colin Crossb60190a2018-09-04 16:28:17 -070063 Include: "$(BUILD_SYSTEM)/soong_cc_prebuilt.mk",
Logan Chien43d34c32017-12-20 01:17:32 +080064
Colin Crossa18e9cf2017-08-10 17:00:19 -070065 Extra: []android.AndroidMkExtraFunc{
66 func(w io.Writer, outputFile android.Path) {
Colin Cross5beccee2017-12-07 15:28:59 -080067 if len(c.Properties.Logtags) > 0 {
68 fmt.Fprintln(w, "LOCAL_LOGTAGS_FILES :=", strings.Join(c.Properties.Logtags, " "))
69 }
Colin Crossa18e9cf2017-08-10 17:00:19 -070070 if len(c.Properties.AndroidMkSharedLibs) > 0 {
71 fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " "))
72 }
Jaewoong Jung16c7d3d2018-11-16 01:19:56 +000073 if len(c.Properties.AndroidMkStaticLibs) > 0 {
74 fmt.Fprintln(w, "LOCAL_STATIC_LIBRARIES := "+strings.Join(c.Properties.AndroidMkStaticLibs, " "))
75 }
76 if len(c.Properties.AndroidMkWholeStaticLibs) > 0 {
77 fmt.Fprintln(w, "LOCAL_WHOLE_STATIC_LIBRARIES := "+strings.Join(c.Properties.AndroidMkWholeStaticLibs, " "))
78 }
Colin Crossb60190a2018-09-04 16:28:17 -070079 fmt.Fprintln(w, "LOCAL_SOONG_LINK_TYPE :=", c.getMakeLinkType())
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -070080 if c.useVndk() {
Colin Crossa18e9cf2017-08-10 17:00:19 -070081 fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
82 }
83 },
84 },
85 }
Colin Crossca860ac2016-01-04 14:34:37 -080086
Colin Crossca860ac2016-01-04 14:34:37 -080087 for _, feature := range c.features {
Colin Crossb916a382016-07-29 17:28:03 -070088 c.subAndroidMk(&ret, feature)
Colin Crossca860ac2016-01-04 14:34:37 -080089 }
90
Colin Crossb916a382016-07-29 17:28:03 -070091 c.subAndroidMk(&ret, c.compiler)
92 c.subAndroidMk(&ret, c.linker)
Colin Cross8ff9ef42017-05-08 13:44:11 -070093 if c.sanitize != nil {
94 c.subAndroidMk(&ret, c.sanitize)
95 }
Colin Crossb916a382016-07-29 17:28:03 -070096 c.subAndroidMk(&ret, c.installer)
Colin Crossca860ac2016-01-04 14:34:37 -080097
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -070098 if c.useVndk() && c.hasVendorVariant() {
Jiyong Park27b188b2017-07-18 13:23:39 +090099 // .vendor suffix is added only when we will have two variants: core and vendor.
100 // The suffix is not added for vendor-only module.
101 ret.SubName += vendorSuffix
Jiyong Parkf9332f12018-02-01 00:54:12 +0900102 } else if c.inRecovery() && !c.onlyInRecovery() {
103 ret.SubName += recoverySuffix
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700104 }
105
Colin Crossa18e9cf2017-08-10 17:00:19 -0700106 return ret
Colin Crossca860ac2016-01-04 14:34:37 -0800107}
108
Anders Lewisb97e8182017-07-14 15:20:13 -0700109func androidMkWriteTestData(data android.Paths, ctx AndroidMkContext, ret *android.AndroidMkData) {
110 var testFiles []string
111 for _, d := range data {
112 rel := d.Rel()
113 path := d.String()
114 if !strings.HasSuffix(path, rel) {
115 panic(fmt.Errorf("path %q does not end with %q", path, rel))
116 }
117 path = strings.TrimSuffix(path, rel)
118 testFiles = append(testFiles, path+":"+rel)
119 }
120 if len(testFiles) > 0 {
Colin Cross27a4b052017-08-10 16:32:23 -0700121 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Anders Lewisb97e8182017-07-14 15:20:13 -0700122 fmt.Fprintln(w, "LOCAL_TEST_DATA := "+strings.Join(testFiles, " "))
Anders Lewisb97e8182017-07-14 15:20:13 -0700123 })
124 }
125}
126
Dan Willemsen58539402017-03-19 13:44:32 -0700127func (library *libraryDecorator) androidMkWriteExportedFlags(w io.Writer) {
128 exportedFlags := library.exportedFlags()
129 if len(exportedFlags) > 0 {
130 fmt.Fprintln(w, "LOCAL_EXPORT_CFLAGS :=", strings.Join(exportedFlags, " "))
Dan Willemsend5781342017-02-15 16:15:21 -0800131 }
Dan Willemsen58539402017-03-19 13:44:32 -0700132 exportedFlagsDeps := library.exportedFlagsDeps()
133 if len(exportedFlagsDeps) > 0 {
134 fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DEPS :=", strings.Join(exportedFlagsDeps.Strings(), " "))
135 }
136}
Dan Willemsend5781342017-02-15 16:15:21 -0800137
Dan Willemsen58539402017-03-19 13:44:32 -0700138func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Dan Willemsend5781342017-02-15 16:15:21 -0800139 if library.static() {
140 ret.Class = "STATIC_LIBRARIES"
141 } else if library.shared() {
Dan Willemsend5781342017-02-15 16:15:21 -0800142 ret.Class = "SHARED_LIBRARIES"
Colin Crossb60190a2018-09-04 16:28:17 -0700143 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
144 fmt.Fprintln(w, "LOCAL_SOONG_TOC :=", library.toc().String())
145 fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", library.unstrippedOutputFile.String())
146 })
Dan Willemsend5781342017-02-15 16:15:21 -0800147 } else if library.header() {
Colin Crossb60190a2018-09-04 16:28:17 -0700148 ret.Class = "HEADER_LIBRARIES"
Dan Willemsend5781342017-02-15 16:15:21 -0800149 }
150
Colin Cross27a4b052017-08-10 16:32:23 -0700151 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsen58539402017-03-19 13:44:32 -0700152 library.androidMkWriteExportedFlags(w)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800153 fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES := ")
154 if library.sAbiOutputFile.Valid() {
155 fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES += ", library.sAbiOutputFile.String())
156 if library.sAbiDiff.Valid() && !library.static() {
157 fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES += ", library.sAbiDiff.String())
Jayant Chowdhary715cac32017-04-20 06:53:59 -0700158 fmt.Fprintln(w, "HEADER_ABI_DIFFS += ", library.sAbiDiff.String())
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800159 }
160 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700161
Logan Chien031d2b32018-07-26 00:19:50 +0800162 _, _, ext := splitFileExt(outputFile.Base())
163
164 fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+ext)
Dan Willemsen218f6562015-07-08 18:13:11 -0700165
Dan Willemsen581341d2017-02-09 16:16:31 -0800166 if library.coverageOutputFile.Valid() {
167 fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", library.coverageOutputFile.String())
168 }
Colin Crossca860ac2016-01-04 14:34:37 -0800169 })
Colin Crossb916a382016-07-29 17:28:03 -0700170
Colin Cross4ac44802017-02-15 14:06:12 -0800171 if library.shared() {
Colin Crossb916a382016-07-29 17:28:03 -0700172 ctx.subAndroidMk(ret, library.baseInstaller)
Colin Crossb60190a2018-09-04 16:28:17 -0700173 } else {
174 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
175 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
176 })
Colin Crossb916a382016-07-29 17:28:03 -0700177 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700178}
179
Dan Willemsenf2c27d72016-07-13 16:50:22 -0700180func (object *objectLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Colin Cross0f86d182017-08-10 17:07:28 -0700181 ret.Custom = func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
Colin Crossca860ac2016-01-04 14:34:37 -0800182 out := ret.OutputFile.Path()
Dan Willemsen2e224ca2018-09-06 00:26:20 -0700183 varname := fmt.Sprintf("SOONG_%sOBJECT_%s%s", prefix, name, data.SubName)
Dan Willemsen218f6562015-07-08 18:13:11 -0700184
Dan Willemsen2e224ca2018-09-06 00:26:20 -0700185 fmt.Fprintf(w, "\n%s := %s\n", varname, out.String())
186 fmt.Fprintln(w, ".KATI_READONLY: "+varname)
Dan Willemsen218f6562015-07-08 18:13:11 -0700187 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700188}
189
Colin Crossb916a382016-07-29 17:28:03 -0700190func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Colin Cross1e7d3702016-08-24 15:25:47 -0700191 ctx.subAndroidMk(ret, binary.baseInstaller)
Dan Willemsen7517ed02016-06-10 17:20:30 -0700192
Dan Willemsen218f6562015-07-08 18:13:11 -0700193 ret.Class = "EXECUTABLES"
Colin Cross27a4b052017-08-10 16:32:23 -0700194 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossb60190a2018-09-04 16:28:17 -0700195 fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", binary.unstrippedOutputFile.String())
Colin Cross9b09f242016-12-07 13:37:42 -0800196 if len(binary.symlinks) > 0 {
197 fmt.Fprintln(w, "LOCAL_MODULE_SYMLINKS := "+strings.Join(binary.symlinks, " "))
198 }
199
Dan Willemsen581341d2017-02-09 16:16:31 -0800200 if binary.coverageOutputFile.Valid() {
201 fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", binary.coverageOutputFile.String())
202 }
Yifan Hong946e32e2018-04-03 13:22:50 -0700203
204 if len(binary.Properties.Overrides) > 0 {
205 fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES := "+strings.Join(binary.Properties.Overrides, " "))
206 }
Colin Crossca860ac2016-01-04 14:34:37 -0800207 })
208}
209
Colin Crossb916a382016-07-29 17:28:03 -0700210func (benchmark *benchmarkDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
211 ctx.subAndroidMk(ret, benchmark.binaryDecorator)
Dan Willemsen58a5c8b2017-05-23 15:10:37 -0700212 ret.Class = "NATIVE_TESTS"
Colin Cross27a4b052017-08-10 16:32:23 -0700213 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crosse28f4e22017-04-24 18:10:29 -0700214 if len(benchmark.Properties.Test_suites) > 0 {
215 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
216 strings.Join(benchmark.Properties.Test_suites, " "))
217 }
Colin Cross303e21f2018-08-07 16:49:25 -0700218 if benchmark.testConfig != nil {
219 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", benchmark.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700220 }
Nelson Li1f6b14e2018-04-18 16:55:21 +0000221 fmt.Fprintln(w, "LOCAL_NATIVE_BENCHMARK := true")
Colin Crosse28f4e22017-04-24 18:10:29 -0700222 })
Anders Lewisb97e8182017-07-14 15:20:13 -0700223
224 androidMkWriteTestData(benchmark.data, ctx, ret)
Colin Crossb916a382016-07-29 17:28:03 -0700225}
226
227func (test *testBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
228 ctx.subAndroidMk(ret, test.binaryDecorator)
Dan Willemsen0fe72532017-01-17 13:25:49 -0800229 ret.Class = "NATIVE_TESTS"
Colin Crossb916a382016-07-29 17:28:03 -0700230 if Bool(test.Properties.Test_per_src) {
Nan Zhang0007d812017-11-07 10:57:05 -0800231 ret.SubName = "_" + String(test.binaryDecorator.Properties.Stem)
Colin Crossa2344662016-03-24 13:14:12 -0700232 }
Colin Crossfaeb7aa2017-02-01 14:12:44 -0800233
Colin Cross27a4b052017-08-10 16:32:23 -0700234 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossa929db02017-03-27 16:27:50 -0700235 if len(test.Properties.Test_suites) > 0 {
Dan Shi4df566d2017-04-03 12:29:25 -0700236 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
Colin Crossa929db02017-03-27 16:27:50 -0700237 strings.Join(test.Properties.Test_suites, " "))
238 }
Colin Cross303e21f2018-08-07 16:49:25 -0700239 if test.testConfig != nil {
240 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", test.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700241 }
Colin Crossa929db02017-03-27 16:27:50 -0700242 })
243
Anders Lewisb97e8182017-07-14 15:20:13 -0700244 androidMkWriteTestData(test.data, ctx, ret)
Colin Crossa2344662016-03-24 13:14:12 -0700245}
246
Colin Crossb916a382016-07-29 17:28:03 -0700247func (test *testLibrary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
248 ctx.subAndroidMk(ret, test.libraryDecorator)
249}
Dan Willemsene7932e82016-05-16 15:56:53 -0700250
Colin Crossb916a382016-07-29 17:28:03 -0700251func (library *toolchainLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
252 ret.Class = "STATIC_LIBRARIES"
Colin Cross27a4b052017-08-10 16:32:23 -0700253 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Logan Chien031d2b32018-07-26 00:19:50 +0800254 _, suffix, _ := splitFileExt(outputFile.Base())
255 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+suffix)
Dan Willemsen7517ed02016-06-10 17:20:30 -0700256 })
257}
258
Dan Willemsenf2c27d72016-07-13 16:50:22 -0700259func (installer *baseInstaller) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Dan Willemsen03ce63e2016-09-29 12:17:49 -0700260 // Soong installation is only supported for host modules. Have Make
261 // installation trigger Soong installation.
262 if ctx.Target().Os.Class == android.Host {
263 ret.OutputFile = android.OptionalPathForPath(installer.path)
264 }
265
Colin Cross27a4b052017-08-10 16:32:23 -0700266 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossa2344662016-03-24 13:14:12 -0700267 path := installer.path.RelPathString()
Colin Crossbf305de2016-03-29 17:32:06 -0700268 dir, file := filepath.Split(path)
Logan Chien031d2b32018-07-26 00:19:50 +0800269 stem, suffix, _ := splitFileExt(file)
270 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+suffix)
Colin Crosse14388b2016-05-03 14:08:40 -0700271 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir))
Colin Crossbf305de2016-03-29 17:32:06 -0700272 fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
Colin Crossa2344662016-03-24 13:14:12 -0700273 })
Dan Willemsen218f6562015-07-08 18:13:11 -0700274}
Dan Albert914449f2016-06-17 16:45:24 -0700275
Colin Crossb916a382016-07-29 17:28:03 -0700276func (c *stubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Dan Willemsen01a90592017-04-07 15:21:13 -0700277 ret.SubName = ndkLibrarySuffix + "." + c.properties.ApiLevel
Dan Albert705c84b2016-08-08 10:45:03 -0700278 ret.Class = "SHARED_LIBRARIES"
Dan Albert914449f2016-06-17 16:45:24 -0700279
Colin Cross27a4b052017-08-10 16:32:23 -0700280 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Cross0875c522017-11-28 17:34:01 -0800281 path, file := filepath.Split(c.installPath.String())
Logan Chien031d2b32018-07-26 00:19:50 +0800282 stem, suffix, _ := splitFileExt(file)
Logan Chien031d2b32018-07-26 00:19:50 +0800283 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+suffix)
Dan Albert914449f2016-06-17 16:45:24 -0700284 fmt.Fprintln(w, "LOCAL_MODULE_PATH := "+path)
285 fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
Dan Willemsen866810d2017-04-04 14:13:45 -0700286 fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
Dan Albert914449f2016-06-17 16:45:24 -0700287 })
288}
Dan Willemsenb916b802017-03-19 13:44:32 -0700289
290func (c *llndkStubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
291 ret.Class = "SHARED_LIBRARIES"
Jiyong Parkf9332f12018-02-01 00:54:12 +0900292 ret.SubName = vendorSuffix
Dan Willemsenb916b802017-03-19 13:44:32 -0700293
Colin Cross27a4b052017-08-10 16:32:23 -0700294 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsenb916b802017-03-19 13:44:32 -0700295 c.libraryDecorator.androidMkWriteExportedFlags(w)
Logan Chien031d2b32018-07-26 00:19:50 +0800296 _, _, ext := splitFileExt(outputFile.Base())
Dan Willemsenb916b802017-03-19 13:44:32 -0700297
Logan Chien031d2b32018-07-26 00:19:50 +0800298 fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+ext)
Dan Willemsenb916b802017-03-19 13:44:32 -0700299 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
300 fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
Colin Crossb60190a2018-09-04 16:28:17 -0700301 fmt.Fprintln(w, "LOCAL_SOONG_TOC :=", c.toc().String())
Dan Willemsenb916b802017-03-19 13:44:32 -0700302 })
303}
Justin Yun71549282017-11-17 12:10:28 +0900304
305func (c *vndkPrebuiltLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
306 ret.Class = "SHARED_LIBRARIES"
307
Jae Shin43ef2642017-12-29 16:20:21 +0900308 ret.SubName = c.NameSuffix()
Justin Yun71549282017-11-17 12:10:28 +0900309
310 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
311 c.libraryDecorator.androidMkWriteExportedFlags(w)
312
313 path := c.path.RelPathString()
314 dir, file := filepath.Split(path)
Logan Chien031d2b32018-07-26 00:19:50 +0800315 stem, suffix, ext := splitFileExt(file)
Logan Chien031d2b32018-07-26 00:19:50 +0800316 fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+ext)
317 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+suffix)
Justin Yun71549282017-11-17 12:10:28 +0900318 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir))
319 fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
320 })
Colin Cross7a6fcbe2017-12-06 13:08:00 -0800321}
Dan Albert8ba131b2017-12-14 13:23:15 -0800322
323func (c *ndkPrebuiltStlLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
324 ret.Class = "SHARED_LIBRARIES"
Dan Albert8ba131b2017-12-14 13:23:15 -0800325}
Jiyong Park374510b2018-03-19 18:23:01 +0900326
327func (c *vendorPublicLibraryStubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
328 ret.Class = "SHARED_LIBRARIES"
329 ret.SubName = vendorPublicLibrarySuffix
330
331 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
332 c.libraryDecorator.androidMkWriteExportedFlags(w)
Logan Chien031d2b32018-07-26 00:19:50 +0800333 _, _, ext := splitFileExt(outputFile.Base())
Jiyong Park374510b2018-03-19 18:23:01 +0900334
Logan Chien031d2b32018-07-26 00:19:50 +0800335 fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+ext)
Jiyong Park374510b2018-03-19 18:23:01 +0900336 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
337 fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
338 })
339}