Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally depend on libstdcxx for windows #383

Merged
merged 1 commit into from
Jul 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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