Skip to content

Commit

Permalink
Add include dirs to the CGO command line arguments (#134)
Browse files Browse the repository at this point in the history
Summary:
X-link: facebook/buck2#134

X-link: facebook/buck2-prelude#8

Pull Request resolved: #23

Without the include dirs, the cgo command won't be able to find the header files causing `buck2 build` to fail.

Differential Revision: D44788778

fbshipit-source-id: 973def0e23995be04f7ba05fc02e73365d15627d
  • Loading branch information
jvshahid authored and facebook-github-bot committed Apr 10, 2023
1 parent 5cf8922 commit fd157b8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions prelude/go/cgo_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def _cgo(

pre = cxx_merge_cpreprocessors(ctx, own_pre, inherited_pre)
pre_args = pre.set.project_as_args("args")
pre_include_dirs = pre.set.project_as_args("include_dirs")

gen_dir = "cgo_gen"

Expand Down Expand Up @@ -96,6 +97,7 @@ def _cgo(
args.add(cmd_args(go_srcs[0].as_output(), format = "--output={}/.."))
args.add(cmd_args(cxx_toolchain.c_compiler_info.preprocessor, format = "--cpp={}"))
args.add(cmd_args(pre_args, format = "--cpp={}"))
args.add(cmd_args(pre_include_dirs, format = "--cpp={}"))
args.add(srcs)

argsfile = ctx.actions.declare_output(paths.join(gen_dir, ".cgo.argsfile"))
Expand Down

0 comments on commit fd157b8

Please sign in to comment.