File tree 4 files changed +89
-0
lines changed 4 files changed +89
-0
lines changed Original file line number Diff line number Diff line change
1
+ package (default_visibility = ["//visibility:public" ])
2
+
3
+ load (
4
+ "@io_bazel_rules_rust//rust:rust.bzl" ,
5
+ "rust_doc" ,
6
+ "rust_doc_test" ,
7
+ "rust_library" ,
8
+ "rust_test" ,
9
+ )
10
+
11
+ rust_library (
12
+ name = "hello_macro" ,
13
+ srcs = [
14
+ "src/lib.rs" ,
15
+ ],
16
+ crate_type = "proc-macro" ,
17
+ )
18
+
19
+ rust_test (
20
+ name = "hello_macro_test" ,
21
+ crate = ":hello_macro" ,
22
+ )
23
+
24
+ rust_test (
25
+ name = "greeting_test" ,
26
+ srcs = ["tests/greeting.rs" ],
27
+ deps = [":hello_macro" ],
28
+ )
29
+
30
+ rust_doc (
31
+ name = "hello_macro_doc" ,
32
+ dep = ":hello_macro" ,
33
+ )
34
+
35
+ rust_doc_test (
36
+ name = "hello_macro_doc_test" ,
37
+ dep = ":hello_macro" ,
38
+ )
Original file line number Diff line number Diff line change
1
+ // Copyright 2020 The Bazel Authors. All rights reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ extern crate proc_macro;
16
+
17
+ use proc_macro:: TokenStream ;
18
+
19
+ /// This macro is a no-op; it is exceedingly simple as a result
20
+ /// of avoiding dependencies on both the syn and quote crates.
21
+ #[ proc_macro_derive( HelloWorld ) ]
22
+ pub fn hello_world ( _input : TokenStream ) -> TokenStream {
23
+ TokenStream :: new ( )
24
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright 2020 The Bazel Authors. All rights reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ extern crate hello_macro;
16
+
17
+ use hello_macro:: HelloWorld ;
18
+
19
+ #[ derive( HelloWorld ) ]
20
+ struct TestStruct {
21
+ }
22
+
23
+ #[ test]
24
+ fn test_hello_world_macro ( ) {
25
+ let _ = TestStruct { } ;
26
+ }
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ def _rust_doc_impl(ctx):
38
38
args = ctx .actions .args ()
39
39
args .add (crate .root .path )
40
40
args .add ("--crate-name" , crate .name )
41
+ args .add ("--crate-type" , crate .type )
41
42
args .add ("--output" , output_dir .path )
42
43
add_edition_flags (args , crate )
43
44
You can’t perform that action at this time.
0 commit comments