Skip to content

Commit

Permalink
Add include dirs to the CGO command line arguments (facebook#134)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#134

X-link: facebook/buck2-prelude#8

X-link: facebook/ocamlrep#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: 56f4f804f58437008339c9bea63cacff1800d0d9
  • Loading branch information
jvshahid authored and facebook-github-bot committed Apr 10, 2023
1 parent 0d74a2c commit 9eefed9
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 9eefed9

Please sign in to comment.