Skip to content

Commit eacb278

Browse files
authored
Organized examples (#803)
1 parent b7c1b0f commit eacb278

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+141
-144
lines changed

.bazelci/presubmit.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ tasks:
7575
- "-@examples//ffi/rust_calling_c:matrix_dylib_test"
7676
- "-@examples//ffi/rust_calling_c:matrix_dynamically_linked"
7777
- "-@examples//ffi/rust_calling_c/simple/..."
78-
- "-@examples//hello_sys/..."
79-
- "-@examples//complex_sys/..."
78+
- "-@examples//sys/..."
8079
- "-@examples//proto/..."
8180
- "-@examples//wasm/..."
8281
build_targets: *windows_targets

examples/examples_deps.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
44
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
5-
load("@examples//complex_sys:repositories.bzl", "rules_rust_examples_complex_sys_repositories")
6-
load("@examples//hello_sys/raze:crates.bzl", "rules_rust_examples_hello_sys_fetch_remote_crates")
5+
load("@examples//sys/basic/raze:crates.bzl", "rules_rust_examples_basic_sys_fetch_remote_crates")
6+
load("@examples//sys/complex:repositories.bzl", "rules_rust_examples_complex_sys_repositories")
77
load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies")
88
load("@rules_rust//bindgen:repositories.bzl", "rust_bindgen_repositories")
99
load("@rules_rust//proto:repositories.bzl", "rust_proto_repositories")
@@ -36,7 +36,7 @@ def deps():
3636
version = "1.46.0",
3737
)
3838

39-
rules_rust_examples_hello_sys_fetch_remote_crates()
39+
rules_rust_examples_basic_sys_fetch_remote_crates()
4040

4141
rules_rust_examples_complex_sys_repositories()
4242

examples/hello_macro/BUILD.bazel

Lines changed: 0 additions & 47 deletions
This file was deleted.

examples/proc_macro/BUILD.bazel

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
load(
2+
"@rules_rust//rust:defs.bzl",
3+
"rust_doc",
4+
"rust_doc_test",
5+
"rust_proc_macro",
6+
"rust_test",
7+
)
8+
9+
package(default_visibility = ["//visibility:public"])
10+
11+
rust_proc_macro(
12+
name = "proc_macro_lib",
13+
srcs = [
14+
"src/lib_2015.rs",
15+
],
16+
)
17+
18+
rust_proc_macro(
19+
name = "proc_macro_lib_2018",
20+
srcs = [
21+
"src/lib.rs",
22+
],
23+
edition = "2018",
24+
)
25+
26+
rust_test(
27+
name = "proc_macro_test",
28+
crate = ":proc_macro_lib",
29+
edition = "2018",
30+
)
31+
32+
rust_test(
33+
name = "greeting_test",
34+
srcs = ["tests/greeting.rs"],
35+
edition = "2018",
36+
proc_macro_deps = [":proc_macro_lib"],
37+
)
38+
39+
rust_doc(
40+
name = "proc_macro_lib_doc",
41+
dep = ":proc_macro_lib",
42+
)
43+
44+
rust_doc_test(
45+
name = "doc_test",
46+
dep = ":proc_macro_lib",
47+
)
File renamed without changes.
File renamed without changes.

examples/hello_macro/tests/greeting.rs renamed to examples/proc_macro/tests/greeting.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
extern crate hello_macro;
16-
17-
use hello_macro::HelloWorld;
15+
use proc_macro_lib::HelloWorld;
1816

1917
#[derive(HelloWorld)]
2018
struct TestStruct {}

examples/hello_sys/BUILD.bazel renamed to examples/sys/basic/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ rust_binary(
2020
name = "hello_sys",
2121
srcs = ["src/main.rs"],
2222
edition = "2018",
23-
deps = ["//hello_sys/raze:bzip2"],
23+
deps = ["//sys/basic/raze:bzip2"],
2424
)
2525

2626
sh_test(

examples/hello_sys/Cargo.lock renamed to examples/sys/basic/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/hello_sys/Cargo.toml renamed to examples/sys/basic/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
[package]
2-
name = "rules_rust_examples_hello_sys"
2+
name = "rules_rust_examples_basic_sys"
33
version = "0.0.1"
44

55
[[bin]]
6-
name = "rules_rust_examples_hello_sys"
6+
name = "rules_rust_examples_basic_sys"
77
path = "src/main.rs"
88

99
[dependencies]
1010
bzip2 = "=0.3.3"
1111

1212
[package.metadata.raze]
13-
workspace_path = "//hello_sys/raze"
13+
workspace_path = "//sys/basic/raze"
1414
genmode = "Remote"
15-
gen_workspace_prefix = "rules_rust_examples_hello_sys"
15+
gen_workspace_prefix = "rules_rust_examples_basic_sys"
1616
rust_rules_workspace_name = "rules_rust"
1717
package_aliases_dir = "raze"
1818
default_gen_buildrs = false

0 commit comments

Comments
 (0)