blob: 73112637e8f61abbe4dc79b35af1b930b29a513a [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 (
27 vendorSuffix = ".vendor"
28)
29
Dan Willemsenf2c27d72016-07-13 16:50:22 -070030type AndroidMkContext interface {
31 Target() android.Target
Colin Crossb916a382016-07-29 17:28:03 -070032 subAndroidMk(*android.AndroidMkData, interface{})
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -070033 useVndk() bool
Colin Crossb916a382016-07-29 17:28:03 -070034}
35
36type subAndroidMkProvider interface {
37 AndroidMk(AndroidMkContext, *android.AndroidMkData)
38}
39
40func (c *Module) subAndroidMk(data *android.AndroidMkData, obj interface{}) {
41 if c.subAndroidMkOnce == nil {
42 c.subAndroidMkOnce = make(map[subAndroidMkProvider]bool)
43 }
44 if androidmk, ok := obj.(subAndroidMkProvider); ok {
45 if !c.subAndroidMkOnce[androidmk] {
46 c.subAndroidMkOnce[androidmk] = true
47 androidmk.AndroidMk(c, data)
48 }
49 }
Dan Willemsenf2c27d72016-07-13 16:50:22 -070050}
51
Colin Crossa18e9cf2017-08-10 17:00:19 -070052func (c *Module) AndroidMk() android.AndroidMkData {
Colin Crossbc6fb162016-05-24 15:39:04 -070053 if c.Properties.HideFromMake {
Colin Crossa18e9cf2017-08-10 17:00:19 -070054 return android.AndroidMkData{
55 Disabled: true,
56 }
Colin Crossbc6fb162016-05-24 15:39:04 -070057 }
58
Colin Crossa18e9cf2017-08-10 17:00:19 -070059 ret := android.AndroidMkData{
60 OutputFile: c.outputFile,
61 Extra: []android.AndroidMkExtraFunc{
62 func(w io.Writer, outputFile android.Path) {
63 fmt.Fprintln(w, "LOCAL_SANITIZE := never")
64 if len(c.Properties.AndroidMkSharedLibs) > 0 {
65 fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " "))
66 }
Nan Zhang0007d812017-11-07 10:57:05 -080067 if c.Target().Os == android.Android &&
68 String(c.Properties.Sdk_version) != "" && !c.useVndk() {
69 fmt.Fprintln(w, "LOCAL_SDK_VERSION := "+String(c.Properties.Sdk_version))
Colin Crossa18e9cf2017-08-10 17:00:19 -070070 fmt.Fprintln(w, "LOCAL_NDK_STL_VARIANT := none")
71 } else {
72 // These are already included in LOCAL_SHARED_LIBRARIES
73 fmt.Fprintln(w, "LOCAL_CXX_STL := none")
74 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -070075 if c.useVndk() {
Colin Crossa18e9cf2017-08-10 17:00:19 -070076 fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
77 }
78 },
79 },
80 }
Colin Crossca860ac2016-01-04 14:34:37 -080081
Colin Crossca860ac2016-01-04 14:34:37 -080082 for _, feature := range c.features {
Colin Crossb916a382016-07-29 17:28:03 -070083 c.subAndroidMk(&ret, feature)
Colin Crossca860ac2016-01-04 14:34:37 -080084 }
85
Colin Crossb916a382016-07-29 17:28:03 -070086 c.subAndroidMk(&ret, c.compiler)
87 c.subAndroidMk(&ret, c.linker)
Colin Cross8ff9ef42017-05-08 13:44:11 -070088 if c.sanitize != nil {
89 c.subAndroidMk(&ret, c.sanitize)
90 }
Colin Crossb916a382016-07-29 17:28:03 -070091 c.subAndroidMk(&ret, c.installer)
Colin Crossca860ac2016-01-04 14:34:37 -080092
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -070093 if c.useVndk() && c.hasVendorVariant() {
Jiyong Park27b188b2017-07-18 13:23:39 +090094 // .vendor suffix is added only when we will have two variants: core and vendor.
95 // The suffix is not added for vendor-only module.
96 ret.SubName += vendorSuffix
Dan Willemsen4416e5d2017-04-06 12:43:22 -070097 }
98
Colin Crossa18e9cf2017-08-10 17:00:19 -070099 return ret
Colin Crossca860ac2016-01-04 14:34:37 -0800100}
101
Anders Lewisb97e8182017-07-14 15:20:13 -0700102func androidMkWriteTestData(data android.Paths, ctx AndroidMkContext, ret *android.AndroidMkData) {
103 var testFiles []string
104 for _, d := range data {
105 rel := d.Rel()
106 path := d.String()
107 if !strings.HasSuffix(path, rel) {
108 panic(fmt.Errorf("path %q does not end with %q", path, rel))
109 }
110 path = strings.TrimSuffix(path, rel)
111 testFiles = append(testFiles, path+":"+rel)
112 }
113 if len(testFiles) > 0 {
Colin Cross27a4b052017-08-10 16:32:23 -0700114 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Anders Lewisb97e8182017-07-14 15:20:13 -0700115 fmt.Fprintln(w, "LOCAL_TEST_DATA := "+strings.Join(testFiles, " "))
Anders Lewisb97e8182017-07-14 15:20:13 -0700116 })
117 }
118}
119
Dan Willemsen58539402017-03-19 13:44:32 -0700120func (library *libraryDecorator) androidMkWriteExportedFlags(w io.Writer) {
121 exportedFlags := library.exportedFlags()
122 if len(exportedFlags) > 0 {
123 fmt.Fprintln(w, "LOCAL_EXPORT_CFLAGS :=", strings.Join(exportedFlags, " "))
Dan Willemsend5781342017-02-15 16:15:21 -0800124 }
Dan Willemsen58539402017-03-19 13:44:32 -0700125 exportedFlagsDeps := library.exportedFlagsDeps()
126 if len(exportedFlagsDeps) > 0 {
127 fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DEPS :=", strings.Join(exportedFlagsDeps.Strings(), " "))
128 }
129}
Dan Willemsend5781342017-02-15 16:15:21 -0800130
Dan Willemsen58539402017-03-19 13:44:32 -0700131func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Dan Willemsend5781342017-02-15 16:15:21 -0800132 if library.static() {
133 ret.Class = "STATIC_LIBRARIES"
134 } else if library.shared() {
135 ctx.subAndroidMk(ret, &library.stripper)
136 ctx.subAndroidMk(ret, &library.relocationPacker)
137
138 ret.Class = "SHARED_LIBRARIES"
139 } else if library.header() {
Colin Cross0f86d182017-08-10 17:07:28 -0700140 ret.Custom = func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
Dan Willemsend5781342017-02-15 16:15:21 -0800141 fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
142 fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
Colin Cross0f86d182017-08-10 17:07:28 -0700143 fmt.Fprintln(w, "LOCAL_MODULE :=", name+data.SubName)
Dan Willemsend5781342017-02-15 16:15:21 -0800144
145 archStr := ctx.Target().Arch.ArchType.String()
146 var host bool
147 switch ctx.Target().Os.Class {
148 case android.Host:
149 fmt.Fprintln(w, "LOCAL_MODULE_HOST_ARCH := ", archStr)
150 host = true
151 case android.HostCross:
152 fmt.Fprintln(w, "LOCAL_MODULE_HOST_CROSS_ARCH := ", archStr)
153 host = true
154 case android.Device:
155 fmt.Fprintln(w, "LOCAL_MODULE_TARGET_ARCH := ", archStr)
156 }
157
158 if host {
Dan Willemsen866b5632017-09-22 12:28:24 -0700159 makeOs := ctx.Target().Os.String()
160 if ctx.Target().Os == android.Linux || ctx.Target().Os == android.LinuxBionic {
161 makeOs = "linux"
162 }
163 fmt.Fprintln(w, "LOCAL_MODULE_HOST_OS :=", makeOs)
Dan Willemsend5781342017-02-15 16:15:21 -0800164 fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700165 } else if ctx.useVndk() {
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700166 fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
Dan Willemsend5781342017-02-15 16:15:21 -0800167 }
168
Dan Willemsen58539402017-03-19 13:44:32 -0700169 library.androidMkWriteExportedFlags(w)
Dan Willemsend5781342017-02-15 16:15:21 -0800170 fmt.Fprintln(w, "include $(BUILD_HEADER_LIBRARY)")
Dan Willemsend5781342017-02-15 16:15:21 -0800171 }
172
173 return
174 }
175
Colin Cross27a4b052017-08-10 16:32:23 -0700176 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsen58539402017-03-19 13:44:32 -0700177 library.androidMkWriteExportedFlags(w)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800178 fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES := ")
179 if library.sAbiOutputFile.Valid() {
180 fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES += ", library.sAbiOutputFile.String())
181 if library.sAbiDiff.Valid() && !library.static() {
182 fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES += ", library.sAbiDiff.String())
Jayant Chowdhary715cac32017-04-20 06:53:59 -0700183 fmt.Fprintln(w, "HEADER_ABI_DIFFS += ", library.sAbiDiff.String())
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800184 }
185 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700186
Dan Willemsen1d577e22016-08-29 15:53:15 -0700187 fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext())
Dan Willemsen218f6562015-07-08 18:13:11 -0700188
Dan Willemsen97750522016-02-09 17:43:51 -0800189 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
Dan Willemsen218f6562015-07-08 18:13:11 -0700190
Dan Willemsen581341d2017-02-09 16:16:31 -0800191 if library.coverageOutputFile.Valid() {
192 fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", library.coverageOutputFile.String())
193 }
Colin Crossca860ac2016-01-04 14:34:37 -0800194 })
Colin Crossb916a382016-07-29 17:28:03 -0700195
Colin Cross4ac44802017-02-15 14:06:12 -0800196 if library.shared() {
Colin Crossb916a382016-07-29 17:28:03 -0700197 ctx.subAndroidMk(ret, library.baseInstaller)
198 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700199}
200
Dan Willemsenf2c27d72016-07-13 16:50:22 -0700201func (object *objectLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Colin Cross0f86d182017-08-10 17:07:28 -0700202 ret.Custom = func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
Colin Crossca860ac2016-01-04 14:34:37 -0800203 out := ret.OutputFile.Path()
Dan Willemsen218f6562015-07-08 18:13:11 -0700204
Colin Cross0f86d182017-08-10 17:07:28 -0700205 fmt.Fprintln(w, "\n$("+prefix+"OUT_INTERMEDIATE_LIBRARIES)/"+name+data.SubName+objectExtension+":", out.String())
Dan Willemsen97750522016-02-09 17:43:51 -0800206 fmt.Fprintln(w, "\t$(copy-file-to-target)")
Dan Willemsen218f6562015-07-08 18:13:11 -0700207 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700208}
209
Colin Crossb916a382016-07-29 17:28:03 -0700210func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Colin Cross1e7d3702016-08-24 15:25:47 -0700211 ctx.subAndroidMk(ret, binary.baseInstaller)
Colin Crossb916a382016-07-29 17:28:03 -0700212 ctx.subAndroidMk(ret, &binary.stripper)
Dan Willemsen7517ed02016-06-10 17:20:30 -0700213
Dan Willemsen218f6562015-07-08 18:13:11 -0700214 ret.Class = "EXECUTABLES"
Colin Cross27a4b052017-08-10 16:32:23 -0700215 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsen97750522016-02-09 17:43:51 -0800216 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
Colin Crossb916a382016-07-29 17:28:03 -0700217 if Bool(binary.Properties.Static_executable) {
Colin Cross3854a602016-01-11 12:49:11 -0800218 fmt.Fprintln(w, "LOCAL_FORCE_STATIC_EXECUTABLE := true")
219 }
Colin Cross9b09f242016-12-07 13:37:42 -0800220
221 if len(binary.symlinks) > 0 {
222 fmt.Fprintln(w, "LOCAL_MODULE_SYMLINKS := "+strings.Join(binary.symlinks, " "))
223 }
224
Dan Willemsen581341d2017-02-09 16:16:31 -0800225 if binary.coverageOutputFile.Valid() {
226 fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", binary.coverageOutputFile.String())
227 }
Colin Crossca860ac2016-01-04 14:34:37 -0800228 })
229}
230
Colin Crossb916a382016-07-29 17:28:03 -0700231func (benchmark *benchmarkDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
232 ctx.subAndroidMk(ret, benchmark.binaryDecorator)
Dan Willemsen58a5c8b2017-05-23 15:10:37 -0700233 ret.Class = "NATIVE_TESTS"
Colin Cross27a4b052017-08-10 16:32:23 -0700234 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crosse28f4e22017-04-24 18:10:29 -0700235 if len(benchmark.Properties.Test_suites) > 0 {
236 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
237 strings.Join(benchmark.Properties.Test_suites, " "))
238 }
Colin Crosse28f4e22017-04-24 18:10:29 -0700239 })
Anders Lewisb97e8182017-07-14 15:20:13 -0700240
241 androidMkWriteTestData(benchmark.data, ctx, ret)
Colin Crossb916a382016-07-29 17:28:03 -0700242}
243
244func (test *testBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
245 ctx.subAndroidMk(ret, test.binaryDecorator)
Dan Willemsen0fe72532017-01-17 13:25:49 -0800246 ret.Class = "NATIVE_TESTS"
Colin Crossb916a382016-07-29 17:28:03 -0700247 if Bool(test.Properties.Test_per_src) {
Nan Zhang0007d812017-11-07 10:57:05 -0800248 ret.SubName = "_" + String(test.binaryDecorator.Properties.Stem)
Colin Crossa2344662016-03-24 13:14:12 -0700249 }
Colin Crossfaeb7aa2017-02-01 14:12:44 -0800250
Colin Cross27a4b052017-08-10 16:32:23 -0700251 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossa929db02017-03-27 16:27:50 -0700252 if len(test.Properties.Test_suites) > 0 {
Dan Shi4df566d2017-04-03 12:29:25 -0700253 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
Colin Crossa929db02017-03-27 16:27:50 -0700254 strings.Join(test.Properties.Test_suites, " "))
255 }
Colin Crossa929db02017-03-27 16:27:50 -0700256 })
257
Anders Lewisb97e8182017-07-14 15:20:13 -0700258 androidMkWriteTestData(test.data, ctx, ret)
Colin Crossa2344662016-03-24 13:14:12 -0700259}
260
Colin Crossb916a382016-07-29 17:28:03 -0700261func (test *testLibrary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
262 ctx.subAndroidMk(ret, test.libraryDecorator)
263}
Dan Willemsene7932e82016-05-16 15:56:53 -0700264
Colin Crossb916a382016-07-29 17:28:03 -0700265func (library *toolchainLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
266 ret.Class = "STATIC_LIBRARIES"
Colin Cross27a4b052017-08-10 16:32:23 -0700267 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsene7932e82016-05-16 15:56:53 -0700268 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext())
Dan Willemsene7932e82016-05-16 15:56:53 -0700269 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
Dan Willemsene7932e82016-05-16 15:56:53 -0700270 })
271}
272
Dan Willemsenf2c27d72016-07-13 16:50:22 -0700273func (stripper *stripper) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
274 // Make only supports stripping target modules
275 if ctx.Target().Os != android.Android {
276 return
277 }
278
Colin Cross27a4b052017-08-10 16:32:23 -0700279 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Nan Zhang0007d812017-11-07 10:57:05 -0800280 if Bool(stripper.StripProperties.Strip.None) {
281
Dan Willemsen7517ed02016-06-10 17:20:30 -0700282 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
Nan Zhang0007d812017-11-07 10:57:05 -0800283 } else if Bool(stripper.StripProperties.Strip.Keep_symbols) {
Dan Willemsen7517ed02016-06-10 17:20:30 -0700284 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := keep_symbols")
Dan Willemsenf2c27d72016-07-13 16:50:22 -0700285 } else {
286 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := mini-debug-info")
Dan Willemsen7517ed02016-06-10 17:20:30 -0700287 }
Dan Willemsen7517ed02016-06-10 17:20:30 -0700288 })
289}
290
Dan Willemsen394e9dc2016-09-14 15:04:48 -0700291func (packer *relocationPacker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Colin Cross27a4b052017-08-10 16:32:23 -0700292 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsen394e9dc2016-09-14 15:04:48 -0700293 if packer.Properties.PackingRelocations {
294 fmt.Fprintln(w, "LOCAL_PACK_MODULE_RELOCATIONS := true")
295 }
Dan Willemsen394e9dc2016-09-14 15:04:48 -0700296 })
297}
298
Dan Willemsenf2c27d72016-07-13 16:50:22 -0700299func (installer *baseInstaller) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Dan Willemsen03ce63e2016-09-29 12:17:49 -0700300 // Soong installation is only supported for host modules. Have Make
301 // installation trigger Soong installation.
302 if ctx.Target().Os.Class == android.Host {
303 ret.OutputFile = android.OptionalPathForPath(installer.path)
304 }
305
Colin Cross27a4b052017-08-10 16:32:23 -0700306 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossa2344662016-03-24 13:14:12 -0700307 path := installer.path.RelPathString()
Colin Crossbf305de2016-03-29 17:32:06 -0700308 dir, file := filepath.Split(path)
309 stem := strings.TrimSuffix(file, filepath.Ext(file))
Dan Willemsen1d577e22016-08-29 15:53:15 -0700310 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+filepath.Ext(file))
Colin Crosse14388b2016-05-03 14:08:40 -0700311 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir))
Colin Crossbf305de2016-03-29 17:32:06 -0700312 fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
Colin Crossa2344662016-03-24 13:14:12 -0700313 })
Dan Willemsen218f6562015-07-08 18:13:11 -0700314}
Dan Albert914449f2016-06-17 16:45:24 -0700315
Colin Crossb916a382016-07-29 17:28:03 -0700316func (c *stubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Dan Willemsen01a90592017-04-07 15:21:13 -0700317 ret.SubName = ndkLibrarySuffix + "." + c.properties.ApiLevel
Dan Albert705c84b2016-08-08 10:45:03 -0700318 ret.Class = "SHARED_LIBRARIES"
Dan Albert914449f2016-06-17 16:45:24 -0700319
Colin Cross27a4b052017-08-10 16:32:23 -0700320 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Colin Cross0875c522017-11-28 17:34:01 -0800321 path, file := filepath.Split(c.installPath.String())
Dan Albert914449f2016-06-17 16:45:24 -0700322 stem := strings.TrimSuffix(file, filepath.Ext(file))
Dan Albertcdd4c242016-08-08 14:44:56 -0700323 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
324 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext())
Dan Albert914449f2016-06-17 16:45:24 -0700325 fmt.Fprintln(w, "LOCAL_MODULE_PATH := "+path)
326 fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
Dan Willemsen866810d2017-04-04 14:13:45 -0700327 fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
Dan Albert914449f2016-06-17 16:45:24 -0700328
329 // Prevent make from installing the libraries to obj/lib (since we have
330 // dozens of libraries with the same name, they'll clobber each other
331 // and the real versions of the libraries from the platform).
332 fmt.Fprintln(w, "LOCAL_COPY_TO_INTERMEDIATE_LIBRARIES := false")
Dan Albert914449f2016-06-17 16:45:24 -0700333 })
334}
Dan Willemsenb916b802017-03-19 13:44:32 -0700335
336func (c *llndkStubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
337 ret.Class = "SHARED_LIBRARIES"
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700338 ret.SubName = ".vendor"
Dan Willemsenb916b802017-03-19 13:44:32 -0700339
Colin Cross27a4b052017-08-10 16:32:23 -0700340 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Dan Willemsenb916b802017-03-19 13:44:32 -0700341 c.libraryDecorator.androidMkWriteExportedFlags(w)
342
343 fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext())
344 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
345 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
346 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
347 fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700348 fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
Dan Willemsenb916b802017-03-19 13:44:32 -0700349 })
350}
Justin Yun71549282017-11-17 12:10:28 +0900351
352func (c *vndkPrebuiltLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
353 ret.Class = "SHARED_LIBRARIES"
354
355 ret.SubName = vndkSuffix + c.version()
356
357 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
358 c.libraryDecorator.androidMkWriteExportedFlags(w)
359
360 path := c.path.RelPathString()
361 dir, file := filepath.Split(path)
362 stem := strings.TrimSuffix(file, filepath.Ext(file))
363 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
364 fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
365 fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
366 fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext())
367 fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+filepath.Ext(file))
368 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir))
369 fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
370 })
Colin Cross7a6fcbe2017-12-06 13:08:00 -0800371}