Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abi hdrs from deps #166

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions build_defs/go.build_defs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,14 @@ def go_library(name:str, srcs:list, resources:list=[], asm_srcs:list=None, hdrs:
private = out.startswith('_')
package_path = _get_import_path(package, import_path)

hdrs_rule = filegroup(
name = name,
tag = "hdrs",
srcs = hdrs,
visibility = visibility,
test_only = test_only,
)

if _module:
# We're in a module, create a modinfo file identifying it
modinfo = build_rule(
Expand Down Expand Up @@ -339,12 +347,20 @@ def go_library(name:str, srcs:list, resources:list=[], asm_srcs:list=None, hdrs:
# a subdirectory for go to be able to transparently import them.
src_labels += [f'link:plz-out/go/src/$PKG/{libname}']
if asm_srcs:
transitive_headers = filegroup(
name = name,
tag = "transitive_hdrs",
exported_deps = deps,
requires = ["hdrs"],
needs_transitive_deps = True,
test_only = test_only,
)
abi_rule = build_rule(
name = name,
tag = 'abi',
srcs = {
'asm': asm_srcs,
'hdrs': hdrs,
'hdrs': [hdrs_rule],
},
outs = [name + '.abi'],
building_description = 'Creating ABI...',
Expand All @@ -356,6 +372,7 @@ def go_library(name:str, srcs:list, resources:list=[], asm_srcs:list=None, hdrs:
tools=[CONFIG.GO.GO_TOOL],
test_only = test_only,
labels=labels,
deps = [transitive_headers],
)
lib_rule = go_library(
name = f'_{name}#lib',
Expand All @@ -369,15 +386,16 @@ def go_library(name:str, srcs:list, resources:list=[], asm_srcs:list=None, hdrs:
_needs_transitive_deps = _needs_transitive_deps,
_all_srcs = _all_srcs,
_generate_import_config=False,
labels=labels,
labels=labels + ["foo"],
import_path=package_path,
)
deps += [lib_rule]
asm_rule = build_rule(
name = name,
tag = 'asm',
srcs = {
'asm': asm_srcs,
'hdrs': hdrs,
'hdrs': [hdrs_rule],
'goasm': [lib_rule + '|h'],
},
outs = [name + '.o'],
Expand All @@ -390,8 +408,9 @@ def go_library(name:str, srcs:list, resources:list=[], asm_srcs:list=None, hdrs:
tools=[CONFIG.GO.GO_TOOL],
test_only = test_only,
labels=labels,
deps = [transitive_headers],
)
provides = {'go': ':' + name, 'go_src': lib_rule, 'modinfo': modinfo}
provides = {'go': ':' + name, 'go_src': lib_rule, 'modinfo': modinfo, 'hdrs': hdrs_rule}
if cover and not CONFIG.GO.COVERAGEREDESIGN:
provides['cover_vars'] = cover_vars
return build_rule(
Expand Down Expand Up @@ -456,13 +475,13 @@ def go_library(name:str, srcs:list, resources:list=[], asm_srcs:list=None, hdrs:
if pgo_file:
srcs['pgo'] = [pgo_file]

provides = {'go': ':' + name, 'go_src': src_rule, 'modinfo': modinfo}
provides = {'go': ':' + name, 'go_src': src_rule, 'modinfo': modinfo, 'hdrs': hdrs_rule}
if cover and not CONFIG.GO.COVERAGEREDESIGN:
provides['cover_vars'] = cover_vars
return build_rule(
name = name,
srcs = srcs,
deps = deps,
deps = deps + [hdrs_rule],
internal_deps = [src_rule],
outs = outs,
cmd = _go_library_cmds(import_path=package_path, complete=complete, all_srcs=_all_srcs, cover=cover, filter_srcs=filter_srcs, abi=_abi, embedcfg=embedcfg, pgo_file=pgo_file),
Expand Down
Loading