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 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 26 | type AndroidMkContext interface { |
| 27 | Target() android.Target |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 28 | subAndroidMk(*android.AndroidMkData, interface{}) |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 29 | vndk() bool |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | type subAndroidMkProvider interface { |
| 33 | AndroidMk(AndroidMkContext, *android.AndroidMkData) |
| 34 | } |
| 35 | |
| 36 | func (c *Module) subAndroidMk(data *android.AndroidMkData, obj interface{}) { |
| 37 | if c.subAndroidMkOnce == nil { |
| 38 | c.subAndroidMkOnce = make(map[subAndroidMkProvider]bool) |
| 39 | } |
| 40 | if androidmk, ok := obj.(subAndroidMkProvider); ok { |
| 41 | if !c.subAndroidMkOnce[androidmk] { |
| 42 | c.subAndroidMkOnce[androidmk] = true |
| 43 | androidmk.AndroidMk(c, data) |
| 44 | } |
| 45 | } |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 46 | } |
| 47 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 48 | func (c *Module) AndroidMk() (ret android.AndroidMkData, err error) { |
Colin Cross | bc6fb16 | 2016-05-24 15:39:04 -0700 | [diff] [blame] | 49 | if c.Properties.HideFromMake { |
| 50 | ret.Disabled = true |
| 51 | return ret, nil |
| 52 | } |
| 53 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 54 | ret.OutputFile = c.outputFile |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 55 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) (err error) { |
Colin Cross | 30d5f51 | 2016-05-03 18:02:42 -0700 | [diff] [blame] | 56 | fmt.Fprintln(w, "LOCAL_SANITIZE := never") |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 57 | if len(c.Properties.AndroidMkSharedLibs) > 0 { |
| 58 | fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " ")) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 59 | } |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 60 | if c.Target().Os == android.Android && c.Properties.Sdk_version != "" && !c.vndk() { |
Dan Willemsen | a96ff64 | 2016-06-07 12:34:45 -0700 | [diff] [blame] | 61 | fmt.Fprintln(w, "LOCAL_SDK_VERSION := "+c.Properties.Sdk_version) |
| 62 | fmt.Fprintln(w, "LOCAL_NDK_STL_VARIANT := none") |
| 63 | } else { |
| 64 | // These are already included in LOCAL_SHARED_LIBRARIES |
| 65 | fmt.Fprintln(w, "LOCAL_CXX_STL := none") |
| 66 | } |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 67 | if c.vndk() { |
| 68 | fmt.Fprintln(w, "LOCAL_USE_VNDK := true") |
| 69 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 70 | return nil |
| 71 | }) |
| 72 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 73 | for _, feature := range c.features { |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 74 | c.subAndroidMk(&ret, feature) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 75 | } |
| 76 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 77 | c.subAndroidMk(&ret, c.compiler) |
| 78 | c.subAndroidMk(&ret, c.linker) |
Colin Cross | 8ff9ef4 | 2017-05-08 13:44:11 -0700 | [diff] [blame] | 79 | if c.sanitize != nil { |
| 80 | c.subAndroidMk(&ret, c.sanitize) |
| 81 | } |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 82 | c.subAndroidMk(&ret, c.installer) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 83 | |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 84 | if c.vndk() { |
| 85 | ret.SubName += ".vendor" |
| 86 | } |
| 87 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 88 | return ret, nil |
| 89 | } |
| 90 | |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 91 | func (library *libraryDecorator) androidMkWriteExportedFlags(w io.Writer) { |
| 92 | exportedFlags := library.exportedFlags() |
| 93 | if len(exportedFlags) > 0 { |
| 94 | fmt.Fprintln(w, "LOCAL_EXPORT_CFLAGS :=", strings.Join(exportedFlags, " ")) |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 95 | } |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 96 | exportedFlagsDeps := library.exportedFlagsDeps() |
| 97 | if len(exportedFlagsDeps) > 0 { |
| 98 | fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DEPS :=", strings.Join(exportedFlagsDeps.Strings(), " ")) |
| 99 | } |
| 100 | } |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 101 | |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 102 | func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 103 | if library.static() { |
| 104 | ret.Class = "STATIC_LIBRARIES" |
| 105 | } else if library.shared() { |
| 106 | ctx.subAndroidMk(ret, &library.stripper) |
| 107 | ctx.subAndroidMk(ret, &library.relocationPacker) |
| 108 | |
| 109 | ret.Class = "SHARED_LIBRARIES" |
| 110 | } else if library.header() { |
| 111 | ret.Custom = func(w io.Writer, name, prefix, moduleDir string) error { |
| 112 | fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)") |
| 113 | fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir) |
| 114 | fmt.Fprintln(w, "LOCAL_MODULE :=", name) |
| 115 | |
| 116 | archStr := ctx.Target().Arch.ArchType.String() |
| 117 | var host bool |
| 118 | switch ctx.Target().Os.Class { |
| 119 | case android.Host: |
| 120 | fmt.Fprintln(w, "LOCAL_MODULE_HOST_ARCH := ", archStr) |
| 121 | host = true |
| 122 | case android.HostCross: |
| 123 | fmt.Fprintln(w, "LOCAL_MODULE_HOST_CROSS_ARCH := ", archStr) |
| 124 | host = true |
| 125 | case android.Device: |
| 126 | fmt.Fprintln(w, "LOCAL_MODULE_TARGET_ARCH := ", archStr) |
| 127 | } |
| 128 | |
| 129 | if host { |
| 130 | fmt.Fprintln(w, "LOCAL_MODULE_HOST_OS :=", ctx.Target().Os.String()) |
| 131 | fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true") |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 132 | } else if ctx.vndk() { |
| 133 | fmt.Fprintln(w, "LOCAL_USE_VNDK := true") |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 134 | } |
| 135 | |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 136 | library.androidMkWriteExportedFlags(w) |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 137 | fmt.Fprintln(w, "include $(BUILD_HEADER_LIBRARY)") |
| 138 | |
| 139 | return nil |
| 140 | } |
| 141 | |
| 142 | return |
| 143 | } |
| 144 | |
| 145 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 146 | library.androidMkWriteExportedFlags(w) |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 147 | fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES := ") |
| 148 | if library.sAbiOutputFile.Valid() { |
| 149 | fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES += ", library.sAbiOutputFile.String()) |
| 150 | if library.sAbiDiff.Valid() && !library.static() { |
| 151 | fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES += ", library.sAbiDiff.String()) |
| 152 | } |
| 153 | } |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 154 | |
Dan Willemsen | 1d577e2 | 2016-08-29 15:53:15 -0700 | [diff] [blame] | 155 | fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext()) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 156 | |
Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 157 | fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 158 | |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 159 | if library.coverageOutputFile.Valid() { |
| 160 | fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", library.coverageOutputFile.String()) |
| 161 | } |
| 162 | |
Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 163 | return nil |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 164 | }) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 165 | |
Colin Cross | 4ac4480 | 2017-02-15 14:06:12 -0800 | [diff] [blame] | 166 | if library.shared() { |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 167 | ctx.subAndroidMk(ret, library.baseInstaller) |
| 168 | } |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 169 | } |
| 170 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 171 | func (object *objectLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Nan Zhang | 6d34b30 | 2017-02-04 17:47:46 -0800 | [diff] [blame] | 172 | ret.Custom = func(w io.Writer, name, prefix, moduleDir string) error { |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 173 | out := ret.OutputFile.Path() |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 174 | |
Dan Willemsen | 72d3993 | 2016-07-08 23:23:48 -0700 | [diff] [blame] | 175 | fmt.Fprintln(w, "\n$("+prefix+"OUT_INTERMEDIATE_LIBRARIES)/"+name+objectExtension+":", out.String()) |
Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 176 | fmt.Fprintln(w, "\t$(copy-file-to-target)") |
| 177 | |
| 178 | return nil |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 179 | } |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 180 | } |
| 181 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 182 | func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Colin Cross | 1e7d370 | 2016-08-24 15:25:47 -0700 | [diff] [blame] | 183 | ctx.subAndroidMk(ret, binary.baseInstaller) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 184 | ctx.subAndroidMk(ret, &binary.stripper) |
Dan Willemsen | 7517ed0 | 2016-06-10 17:20:30 -0700 | [diff] [blame] | 185 | |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 186 | ret.Class = "EXECUTABLES" |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 187 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { |
Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 188 | fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 189 | if Bool(binary.Properties.Static_executable) { |
Colin Cross | 3854a60 | 2016-01-11 12:49:11 -0800 | [diff] [blame] | 190 | fmt.Fprintln(w, "LOCAL_FORCE_STATIC_EXECUTABLE := true") |
| 191 | } |
Colin Cross | 9b09f24 | 2016-12-07 13:37:42 -0800 | [diff] [blame] | 192 | |
| 193 | if len(binary.symlinks) > 0 { |
| 194 | fmt.Fprintln(w, "LOCAL_MODULE_SYMLINKS := "+strings.Join(binary.symlinks, " ")) |
| 195 | } |
| 196 | |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 197 | if binary.coverageOutputFile.Valid() { |
| 198 | fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", binary.coverageOutputFile.String()) |
| 199 | } |
Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 200 | return nil |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 201 | }) |
| 202 | } |
| 203 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 204 | func (benchmark *benchmarkDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 205 | ctx.subAndroidMk(ret, benchmark.binaryDecorator) |
Dan Willemsen | 58a5c8b | 2017-05-23 15:10:37 -0700 | [diff] [blame] | 206 | ret.Class = "NATIVE_TESTS" |
Colin Cross | e28f4e2 | 2017-04-24 18:10:29 -0700 | [diff] [blame] | 207 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { |
| 208 | if len(benchmark.Properties.Test_suites) > 0 { |
| 209 | fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", |
| 210 | strings.Join(benchmark.Properties.Test_suites, " ")) |
| 211 | } |
| 212 | return nil |
| 213 | }) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | func (test *testBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 217 | ctx.subAndroidMk(ret, test.binaryDecorator) |
Dan Willemsen | 0fe7253 | 2017-01-17 13:25:49 -0800 | [diff] [blame] | 218 | ret.Class = "NATIVE_TESTS" |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 219 | if Bool(test.Properties.Test_per_src) { |
| 220 | ret.SubName = "_" + test.binaryDecorator.Properties.Stem |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 221 | } |
Colin Cross | faeb7aa | 2017-02-01 14:12:44 -0800 | [diff] [blame] | 222 | |
Colin Cross | a929db0 | 2017-03-27 16:27:50 -0700 | [diff] [blame] | 223 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { |
| 224 | if len(test.Properties.Test_suites) > 0 { |
Dan Shi | 4df566d | 2017-04-03 12:29:25 -0700 | [diff] [blame] | 225 | fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", |
Colin Cross | a929db0 | 2017-03-27 16:27:50 -0700 | [diff] [blame] | 226 | strings.Join(test.Properties.Test_suites, " ")) |
| 227 | } |
| 228 | return nil |
| 229 | }) |
| 230 | |
Colin Cross | faeb7aa | 2017-02-01 14:12:44 -0800 | [diff] [blame] | 231 | var testFiles []string |
| 232 | for _, d := range test.data { |
| 233 | rel := d.Rel() |
| 234 | path := d.String() |
| 235 | if !strings.HasSuffix(path, rel) { |
| 236 | panic(fmt.Errorf("path %q does not end with %q", path, rel)) |
| 237 | } |
| 238 | path = strings.TrimSuffix(path, rel) |
| 239 | testFiles = append(testFiles, path+":"+rel) |
| 240 | } |
| 241 | if len(testFiles) > 0 { |
| 242 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { |
| 243 | fmt.Fprintln(w, "LOCAL_TEST_DATA := "+strings.Join(testFiles, " ")) |
| 244 | return nil |
| 245 | }) |
| 246 | } |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 247 | } |
| 248 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 249 | func (test *testLibrary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 250 | ctx.subAndroidMk(ret, test.libraryDecorator) |
| 251 | } |
Dan Willemsen | e7932e8 | 2016-05-16 15:56:53 -0700 | [diff] [blame] | 252 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 253 | func (library *toolchainLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 254 | ret.Class = "STATIC_LIBRARIES" |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 255 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { |
Dan Willemsen | e7932e8 | 2016-05-16 15:56:53 -0700 | [diff] [blame] | 256 | fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext()) |
Dan Willemsen | e7932e8 | 2016-05-16 15:56:53 -0700 | [diff] [blame] | 257 | fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") |
| 258 | |
| 259 | return nil |
| 260 | }) |
| 261 | } |
| 262 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 263 | func (stripper *stripper) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 264 | // Make only supports stripping target modules |
| 265 | if ctx.Target().Os != android.Android { |
| 266 | return |
| 267 | } |
| 268 | |
Dan Willemsen | 7517ed0 | 2016-06-10 17:20:30 -0700 | [diff] [blame] | 269 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { |
| 270 | if stripper.StripProperties.Strip.None { |
| 271 | fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false") |
| 272 | } else if stripper.StripProperties.Strip.Keep_symbols { |
| 273 | fmt.Fprintln(w, "LOCAL_STRIP_MODULE := keep_symbols") |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 274 | } else { |
| 275 | fmt.Fprintln(w, "LOCAL_STRIP_MODULE := mini-debug-info") |
Dan Willemsen | 7517ed0 | 2016-06-10 17:20:30 -0700 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | return nil |
| 279 | }) |
| 280 | } |
| 281 | |
Dan Willemsen | 394e9dc | 2016-09-14 15:04:48 -0700 | [diff] [blame] | 282 | func (packer *relocationPacker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 283 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { |
| 284 | if packer.Properties.PackingRelocations { |
| 285 | fmt.Fprintln(w, "LOCAL_PACK_MODULE_RELOCATIONS := true") |
| 286 | } |
| 287 | return nil |
| 288 | }) |
| 289 | } |
| 290 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 291 | func (installer *baseInstaller) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Dan Willemsen | 03ce63e | 2016-09-29 12:17:49 -0700 | [diff] [blame] | 292 | // Soong installation is only supported for host modules. Have Make |
| 293 | // installation trigger Soong installation. |
| 294 | if ctx.Target().Os.Class == android.Host { |
| 295 | ret.OutputFile = android.OptionalPathForPath(installer.path) |
| 296 | } |
| 297 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 298 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 299 | path := installer.path.RelPathString() |
Colin Cross | bf305de | 2016-03-29 17:32:06 -0700 | [diff] [blame] | 300 | dir, file := filepath.Split(path) |
| 301 | stem := strings.TrimSuffix(file, filepath.Ext(file)) |
Dan Willemsen | 1d577e2 | 2016-08-29 15:53:15 -0700 | [diff] [blame] | 302 | fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+filepath.Ext(file)) |
Colin Cross | e14388b | 2016-05-03 14:08:40 -0700 | [diff] [blame] | 303 | fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir)) |
Colin Cross | bf305de | 2016-03-29 17:32:06 -0700 | [diff] [blame] | 304 | fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem) |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 305 | return nil |
| 306 | }) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 307 | } |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 308 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 309 | func (c *stubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
Dan Willemsen | 01a9059 | 2017-04-07 15:21:13 -0700 | [diff] [blame] | 310 | ret.SubName = ndkLibrarySuffix + "." + c.properties.ApiLevel |
Dan Albert | 705c84b | 2016-08-08 10:45:03 -0700 | [diff] [blame] | 311 | ret.Class = "SHARED_LIBRARIES" |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 312 | |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 313 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 314 | path, file := filepath.Split(c.installPath) |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 315 | stem := strings.TrimSuffix(file, filepath.Ext(file)) |
Dan Albert | cdd4c24 | 2016-08-08 14:44:56 -0700 | [diff] [blame] | 316 | fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") |
| 317 | fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext()) |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 318 | fmt.Fprintln(w, "LOCAL_MODULE_PATH := "+path) |
| 319 | fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem) |
Dan Willemsen | 866810d | 2017-04-04 14:13:45 -0700 | [diff] [blame] | 320 | fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true") |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 321 | |
| 322 | // Prevent make from installing the libraries to obj/lib (since we have |
| 323 | // dozens of libraries with the same name, they'll clobber each other |
| 324 | // and the real versions of the libraries from the platform). |
| 325 | fmt.Fprintln(w, "LOCAL_COPY_TO_INTERMEDIATE_LIBRARIES := false") |
| 326 | return nil |
| 327 | }) |
| 328 | } |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 329 | |
| 330 | func (c *llndkStubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { |
| 331 | ret.Class = "SHARED_LIBRARIES" |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 332 | ret.SubName = ".vendor" |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 333 | |
| 334 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { |
| 335 | c.libraryDecorator.androidMkWriteExportedFlags(w) |
| 336 | |
| 337 | fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext()) |
| 338 | fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false") |
| 339 | fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") |
| 340 | fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true") |
| 341 | fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true") |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 342 | fmt.Fprintln(w, "LOCAL_USE_VNDK := true") |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 343 | |
| 344 | return nil |
| 345 | }) |
| 346 | } |