From 9eefed9ab912f1c772f5f242461dde683757e0fd Mon Sep 17 00:00:00 2001 From: John Shahid Date: Mon, 10 Apr 2023 08:47:21 -0700 Subject: [PATCH] Add include dirs to the CGO command line arguments (#134) Summary: Pull Request resolved: https://github.com/facebook/buck2/pull/134 X-link: https://github.com/facebook/buck2-prelude/pull/8 X-link: https://github.com/facebook/ocamlrep/pull/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 --- prelude/go/cgo_library.bzl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/prelude/go/cgo_library.bzl b/prelude/go/cgo_library.bzl index b3f0cf2b456b..6caf10e8c803 100644 --- a/prelude/go/cgo_library.bzl +++ b/prelude/go/cgo_library.bzl @@ -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" @@ -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"))