Skip to content

Commit

Permalink
Fix publish build (#5)
Browse files Browse the repository at this point in the history
* Add build.rs to include README.md in workspace

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* Deny unsafe for good measures

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

---------

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
  • Loading branch information
ggwpez authored May 14, 2023
1 parent c68eb26 commit d73fd4a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion proc-macro-warning/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = ["Oliver Tale-Yazdi <[email protected]>"]
description = "Emit warnings from inside proc macros."
repository = "https://github.com/ggwpez/proc-macro-warning"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
build = "build.rs"

[dependencies]
proc-macro2 = { version = "1.0.56", default-features = false }
Expand Down
15 changes: 15 additions & 0 deletions proc-macro-warning/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Only needed to find the README to use `include_str!` on it.

fn main() {
// Go upwards until we find a README.md
let mut path = std::env::current_dir().unwrap();
while !path.join("README.md").exists() {
path = path.parent().unwrap().to_path_buf();
}
path = path.join("README.md");
// Sanity check that it contains the string "Proc Macro Warning".
let contents = std::fs::read_to_string(&path).unwrap();
assert!(contents.contains("Proc Macro Warning"));

println!("cargo:rustc-env=README_PATH={}", path.display());
}
3 changes: 2 additions & 1 deletion proc-macro-warning/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* SPDX-License-Identifier: (GPL-3.0 or Apache-2.0)
*/

#![doc = include_str!("../../README.md")]
#![doc = include_str!(env!("README_PATH"))]
#![deny(unsafe_code)]

use core::ops::Deref;
use proc_macro2::Span;
Expand Down

0 comments on commit d73fd4a

Please sign in to comment.