-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add hdrs and indlues attributes to rust_static_library
- Loading branch information
Vinh Tran
committed
Sep 28, 2023
1 parent
4a5d7a1
commit 184a9b4
Showing
7 changed files
with
69 additions
and
2 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,7 @@ | ||
load("@rules_cc//cc:defs.bzl", "cc_test") | ||
|
||
cc_test( | ||
name = "main", | ||
srcs = ["main.cpp"], | ||
deps = ["//ffi/cpp_calling_rust_with_header/rust:librusty"], | ||
) |
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,6 @@ | ||
#include "rusty.h" | ||
|
||
int main() { | ||
print_c_hello_rust(); | ||
return 0; | ||
} |
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 @@ | ||
load("@rules_rust//rust:defs.bzl", "rust_static_library") | ||
|
||
rust_static_library( | ||
name = "librusty", | ||
srcs = ["librusty.rs"], | ||
hdrs = ["rusty.h"], | ||
crate_name = "rusty", | ||
includes = ["."], | ||
visibility = ["//visibility:public"], | ||
) |
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 @@ | ||
//! A simple hello world example that can be called from C | ||
#[no_mangle] | ||
/// Print "Hello Rust!" | ||
pub extern fn print_c_hello_rust() { | ||
println!("Hello Rust!"); | ||
} |
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,6 @@ | ||
#ifndef SIMPLE_PRINTER_H | ||
#define SIMPLE_PRINTER_H | ||
|
||
extern "C" void print_c_hello_rust(); | ||
|
||
#endif |
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