blob: e8d3422e8f2158711f136a8520bc0510ec73a503 [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
101 p.libraryDecorator.exportIncludes(ctx)
102 p.libraryDecorator.reexportDirs(deps.ReexportedDirs...)
103 p.libraryDecorator.reexportSystemDirs(deps.ReexportedSystemDirs...)
104 p.libraryDecorator.reexportFlags(deps.ReexportedFlags...)
105 p.libraryDecorator.reexportDeps(deps.ReexportedDeps...)
106 p.libraryDecorator.addExportedGeneratedHeaders(deps.ReexportedGeneratedHeaders...)
107
Colin Crossce75d2c2016-10-06 16:12:58 -0700108 // TODO(ccross): verify shared library dependencies
Evgenii Stepanov2080bfe2020-07-24 15:35:40 -0700109 srcs := p.prebuiltSrcs(ctx)
Paul Duffinbce90da2020-03-12 20:17:14 +0000110 if len(srcs) > 0 {
Colin Cross88f6fef2018-09-05 14:20:03 -0700111 builderFlags := flagsToBuilderFlags(flags)
112
Paul Duffinbce90da2020-03-12 20:17:14 +0000113 if len(srcs) > 1 {
114 ctx.PropertyErrorf("srcs", "multiple prebuilt source files")
115 return nil
116 }
117
118 in := android.PathForModuleSrc(ctx, srcs[0])
Colin Cross88f6fef2018-09-05 14:20:03 -0700119
Yo Chianga3ad9b22020-03-18 14:19:07 +0800120 if p.static() {
121 return in
122 }
123
Colin Cross88f6fef2018-09-05 14:20:03 -0700124 if p.shared() {
Colin Crossb60190a2018-09-04 16:28:17 -0700125 p.unstrippedOutputFile = in
Colin Cross0fd6a412019-08-16 14:22:10 -0700126 libName := p.libraryDecorator.getLibName(ctx) + flags.Toolchain.ShlibSuffix()
Yo Chianga3ad9b22020-03-18 14:19:07 +0800127 outputFile := android.PathForModuleOut(ctx, libName)
128 var implicits android.Paths
129
ThiƩbaud Weksteend4587452020-08-19 14:53:01 +0200130 if p.stripper.NeedsStrip(ctx) {
131 stripFlags := flagsToStripFlags(flags)
Colin Cross88f6fef2018-09-05 14:20:03 -0700132 stripped := android.PathForModuleOut(ctx, "stripped", libName)
ThiƩbaud Weksteend4587452020-08-19 14:53:01 +0200133 p.stripper.StripExecutableOrSharedLib(ctx, in, stripped, stripFlags)
Colin Cross88f6fef2018-09-05 14:20:03 -0700134 in = stripped
135 }
136
Colin Crossb60190a2018-09-04 16:28:17 -0700137 // Optimize out relinking against shared libraries whose interface hasn't changed by
138 // depending on a table of contents file instead of the library itself.
139 tocFile := android.PathForModuleOut(ctx, libName+".toc")
140 p.tocFile = android.OptionalPathForPath(tocFile)
Yo Chianga3ad9b22020-03-18 14:19:07 +0800141 TransformSharedObjectToToc(ctx, outputFile, tocFile, builderFlags)
Colin Cross88f6fef2018-09-05 14:20:03 -0700142
Yo Chianga3ad9b22020-03-18 14:19:07 +0800143 if ctx.Windows() && p.properties.Windows_import_lib != nil {
144 // Consumers of this library actually links to the import library in build
145 // time and dynamically links to the DLL in run time. i.e.
146 // a.exe <-- static link --> foo.lib <-- dynamic link --> foo.dll
147 importLibSrc := android.PathForModuleSrc(ctx, String(p.properties.Windows_import_lib))
148 importLibName := p.libraryDecorator.getLibName(ctx) + ".lib"
149 importLibOutputFile := android.PathForModuleOut(ctx, importLibName)
150 implicits = append(implicits, importLibOutputFile)
151
152 ctx.Build(pctx, android.BuildParams{
153 Rule: android.Cp,
154 Description: "prebuilt import library",
155 Input: importLibSrc,
156 Output: importLibOutputFile,
157 Args: map[string]string{
158 "cpFlags": "-L",
159 },
160 })
161 }
162
163 ctx.Build(pctx, android.BuildParams{
164 Rule: android.Cp,
165 Description: "prebuilt shared library",
166 Implicits: implicits,
167 Input: in,
168 Output: outputFile,
169 Args: map[string]string{
170 "cpFlags": "-L",
171 },
172 })
173
174 return outputFile
175 }
Colin Crossce75d2c2016-10-06 16:12:58 -0700176 }
177
178 return nil
179}
180
Evgenii Stepanov2080bfe2020-07-24 15:35:40 -0700181func (p *prebuiltLibraryLinker) prebuiltSrcs(ctx android.BaseModuleContext) []string {
182 sanitize := ctx.Module().(*Module).sanitize
Paul Duffinbce90da2020-03-12 20:17:14 +0000183 srcs := p.properties.Srcs
Evgenii Stepanov2080bfe2020-07-24 15:35:40 -0700184 srcs = append(srcs, srcsForSanitizer(sanitize, p.properties.Sanitized)...)
Paul Duffinbce90da2020-03-12 20:17:14 +0000185 if p.static() {
186 srcs = append(srcs, p.libraryDecorator.StaticProperties.Static.Srcs...)
Evgenii Stepanov2080bfe2020-07-24 15:35:40 -0700187 srcs = append(srcs, srcsForSanitizer(sanitize, p.libraryDecorator.StaticProperties.Static.Sanitized)...)
Paul Duffinbce90da2020-03-12 20:17:14 +0000188 }
189 if p.shared() {
190 srcs = append(srcs, p.libraryDecorator.SharedProperties.Shared.Srcs...)
Evgenii Stepanov2080bfe2020-07-24 15:35:40 -0700191 srcs = append(srcs, srcsForSanitizer(sanitize, p.libraryDecorator.SharedProperties.Shared.Sanitized)...)
Paul Duffinbce90da2020-03-12 20:17:14 +0000192 }
Paul Duffinbce90da2020-03-12 20:17:14 +0000193 return srcs
194}
195
Jiyong Park379de2f2018-12-19 02:47:14 +0900196func (p *prebuiltLibraryLinker) shared() bool {
197 return p.libraryDecorator.shared()
198}
199
Pirama Arumuga Nainar65c95ff2019-03-25 10:21:31 -0700200func (p *prebuiltLibraryLinker) nativeCoverage() bool {
201 return false
202}
203
Colin Cross33b2fb72019-05-14 14:07:01 -0700204func (p *prebuiltLibraryLinker) disablePrebuilt() {
205 p.properties.Srcs = nil
206}
207
Paul Duffinac6e6082019-12-11 15:22:32 +0000208func NewPrebuiltLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
Leo Li74f7b972017-05-17 11:30:45 -0700209 module, library := NewLibrary(hod)
Colin Crossce75d2c2016-10-06 16:12:58 -0700210 module.compiler = nil
211
212 prebuilt := &prebuiltLibraryLinker{
213 libraryDecorator: library,
214 }
215 module.linker = prebuilt
Colin Crossde89fb82017-03-17 13:28:06 -0700216
Colin Cross74d73e22017-08-02 11:05:49 -0700217 module.AddProperties(&prebuilt.properties)
218
Evgenii Stepanov2080bfe2020-07-24 15:35:40 -0700219 srcsSupplier := func(ctx android.BaseModuleContext) []string {
220 return prebuilt.prebuiltSrcs(ctx)
Paul Duffinbce90da2020-03-12 20:17:14 +0000221 }
222
223 android.InitPrebuiltModuleWithSrcSupplier(module, srcsSupplier, "srcs")
Jiyong Park379de2f2018-12-19 02:47:14 +0900224
Paul Duffinac6e6082019-12-11 15:22:32 +0000225 // Prebuilt libraries can be used in SDKs.
Jiyong Parkd1063c12019-07-17 20:08:41 +0900226 android.InitSdkAwareModule(module)
Paul Duffinac6e6082019-12-11 15:22:32 +0000227 return module, library
228}
229
Paul Duffinbce90da2020-03-12 20:17:14 +0000230// cc_prebuilt_library installs a precompiled shared library that are
231// listed in the srcs property in the device's directory.
232func PrebuiltLibraryFactory() android.Module {
233 module, _ := NewPrebuiltLibrary(android.HostAndDeviceSupported)
234
235 // Prebuilt shared libraries can be included in APEXes
236 android.InitApexModule(module)
237
238 return module.Init()
239}
240
Paul Duffinac6e6082019-12-11 15:22:32 +0000241// cc_prebuilt_library_shared installs a precompiled shared library that are
242// listed in the srcs property in the device's directory.
243func PrebuiltSharedLibraryFactory() android.Module {
244 module, _ := NewPrebuiltSharedLibrary(android.HostAndDeviceSupported)
245 return module.Init()
246}
247
Chris Parsons1f6d90f2020-06-17 16:10:42 -0400248// cc_prebuilt_test_library_shared installs a precompiled shared library
249// to be used as a data dependency of a test-related module (such as cc_test, or
250// cc_test_library).
251func PrebuiltSharedTestLibraryFactory() android.Module {
252 module, library := NewPrebuiltLibrary(android.HostAndDeviceSupported)
253 library.BuildOnlyShared()
254 library.baseInstaller = NewTestInstaller()
255 return module.Init()
256}
257
Paul Duffinac6e6082019-12-11 15:22:32 +0000258func NewPrebuiltSharedLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
259 module, library := NewPrebuiltLibrary(hod)
260 library.BuildOnlyShared()
261
262 // Prebuilt shared libraries can be included in APEXes
263 android.InitApexModule(module)
Jiyong Park379de2f2018-12-19 02:47:14 +0900264
Leo Li74f7b972017-05-17 11:30:45 -0700265 return module, library
Colin Crossde89fb82017-03-17 13:28:06 -0700266}
267
Patrice Arruda3554a982019-03-27 19:09:10 -0700268// cc_prebuilt_library_static installs a precompiled static library that are
269// listed in the srcs property in the device's directory.
Jooyung Han344d5432019-08-23 11:17:39 +0900270func PrebuiltStaticLibraryFactory() android.Module {
Leo Li74f7b972017-05-17 11:30:45 -0700271 module, _ := NewPrebuiltStaticLibrary(android.HostAndDeviceSupported)
272 return module.Init()
273}
274
275func NewPrebuiltStaticLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
Paul Duffinac6e6082019-12-11 15:22:32 +0000276 module, library := NewPrebuiltLibrary(hod)
Colin Crossde89fb82017-03-17 13:28:06 -0700277 library.BuildOnlyStatic()
Leo Li74f7b972017-05-17 11:30:45 -0700278 return module, library
Colin Crossde89fb82017-03-17 13:28:06 -0700279}
280
Martin Stjernholm0b92ac82020-03-11 21:45:49 +0000281type prebuiltObjectProperties struct {
282 Srcs []string `android:"path,arch_variant"`
283}
284
285type prebuiltObjectLinker struct {
286 android.Prebuilt
287 objectLinker
288
289 properties prebuiltObjectProperties
290}
291
292func (p *prebuiltObjectLinker) prebuilt() *android.Prebuilt {
293 return &p.Prebuilt
294}
295
296var _ prebuiltLinkerInterface = (*prebuiltObjectLinker)(nil)
297
298func (p *prebuiltObjectLinker) link(ctx ModuleContext,
299 flags Flags, deps PathDeps, objs Objects) android.Path {
300 if len(p.properties.Srcs) > 0 {
301 return p.Prebuilt.SingleSourcePath(ctx)
302 }
303 return nil
304}
305
Inseob Kim1042d292020-06-01 23:23:05 +0900306func (p *prebuiltObjectLinker) object() bool {
307 return true
308}
309
Martin Stjernholm0b92ac82020-03-11 21:45:49 +0000310func newPrebuiltObject() *Module {
311 module := newObject()
312 prebuilt := &prebuiltObjectLinker{
313 objectLinker: objectLinker{
314 baseLinker: NewBaseLinker(nil),
315 },
316 }
317 module.linker = prebuilt
318 module.AddProperties(&prebuilt.properties)
319 android.InitPrebuiltModule(module, &prebuilt.properties.Srcs)
320 android.InitSdkAwareModule(module)
321 return module
322}
323
324func prebuiltObjectFactory() android.Module {
325 module := newPrebuiltObject()
326 return module.Init()
327}
328
Colin Crossde89fb82017-03-17 13:28:06 -0700329type prebuiltBinaryLinker struct {
330 *binaryDecorator
331 prebuiltLinker
Martin Stjernholm837ee1a2020-08-20 02:54:52 +0100332
333 toolPath android.OptionalPath
Colin Crossde89fb82017-03-17 13:28:06 -0700334}
335
336var _ prebuiltLinkerInterface = (*prebuiltBinaryLinker)(nil)
337
Martin Stjernholm837ee1a2020-08-20 02:54:52 +0100338func (p *prebuiltBinaryLinker) hostToolPath() android.OptionalPath {
339 return p.toolPath
340}
341
Colin Crossde89fb82017-03-17 13:28:06 -0700342func (p *prebuiltBinaryLinker) link(ctx ModuleContext,
343 flags Flags, deps PathDeps, objs Objects) android.Path {
344 // TODO(ccross): verify shared library dependencies
Colin Cross74d73e22017-08-02 11:05:49 -0700345 if len(p.properties.Srcs) > 0 {
Colin Cross88f6fef2018-09-05 14:20:03 -0700346 fileName := p.getStem(ctx) + flags.Toolchain.ExecutableSuffix()
347 in := p.Prebuilt.SingleSourcePath(ctx)
Martin Stjernholm837ee1a2020-08-20 02:54:52 +0100348 outputFile := android.PathForModuleOut(ctx, fileName)
Colin Crossb60190a2018-09-04 16:28:17 -0700349 p.unstrippedOutputFile = in
350
Martin Stjernholm837ee1a2020-08-20 02:54:52 +0100351 if ctx.Host() {
352 // Host binaries are symlinked to their prebuilt source locations. That
353 // way they are executed directly from there so the linker resolves their
354 // shared library dependencies relative to that location (using
355 // $ORIGIN/../lib(64):$ORIGIN/lib(64) as RUNPATH). This way the prebuilt
356 // repository can supply the expected versions of the shared libraries
357 // without interference from what is in the out tree.
Colin Cross94921e72017-08-08 16:20:15 -0700358
Martin Stjernholm837ee1a2020-08-20 02:54:52 +0100359 // These shared lib paths may point to copies of the libs in
360 // .intermediates, which isn't where the binary will load them from, but
361 // it's fine for dependency tracking. If a library dependency is updated,
362 // the symlink will get a new timestamp, along with any installed symlinks
363 // handled in make.
364 sharedLibPaths := deps.EarlySharedLibs
365 sharedLibPaths = append(sharedLibPaths, deps.SharedLibs...)
366 sharedLibPaths = append(sharedLibPaths, deps.LateSharedLibs...)
367
Martin Stjernholm14ee8322020-09-21 21:45:49 +0100368 var fromPath = in.String()
369 if !filepath.IsAbs(fromPath) {
370 fromPath = "$$PWD/" + fromPath
371 }
372
Martin Stjernholm837ee1a2020-08-20 02:54:52 +0100373 ctx.Build(pctx, android.BuildParams{
374 Rule: android.Symlink,
375 Output: outputFile,
376 Input: in,
377 Implicits: sharedLibPaths,
378 Args: map[string]string{
Martin Stjernholm14ee8322020-09-21 21:45:49 +0100379 "fromPath": fromPath,
Martin Stjernholm837ee1a2020-08-20 02:54:52 +0100380 },
381 })
382
383 p.toolPath = android.OptionalPathForPath(outputFile)
384 } else {
385 if p.stripper.NeedsStrip(ctx) {
386 stripped := android.PathForModuleOut(ctx, "stripped", fileName)
387 p.stripper.StripExecutableOrSharedLib(ctx, in, stripped, flagsToStripFlags(flags))
388 in = stripped
389 }
390
391 // Copy binaries to a name matching the final installed name
392 ctx.Build(pctx, android.BuildParams{
393 Rule: android.CpExecutable,
394 Description: "prebuilt",
395 Output: outputFile,
396 Input: in,
397 })
398 }
Colin Cross94921e72017-08-08 16:20:15 -0700399
400 return outputFile
Colin Crossde89fb82017-03-17 13:28:06 -0700401 }
402
403 return nil
404}
405
Inseob Kim7f283f42020-06-01 21:53:49 +0900406func (p *prebuiltBinaryLinker) binary() bool {
407 return true
408}
409
Patrice Arruda3554a982019-03-27 19:09:10 -0700410// cc_prebuilt_binary installs a precompiled executable in srcs property in the
411// device's directory.
Colin Cross36242852017-06-23 15:06:31 -0700412func prebuiltBinaryFactory() android.Module {
Leo Li74f7b972017-05-17 11:30:45 -0700413 module, _ := NewPrebuiltBinary(android.HostAndDeviceSupported)
414 return module.Init()
415}
416
417func NewPrebuiltBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecorator) {
418 module, binary := NewBinary(hod)
Colin Crossde89fb82017-03-17 13:28:06 -0700419 module.compiler = nil
420
421 prebuilt := &prebuiltBinaryLinker{
422 binaryDecorator: binary,
423 }
424 module.linker = prebuilt
Martin Stjernholm837ee1a2020-08-20 02:54:52 +0100425 module.installer = prebuilt
Colin Crossce75d2c2016-10-06 16:12:58 -0700426
Colin Cross74d73e22017-08-02 11:05:49 -0700427 module.AddProperties(&prebuilt.properties)
428
429 android.InitPrebuiltModule(module, &prebuilt.properties.Srcs)
Leo Li74f7b972017-05-17 11:30:45 -0700430 return module, binary
Colin Crossce75d2c2016-10-06 16:12:58 -0700431}
Evgenii Stepanov2080bfe2020-07-24 15:35:40 -0700432
433type Sanitized struct {
434 None struct {
435 Srcs []string `android:"path,arch_variant"`
436 } `android:"arch_variant"`
437 Address struct {
438 Srcs []string `android:"path,arch_variant"`
439 } `android:"arch_variant"`
440 Hwaddress struct {
441 Srcs []string `android:"path,arch_variant"`
442 } `android:"arch_variant"`
443}
444
445func srcsForSanitizer(sanitize *sanitize, sanitized Sanitized) []string {
446 if sanitize == nil {
447 return nil
448 }
449 if Bool(sanitize.Properties.Sanitize.Address) && sanitized.Address.Srcs != nil {
450 return sanitized.Address.Srcs
451 }
452 if Bool(sanitize.Properties.Sanitize.Hwaddress) && sanitized.Hwaddress.Srcs != nil {
453 return sanitized.Hwaddress.Srcs
454 }
455 return sanitized.None.Srcs
456}