-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for depending on shared libraries on linux. (#61)
* Add support for depending on shared libraries on linux. * Use portable bash for TMPDIR check. * Move example 'matrix' to 'ffi/rust_calling_c'. * Use toolchain to get dylib/staticlib file extensions. * Skip dylib test targets on osx. * Simplify presubmit config. * Fix skipped labels. * Allow `rust_binary` to depend on `cc_library` (#83) The error message and the documentation both say this is possible. Light testing seems to show that this is the only change required. * Skip just rpath setup on non-linux. * Address review comments. * Attempt to clarify _setup_deps * Adjust provider test for field changes. * Actually provide correct patterns in test * Undo removing skipping of os check * Add FreeBSD toolchain. (#85) * Add os field to freebsd toolchain.
- Loading branch information
1 parent
634a6f3
commit f4b5743
Showing
15 changed files
with
248 additions
and
133 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
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,41 @@ | ||
package(default_visibility = ["//ffi/rust_calling_c:__subpackages__"]) | ||
|
||
load("@//rust:rust.bzl", "rust_library", "rust_test", "rust_binary") | ||
|
||
rust_library( | ||
name = "matrix", | ||
srcs = [ | ||
"src/ffi.rs", | ||
"src/lib.rs", | ||
"src/matrix.rs", | ||
], | ||
deps = [ | ||
"//ffi/rust_calling_c/c:native_matrix", | ||
"@libc//:libc", | ||
], | ||
) | ||
|
||
rust_test( | ||
name = "matrix_test", | ||
deps = [":matrix"], | ||
) | ||
|
||
## Do the same as above, but with a dynamic c library. | ||
|
||
rust_library( | ||
name = "matrix_dynamically_linked", | ||
srcs = [ | ||
"src/ffi.rs", | ||
"src/lib.rs", | ||
"src/matrix.rs", | ||
], | ||
deps = [ | ||
"//ffi/rust_calling_c/c:native_matrix_so", | ||
"@libc//:libc", | ||
], | ||
) | ||
|
||
rust_test( | ||
name = "matrix_dylib_test", | ||
deps = [":matrix_dynamically_linked"], | ||
) |
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,35 @@ | ||
package(default_visibility = ["//ffi/rust_calling_c:__subpackages__"]) | ||
|
||
cc_library( | ||
name = "native_matrix", | ||
srcs = ["matrix.c"], | ||
hdrs = ["matrix.h"], | ||
copts = ["-std=c99"], | ||
) | ||
|
||
cc_test( | ||
name = "native_matrix_test", | ||
srcs = ["matrix_test.c"], | ||
copts = ["-std=c99"], | ||
deps = [ | ||
":native_matrix", | ||
], | ||
) | ||
|
||
## Do the same as above, but with a dynamic c library. | ||
|
||
cc_library( | ||
name = "native_matrix_so", | ||
srcs = [":libnative_matrix_so.so"], | ||
hdrs = ["matrix.h"], | ||
) | ||
|
||
cc_binary( | ||
name = "libnative_matrix_so.so", | ||
srcs = [ | ||
"matrix.c", | ||
"matrix.h", | ||
], | ||
copts = ["-std=c99"], | ||
linkshared = True, | ||
) |
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
File renamed without changes.
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
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
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 |
---|---|---|
|
@@ -16,4 +16,4 @@ extern crate libc; | |
|
||
mod ffi; | ||
|
||
pub mod matrix; | ||
pub mod matrix; |
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
This file was deleted.
Oops, something went wrong.
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.