-
Notifications
You must be signed in to change notification settings - Fork 197
/
go_exported_library.bzl
46 lines (44 loc) · 1.38 KB
/
go_exported_library.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under both the MIT license found in the
# LICENSE-MIT file in the root directory of this source tree and the Apache
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory
# of this source tree.
load(
"@prelude//linking:link_info.bzl",
"LinkStyle",
)
load(
"@prelude//utils:utils.bzl",
"map_val",
"value_or",
)
load(":compile.bzl", "compile", "get_filtered_srcs")
load(":link.bzl", "GoBuildMode", "link")
def go_exported_library_impl(ctx: AnalysisContext) -> list[Provider]:
lib = compile(
ctx,
"main",
get_filtered_srcs(ctx, ctx.attrs.srcs),
deps = ctx.attrs.deps,
compile_flags = ctx.attrs.compiler_flags,
shared = True,
race = ctx.attrs._race,
)
(bin, runtime_files, _external_debug_info) = link(
ctx,
lib,
deps = ctx.attrs.deps,
build_mode = GoBuildMode(ctx.attrs.build_mode),
link_style = value_or(map_val(LinkStyle, ctx.attrs.link_style), LinkStyle("static_pic")),
linker_flags = ctx.attrs.linker_flags,
external_linker_flags = ctx.attrs.external_linker_flags,
shared = True,
race = ctx.attrs._race,
)
return [
DefaultInfo(
default_output = bin,
other_outputs = runtime_files,
),
]