Skip to content

Commit

Permalink
Optionally depend on libstdxx for windows (#383)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jalal El Mansouri committed Jul 27, 2020
1 parent 7004ca3 commit fdf9655
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions bindgen/bindgen.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -93,26 +93,31 @@ def _rust_bindgen_impl(ctx):
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(
[header],
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],
)
Expand Down

0 comments on commit fdf9655

Please sign in to comment.