-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create symlinks to ambiguous native dependencies (#1148)
Co-authored-by: cfredric <cfredric@chromium.org> Co-authored-by: Chris Fredrickson <cfredric@users.noreply.github.com>
- Loading branch information
1 parent
4a4d217
commit 5591596
Showing
12 changed files
with
255 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
load("@rules_cc//cc:defs.bzl", "cc_library") | ||
load("@rules_rust//rust:defs.bzl", "rust_binary") | ||
|
||
# A rust_binary that depends on two native libs with the same name. | ||
# See https://github.com/bazelbuild/rules_rust/issues/840. | ||
rust_binary( | ||
name = "bin_with_same_name_deps", | ||
srcs = ["bin.rs"], | ||
deps = [ | ||
"//ambiguous_deps/x:exc", | ||
"//ambiguous_deps/y:exc", | ||
], | ||
) | ||
|
||
# A rust_binary that depends on a native library with a name that doesn't | ||
# match the `lib<name>.a` pattern on linux. | ||
rust_binary( | ||
name = "nonstandard_name_bin", | ||
srcs = ["nonstandard_name_bin.rs"], | ||
deps = [":nonstandard_name_intermediate"], | ||
) | ||
|
||
cc_library( | ||
name = "nonstandard_name_cc_lib", | ||
srcs = ["cc_library_with_func.cc"], | ||
) | ||
|
||
genrule( | ||
name = "nonstandard_name_gen", | ||
srcs = [":nonstandard_name_cc_lib"], | ||
outs = ["nonstandard_name_gen.a"], | ||
# Copy the first member (libnonstandard_name_cc_lib.a) from the srcs to the | ||
# output nonstandard_name_gen.a. | ||
cmd = "cp $$(awk '{print $$1}' <<< '$(SRCS)') $@", | ||
) | ||
|
||
cc_library( | ||
name = "nonstandard_name_intermediate", | ||
srcs = [":nonstandard_name_gen.a"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use std::os::raw::c_int; | ||
|
||
extern "C" { | ||
pub fn cx() -> c_int; | ||
pub fn cy() -> c_int; | ||
} | ||
|
||
fn main() { | ||
println!("hi {} {}", unsafe { cx() }, unsafe { cy() }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
extern "C" int func() { | ||
return 123; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use std::os::raw::c_int; | ||
|
||
extern "C" { | ||
pub fn func() -> c_int; | ||
} | ||
|
||
fn main() { | ||
println!("hi {}", unsafe { func() }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
load("@rules_cc//cc:defs.bzl", "cc_library") | ||
|
||
cc_library( | ||
name = "exc", | ||
srcs = ["exc.cc"], | ||
visibility = ["//ambiguous_deps:__subpackages__"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
extern "C" int cx() { return 17; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
load("@rules_cc//cc:defs.bzl", "cc_library") | ||
|
||
cc_library( | ||
name = "exc", | ||
srcs = ["exc.cc"], | ||
visibility = ["//ambiguous_deps:__subpackages__"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
extern "C" int cy() { return 113; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.