forked from bazelbuild/rules_rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
527 additions
and
0 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,34 @@ | ||
load("//rust:defs.bzl", "rust_library", "rust_proc_macro", "rust_test") | ||
|
||
rust_proc_macro( | ||
name = "import", | ||
srcs = [ | ||
"import.rs", | ||
], | ||
deps = [ | ||
":import_internal", | ||
# syn | ||
], | ||
) | ||
|
||
rust_library( | ||
name = "import_internal", | ||
srcs = [ | ||
"import_internal.rs", | ||
], | ||
deps = [ | ||
# aho_corasick | ||
# lazy_static | ||
# proc_macro2 | ||
# quote | ||
# syn | ||
], | ||
) | ||
|
||
rust_test( | ||
name = "import_internal_test", | ||
crate = ":import_internal", | ||
deps = [ | ||
# quickcheck | ||
], | ||
) |
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,15 @@ | ||
use proc_macro; | ||
use syn::parse_macro_input; | ||
|
||
use import_internal; | ||
|
||
// Flipping this bool allows easy switching between renaming crates and not. | ||
const RENAME_1P_CRATES: bool = true; | ||
|
||
#[proc_macro] | ||
pub fn import(input: proc_macro::TokenStream) -> proc_macro::TokenStream { | ||
let input = parse_macro_input!(input as import_internal::ImportMacroInput); | ||
import_internal::expand_imports(input, RENAME_1P_CRATES) | ||
.unwrap_or_else(|errors| errors.into_iter().map(|e| e.into_compile_error()).collect()) | ||
.into() | ||
} |
Oops, something went wrong.