blob: 37df4ba0f033a221734d37c556336b399068fb94 [file] [log] [blame]
Colin Crossce75d2c2016-10-06 16:12:58 -07001// Copyright 2016 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 (
18 "android/soong/android"
Martin Stjernholm14ee8322020-09-21 21:45:49 +010019 "path/filepath"
Colin Crossce75d2c2016-10-06 16:12:58 -070020)
21
22func init() {
Paul Duffin59986b22019-12-19 14:38:36 +000023 RegisterPrebuiltBuildComponents(android.InitRegistrationContext)
24}
25
26func RegisterPrebuiltBuildComponents(ctx android.RegistrationContext) {
Paul Duffinbce90da2020-03-12 20:17:14 +000027 ctx.RegisterModuleType("cc_prebuilt_library", PrebuiltLibraryFactory)
Paul Duffin59986b22019-12-19 14:38:36 +000028 ctx.RegisterModuleType("cc_prebuilt_library_shared", PrebuiltSharedLibraryFactory)
29 ctx.RegisterModuleType("cc_prebuilt_library_static", PrebuiltStaticLibraryFactory)
Chris Parsons1f6d90f2020-06-17 16:10:42 -040030 ctx.RegisterModuleType("cc_prebuilt_test_library_shared", PrebuiltSharedTestLibraryFactory)
Martin Stjernholm0b92ac82020-03-11 21:45:49 +000031 ctx.RegisterModuleType("cc_prebuilt_object", prebuiltObjectFactory)
Paul Duffin59986b22019-12-19 14:38:36 +000032 ctx.RegisterModuleType("cc_prebuilt_binary", prebuiltBinaryFactory)
Colin Crossce75d2c2016-10-06 16:12:58 -070033}
34
35type prebuiltLinkerInterface interface {
36 Name(string) string
37 prebuilt() *android.Prebuilt
38}
39
Patrice Arruda3554a982019-03-27 19:09:10 -070040type prebuiltLinkerProperties struct {
Patrice Arruda3554a982019-03-27 19:09:10 -070041 // a prebuilt library or binary. Can reference a genrule module that generates an executable file.
42 Srcs []string `android:"path,arch_variant"`
43
Evgenii Stepanov2080bfe2020-07-24 15:35:40 -070044 Sanitized Sanitized `android:"arch_variant"`
45
Patrice Arruda3554a982019-03-27 19:09:10 -070046 // Check the prebuilt ELF files (e.g. DT_SONAME, DT_NEEDED, resolution of undefined
47 // symbols, etc), default true.
48 Check_elf_files *bool
Yo Chianga3ad9b22020-03-18 14:19:07 +080049
50 // Optionally provide an import library if this is a Windows PE DLL prebuilt.
51 // This is needed only if this library is linked by other modules in build time.
52 // Only makes sense for the Windows target.
53 Windows_import_lib *string `android:"path,arch_variant"`
Patrice Arruda3554a982019-03-27 19:09:10 -070054}
55
Colin Crossde89fb82017-03-17 13:28:06 -070056type prebuiltLinker struct {
Colin Crossce75d2c2016-10-06 16:12:58 -070057 android.Prebuilt
Logan Chien4fcea3d2018-11-20 11:59:08 +080058
Patrice Arruda3554a982019-03-27 19:09:10 -070059 properties prebuiltLinkerProperties
Colin Crossce75d2c2016-10-06 16:12:58 -070060}
61
Colin Crossde89fb82017-03-17 13:28:06 -070062func (p *prebuiltLinker) prebuilt() *android.Prebuilt {
Colin Crossce75d2c2016-10-06 16:12:58 -070063 return &p.Prebuilt
64}
65
Colin Cross74d73e22017-08-02 11:05:49 -070066func (p *prebuiltLinker) PrebuiltSrcs() []string {
67 return p.properties.Srcs
68}
69
Colin Cross33b2fb72019-05-14 14:07:01 -070070type prebuiltLibraryInterface interface {
71 libraryInterface
72 prebuiltLinkerInterface
73 disablePrebuilt()
74}
75
Colin Crossde89fb82017-03-17 13:28:06 -070076type prebuiltLibraryLinker struct {
77 *libraryDecorator
78 prebuiltLinker
79}
80
81var _ prebuiltLinkerInterface = (*prebuiltLibraryLinker)(nil)
Colin Cross33b2fb72019-05-14 14:07:01 -070082var _ prebuiltLibraryInterface = (*prebuiltLibraryLinker)(nil)
Colin Crossde89fb82017-03-17 13:28:06 -070083
Yi Kong00981662018-08-13 16:02:49 -070084func (p *prebuiltLibraryLinker) linkerInit(ctx BaseModuleContext) {}
85
86func (p *prebuiltLibraryLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
Logan Chienc7f797e2019-01-14 15:35:08 +080087 return p.libraryDecorator.linkerDeps(ctx, deps)
Yi Kong00981662018-08-13 16:02:49 -070088}
89
90func (p *prebuiltLibraryLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
Colin Cross1ab10a72018-09-04 11:02:37 -070091 return flags
Yi Kong00981662018-08-13 16:02:49 -070092}
93
94func (p *prebuiltLibraryLinker) linkerProps() []interface{} {
95 return p.libraryDecorator.linkerProps()
96}
97
Colin Crossce75d2c2016-10-06 16:12:58 -070098func (p *prebuiltLibraryLinker) link(ctx ModuleContext,
Dan Willemsen5cb580f2016-09-26 17:33:01 -070099 flags Flags, deps PathDeps, objs Objects) android.Path {
Paul Duffinf5ea9e12020-02-21 10:57:00 +0000100
Colin Cross0de8a1e2020-09-18 14:15:30 -0700101 p.libraryDecorator.flagExporter.exportIncludes(ctx)
102 p.libraryDecorator.flagExporter.reexportDirs(deps.ReexportedDirs...)
103 p.libraryDecorator.flagExporter.reexportSystemDirs(deps.ReexportedSystemDirs...)
104 p.libraryDecorator.flagExporter.reexportFlags(deps.ReexportedFlags...)
105 p.libraryDecorator.flagExporter.reexportDeps(deps.ReexportedDeps...)
106 p.libraryDecorator.flagExporter.addExportedGeneratedHeaders(deps.ReexportedGeneratedHeaders...)
107
108 p.libraryDecorator.flagExporter.setProvider(ctx)
Paul Duffinf5ea9e12020-02-21 10:57:00 +0000109
Colin Crossce75d2c2016-10-06 16:12:58 -0700110 // TODO(ccross): verify shared library dependencies
Evgenii Stepanov2080bfe2020-07-24 15:35:40 -0700111 srcs := p.prebuiltSrcs(ctx)
Paul Duffinbce90da2020-03-12 20:17:14 +0000112 if len(srcs) > 0 {
Colin Cross88f6fef2018-09-05 14:20:03 -0700113 builderFlags := flagsToBuilderFlags(flags)
114
Paul Duffinbce90da2020-03-12 20:17:14 +0000115 if len(srcs) > 1 {
116 ctx.PropertyErrorf("srcs", "multiple prebuilt source files")
117 return nil
118 }
119
120 in := android.PathForModuleSrc(ctx, srcs[0])
Colin Cross88f6fef2018-09-05 14:20:03 -0700121
Yo Chianga3ad9b22020-03-18 14:19:07 +0800122 if p.static() {
Colin Cross0de8a1e2020-09-18 14:15:30 -0700123 depSet := android.NewDepSetBuilder(android.TOPOLOGICAL).Direct(in).Build()
124 ctx.SetProvider(StaticLibraryInfoProvider, StaticLibraryInfo{
125 StaticLibrary: in,
126
127 TransitiveStaticLibrariesForOrdering: depSet,
128 })
Yo Chianga3ad9b22020-03-18 14:19:07 +0800129 return in
130 }
131
Colin Cross88f6fef2018-09-05 14:20:03 -0700132 if p.shared() {
Colin Crossb60190a2018-09-04 16:28:17 -0700133 p.unstrippedOutputFile = in
Colin Cross0fd6a412019-08-16 14:22:10 -0700134 libName := p.libraryDecorator.getLibName(ctx) + flags.Toolchain.ShlibSuffix()
Yo Chianga3ad9b22020-03-18 14:19:07 +0800135 outputFile := android.PathForModuleOut(ctx, libName)
136 var implicits android.Paths
137
ThiƩbaud Weksteend4587452020-08-19 14:53:01 +0200138 if p.stripper.NeedsStrip(ctx) {
139 stripFlags := flagsToStripFlags(flags)
Colin Cross88f6fef2018-09-05 14:20:03 -0700140 stripped := android.PathForModuleOut(ctx, "stripped", libName)
ThiƩbaud Weksteend4587452020-08-19 14:53:01 +0200141 p.stripper.StripExecutableOrSharedLib(ctx, in, stripped, stripFlags)
Colin Cross88f6fef2018-09-05 14:20:03 -0700142 in = stripped
143 }
144
Colin Crossb60190a2018-09-04 16:28:17 -0700145 // Optimize out relinking against shared libraries whose interface hasn't changed by
146 // depending on a table of contents file instead of the library itself.
147 tocFile := android.PathForModuleOut(ctx, libName+".toc")
148 p.tocFile = android.OptionalPathForPath(tocFile)
Chris Parsonsbf4f55f2020-11-23 17:02:44 -0500149 transformSharedObjectToToc(ctx, outputFile, tocFile, builderFlags)
Colin Cross88f6fef2018-09-05 14:20:03 -0700150
Yo Chianga3ad9b22020-03-18 14:19:07 +0800151 if ctx.Windows() && p.properties.Windows_import_lib != nil {
152 // Consumers of this library actually links to the import library in build
153 // time and dynamically links to the DLL in run time. i.e.
154 // a.exe <-- static link --> foo.lib <-- dynamic link --> foo.dll
155 importLibSrc := android.PathForModuleSrc(ctx, String(p.properties.Windows_import_lib))
156 importLibName := p.libraryDecorator.getLibName(ctx) + ".lib"
157 importLibOutputFile := android.PathForModuleOut(ctx, importLibName)
158 implicits = append(implicits, importLibOutputFile)
159
160 ctx.Build(pctx, android.BuildParams{
161 Rule: android.Cp,
162 Description: "prebuilt import library",
163 Input: importLibSrc,
164 Output: importLibOutputFile,
165 Args: map[string]string{
166 "cpFlags": "-L",
167 },
168 })
169 }
170
171 ctx.Build(pctx, android.BuildParams{
172 Rule: android.Cp,
173 Description: "prebuilt shared library",
174 Implicits: implicits,
175 Input: in,
176 Output: outputFile,
177 Args: map[string]string{
178 "cpFlags": "-L",
179 },
180 })
181
Colin Cross0de8a1e2020-09-18 14:15:30 -0700182 ctx.SetProvider(SharedLibraryInfoProvider, SharedLibraryInfo{
183 SharedLibrary: outputFile,
184 UnstrippedSharedLibrary: p.unstrippedOutputFile,
185
186 TableOfContents: p.tocFile,
187 })
188
Yo Chianga3ad9b22020-03-18 14:19:07 +0800189 return outputFile
190 }
Colin Crossce75d2c2016-10-06 16:12:58 -0700191 }
192
193 return nil
194}
195
Evgenii Stepanov2080bfe2020-07-24 15:35:40 -0700196func (p *prebuiltLibraryLinker) prebuiltSrcs(ctx android.BaseModuleContext) []string {
197 sanitize := ctx.Module().(*Module).sanitize
Paul Duffinbce90da2020-03-12 20:17:14 +0000198 srcs := p.properties.Srcs
Evgenii Stepanov2080bfe2020-07-24 15:35:40 -0700199 srcs = append(srcs, srcsForSanitizer(sanitize, p.properties.Sanitized)...)
Paul Duffinbce90da2020-03-12 20:17:14 +0000200 if p.static() {
201 srcs = append(srcs, p.libraryDecorator.StaticProperties.Static.Srcs...)
Evgenii Stepanov2080bfe2020-07-24 15:35:40 -0700202 srcs = append(srcs, srcsForSanitizer(sanitize, p.libraryDecorator.StaticProperties.Static.Sanitized)...)
Paul Duffinbce90da2020-03-12 20:17:14 +0000203 }
204 if p.shared() {
205 srcs = append(srcs, p.libraryDecorator.SharedProperties.Shared.Srcs...)
Evgenii Stepanov2080bfe2020-07-24 15:35:40 -0700206 srcs = append(srcs, srcsForSanitizer(sanitize, p.libraryDecorator.SharedProperties.Shared.Sanitized)...)
Paul Duffinbce90da2020-03-12 20:17:14 +0000207 }
Paul Duffinbce90da2020-03-12 20:17:14 +0000208 return srcs
209}
210
Jiyong Park379de2f2018-12-19 02:47:14 +0900211func (p *prebuiltLibraryLinker) shared() bool {
212 return p.libraryDecorator.shared()
213}
214
Pirama Arumuga Nainar65c95ff2019-03-25 10:21:31 -0700215func (p *prebuiltLibraryLinker) nativeCoverage() bool {
216 return false
217}
218
Colin Cross33b2fb72019-05-14 14:07:01 -0700219func (p *prebuiltLibraryLinker) disablePrebuilt() {
220 p.properties.Srcs = nil
221}
222
Paul Duffinac6e6082019-12-11 15:22:32 +0000223func NewPrebuiltLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
Leo Li74f7b972017-05-17 11:30:45 -0700224 module, library := NewLibrary(hod)
Colin Crossce75d2c2016-10-06 16:12:58 -0700225 module.compiler = nil
226
227 prebuilt := &prebuiltLibraryLinker{
228 libraryDecorator: library,
229 }
230 module.linker = prebuilt
Colin Cross31076b32020-10-23 17:22:06 -0700231 module.library = prebuilt
Colin Crossde89fb82017-03-17 13:28:06 -0700232
Colin Cross74d73e22017-08-02 11:05:49 -0700233 module.AddProperties(&prebuilt.properties)
234
Evgenii Stepanov2080bfe2020-07-24 15:35:40 -0700235 srcsSupplier := func(ctx android.BaseModuleContext) []string {
236 return prebuilt.prebuiltSrcs(ctx)
Paul Duffinbce90da2020-03-12 20:17:14 +0000237 }
238
239 android.InitPrebuiltModuleWithSrcSupplier(module, srcsSupplier, "srcs")
Jiyong Park379de2f2018-12-19 02:47:14 +0900240
Paul Duffinac6e6082019-12-11 15:22:32 +0000241 // Prebuilt libraries can be used in SDKs.
Jiyong Parkd1063c12019-07-17 20:08:41 +0900242 android.InitSdkAwareModule(module)
Paul Duffinac6e6082019-12-11 15:22:32 +0000243 return module, library
244}
245
Paul Duffinbce90da2020-03-12 20:17:14 +0000246// cc_prebuilt_library installs a precompiled shared library that are
247// listed in the srcs property in the device's directory.
248func PrebuiltLibraryFactory() android.Module {
249 module, _ := NewPrebuiltLibrary(android.HostAndDeviceSupported)
250
251 // Prebuilt shared libraries can be included in APEXes
252 android.InitApexModule(module)
253
254 return module.Init()
255}
256
Paul Duffinac6e6082019-12-11 15:22:32 +0000257// cc_prebuilt_library_shared installs a precompiled shared library that are
258// listed in the srcs property in the device's directory.
259func PrebuiltSharedLibraryFactory() android.Module {
260 module, _ := NewPrebuiltSharedLibrary(android.HostAndDeviceSupported)
261 return module.Init()
262}
263
Chris Parsons1f6d90f2020-06-17 16:10:42 -0400264// cc_prebuilt_test_library_shared installs a precompiled shared library
265// to be used as a data dependency of a test-related module (such as cc_test, or
266// cc_test_library).
267func PrebuiltSharedTestLibraryFactory() android.Module {
268 module, library := NewPrebuiltLibrary(android.HostAndDeviceSupported)
269 library.BuildOnlyShared()
270 library.baseInstaller = NewTestInstaller()
271 return module.Init()
272}
273
Paul Duffinac6e6082019-12-11 15:22:32 +0000274func NewPrebuiltSharedLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
275 module, library := NewPrebuiltLibrary(hod)
276 library.BuildOnlyShared()
277
278 // Prebuilt shared libraries can be included in APEXes
279 android.InitApexModule(module)
Jiyong Park379de2f2018-12-19 02:47:14 +0900280
Leo Li74f7b972017-05-17 11:30:45 -0700281 return module, library
Colin Crossde89fb82017-03-17 13:28:06 -0700282}
283
Patrice Arruda3554a982019-03-27 19:09:10 -0700284// cc_prebuilt_library_static installs a precompiled static library that are
285// listed in the srcs property in the device's directory.
Jooyung Han344d5432019-08-23 11:17:39 +0900286func PrebuiltStaticLibraryFactory() android.Module {
Leo Li74f7b972017-05-17 11:30:45 -0700287 module, _ := NewPrebuiltStaticLibrary(android.HostAndDeviceSupported)
288 return module.Init()
289}
290
291func NewPrebuiltStaticLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
Paul Duffinac6e6082019-12-11 15:22:32 +0000292 module, library := NewPrebuiltLibrary(hod)
Colin Crossde89fb82017-03-17 13:28:06 -0700293 library.BuildOnlyStatic()
Leo Li74f7b972017-05-17 11:30:45 -0700294 return module, library
Colin Crossde89fb82017-03-17 13:28:06 -0700295}
296
Martin Stjernholm0b92ac82020-03-11 21:45:49 +0000297type prebuiltObjectProperties struct {
298 Srcs []string `android:"path,arch_variant"`
299}
300
301type prebuiltObjectLinker struct {
302 android.Prebuilt
303 objectLinker
304
305 properties prebuiltObjectProperties
306}
307
308func (p *prebuiltObjectLinker) prebuilt() *android.Prebuilt {
309 return &p.Prebuilt
310}
311
312var _ prebuiltLinkerInterface = (*prebuiltObjectLinker)(nil)
313
314func (p *prebuiltObjectLinker) link(ctx ModuleContext,
315 flags Flags, deps PathDeps, objs Objects) android.Path {
316 if len(p.properties.Srcs) > 0 {
317 return p.Prebuilt.SingleSourcePath(ctx)
318 }
319 return nil
320}
321
Inseob Kim1042d292020-06-01 23:23:05 +0900322func (p *prebuiltObjectLinker) object() bool {
323 return true
324}
325
Martin Stjernholm0b92ac82020-03-11 21:45:49 +0000326func newPrebuiltObject() *Module {
327 module := newObject()
328 prebuilt := &prebuiltObjectLinker{
329 objectLinker: objectLinker{
330 baseLinker: NewBaseLinker(nil),
331 },
332 }
333 module.linker = prebuilt
334 module.AddProperties(&prebuilt.properties)
335 android.InitPrebuiltModule(module, &prebuilt.properties.Srcs)
336 android.InitSdkAwareModule(module)
337 return module
338}
339
340func prebuiltObjectFactory() android.Module {
341 module := newPrebuiltObject()
342 return module.Init()
343}
344
Colin Crossde89fb82017-03-17 13:28:06 -0700345type prebuiltBinaryLinker struct {
346 *binaryDecorator
347 prebuiltLinker
Martin Stjernholm837ee1a2020-08-20 02:54:52 +0100348
349 toolPath android.OptionalPath
Colin Crossde89fb82017-03-17 13:28:06 -0700350}
351
352var _ prebuiltLinkerInterface = (*prebuiltBinaryLinker)(nil)
353
Martin Stjernholm837ee1a2020-08-20 02:54:52 +0100354func (p *prebuiltBinaryLinker) hostToolPath() android.OptionalPath {
355 return p.toolPath
356}
357
Colin Crossde89fb82017-03-17 13:28:06 -0700358func (p *prebuiltBinaryLinker) link(ctx ModuleContext,
359 flags Flags, deps PathDeps, objs Objects) android.Path {
360 // TODO(ccross): verify shared library dependencies
Colin Cross74d73e22017-08-02 11:05:49 -0700361 if len(p.properties.Srcs) > 0 {
Colin Cross88f6fef2018-09-05 14:20:03 -0700362 fileName := p.getStem(ctx) + flags.Toolchain.ExecutableSuffix()
363 in := p.Prebuilt.SingleSourcePath(ctx)
Martin Stjernholm837ee1a2020-08-20 02:54:52 +0100364 outputFile := android.PathForModuleOut(ctx, fileName)
Colin Crossb60190a2018-09-04 16:28:17 -0700365 p.unstrippedOutputFile = in
366
Martin Stjernholm837ee1a2020-08-20 02:54:52 +0100367 if ctx.Host() {
368 // Host binaries are symlinked to their prebuilt source locations. That
369 // way they are executed directly from there so the linker resolves their
370 // shared library dependencies relative to that location (using
371 // $ORIGIN/../lib(64):$ORIGIN/lib(64) as RUNPATH). This way the prebuilt
372 // repository can supply the expected versions of the shared libraries
373 // without interference from what is in the out tree.
Colin Cross94921e72017-08-08 16:20:15 -0700374
Martin Stjernholm837ee1a2020-08-20 02:54:52 +0100375 // These shared lib paths may point to copies of the libs in
376 // .intermediates, which isn't where the binary will load them from, but
377 // it's fine for dependency tracking. If a library dependency is updated,
378 // the symlink will get a new timestamp, along with any installed symlinks
379 // handled in make.
380 sharedLibPaths := deps.EarlySharedLibs
381 sharedLibPaths = append(sharedLibPaths, deps.SharedLibs...)
382 sharedLibPaths = append(sharedLibPaths, deps.LateSharedLibs...)
383
Martin Stjernholm14ee8322020-09-21 21:45:49 +0100384 var fromPath = in.String()
385 if !filepath.IsAbs(fromPath) {
386 fromPath = "$$PWD/" + fromPath
387 }
388
Martin Stjernholm837ee1a2020-08-20 02:54:52 +0100389 ctx.Build(pctx, android.BuildParams{
390 Rule: android.Symlink,
391 Output: outputFile,
392 Input: in,
393 Implicits: sharedLibPaths,
394 Args: map[string]string{
Martin Stjernholm14ee8322020-09-21 21:45:49 +0100395 "fromPath": fromPath,
Martin Stjernholm837ee1a2020-08-20 02:54:52 +0100396 },
397 })
398
399 p.toolPath = android.OptionalPathForPath(outputFile)
400 } else {
401 if p.stripper.NeedsStrip(ctx) {
402 stripped := android.PathForModuleOut(ctx, "stripped", fileName)
403 p.stripper.StripExecutableOrSharedLib(ctx, in, stripped, flagsToStripFlags(flags))
404 in = stripped
405 }
406
407 // Copy binaries to a name matching the final installed name
408 ctx.Build(pctx, android.BuildParams{
409 Rule: android.CpExecutable,
410 Description: "prebuilt",
411 Output: outputFile,
412 Input: in,
413 })
414 }
Colin Cross94921e72017-08-08 16:20:15 -0700415
416 return outputFile
Colin Crossde89fb82017-03-17 13:28:06 -0700417 }
418
419 return nil
420}
421
Inseob Kim7f283f42020-06-01 21:53:49 +0900422func (p *prebuiltBinaryLinker) binary() bool {
423 return true
424}
425
Patrice Arruda3554a982019-03-27 19:09:10 -0700426// cc_prebuilt_binary installs a precompiled executable in srcs property in the
427// device's directory.
Colin Cross36242852017-06-23 15:06:31 -0700428func prebuiltBinaryFactory() android.Module {
Leo Li74f7b972017-05-17 11:30:45 -0700429 module, _ := NewPrebuiltBinary(android.HostAndDeviceSupported)
430 return module.Init()
431}
432
433func NewPrebuiltBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecorator) {
434 module, binary := NewBinary(hod)
Colin Crossde89fb82017-03-17 13:28:06 -0700435 module.compiler = nil
436
437 prebuilt := &prebuiltBinaryLinker{
438 binaryDecorator: binary,
439 }
440 module.linker = prebuilt
Martin Stjernholm837ee1a2020-08-20 02:54:52 +0100441 module.installer = prebuilt
Colin Crossce75d2c2016-10-06 16:12:58 -0700442
Colin Cross74d73e22017-08-02 11:05:49 -0700443 module.AddProperties(&prebuilt.properties)
444
445 android.InitPrebuiltModule(module, &prebuilt.properties.Srcs)
Leo Li74f7b972017-05-17 11:30:45 -0700446 return module, binary
Colin Crossce75d2c2016-10-06 16:12:58 -0700447}
Evgenii Stepanov2080bfe2020-07-24 15:35:40 -0700448
449type Sanitized struct {
450 None struct {
451 Srcs []string `android:"path,arch_variant"`
452 } `android:"arch_variant"`
453 Address struct {
454 Srcs []string `android:"path,arch_variant"`
455 } `android:"arch_variant"`
456 Hwaddress struct {
457 Srcs []string `android:"path,arch_variant"`
458 } `android:"arch_variant"`
459}
460
461func srcsForSanitizer(sanitize *sanitize, sanitized Sanitized) []string {
462 if sanitize == nil {
463 return nil
464 }
465 if Bool(sanitize.Properties.Sanitize.Address) && sanitized.Address.Srcs != nil {
466 return sanitized.Address.Srcs
467 }
468 if Bool(sanitize.Properties.Sanitize.Hwaddress) && sanitized.Hwaddress.Srcs != nil {
469 return sanitized.Hwaddress.Srcs
470 }
471 return sanitized.None.Srcs
472}