Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions go/private/actions/archive.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ def emit_archive(go, source = None, _recompile_suffix = "", recompile_internal_d
importpath, _ = effective_importpath_pkgpath(source)

cgo_out_dir = None
headers = depset(
direct = [f for f in source.srcs if f.path.split(".")[-1].lower().startswith("h")],
transitive = [a._headers for a in direct],
)

if source.cgo and not go.mode.pure:
cgo_out_dir = go.declare_directory(go, path = out_lib.basename + ".cgo")

Expand Down Expand Up @@ -116,6 +121,7 @@ def emit_archive(go, source = None, _recompile_suffix = "", recompile_internal_d
importpath = importpath,
importmap = importmap,
archives = direct,
headers = headers,
out_lib = out_lib,
out_export = out_export,
out_facts = out_facts,
Expand Down Expand Up @@ -146,6 +152,7 @@ def emit_archive(go, source = None, _recompile_suffix = "", recompile_internal_d
importpath = importpath,
importmap = importmap,
archives = direct,
headers = headers,
out_lib = out_lib,
out_export = out_export,
out_facts = out_facts,
Expand Down Expand Up @@ -217,4 +224,5 @@ def emit_archive(go, source = None, _recompile_suffix = "", recompile_internal_d
cgo_deps = depset(transitive = [cgo_deps] + [a.cgo_deps for a in direct]),
cgo_exports = cgo_exports,
runfiles = runfiles,
_headers = headers,
)
3 changes: 2 additions & 1 deletion go/private/actions/compilepkg.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def emit_compilepkg(
importpath = "",
importmap = "",
archives = [],
headers = depset(),
cgo = False,
cgo_inputs = depset(),
cgo_out_dir = None,
Expand Down Expand Up @@ -95,7 +96,7 @@ def emit_compilepkg(
sdk = go.sdk
inputs_direct = (sources + embedsrcs + [sdk.package_list] +
[archive.data.export_file for archive in archives])
inputs_transitive = [sdk.headers, sdk.tools, go.stdlib.libs]
inputs_transitive = [sdk.headers, sdk.tools, go.stdlib.libs, headers]
outputs = [out_lib, out_export]

shared_args = go.builder_args(go, use_path_mapping = True)
Expand Down
1 change: 1 addition & 0 deletions go/private/rules/test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ def _recompile_external_deps(go, external_go_info, internal_archive, library_lab
cgo_exports = depset(transitive = [a.cgo_exports for a in deps]),
runfiles = go_info.runfiles,
mode = go.mode,
_headers = internal_archive._headers,
)
label_to_archive[label] = archive

Expand Down
11 changes: 11 additions & 0 deletions tests/core/transitive_headers/a/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
load("//go:def.bzl", "go_library")

go_library(
name = "a",
srcs = [
"a.go",
"a.s",
],
deps = ["//tests/core/transitive_headers/b"],
importpath = "github.com/bazelbuild/rules_go/tests/core/transitive_headers/a",
)
1 change: 1 addition & 0 deletions tests/core/transitive_headers/a/a.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package a
1 change: 1 addition & 0 deletions tests/core/transitive_headers/a/a.s
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../b/b.h"
12 changes: 12 additions & 0 deletions tests/core/transitive_headers/b/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
load("//go:def.bzl", "go_library")

go_library(
name = "b",
srcs = [
"b.go",
"b.h",
],
deps = ["//tests/core/transitive_headers/c"],
importpath = "github.com/bazelbuild/rules_go/tests/core/transitive_headers/b",
visibility = ["//visibility:public"],
)
1 change: 1 addition & 0 deletions tests/core/transitive_headers/b/b.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package b
1 change: 1 addition & 0 deletions tests/core/transitive_headers/b/b.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../c/c.h"
11 changes: 11 additions & 0 deletions tests/core/transitive_headers/c/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
load("//go:def.bzl", "go_library")

go_library(
name = "c",
srcs = [
"c.go",
"c.h",
],
importpath = "github.com/bazelbuild/rules_go/tests/core/transitive_headers/c",
visibility = ["//visibility:public"],
)
1 change: 1 addition & 0 deletions tests/core/transitive_headers/c/c.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package c
Empty file.