Optionally depend on libstdxx for windows (#383)
diff --git a/bindgen/bindgen.bzl b/bindgen/bindgen.bzl
index ea7fb3f..05302ca 100644
--- a/bindgen/bindgen.bzl
+++ b/bindgen/bindgen.bzl
@@ -93,6 +93,16 @@
args.add_all(quote_include_directories, before_each = "-iquote")
args.add_all(system_include_directories, before_each = "-isystem")
args.add_all(clang_args)
+
+ env = {
+ "RUST_BACKTRACE": "1",
+ "CLANG_PATH": clang_bin.path,
+ "LIBCLANG_PATH": libclang_dir,
+ }
+
+ if libstdcxx:
+ env["LD_LIBRARY_PATH"] = ":".join([f.dirname for f in get_libs_for_static_executable(libstdcxx).to_list()])
+
ctx.actions.run(
executable = bindgen_bin,
inputs = depset(
@@ -100,19 +110,14 @@
transitive = [
cc_lib[CcInfo].compilation_context.headers,
get_libs_for_static_executable(libclang),
+ ] + [
get_libs_for_static_executable(libstdcxx),
- ],
+ ] if libstdcxx else [],
),
outputs = [unformatted_output],
mnemonic = "RustBindgen",
progress_message = "Generating bindings for {}..".format(header.path),
- env = {
- "RUST_BACKTRACE": "1",
- "CLANG_PATH": clang_bin.path,
- # Bindgen loads libclang at runtime, which also needs libstdc++, so we setup LD_LIBRARY_PATH
- "LIBCLANG_PATH": libclang_dir,
- "LD_LIBRARY_PATH": ":".join([f.dirname for f in get_libs_for_static_executable(libstdcxx).to_list()]),
- },
+ env = env,
arguments = [args],
tools = [clang_bin],
)