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 ( |
| 27 | vendorSuffix = ".vendor" |
| 28 | ) |
| 29 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 30 | type AndroidMkContext interface { |
| 31 | Target() android.Target |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 32 | subAndroidMk(*android.AndroidMkData, interface{}) |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 33 | useVndk() bool |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | type subAndroidMkProvider interface { |
| 37 | AndroidMk(AndroidMkContext, *android.AndroidMkData) |
| 38 | } |
| 39 | |
| 40 | func (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 Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 50 | } |
| 51 | |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 52 | func (c *Module) AndroidMk() android.AndroidMkData { |
Colin Cross | bc6fb16 | 2016-05-24 15:39:04 -0700 | [diff] [blame] | 53 | if c.Properties.HideFromMake { |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 54 | return android.AndroidMkData{ |
| 55 | Disabled: true, |
| 56 | } |
Colin Cross | bc6fb16 | 2016-05-24 15:39:04 -0700 | [diff] [blame] | 57 | } |
| 58 | |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 59 | 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 Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 67 | 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 Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 70 | 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 Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 75 | if c.useVndk() { |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 76 | fmt.Fprintln(w, "LOCAL_USE_VNDK := true") |
| 77 | } |
| 78 | }, |
| 79 | }, |
| 80 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 81 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 82 | for _, feature := range c.features { |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 83 | c.subAndroidMk(&ret, feature) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 84 | } |
| 85 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 86 | c.subAndroidMk(&ret, c.compiler) |
| 87 | c.subAndroidMk(&ret, c.linker) |
Colin Cross | 8ff9ef4 | 2017-05-08 13:44:11 -0700 | [diff] [blame] | 88 | if c.sanitize != nil { |
| 89 | c.subAndroidMk(&ret, c.sanitize) |
| 90 | } |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 91 | c.subAndroidMk(&ret, c.installer) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 92 | |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 93 | if c.useVndk() && c.hasVendorVariant() { |
Jiyong Park | 27b188b | 2017-07-18 13:23:39 +0900 | [diff] [blame] | 94 | // .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 Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 97 | } |
| 98 | |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 99 | return ret |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 100 | } |
| 101 | |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 102 | func 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 Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 114 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 115 | fmt.Fprintln(w, "LOCAL_TEST_DATA := "+strings.Join(testFiles, " ")) |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 116 | }) |
| 117 | } |
| 118 | } |
| 119 | |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 120 | func (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 Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 124 | } |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 125 | exportedFlagsDeps := library.exportedFlagsDeps() |
| 126 | if len(exportedFlagsDeps) > 0 { |
| 127 | fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DEPS :=", strings.Join(exportedFlagsDeps.Strings(), " ")) |
| 128 | } |
| 129 | } |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 130 | |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 131 | func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 132 | 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 Cross | 0f86d18 | 2017-08-10 17:07:28 -0700 | [diff] [blame] | 140 | ret.Custom = func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) { |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 141 | fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)") |
| 142 | fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir) |
Colin Cross | 0f86d18 | 2017-08-10 17:07:28 -0700 | [diff] [blame] | 143 | fmt.Fprintln(w, "LOCAL_MODULE :=", name+data.SubName) |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 144 | |
| 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 Willemsen | 866b563 | 2017-09-22 12:28:24 -0700 | [diff] [blame] | 159 | 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 Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 164 | fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true") |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 165 | } else if ctx.useVndk() { |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 166 | fmt.Fprintln(w, "LOCAL_USE_VNDK := true") |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 167 | } |
| 168 | |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 169 | library.androidMkWriteExportedFlags(w) |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 170 | fmt.Fprintln(w, "include $(BUILD_HEADER_LIBRARY)") |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | return |
| 174 | } |
| 175 | |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 176 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 177 | library.androidMkWriteExportedFlags(w) |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 178 | 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 Chowdhary | 715cac3 | 2017-04-20 06:53:59 -0700 | [diff] [blame] | 183 | fmt.Fprintln(w, "HEADER_ABI_DIFFS += ", library.sAbiDiff.String()) |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 184 | } |
| 185 | } |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 186 | |
Dan Willemsen | 1d577e2 | 2016-08-29 15:53:15 -0700 | [diff] [blame] | 187 | fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext()) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 188 | |
Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 189 | fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 190 | |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 191 | if library.coverageOutputFile.Valid() { |
| 192 | fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", library.coverageOutputFile.String()) |
| 193 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 194 | }) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 195 | |
Colin Cross | 4ac4480 | 2017-02-15 14:06:12 -0800 | [diff] [blame] | 196 | if library.shared() { |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 197 | ctx.subAndroidMk(ret, library.baseInstaller) |
| 198 | } |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 199 | } |
| 200 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 201 | func (object *objectLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Colin Cross | 0f86d18 | 2017-08-10 17:07:28 -0700 | [diff] [blame] | 202 | 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] | 203 | out := ret.OutputFile.Path() |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 204 | |
Colin Cross | 0f86d18 | 2017-08-10 17:07:28 -0700 | [diff] [blame] | 205 | fmt.Fprintln(w, "\n$("+prefix+"OUT_INTERMEDIATE_LIBRARIES)/"+name+data.SubName+objectExtension+":", out.String()) |
Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 206 | fmt.Fprintln(w, "\t$(copy-file-to-target)") |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 207 | } |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 208 | } |
| 209 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 210 | func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Colin Cross | 1e7d370 | 2016-08-24 15:25:47 -0700 | [diff] [blame] | 211 | ctx.subAndroidMk(ret, binary.baseInstaller) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 212 | ctx.subAndroidMk(ret, &binary.stripper) |
Dan Willemsen | 7517ed0 | 2016-06-10 17:20:30 -0700 | [diff] [blame] | 213 | |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 214 | ret.Class = "EXECUTABLES" |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 215 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 216 | fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 217 | if Bool(binary.Properties.Static_executable) { |
Colin Cross | 3854a60 | 2016-01-11 12:49:11 -0800 | [diff] [blame] | 218 | fmt.Fprintln(w, "LOCAL_FORCE_STATIC_EXECUTABLE := true") |
| 219 | } |
Colin Cross | 9b09f24 | 2016-12-07 13:37:42 -0800 | [diff] [blame] | 220 | |
| 221 | if len(binary.symlinks) > 0 { |
| 222 | fmt.Fprintln(w, "LOCAL_MODULE_SYMLINKS := "+strings.Join(binary.symlinks, " ")) |
| 223 | } |
| 224 | |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 225 | if binary.coverageOutputFile.Valid() { |
| 226 | fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", binary.coverageOutputFile.String()) |
| 227 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 228 | }) |
| 229 | } |
| 230 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 231 | func (benchmark *benchmarkDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 232 | ctx.subAndroidMk(ret, benchmark.binaryDecorator) |
Dan Willemsen | 58a5c8b | 2017-05-23 15:10:37 -0700 | [diff] [blame] | 233 | ret.Class = "NATIVE_TESTS" |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 234 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Colin Cross | e28f4e2 | 2017-04-24 18:10:29 -0700 | [diff] [blame] | 235 | if len(benchmark.Properties.Test_suites) > 0 { |
| 236 | fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", |
| 237 | strings.Join(benchmark.Properties.Test_suites, " ")) |
| 238 | } |
Colin Cross | e28f4e2 | 2017-04-24 18:10:29 -0700 | [diff] [blame] | 239 | }) |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 240 | |
| 241 | androidMkWriteTestData(benchmark.data, ctx, ret) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | func (test *testBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 245 | ctx.subAndroidMk(ret, test.binaryDecorator) |
Dan Willemsen | 0fe7253 | 2017-01-17 13:25:49 -0800 | [diff] [blame] | 246 | ret.Class = "NATIVE_TESTS" |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 247 | if Bool(test.Properties.Test_per_src) { |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 248 | ret.SubName = "_" + String(test.binaryDecorator.Properties.Stem) |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 249 | } |
Colin Cross | faeb7aa | 2017-02-01 14:12:44 -0800 | [diff] [blame] | 250 | |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 251 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Colin Cross | a929db0 | 2017-03-27 16:27:50 -0700 | [diff] [blame] | 252 | if len(test.Properties.Test_suites) > 0 { |
Dan Shi | 4df566d | 2017-04-03 12:29:25 -0700 | [diff] [blame] | 253 | fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", |
Colin Cross | a929db0 | 2017-03-27 16:27:50 -0700 | [diff] [blame] | 254 | strings.Join(test.Properties.Test_suites, " ")) |
| 255 | } |
Colin Cross | a929db0 | 2017-03-27 16:27:50 -0700 | [diff] [blame] | 256 | }) |
| 257 | |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 258 | androidMkWriteTestData(test.data, ctx, ret) |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 259 | } |
| 260 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 261 | func (test *testLibrary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 262 | ctx.subAndroidMk(ret, test.libraryDecorator) |
| 263 | } |
Dan Willemsen | e7932e8 | 2016-05-16 15:56:53 -0700 | [diff] [blame] | 264 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 265 | func (library *toolchainLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 266 | ret.Class = "STATIC_LIBRARIES" |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 267 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Dan Willemsen | e7932e8 | 2016-05-16 15:56:53 -0700 | [diff] [blame] | 268 | fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext()) |
Dan Willemsen | e7932e8 | 2016-05-16 15:56:53 -0700 | [diff] [blame] | 269 | fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") |
Dan Willemsen | e7932e8 | 2016-05-16 15:56:53 -0700 | [diff] [blame] | 270 | }) |
| 271 | } |
| 272 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 273 | func (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 Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 279 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 280 | if Bool(stripper.StripProperties.Strip.None) { |
| 281 | |
Dan Willemsen | 7517ed0 | 2016-06-10 17:20:30 -0700 | [diff] [blame] | 282 | fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false") |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 283 | } else if Bool(stripper.StripProperties.Strip.Keep_symbols) { |
Dan Willemsen | 7517ed0 | 2016-06-10 17:20:30 -0700 | [diff] [blame] | 284 | fmt.Fprintln(w, "LOCAL_STRIP_MODULE := keep_symbols") |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 285 | } else { |
| 286 | fmt.Fprintln(w, "LOCAL_STRIP_MODULE := mini-debug-info") |
Dan Willemsen | 7517ed0 | 2016-06-10 17:20:30 -0700 | [diff] [blame] | 287 | } |
Dan Willemsen | 7517ed0 | 2016-06-10 17:20:30 -0700 | [diff] [blame] | 288 | }) |
| 289 | } |
| 290 | |
Dan Willemsen | 394e9dc | 2016-09-14 15:04:48 -0700 | [diff] [blame] | 291 | func (packer *relocationPacker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 292 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Dan Willemsen | 394e9dc | 2016-09-14 15:04:48 -0700 | [diff] [blame] | 293 | if packer.Properties.PackingRelocations { |
| 294 | fmt.Fprintln(w, "LOCAL_PACK_MODULE_RELOCATIONS := true") |
| 295 | } |
Dan Willemsen | 394e9dc | 2016-09-14 15:04:48 -0700 | [diff] [blame] | 296 | }) |
| 297 | } |
| 298 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 299 | func (installer *baseInstaller) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Dan Willemsen | 03ce63e | 2016-09-29 12:17:49 -0700 | [diff] [blame] | 300 | // 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 Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 306 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 307 | path := installer.path.RelPathString() |
Colin Cross | bf305de | 2016-03-29 17:32:06 -0700 | [diff] [blame] | 308 | dir, file := filepath.Split(path) |
| 309 | stem := strings.TrimSuffix(file, filepath.Ext(file)) |
Dan Willemsen | 1d577e2 | 2016-08-29 15:53:15 -0700 | [diff] [blame] | 310 | fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+filepath.Ext(file)) |
Colin Cross | e14388b | 2016-05-03 14:08:40 -0700 | [diff] [blame] | 311 | fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir)) |
Colin Cross | bf305de | 2016-03-29 17:32:06 -0700 | [diff] [blame] | 312 | fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem) |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 313 | }) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 314 | } |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 315 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 316 | func (c *stubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Dan Willemsen | 01a9059 | 2017-04-07 15:21:13 -0700 | [diff] [blame] | 317 | ret.SubName = ndkLibrarySuffix + "." + c.properties.ApiLevel |
Dan Albert | 705c84b | 2016-08-08 10:45:03 -0700 | [diff] [blame] | 318 | ret.Class = "SHARED_LIBRARIES" |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 319 | |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 320 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 321 | path, file := filepath.Split(c.installPath.String()) |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 322 | stem := strings.TrimSuffix(file, filepath.Ext(file)) |
Dan Albert | cdd4c24 | 2016-08-08 14:44:56 -0700 | [diff] [blame] | 323 | fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") |
| 324 | fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext()) |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 325 | fmt.Fprintln(w, "LOCAL_MODULE_PATH := "+path) |
| 326 | fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem) |
Dan Willemsen | 866810d | 2017-04-04 14:13:45 -0700 | [diff] [blame] | 327 | fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true") |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 328 | |
| 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 Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 333 | }) |
| 334 | } |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 335 | |
| 336 | func (c *llndkStubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 337 | ret.Class = "SHARED_LIBRARIES" |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 338 | ret.SubName = ".vendor" |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 339 | |
Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 340 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 341 | 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 Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 348 | fmt.Fprintln(w, "LOCAL_USE_VNDK := true") |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 349 | }) |
| 350 | } |
Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 351 | |
| 352 | func (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 Cross | 7a6fcbe | 2017-12-06 13:08:00 -0800 | [diff] [blame^] | 371 | } |