blob: 151b63d2ac982b7631500b52539ce9839591dc24 [file] [log] [blame]
Colin Cross4d9c2d12016-07-29 12:48:20 -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 "strings"
19
20 "github.com/google/blueprint"
Colin Cross26c34ed2016-09-30 17:10:16 -070021 "github.com/google/blueprint/pathtools"
Colin Cross4d9c2d12016-07-29 12:48:20 -070022
Colin Cross4d9c2d12016-07-29 12:48:20 -070023 "android/soong/android"
24)
25
Colin Crossb916a382016-07-29 17:28:03 -070026type LibraryProperties struct {
Colin Cross4d9c2d12016-07-29 12:48:20 -070027 Static struct {
Colin Cross2f336352016-10-26 10:03:47 -070028 Srcs []string `android:"arch_variant"`
29 Cflags []string `android:"arch_variant"`
Colin Cross4d9c2d12016-07-29 12:48:20 -070030
Colin Cross4d9c2d12016-07-29 12:48:20 -070031 Enabled *bool `android:"arch_variant"`
32 Whole_static_libs []string `android:"arch_variant"`
33 Static_libs []string `android:"arch_variant"`
34 Shared_libs []string `android:"arch_variant"`
35 } `android:"arch_variant"`
36 Shared struct {
Colin Cross2f336352016-10-26 10:03:47 -070037 Srcs []string `android:"arch_variant"`
38 Cflags []string `android:"arch_variant"`
Colin Crossb916a382016-07-29 17:28:03 -070039
Colin Cross4d9c2d12016-07-29 12:48:20 -070040 Enabled *bool `android:"arch_variant"`
41 Whole_static_libs []string `android:"arch_variant"`
42 Static_libs []string `android:"arch_variant"`
43 Shared_libs []string `android:"arch_variant"`
44 } `android:"arch_variant"`
45
46 // local file name to pass to the linker as --version_script
47 Version_script *string `android:"arch_variant"`
48 // local file name to pass to the linker as -unexported_symbols_list
49 Unexported_symbols_list *string `android:"arch_variant"`
50 // local file name to pass to the linker as -force_symbols_not_weak_list
51 Force_symbols_not_weak_list *string `android:"arch_variant"`
52 // local file name to pass to the linker as -force_symbols_weak_list
53 Force_symbols_weak_list *string `android:"arch_variant"`
54
55 // rename host libraries to prevent overlap with system installed libraries
56 Unique_host_soname *bool
57
Dan Willemsene1240db2016-11-03 14:28:51 -070058 Aidl struct {
59 // export headers generated from .aidl sources
60 Export_aidl_headers bool
61 }
62
Colin Cross0c461f12016-10-20 16:11:43 -070063 Proto struct {
64 // export headers generated from .proto sources
65 Export_proto_headers bool
66 }
Colin Crossa48ab5b2017-02-14 15:28:44 -080067}
Colin Cross0c461f12016-10-20 16:11:43 -070068
Colin Crossa48ab5b2017-02-14 15:28:44 -080069type LibraryMutatedProperties struct {
Colin Cross4d9c2d12016-07-29 12:48:20 -070070 VariantName string `blueprint:"mutated"`
Colin Crossb916a382016-07-29 17:28:03 -070071
72 // Build a static variant
73 BuildStatic bool `blueprint:"mutated"`
74 // Build a shared variant
75 BuildShared bool `blueprint:"mutated"`
76 // This variant is shared
77 VariantIsShared bool `blueprint:"mutated"`
78 // This variant is static
79 VariantIsStatic bool `blueprint:"mutated"`
80}
81
82type FlagExporterProperties struct {
83 // list of directories relative to the Blueprints file that will
Dan Willemsen273af7f2016-11-03 15:53:42 -070084 // be added to the include path (using -I) for this module and any module that links
Colin Cross5d195602017-10-17 16:15:50 -070085 // against this module. Directories listed in export_include_dirs do not need to be
86 // listed in local_include_dirs.
Colin Crossb916a382016-07-29 17:28:03 -070087 Export_include_dirs []string `android:"arch_variant"`
Dan Willemsen4416e5d2017-04-06 12:43:22 -070088
89 Target struct {
90 Vendor struct {
91 // list of exported include directories, like
92 // export_include_dirs, that will be applied to the
93 // vendor variant of this library. This will overwrite
94 // any other declarations.
95 Export_include_dirs []string
96 }
97 }
Colin Cross4d9c2d12016-07-29 12:48:20 -070098}
99
100func init() {
Colin Cross798bfce2016-10-12 14:28:16 -0700101 android.RegisterModuleType("cc_library_static", libraryStaticFactory)
102 android.RegisterModuleType("cc_library_shared", librarySharedFactory)
103 android.RegisterModuleType("cc_library", libraryFactory)
104 android.RegisterModuleType("cc_library_host_static", libraryHostStaticFactory)
105 android.RegisterModuleType("cc_library_host_shared", libraryHostSharedFactory)
Colin Cross5950f382016-12-13 12:50:57 -0800106 android.RegisterModuleType("cc_library_headers", libraryHeaderFactory)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700107}
108
109// Module factory for combined static + shared libraries, device by default but with possible host
110// support
Colin Cross36242852017-06-23 15:06:31 -0700111func libraryFactory() android.Module {
Colin Crossab3b7322016-12-09 14:46:15 -0800112 module, _ := NewLibrary(android.HostAndDeviceSupported)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700113 return module.Init()
114}
115
116// Module factory for static libraries
Colin Cross36242852017-06-23 15:06:31 -0700117func libraryStaticFactory() android.Module {
Colin Crossab3b7322016-12-09 14:46:15 -0800118 module, library := NewLibrary(android.HostAndDeviceSupported)
119 library.BuildOnlyStatic()
Colin Cross4d9c2d12016-07-29 12:48:20 -0700120 return module.Init()
121}
122
123// Module factory for shared libraries
Colin Cross36242852017-06-23 15:06:31 -0700124func librarySharedFactory() android.Module {
Colin Crossab3b7322016-12-09 14:46:15 -0800125 module, library := NewLibrary(android.HostAndDeviceSupported)
126 library.BuildOnlyShared()
Colin Cross4d9c2d12016-07-29 12:48:20 -0700127 return module.Init()
128}
129
130// Module factory for host static libraries
Colin Cross36242852017-06-23 15:06:31 -0700131func libraryHostStaticFactory() android.Module {
Colin Crossab3b7322016-12-09 14:46:15 -0800132 module, library := NewLibrary(android.HostSupported)
133 library.BuildOnlyStatic()
Colin Cross4d9c2d12016-07-29 12:48:20 -0700134 return module.Init()
135}
136
137// Module factory for host shared libraries
Colin Cross36242852017-06-23 15:06:31 -0700138func libraryHostSharedFactory() android.Module {
Colin Crossab3b7322016-12-09 14:46:15 -0800139 module, library := NewLibrary(android.HostSupported)
140 library.BuildOnlyShared()
Colin Cross4d9c2d12016-07-29 12:48:20 -0700141 return module.Init()
142}
143
Colin Cross5950f382016-12-13 12:50:57 -0800144// Module factory for header-only libraries
Colin Cross36242852017-06-23 15:06:31 -0700145func libraryHeaderFactory() android.Module {
Colin Cross5950f382016-12-13 12:50:57 -0800146 module, library := NewLibrary(android.HostAndDeviceSupported)
147 library.HeaderOnly()
148 return module.Init()
149}
150
Colin Cross4d9c2d12016-07-29 12:48:20 -0700151type flagExporter struct {
152 Properties FlagExporterProperties
153
Dan Willemsen847dcc72016-09-29 12:13:36 -0700154 flags []string
155 flagsDeps android.Paths
Colin Cross4d9c2d12016-07-29 12:48:20 -0700156}
157
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700158func (f *flagExporter) exportedIncludes(ctx ModuleContext) android.Paths {
Jeff Gaston7b6118b2017-10-04 21:07:42 +0000159 if ctx.vndk() && f.Properties.Target.Vendor.Export_include_dirs != nil {
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700160 return android.PathsForModuleSrc(ctx, f.Properties.Target.Vendor.Export_include_dirs)
161 } else {
162 return android.PathsForModuleSrc(ctx, f.Properties.Export_include_dirs)
163 }
164}
165
Colin Cross4d9c2d12016-07-29 12:48:20 -0700166func (f *flagExporter) exportIncludes(ctx ModuleContext, inc string) {
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700167 includeDirs := f.exportedIncludes(ctx)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700168 for _, dir := range includeDirs.Strings() {
169 f.flags = append(f.flags, inc+dir)
170 }
171}
172
173func (f *flagExporter) reexportFlags(flags []string) {
174 f.flags = append(f.flags, flags...)
175}
176
Dan Willemsen847dcc72016-09-29 12:13:36 -0700177func (f *flagExporter) reexportDeps(deps android.Paths) {
178 f.flagsDeps = append(f.flagsDeps, deps...)
179}
180
Colin Cross4d9c2d12016-07-29 12:48:20 -0700181func (f *flagExporter) exportedFlags() []string {
182 return f.flags
183}
184
Dan Willemsen847dcc72016-09-29 12:13:36 -0700185func (f *flagExporter) exportedFlagsDeps() android.Paths {
186 return f.flagsDeps
187}
188
Colin Cross4d9c2d12016-07-29 12:48:20 -0700189type exportedFlagsProducer interface {
190 exportedFlags() []string
Dan Willemsen847dcc72016-09-29 12:13:36 -0700191 exportedFlagsDeps() android.Paths
Colin Cross4d9c2d12016-07-29 12:48:20 -0700192}
193
194var _ exportedFlagsProducer = (*flagExporter)(nil)
195
Colin Crossb916a382016-07-29 17:28:03 -0700196// libraryDecorator wraps baseCompiler, baseLinker and baseInstaller to provide library-specific
197// functionality: static vs. shared linkage, reusing object files for shared libraries
198type libraryDecorator struct {
Colin Crossa48ab5b2017-02-14 15:28:44 -0800199 Properties LibraryProperties
200 MutatedProperties LibraryMutatedProperties
Colin Cross4d9c2d12016-07-29 12:48:20 -0700201
202 // For reusing static library objects for shared library
Colin Cross10d22312017-05-03 11:01:58 -0700203 reuseObjects Objects
204 reuseExportedFlags []string
Colin Crossbbc9f4d2017-05-03 16:24:55 -0700205 reuseExportedDeps android.Paths
Colin Cross10d22312017-05-03 11:01:58 -0700206
Colin Cross26c34ed2016-09-30 17:10:16 -0700207 // table-of-contents file to optimize out relinking when possible
208 tocFile android.OptionalPath
Colin Cross4d9c2d12016-07-29 12:48:20 -0700209
Colin Cross4d9c2d12016-07-29 12:48:20 -0700210 flagExporter
211 stripper
Dan Willemsen394e9dc2016-09-14 15:04:48 -0700212 relocationPacker
Colin Cross4d9c2d12016-07-29 12:48:20 -0700213
Colin Cross4d9c2d12016-07-29 12:48:20 -0700214 // If we're used as a whole_static_lib, our missing dependencies need
215 // to be given
216 wholeStaticMissingDeps []string
217
218 // For whole_static_libs
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700219 objects Objects
Colin Cross4d9c2d12016-07-29 12:48:20 -0700220
221 // Uses the module's name if empty, but can be overridden. Does not include
222 // shlib suffix.
223 libName string
Colin Crossb916a382016-07-29 17:28:03 -0700224
225 sanitize *sanitize
226
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800227 sabi *sabi
228
Dan Willemsen581341d2017-02-09 16:16:31 -0800229 // Output archive of gcno coverage information files
230 coverageOutputFile android.OptionalPath
231
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800232 // linked Source Abi Dump
233 sAbiOutputFile android.OptionalPath
234
235 // Source Abi Diff
236 sAbiDiff android.OptionalPath
237
Colin Crossb916a382016-07-29 17:28:03 -0700238 // Decorated interafaces
239 *baseCompiler
240 *baseLinker
241 *baseInstaller
Colin Cross4d9c2d12016-07-29 12:48:20 -0700242}
243
Colin Crossb916a382016-07-29 17:28:03 -0700244func (library *libraryDecorator) linkerProps() []interface{} {
245 var props []interface{}
246 props = append(props, library.baseLinker.linkerProps()...)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700247 return append(props,
248 &library.Properties,
Colin Crossa48ab5b2017-02-14 15:28:44 -0800249 &library.MutatedProperties,
Colin Cross4d9c2d12016-07-29 12:48:20 -0700250 &library.flagExporter.Properties,
Dan Willemsen394e9dc2016-09-14 15:04:48 -0700251 &library.stripper.StripProperties,
252 &library.relocationPacker.Properties)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700253}
254
Colin Crossb916a382016-07-29 17:28:03 -0700255func (library *libraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
Colin Cross42742b82016-08-01 13:20:05 -0700256 flags = library.baseLinker.linkerFlags(ctx, flags)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700257
Colin Crossb916a382016-07-29 17:28:03 -0700258 // MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because
259 // all code is position independent, and then those warnings get promoted to
260 // errors.
Colin Cross3edeee12017-04-04 12:59:48 -0700261 if !ctx.Windows() {
Colin Crossb916a382016-07-29 17:28:03 -0700262 flags.CFlags = append(flags.CFlags, "-fPIC")
263 }
264
265 if library.static() {
266 flags.CFlags = append(flags.CFlags, library.Properties.Static.Cflags...)
Colin Crossa48ab5b2017-02-14 15:28:44 -0800267 } else if library.shared() {
Colin Crossb916a382016-07-29 17:28:03 -0700268 flags.CFlags = append(flags.CFlags, library.Properties.Shared.Cflags...)
269 }
270
Colin Crossa48ab5b2017-02-14 15:28:44 -0800271 if library.shared() {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700272 libName := library.getLibName(ctx)
273 // GCC for Android assumes that -shared means -Bsymbolic, use -Wl,-shared instead
274 sharedFlag := "-Wl,-shared"
275 if flags.Clang || ctx.Host() {
276 sharedFlag = "-shared"
277 }
278 var f []string
Dan Willemsen01a405a2016-06-13 17:19:03 -0700279 if ctx.toolchain().Bionic() {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700280 f = append(f,
281 "-nostdlib",
282 "-Wl,--gc-sections",
283 )
284 }
285
286 if ctx.Darwin() {
287 f = append(f,
288 "-dynamiclib",
289 "-single_module",
Colin Cross4d9c2d12016-07-29 12:48:20 -0700290 "-install_name @rpath/"+libName+flags.Toolchain.ShlibSuffix(),
291 )
Colin Cross7863cf52016-10-20 10:47:21 -0700292 if ctx.Arch().ArchType == android.X86 {
293 f = append(f,
294 "-read_only_relocs suppress",
295 )
296 }
Colin Cross4d9c2d12016-07-29 12:48:20 -0700297 } else {
298 f = append(f,
299 sharedFlag,
300 "-Wl,-soname,"+libName+flags.Toolchain.ShlibSuffix())
301 }
302
303 flags.LdFlags = append(f, flags.LdFlags...)
304 }
305
306 return flags
307}
308
Dan Willemsen273af7f2016-11-03 15:53:42 -0700309func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags) Flags {
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700310 exportIncludeDirs := library.flagExporter.exportedIncludes(ctx)
Dan Willemsen273af7f2016-11-03 15:53:42 -0700311 if len(exportIncludeDirs) > 0 {
Colin Crossdad8c952017-04-26 14:55:27 -0700312 f := includeDirsToFlags(exportIncludeDirs)
313 flags.GlobalFlags = append(flags.GlobalFlags, f)
314 flags.YasmFlags = append(flags.YasmFlags, f)
Dan Willemsen273af7f2016-11-03 15:53:42 -0700315 }
316
317 return library.baseCompiler.compilerFlags(ctx, flags)
318}
319
Jayant Chowdhary715cac32017-04-20 06:53:59 -0700320func extractExportIncludesFromFlags(flags []string) []string {
321 // This method is used in the generation of rules which produce
322 // abi-dumps for source files. Exported headers are needed to infer the
323 // abi exported by a library and filter out the rest of the abi dumped
324 // from a source. We extract the include flags exported by a library.
325 // This includes the flags exported which are re-exported from static
326 // library dependencies, exported header library dependencies and
Jayant Chowdharyaf6eb712017-08-23 16:08:29 -0700327 // generated header dependencies. -isystem headers are not included
Jayant Chowdhary715cac32017-04-20 06:53:59 -0700328 // since for bionic libraries, abi-filtering is taken care of by version
329 // scripts.
330 var exportedIncludes []string
331 for _, flag := range flags {
332 if strings.HasPrefix(flag, "-I") {
333 exportedIncludes = append(exportedIncludes, flag)
334 }
335 }
336 return exportedIncludes
337}
338
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700339func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
Colin Cross5950f382016-12-13 12:50:57 -0800340 if !library.buildShared() && !library.buildStatic() {
341 if len(library.baseCompiler.Properties.Srcs) > 0 {
342 ctx.PropertyErrorf("srcs", "cc_library_headers must not have any srcs")
343 }
344 if len(library.Properties.Static.Srcs) > 0 {
345 ctx.PropertyErrorf("static.srcs", "cc_library_headers must not have any srcs")
346 }
347 if len(library.Properties.Shared.Srcs) > 0 {
348 ctx.PropertyErrorf("shared.srcs", "cc_library_headers must not have any srcs")
349 }
350 return Objects{}
351 }
Jayant Chowdhary2a966402017-08-07 14:09:45 -0700352 if ctx.createVndkSourceAbiDump() || library.sabi.Properties.CreateSAbiDumps {
Jayant Chowdharya4fce192017-09-06 13:10:03 -0700353 exportIncludeDirs := library.flagExporter.exportedIncludes(ctx)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800354 var SourceAbiFlags []string
355 for _, dir := range exportIncludeDirs.Strings() {
Jayant Chowdhary715cac32017-04-20 06:53:59 -0700356 SourceAbiFlags = append(SourceAbiFlags, "-I"+dir)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800357 }
Jayant Chowdhary715cac32017-04-20 06:53:59 -0700358 for _, reexportedInclude := range extractExportIncludesFromFlags(library.sabi.Properties.ReexportedIncludeFlags) {
359 SourceAbiFlags = append(SourceAbiFlags, reexportedInclude)
360 }
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800361 flags.SAbiFlags = SourceAbiFlags
362 total_length := len(library.baseCompiler.Properties.Srcs) + len(deps.GeneratedSources) + len(library.Properties.Shared.Srcs) +
363 len(library.Properties.Static.Srcs)
364 if total_length > 0 {
365 flags.SAbiDump = true
366 }
367 }
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700368 objs := library.baseCompiler.compile(ctx, flags, deps)
369 library.reuseObjects = objs
Colin Cross2f336352016-10-26 10:03:47 -0700370 buildFlags := flagsToBuilderFlags(flags)
Colin Crossb916a382016-07-29 17:28:03 -0700371
Colin Cross4d9c2d12016-07-29 12:48:20 -0700372 if library.static() {
Colin Cross2f336352016-10-26 10:03:47 -0700373 srcs := android.PathsForModuleSrc(ctx, library.Properties.Static.Srcs)
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700374 objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceStaticLibrary,
375 srcs, library.baseCompiler.deps))
Colin Crossa48ab5b2017-02-14 15:28:44 -0800376 } else if library.shared() {
Colin Cross2f336352016-10-26 10:03:47 -0700377 srcs := android.PathsForModuleSrc(ctx, library.Properties.Shared.Srcs)
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700378 objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceSharedLibrary,
379 srcs, library.baseCompiler.deps))
Colin Crossb916a382016-07-29 17:28:03 -0700380 }
381
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700382 return objs
Colin Crossb916a382016-07-29 17:28:03 -0700383}
384
385type libraryInterface interface {
386 getWholeStaticMissingDeps() []string
387 static() bool
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700388 objs() Objects
Colin Crossbbc9f4d2017-05-03 16:24:55 -0700389 reuseObjs() (Objects, []string, android.Paths)
Colin Cross26c34ed2016-09-30 17:10:16 -0700390 toc() android.OptionalPath
Colin Crossb916a382016-07-29 17:28:03 -0700391
392 // Returns true if the build options for the module have selected a static or shared build
393 buildStatic() bool
394 buildShared() bool
395
396 // Sets whether a specific variant is static or shared
Colin Crossa48ab5b2017-02-14 15:28:44 -0800397 setStatic()
398 setShared()
Colin Crossb916a382016-07-29 17:28:03 -0700399}
400
401func (library *libraryDecorator) getLibName(ctx ModuleContext) string {
402 name := library.libName
403 if name == "" {
Colin Crossce75d2c2016-10-06 16:12:58 -0700404 name = ctx.baseModuleName()
Colin Crossb916a382016-07-29 17:28:03 -0700405 }
406
407 if ctx.Host() && Bool(library.Properties.Unique_host_soname) {
408 if !strings.HasSuffix(name, "-host") {
409 name = name + "-host"
410 }
411 }
412
Colin Crossa48ab5b2017-02-14 15:28:44 -0800413 return name + library.MutatedProperties.VariantName
Colin Crossb916a382016-07-29 17:28:03 -0700414}
415
416func (library *libraryDecorator) linkerInit(ctx BaseModuleContext) {
417 location := InstallInSystem
Vishwath Mohan1dd88392017-03-29 22:00:18 -0700418 if library.sanitize.inSanitizerDir() {
419 location = InstallInSanitizerDir
Colin Crossb916a382016-07-29 17:28:03 -0700420 }
421 library.baseInstaller.location = location
422
423 library.baseLinker.linkerInit(ctx)
Dan Willemsen394e9dc2016-09-14 15:04:48 -0700424
425 library.relocationPacker.packingInit(ctx)
Colin Crossb916a382016-07-29 17:28:03 -0700426}
427
Colin Cross37047f12016-12-13 17:06:13 -0800428func (library *libraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
Colin Crossb916a382016-07-29 17:28:03 -0700429 deps = library.baseLinker.linkerDeps(ctx, deps)
430
431 if library.static() {
432 deps.WholeStaticLibs = append(deps.WholeStaticLibs,
433 library.Properties.Static.Whole_static_libs...)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700434 deps.StaticLibs = append(deps.StaticLibs, library.Properties.Static.Static_libs...)
435 deps.SharedLibs = append(deps.SharedLibs, library.Properties.Static.Shared_libs...)
Colin Crossa48ab5b2017-02-14 15:28:44 -0800436 } else if library.shared() {
Dan Willemsen2e47b342016-11-17 01:02:25 -0800437 if ctx.toolchain().Bionic() && !Bool(library.baseLinker.Properties.Nocrt) {
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700438 if !ctx.sdk() {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700439 deps.CrtBegin = "crtbegin_so"
440 deps.CrtEnd = "crtend_so"
441 } else {
Dan Albertebedf672016-11-08 15:06:22 -0800442 // TODO(danalbert): Add generation of crt objects.
443 // For `sdk_version: "current"`, we don't actually have a
444 // freshly generated set of CRT objects. Use the last stable
445 // version.
446 version := ctx.sdkVersion()
447 if version == "current" {
Jayant Chowdhary6e8115a2017-05-09 10:21:52 -0700448 version = getCurrentNdkPrebuiltVersion(ctx)
Dan Albertebedf672016-11-08 15:06:22 -0800449 }
450 deps.CrtBegin = "ndk_crtbegin_so." + version
451 deps.CrtEnd = "ndk_crtend_so." + version
Colin Cross4d9c2d12016-07-29 12:48:20 -0700452 }
453 }
454 deps.WholeStaticLibs = append(deps.WholeStaticLibs, library.Properties.Shared.Whole_static_libs...)
455 deps.StaticLibs = append(deps.StaticLibs, library.Properties.Shared.Static_libs...)
456 deps.SharedLibs = append(deps.SharedLibs, library.Properties.Shared.Shared_libs...)
457 }
458
459 return deps
460}
461
Colin Crossb916a382016-07-29 17:28:03 -0700462func (library *libraryDecorator) linkStatic(ctx ModuleContext,
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700463 flags Flags, deps PathDeps, objs Objects) android.Path {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700464
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700465 library.objects = deps.WholeStaticLibObjs.Copy()
466 library.objects = library.objects.Append(objs)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700467
468 outputFile := android.PathForModuleOut(ctx,
Colin Crossa48ab5b2017-02-14 15:28:44 -0800469 ctx.ModuleName()+library.MutatedProperties.VariantName+staticLibraryExtension)
Dan Willemsen581341d2017-02-09 16:16:31 -0800470 builderFlags := flagsToBuilderFlags(flags)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700471
Dan Willemsen581341d2017-02-09 16:16:31 -0800472 TransformObjToStaticLib(ctx, library.objects.objFiles, builderFlags, outputFile, objs.tidyFiles)
473
474 library.coverageOutputFile = TransformCoverageFilesToLib(ctx, library.objects, builderFlags,
Colin Crossa48ab5b2017-02-14 15:28:44 -0800475 ctx.ModuleName()+library.MutatedProperties.VariantName)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700476
477 library.wholeStaticMissingDeps = ctx.GetMissingDependencies()
478
479 ctx.CheckbuildFile(outputFile)
480
481 return outputFile
482}
483
Colin Crossb916a382016-07-29 17:28:03 -0700484func (library *libraryDecorator) linkShared(ctx ModuleContext,
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700485 flags Flags, deps PathDeps, objs Objects) android.Path {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700486
487 var linkerDeps android.Paths
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700488 linkerDeps = append(linkerDeps, flags.LdFlagsDeps...)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700489
490 versionScript := android.OptionalPathForModuleSrc(ctx, library.Properties.Version_script)
491 unexportedSymbols := android.OptionalPathForModuleSrc(ctx, library.Properties.Unexported_symbols_list)
492 forceNotWeakSymbols := android.OptionalPathForModuleSrc(ctx, library.Properties.Force_symbols_not_weak_list)
493 forceWeakSymbols := android.OptionalPathForModuleSrc(ctx, library.Properties.Force_symbols_weak_list)
494 if !ctx.Darwin() {
495 if versionScript.Valid() {
496 flags.LdFlags = append(flags.LdFlags, "-Wl,--version-script,"+versionScript.String())
497 linkerDeps = append(linkerDeps, versionScript.Path())
498 }
499 if unexportedSymbols.Valid() {
500 ctx.PropertyErrorf("unexported_symbols_list", "Only supported on Darwin")
501 }
502 if forceNotWeakSymbols.Valid() {
503 ctx.PropertyErrorf("force_symbols_not_weak_list", "Only supported on Darwin")
504 }
505 if forceWeakSymbols.Valid() {
506 ctx.PropertyErrorf("force_symbols_weak_list", "Only supported on Darwin")
507 }
508 } else {
509 if versionScript.Valid() {
510 ctx.PropertyErrorf("version_script", "Not supported on Darwin")
511 }
512 if unexportedSymbols.Valid() {
513 flags.LdFlags = append(flags.LdFlags, "-Wl,-unexported_symbols_list,"+unexportedSymbols.String())
514 linkerDeps = append(linkerDeps, unexportedSymbols.Path())
515 }
516 if forceNotWeakSymbols.Valid() {
517 flags.LdFlags = append(flags.LdFlags, "-Wl,-force_symbols_not_weak_list,"+forceNotWeakSymbols.String())
518 linkerDeps = append(linkerDeps, forceNotWeakSymbols.Path())
519 }
520 if forceWeakSymbols.Valid() {
521 flags.LdFlags = append(flags.LdFlags, "-Wl,-force_symbols_weak_list,"+forceWeakSymbols.String())
522 linkerDeps = append(linkerDeps, forceWeakSymbols.Path())
523 }
524 }
525
526 fileName := library.getLibName(ctx) + flags.Toolchain.ShlibSuffix()
527 outputFile := android.PathForModuleOut(ctx, fileName)
528 ret := outputFile
529
530 builderFlags := flagsToBuilderFlags(flags)
531
Colin Crossd8f8d072017-04-04 13:00:15 -0700532 if !ctx.Darwin() && !ctx.Windows() {
Colin Cross89562dc2016-10-03 17:47:19 -0700533 // Optimize out relinking against shared libraries whose interface hasn't changed by
534 // depending on a table of contents file instead of the library itself.
535 tocPath := outputFile.RelPathString()
536 tocPath = pathtools.ReplaceExtension(tocPath, flags.Toolchain.ShlibSuffix()[1:]+".toc")
537 tocFile := android.PathForOutput(ctx, tocPath)
538 library.tocFile = android.OptionalPathForPath(tocFile)
539 TransformSharedObjectToToc(ctx, outputFile, tocFile, builderFlags)
540 }
541
Dan Willemsen394e9dc2016-09-14 15:04:48 -0700542 if library.relocationPacker.needsPacking(ctx) {
543 packedOutputFile := outputFile
544 outputFile = android.PathForModuleOut(ctx, "unpacked", fileName)
545 library.relocationPacker.pack(ctx, outputFile, packedOutputFile, builderFlags)
546 }
547
Colin Cross4d9c2d12016-07-29 12:48:20 -0700548 if library.stripper.needsStrip(ctx) {
549 strippedOutputFile := outputFile
550 outputFile = android.PathForModuleOut(ctx, "unstripped", fileName)
551 library.stripper.strip(ctx, outputFile, strippedOutputFile, builderFlags)
552 }
553
554 sharedLibs := deps.SharedLibs
555 sharedLibs = append(sharedLibs, deps.LateSharedLibs...)
556
Dan Albertd015c4a2016-08-10 14:34:08 -0700557 // TODO(danalbert): Clean this up when soong supports prebuilts.
558 if strings.HasPrefix(ctx.selectedStl(), "ndk_libc++") {
559 libDir := getNdkStlLibDir(ctx, flags.Toolchain, "libc++")
560
561 if strings.HasSuffix(ctx.selectedStl(), "_shared") {
562 deps.StaticLibs = append(deps.StaticLibs,
563 libDir.Join(ctx, "libandroid_support.a"))
564 } else {
565 deps.StaticLibs = append(deps.StaticLibs,
566 libDir.Join(ctx, "libc++abi.a"),
567 libDir.Join(ctx, "libandroid_support.a"))
568 }
569
570 if ctx.Arch().ArchType == android.Arm {
571 deps.StaticLibs = append(deps.StaticLibs,
572 libDir.Join(ctx, "libunwind.a"))
573 }
574 }
575
Colin Cross26c34ed2016-09-30 17:10:16 -0700576 linkerDeps = append(linkerDeps, deps.SharedLibsDeps...)
577 linkerDeps = append(linkerDeps, deps.LateSharedLibsDeps...)
Dan Willemsena03cf6d2016-09-26 15:45:04 -0700578 linkerDeps = append(linkerDeps, objs.tidyFiles...)
Colin Cross26c34ed2016-09-30 17:10:16 -0700579
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700580 TransformObjToDynamicBinary(ctx, objs.objFiles, sharedLibs,
Colin Cross4d9c2d12016-07-29 12:48:20 -0700581 deps.StaticLibs, deps.LateStaticLibs, deps.WholeStaticLibs,
582 linkerDeps, deps.CrtBegin, deps.CrtEnd, false, builderFlags, outputFile)
583
Dan Willemsen581341d2017-02-09 16:16:31 -0800584 objs.coverageFiles = append(objs.coverageFiles, deps.StaticLibObjs.coverageFiles...)
585 objs.coverageFiles = append(objs.coverageFiles, deps.WholeStaticLibObjs.coverageFiles...)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800586
587 objs.sAbiDumpFiles = append(objs.sAbiDumpFiles, deps.StaticLibObjs.sAbiDumpFiles...)
588 objs.sAbiDumpFiles = append(objs.sAbiDumpFiles, deps.WholeStaticLibObjs.sAbiDumpFiles...)
589
Dan Willemsen581341d2017-02-09 16:16:31 -0800590 library.coverageOutputFile = TransformCoverageFilesToLib(ctx, objs, builderFlags, library.getLibName(ctx))
Jayant Chowdhary6ab3d842017-06-26 12:52:58 -0700591 library.linkSAbiDumpFiles(ctx, objs, fileName, ret)
Dan Willemsen581341d2017-02-09 16:16:31 -0800592
Colin Cross4d9c2d12016-07-29 12:48:20 -0700593 return ret
594}
595
Jayant Chowdhary6ab3d842017-06-26 12:52:58 -0700596func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objects, fileName string, soFile android.Path) {
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800597 //Also take into account object re-use.
Justin Yun8effde42017-06-23 19:24:43 +0900598 if len(objs.sAbiDumpFiles) > 0 && ctx.createVndkSourceAbiDump() {
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800599 refSourceDumpFile := android.PathForVndkRefAbiDump(ctx, "current", fileName, vndkVsNdk(ctx), true)
600 versionScript := android.OptionalPathForModuleSrc(ctx, library.Properties.Version_script)
601 var symbolFile android.OptionalPath
602 if versionScript.Valid() {
603 symbolFile = versionScript
604 }
Jayant Chowdharya4fce192017-09-06 13:10:03 -0700605 exportIncludeDirs := library.flagExporter.exportedIncludes(ctx)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800606 var SourceAbiFlags []string
607 for _, dir := range exportIncludeDirs.Strings() {
Jayant Chowdhary715cac32017-04-20 06:53:59 -0700608 SourceAbiFlags = append(SourceAbiFlags, "-I"+dir)
609 }
610 for _, reexportedInclude := range extractExportIncludesFromFlags(library.sabi.Properties.ReexportedIncludeFlags) {
611 SourceAbiFlags = append(SourceAbiFlags, reexportedInclude)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800612 }
613 exportedHeaderFlags := strings.Join(SourceAbiFlags, " ")
Jayant Chowdhary6ab3d842017-06-26 12:52:58 -0700614 library.sAbiOutputFile = TransformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, soFile, symbolFile, "current", fileName, exportedHeaderFlags)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800615 if refSourceDumpFile.Valid() {
Jayant Chowdhary715cac32017-04-20 06:53:59 -0700616 unzippedRefDump := UnzipRefDump(ctx, refSourceDumpFile.Path(), fileName)
617 library.sAbiDiff = SourceAbiDiff(ctx, library.sAbiOutputFile.Path(), unzippedRefDump, fileName)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800618 }
619 }
620}
621
622func vndkVsNdk(ctx ModuleContext) bool {
Jiyong Parkab0fd5f2017-08-03 21:22:50 +0900623 if inList(ctx.baseModuleName(), llndkLibraries) {
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800624 return false
625 }
626 return true
627}
628
Colin Crossb916a382016-07-29 17:28:03 -0700629func (library *libraryDecorator) link(ctx ModuleContext,
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700630 flags Flags, deps PathDeps, objs Objects) android.Path {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700631
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700632 objs = objs.Append(deps.Objs)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700633 var out android.Path
Colin Crossa48ab5b2017-02-14 15:28:44 -0800634 if library.static() || library.header() {
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700635 out = library.linkStatic(ctx, flags, deps, objs)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700636 } else {
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700637 out = library.linkShared(ctx, flags, deps, objs)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700638 }
639
640 library.exportIncludes(ctx, "-I")
641 library.reexportFlags(deps.ReexportedFlags)
Dan Willemsen847dcc72016-09-29 12:13:36 -0700642 library.reexportDeps(deps.ReexportedFlagsDeps)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700643
Dan Willemsene1240db2016-11-03 14:28:51 -0700644 if library.Properties.Aidl.Export_aidl_headers {
645 if library.baseCompiler.hasSrcExt(".aidl") {
Colin Cross10d22312017-05-03 11:01:58 -0700646 flags := []string{
Dan Willemsene1240db2016-11-03 14:28:51 -0700647 "-I" + android.PathForModuleGen(ctx, "aidl").String(),
Colin Cross10d22312017-05-03 11:01:58 -0700648 }
649 library.reexportFlags(flags)
650 library.reuseExportedFlags = append(library.reuseExportedFlags, flags...)
Dan Willemsene1240db2016-11-03 14:28:51 -0700651 library.reexportDeps(library.baseCompiler.deps) // TODO: restrict to aidl deps
Colin Crossbbc9f4d2017-05-03 16:24:55 -0700652 library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.deps...)
Dan Willemsene1240db2016-11-03 14:28:51 -0700653 }
654 }
655
656 if library.Properties.Proto.Export_proto_headers {
657 if library.baseCompiler.hasSrcExt(".proto") {
Colin Cross10d22312017-05-03 11:01:58 -0700658 flags := []string{
Colin Cross38f794e2017-09-07 10:53:07 -0700659 "-I" + android.ProtoSubDir(ctx).String(),
660 "-I" + android.ProtoDir(ctx).String(),
Colin Cross10d22312017-05-03 11:01:58 -0700661 }
662 library.reexportFlags(flags)
663 library.reuseExportedFlags = append(library.reuseExportedFlags, flags...)
Colin Cross0c461f12016-10-20 16:11:43 -0700664 library.reexportDeps(library.baseCompiler.deps) // TODO: restrict to proto deps
Colin Crossbbc9f4d2017-05-03 16:24:55 -0700665 library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.deps...)
Colin Cross0c461f12016-10-20 16:11:43 -0700666 }
667 }
668
Colin Cross4d9c2d12016-07-29 12:48:20 -0700669 return out
670}
671
Colin Crossb916a382016-07-29 17:28:03 -0700672func (library *libraryDecorator) buildStatic() bool {
Colin Crossa48ab5b2017-02-14 15:28:44 -0800673 return library.MutatedProperties.BuildStatic &&
Colin Cross4d9c2d12016-07-29 12:48:20 -0700674 (library.Properties.Static.Enabled == nil || *library.Properties.Static.Enabled)
675}
676
Colin Crossb916a382016-07-29 17:28:03 -0700677func (library *libraryDecorator) buildShared() bool {
Colin Crossa48ab5b2017-02-14 15:28:44 -0800678 return library.MutatedProperties.BuildShared &&
Colin Cross4d9c2d12016-07-29 12:48:20 -0700679 (library.Properties.Shared.Enabled == nil || *library.Properties.Shared.Enabled)
680}
681
Colin Crossb916a382016-07-29 17:28:03 -0700682func (library *libraryDecorator) getWholeStaticMissingDeps() []string {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700683 return library.wholeStaticMissingDeps
684}
685
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700686func (library *libraryDecorator) objs() Objects {
687 return library.objects
Colin Cross4d9c2d12016-07-29 12:48:20 -0700688}
689
Colin Crossbbc9f4d2017-05-03 16:24:55 -0700690func (library *libraryDecorator) reuseObjs() (Objects, []string, android.Paths) {
691 return library.reuseObjects, library.reuseExportedFlags, library.reuseExportedDeps
Colin Cross4d9c2d12016-07-29 12:48:20 -0700692}
693
Colin Cross26c34ed2016-09-30 17:10:16 -0700694func (library *libraryDecorator) toc() android.OptionalPath {
695 return library.tocFile
696}
697
Colin Crossb916a382016-07-29 17:28:03 -0700698func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
Colin Crossc43ae772017-04-14 15:42:53 -0700699 if library.shared() {
Justin Yun8effde42017-06-23 19:24:43 +0900700 if ctx.Device() {
Jeff Gaston7b6118b2017-10-04 21:07:42 +0000701 if ctx.vndk() {
Justin Yun8effde42017-06-23 19:24:43 +0900702 if ctx.isVndkSp() {
703 library.baseInstaller.subDir = "vndk-sp"
704 } else if ctx.isVndk() {
705 library.baseInstaller.subDir = "vndk"
706 }
707 }
708 }
Colin Cross4d9c2d12016-07-29 12:48:20 -0700709 library.baseInstaller.install(ctx, file)
710 }
711}
712
Colin Crossb916a382016-07-29 17:28:03 -0700713func (library *libraryDecorator) static() bool {
Colin Crossa48ab5b2017-02-14 15:28:44 -0800714 return library.MutatedProperties.VariantIsStatic
Colin Cross4d9c2d12016-07-29 12:48:20 -0700715}
716
Colin Crossa48ab5b2017-02-14 15:28:44 -0800717func (library *libraryDecorator) shared() bool {
718 return library.MutatedProperties.VariantIsShared
719}
720
721func (library *libraryDecorator) header() bool {
722 return !library.static() && !library.shared()
723}
724
725func (library *libraryDecorator) setStatic() {
726 library.MutatedProperties.VariantIsStatic = true
727 library.MutatedProperties.VariantIsShared = false
728}
729
730func (library *libraryDecorator) setShared() {
731 library.MutatedProperties.VariantIsStatic = false
732 library.MutatedProperties.VariantIsShared = true
Colin Crossb916a382016-07-29 17:28:03 -0700733}
734
Colin Crossab3b7322016-12-09 14:46:15 -0800735func (library *libraryDecorator) BuildOnlyStatic() {
Colin Crossa48ab5b2017-02-14 15:28:44 -0800736 library.MutatedProperties.BuildShared = false
Colin Crossab3b7322016-12-09 14:46:15 -0800737}
738
739func (library *libraryDecorator) BuildOnlyShared() {
Colin Crossa48ab5b2017-02-14 15:28:44 -0800740 library.MutatedProperties.BuildStatic = false
Colin Crossab3b7322016-12-09 14:46:15 -0800741}
742
Colin Cross5950f382016-12-13 12:50:57 -0800743func (library *libraryDecorator) HeaderOnly() {
Colin Crossa48ab5b2017-02-14 15:28:44 -0800744 library.MutatedProperties.BuildShared = false
745 library.MutatedProperties.BuildStatic = false
Colin Cross5950f382016-12-13 12:50:57 -0800746}
747
Colin Crossab3b7322016-12-09 14:46:15 -0800748func NewLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700749 module := newModule(hod, android.MultilibBoth)
750
Colin Crossb916a382016-07-29 17:28:03 -0700751 library := &libraryDecorator{
Colin Crossa48ab5b2017-02-14 15:28:44 -0800752 MutatedProperties: LibraryMutatedProperties{
Colin Crossab3b7322016-12-09 14:46:15 -0800753 BuildShared: true,
754 BuildStatic: true,
Colin Cross4d9c2d12016-07-29 12:48:20 -0700755 },
Colin Crossb916a382016-07-29 17:28:03 -0700756 baseCompiler: NewBaseCompiler(),
757 baseLinker: NewBaseLinker(),
758 baseInstaller: NewBaseInstaller("lib", "lib64", InstallInSystem),
759 sanitize: module.sanitize,
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800760 sabi: module.sabi,
Colin Cross4d9c2d12016-07-29 12:48:20 -0700761 }
762
Colin Crossb916a382016-07-29 17:28:03 -0700763 module.compiler = library
764 module.linker = library
765 module.installer = library
766
767 return module, library
768}
769
Colin Cross10d22312017-05-03 11:01:58 -0700770// connects a shared library to a static library in order to reuse its .o files to avoid
771// compiling source files twice.
772func reuseStaticLibrary(mctx android.BottomUpMutatorContext, static, shared *Module) {
773 if staticCompiler, ok := static.compiler.(*libraryDecorator); ok {
774 sharedCompiler := shared.compiler.(*libraryDecorator)
775 if len(staticCompiler.Properties.Static.Cflags) == 0 &&
776 len(sharedCompiler.Properties.Shared.Cflags) == 0 {
777
778 mctx.AddInterVariantDependency(reuseObjTag, shared, static)
779 sharedCompiler.baseCompiler.Properties.OriginalSrcs =
780 sharedCompiler.baseCompiler.Properties.Srcs
781 sharedCompiler.baseCompiler.Properties.Srcs = nil
782 sharedCompiler.baseCompiler.Properties.Generated_sources = nil
783 }
784 }
785}
786
Colin Crossb916a382016-07-29 17:28:03 -0700787func linkageMutator(mctx android.BottomUpMutatorContext) {
788 if m, ok := mctx.Module().(*Module); ok && m.linker != nil {
789 if library, ok := m.linker.(libraryInterface); ok {
790 var modules []blueprint.Module
791 if library.buildStatic() && library.buildShared() {
792 modules = mctx.CreateLocalVariations("static", "shared")
793 static := modules[0].(*Module)
794 shared := modules[1].(*Module)
795
Colin Crossa48ab5b2017-02-14 15:28:44 -0800796 static.linker.(libraryInterface).setStatic()
797 shared.linker.(libraryInterface).setShared()
Colin Crossb916a382016-07-29 17:28:03 -0700798
Colin Cross10d22312017-05-03 11:01:58 -0700799 reuseStaticLibrary(mctx, static, shared)
800
Colin Crossb916a382016-07-29 17:28:03 -0700801 } else if library.buildStatic() {
802 modules = mctx.CreateLocalVariations("static")
Colin Crossa48ab5b2017-02-14 15:28:44 -0800803 modules[0].(*Module).linker.(libraryInterface).setStatic()
Colin Crossb916a382016-07-29 17:28:03 -0700804 } else if library.buildShared() {
805 modules = mctx.CreateLocalVariations("shared")
Colin Crossa48ab5b2017-02-14 15:28:44 -0800806 modules[0].(*Module).linker.(libraryInterface).setShared()
Colin Crossb916a382016-07-29 17:28:03 -0700807 }
808 }
809 }
Colin Cross4d9c2d12016-07-29 12:48:20 -0700810}