From a23238a5fafd75d6717d06e66f1520369190f005 Mon Sep 17 00:00:00 2001 From: Soutaro Matsumoto Date: Tue, 3 Feb 2026 06:17:41 +0900 Subject: [PATCH 1/2] Add crate metadata --- rust/ruby-rbs-sys/Cargo.toml | 5 +++++ rust/ruby-rbs/Cargo.toml | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/rust/ruby-rbs-sys/Cargo.toml b/rust/ruby-rbs-sys/Cargo.toml index c70471abe..496b09baf 100644 --- a/rust/ruby-rbs-sys/Cargo.toml +++ b/rust/ruby-rbs-sys/Cargo.toml @@ -2,6 +2,11 @@ name = "ruby-rbs-sys" version = "0.1.0" edition = "2024" +license = "BSD-2-Clause" +description = "Low-level FFI bindings for RBS -- the type signature language for Ruby programs" +homepage = "https://github.com/ruby/rbs" +repository = "https://github.com/ruby/rbs.git" +readme = "../../README.md" [lib] doctest = false diff --git a/rust/ruby-rbs/Cargo.toml b/rust/ruby-rbs/Cargo.toml index 9c4731d41..fbb39dffc 100644 --- a/rust/ruby-rbs/Cargo.toml +++ b/rust/ruby-rbs/Cargo.toml @@ -2,9 +2,14 @@ name = "ruby-rbs" version = "0.1.0" edition = "2024" +license = "BSD-2-Clause" +description = "Rust bindings for RBS -- the type signature language for Ruby programs" +homepage = "https://github.com/ruby/rbs" +repository = "https://github.com/ruby/rbs.git" +readme = "../../README.md" [dependencies] -ruby-rbs-sys = { path = "../ruby-rbs-sys" } +ruby-rbs-sys = { version = "0.1", path = "../ruby-rbs-sys" } [build-dependencies] serde = { version = "1.0", features = ["derive"] } From ff6d9b75804ec4b6db0aa8d377b27ebeaf98d7da Mon Sep 17 00:00:00 2001 From: Soutaro Matsumoto Date: Tue, 3 Feb 2026 10:10:05 +0900 Subject: [PATCH 2/2] Fix `build.rs` to read files during `cargo publish` --- rust/ruby-rbs-sys/build.rs | 35 ++++++++++++++++++++++++++++++----- rust/ruby-rbs/build.rs | 16 +++++++++++++--- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/rust/ruby-rbs-sys/build.rs b/rust/ruby-rbs-sys/build.rs index cb3f2430e..bf17e9114 100644 --- a/rust/ruby-rbs-sys/build.rs +++ b/rust/ruby-rbs-sys/build.rs @@ -33,11 +33,36 @@ fn build(include_dir: &Path, src_dir: &Path) -> Result<(), Box> { } fn root_dir() -> Result> { - Ok(Path::new(env!("CARGO_MANIFEST_DIR")) - .ancestors() - .nth(2) - .ok_or("Failed to find project root directory")? - .to_path_buf()) + // Allow overriding via environment variable (useful for packaging) + if let Ok(source_dir) = env::var("RBS_SOURCE_DIR") { + let root = PathBuf::from(source_dir); + let include_dir = root.join("include"); + let src_dir = root.join("src"); + + if include_dir.exists() && src_dir.exists() { + return Ok(root); + } else { + return Err(format!( + "RBS_SOURCE_DIR is set to {:?}, but include/ and src/ directories not found", + root + ) + .into()); + } + } + + let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR")); + + // Try workspace structure (development) + if let Some(workspace_root) = manifest_dir.ancestors().nth(2) { + let include_dir = workspace_root.join("include"); + let src_dir = workspace_root.join("src"); + + if include_dir.exists() && src_dir.exists() { + return Ok(workspace_root.to_path_buf()); + } + } + + Err("Cannot find include/ and src/ directories. Set RBS_SOURCE_DIR environment variable to the repository root.".into()) } fn source_files>(root_dir: P) -> Result, Box> { diff --git a/rust/ruby-rbs/build.rs b/rust/ruby-rbs/build.rs index 701374fa7..019341d79 100644 --- a/rust/ruby-rbs/build.rs +++ b/rust/ruby-rbs/build.rs @@ -51,9 +51,19 @@ impl Node { } fn main() -> Result<(), Box> { - let config_path = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../../config.yml") - .canonicalize()?; + // Allow overriding the source directory via environment variable (useful for packaging) + let config_path = if let Ok(source_dir) = env::var("RBS_SOURCE_DIR") { + Path::new(&source_dir).join("config.yml") + } else { + Path::new(env!("CARGO_MANIFEST_DIR")).join("../../config.yml") + }; + + let config_path = config_path.canonicalize().map_err(|e| { + format!( + "Failed to find config.yml at {:?}: {}. Set RBS_SOURCE_DIR environment variable to the repository root.", + config_path, e + ) + })?; println!("cargo:rerun-if-changed={}", config_path.display());