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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ licenses([
1414
# Aliased targets
1515
alias(
1616
name = "bzip2",
17-
actual = "@rules_rust_examples_hello_sys__bzip2__0_3_3//:bzip2",
17+
actual = "@rules_rust_examples_basic_sys__bzip2__0_3_3//:bzip2",
1818
tags = [
1919
"cargo-raze",
2020
"manual",

examples/hello_sys/raze/crates.bzl renamed to examples/sys/basic/raze/crates.bzl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,54 +9,54 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # bui
99
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load
1010
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load
1111

12-
def rules_rust_examples_hello_sys_fetch_remote_crates():
12+
def rules_rust_examples_basic_sys_fetch_remote_crates():
1313
"""This function defines a collection of repos and should be called in a WORKSPACE file"""
1414
maybe(
1515
http_archive,
16-
name = "rules_rust_examples_hello_sys__bzip2__0_3_3",
16+
name = "rules_rust_examples_basic_sys__bzip2__0_3_3",
1717
url = "https://crates.io/api/v1/crates/bzip2/0.3.3/download",
1818
type = "tar.gz",
1919
sha256 = "42b7c3cbf0fa9c1b82308d57191728ca0256cb821220f4e2fd410a72ade26e3b",
2020
strip_prefix = "bzip2-0.3.3",
21-
build_file = Label("//hello_sys/raze/remote:BUILD.bzip2-0.3.3.bazel"),
21+
build_file = Label("//sys/basic/raze/remote:BUILD.bzip2-0.3.3.bazel"),
2222
)
2323

2424
maybe(
2525
http_archive,
26-
name = "rules_rust_examples_hello_sys__bzip2_sys__0_1_9_1_0_8",
26+
name = "rules_rust_examples_basic_sys__bzip2_sys__0_1_9_1_0_8",
2727
url = "https://crates.io/api/v1/crates/bzip2-sys/0.1.9+1.0.8/download",
2828
type = "tar.gz",
2929
sha256 = "ad3b39a260062fca31f7b0b12f207e8f2590a67d32ec7d59c20484b07ea7285e",
3030
strip_prefix = "bzip2-sys-0.1.9+1.0.8",
31-
build_file = Label("//hello_sys/raze/remote:BUILD.bzip2-sys-0.1.9+1.0.8.bazel"),
31+
build_file = Label("//sys/basic/raze/remote:BUILD.bzip2-sys-0.1.9+1.0.8.bazel"),
3232
)
3333

3434
maybe(
3535
http_archive,
36-
name = "rules_rust_examples_hello_sys__cc__1_0_60",
36+
name = "rules_rust_examples_basic_sys__cc__1_0_60",
3737
url = "https://crates.io/api/v1/crates/cc/1.0.60/download",
3838
type = "tar.gz",
3939
sha256 = "ef611cc68ff783f18535d77ddd080185275713d852c4f5cbb6122c462a7a825c",
4040
strip_prefix = "cc-1.0.60",
41-
build_file = Label("//hello_sys/raze/remote:BUILD.cc-1.0.60.bazel"),
41+
build_file = Label("//sys/basic/raze/remote:BUILD.cc-1.0.60.bazel"),
4242
)
4343

4444
maybe(
4545
http_archive,
46-
name = "rules_rust_examples_hello_sys__libc__0_2_77",
46+
name = "rules_rust_examples_basic_sys__libc__0_2_77",
4747
url = "https://crates.io/api/v1/crates/libc/0.2.77/download",
4848
type = "tar.gz",
4949
sha256 = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235",
5050
strip_prefix = "libc-0.2.77",
51-
build_file = Label("//hello_sys/raze/remote:BUILD.libc-0.2.77.bazel"),
51+
build_file = Label("//sys/basic/raze/remote:BUILD.libc-0.2.77.bazel"),
5252
)
5353

5454
maybe(
5555
http_archive,
56-
name = "rules_rust_examples_hello_sys__pkg_config__0_3_18",
56+
name = "rules_rust_examples_basic_sys__pkg_config__0_3_18",
5757
url = "https://crates.io/api/v1/crates/pkg-config/0.3.18/download",
5858
type = "tar.gz",
5959
sha256 = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33",
6060
strip_prefix = "pkg-config-0.3.18",
61-
build_file = Label("//hello_sys/raze/remote:BUILD.pkg-config-0.3.18.bazel"),
61+
build_file = Label("//sys/basic/raze/remote:BUILD.pkg-config-0.3.18.bazel"),
6262
)

examples/hello_sys/raze/remote/BUILD.bzip2-0.3.3.bazel renamed to examples/sys/basic/raze/remote/BUILD.bzip2-0.3.3.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ load(
1919
package(default_visibility = [
2020
# Public for visibility by "@raze__crate__version//" targets.
2121
#
22-
# Prefer access through "//hello_sys/raze", which limits external
22+
# Prefer access through "//sys/basic/raze", which limits external
2323
# visibility to explicit Cargo.toml dependencies.
2424
"//visibility:public",
2525
])
@@ -49,8 +49,8 @@ rust_library(
4949
version = "0.3.3",
5050
# buildifier: leave-alone
5151
deps = [
52-
"@rules_rust_examples_hello_sys__bzip2_sys__0_1_9_1_0_8//:bzip2_sys",
53-
"@rules_rust_examples_hello_sys__libc__0_2_77//:libc",
52+
"@rules_rust_examples_basic_sys__bzip2_sys__0_1_9_1_0_8//:bzip2_sys",
53+
"@rules_rust_examples_basic_sys__libc__0_2_77//:libc",
5454
],
5555
)
5656

examples/hello_sys/raze/remote/BUILD.bzip2-sys-0.1.9+1.0.8.bazel renamed to examples/sys/basic/raze/remote/BUILD.bzip2-sys-0.1.9+1.0.8.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ load(
1919
package(default_visibility = [
2020
# Public for visibility by "@raze__crate__version//" targets.
2121
#
22-
# Prefer access through "//hello_sys/raze", which limits external
22+
# Prefer access through "//sys/basic/raze", which limits external
2323
# visibility to explicit Cargo.toml dependencies.
2424
"//visibility:public",
2525
])
@@ -57,8 +57,8 @@ cargo_build_script(
5757
version = "0.1.9+1.0.8",
5858
visibility = ["//visibility:private"],
5959
deps = [
60-
"@rules_rust_examples_hello_sys__cc__1_0_60//:cc",
61-
"@rules_rust_examples_hello_sys__pkg_config__0_3_18//:pkg_config",
60+
"@rules_rust_examples_basic_sys__cc__1_0_60//:cc",
61+
"@rules_rust_examples_basic_sys__pkg_config__0_3_18//:pkg_config",
6262
],
6363
)
6464

@@ -82,6 +82,6 @@ rust_library(
8282
# buildifier: leave-alone
8383
deps = [
8484
":bzip2_sys_build_script",
85-
"@rules_rust_examples_hello_sys__libc__0_2_77//:libc",
85+
"@rules_rust_examples_basic_sys__libc__0_2_77//:libc",
8686
],
8787
)

examples/hello_sys/raze/remote/BUILD.cc-1.0.60.bazel renamed to examples/sys/basic/raze/remote/BUILD.cc-1.0.60.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ load(
1919
package(default_visibility = [
2020
# Public for visibility by "@raze__crate__version//" targets.
2121
#
22-
# Prefer access through "//hello_sys/raze", which limits external
22+
# Prefer access through "//sys/basic/raze", which limits external
2323
# visibility to explicit Cargo.toml dependencies.
2424
"//visibility:public",
2525
])

examples/hello_sys/raze/remote/BUILD.libc-0.2.77.bazel renamed to examples/sys/basic/raze/remote/BUILD.libc-0.2.77.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ load(
1919
package(default_visibility = [
2020
# Public for visibility by "@raze__crate__version//" targets.
2121
#
22-
# Prefer access through "//hello_sys/raze", which limits external
22+
# Prefer access through "//sys/basic/raze", which limits external
2323
# visibility to explicit Cargo.toml dependencies.
2424
"//visibility:public",
2525
])

examples/hello_sys/raze/remote/BUILD.pkg-config-0.3.18.bazel renamed to examples/sys/basic/raze/remote/BUILD.pkg-config-0.3.18.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ load(
1919
package(default_visibility = [
2020
# Public for visibility by "@raze__crate__version//" targets.
2121
#
22-
# Prefer access through "//hello_sys/raze", which limits external
22+
# Prefer access through "//sys/basic/raze", which limits external
2323
# visibility to explicit Cargo.toml dependencies.
2424
"//visibility:public",
2525
])
File renamed without changes.
File renamed without changes.

examples/complex_sys/BUILD.bazel renamed to examples/sys/complex/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ rust_binary(
2020
name = "complex_sys",
2121
srcs = ["src/main.rs"],
2222
edition = "2018",
23-
deps = ["//complex_sys/raze:git2"],
23+
deps = ["//sys/complex/raze:git2"],
2424
)
File renamed without changes.

examples/complex_sys/Cargo.toml renamed to examples/sys/complex/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ openssl = "=0.10.32"
1212
openssl-sys = "=0.9.60"
1313

1414
[package.metadata.raze]
15-
workspace_path = "//complex_sys/raze"
15+
workspace_path = "//sys/complex/raze"
1616
genmode = "Remote"
1717
gen_workspace_prefix = "rules_rust_examples_complex_sys"
1818
rust_rules_workspace_name = "rules_rust"

0 commit comments

Comments
 (0)