Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer OUT_DIR for outputting the multicodec table #558

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions crates/multicodec/build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use std::{fs, io, io::Write, path::Path};
use std::{env, fs, io, io::Write, path::Path};

fn main() {
println!("cargo:rerun-if-changed=src/table.csv");
if let Err(e) = generate_codecs("src/table.csv", "src/table.rs") {
let out_dir = env::var_os("OUT_DIR").unwrap();
if let Err(e) = generate_codecs("src/table.csv", Path::new(&out_dir).join("table.rs")) {
eprintln!("unable to generate codecs: {e}");
std::process::exit(1);
}
Expand Down
5 changes: 1 addition & 4 deletions crates/multicodec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ use std::ops::Deref;

pub use unsigned_varint::decode::Error;

#[rustfmt::skip]
mod table;

pub use table::*;
include!(concat!(env!("OUT_DIR"), "/table.rs"));

/// Multi-encoded byte slice.
pub struct MultiEncoded([u8]);
Expand Down