diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 747375d18..ce6660914 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -224,7 +224,7 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "ruby-rbs" -version = "0.1.0" +version = "0.1.1" dependencies = [ "ruby-rbs-sys", "serde", @@ -233,7 +233,7 @@ dependencies = [ [[package]] name = "ruby-rbs-sys" -version = "0.1.0" +version = "0.1.1" dependencies = [ "bindgen", "cc", diff --git a/rust/ruby-rbs-sys/Cargo.toml b/rust/ruby-rbs-sys/Cargo.toml index 496b09baf..47241fb10 100644 --- a/rust/ruby-rbs-sys/Cargo.toml +++ b/rust/ruby-rbs-sys/Cargo.toml @@ -1,12 +1,19 @@ [package] name = "ruby-rbs-sys" -version = "0.1.0" +version = "0.1.1" 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" +include = [ + "src/**/*", + "vendor/**/*", + "build.rs", + "wrapper.h", + "Cargo.toml", +] [lib] doctest = false diff --git a/rust/ruby-rbs-sys/build.rs b/rust/ruby-rbs-sys/build.rs index bf17e9114..8131f714f 100644 --- a/rust/ruby-rbs-sys/build.rs +++ b/rust/ruby-rbs-sys/build.rs @@ -6,11 +6,12 @@ use std::{ }; fn main() -> Result<(), Box> { - let root = root_dir()?; - let include = root.join("include"); - let src = root.join("src"); + let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR")); + let vendor_rbs = manifest_dir.join("vendor/rbs"); + let include = vendor_rbs.join("include"); + let c_src = vendor_rbs.join("src"); - build(&include, &src)?; + build(&include, &c_src)?; let bindings = generate_bindings(&include)?; write_bindings(&bindings)?; @@ -32,38 +33,6 @@ fn build(include_dir: &Path, src_dir: &Path) -> Result<(), Box> { Ok(()) } -fn root_dir() -> Result> { - // 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> { let mut files = Vec::new(); diff --git a/rust/ruby-rbs-sys/vendor/rbs/include b/rust/ruby-rbs-sys/vendor/rbs/include new file mode 120000 index 000000000..0f0436a65 --- /dev/null +++ b/rust/ruby-rbs-sys/vendor/rbs/include @@ -0,0 +1 @@ +../../../../include \ No newline at end of file diff --git a/rust/ruby-rbs-sys/vendor/rbs/src b/rust/ruby-rbs-sys/vendor/rbs/src new file mode 120000 index 000000000..b3e266f12 --- /dev/null +++ b/rust/ruby-rbs-sys/vendor/rbs/src @@ -0,0 +1 @@ +../../../../src \ No newline at end of file diff --git a/rust/ruby-rbs/Cargo.toml b/rust/ruby-rbs/Cargo.toml index fbb39dffc..3151d8125 100644 --- a/rust/ruby-rbs/Cargo.toml +++ b/rust/ruby-rbs/Cargo.toml @@ -1,12 +1,18 @@ [package] name = "ruby-rbs" -version = "0.1.0" +version = "0.1.1" 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" +include = [ + "src/**/*", + "vendor/**/*", + "build.rs", + "Cargo.toml", +] [dependencies] ruby-rbs-sys = { version = "0.1", path = "../ruby-rbs-sys" } diff --git a/rust/ruby-rbs/build.rs b/rust/ruby-rbs/build.rs index 019341d79..7360f5743 100644 --- a/rust/ruby-rbs/build.rs +++ b/rust/ruby-rbs/build.rs @@ -51,16 +51,12 @@ impl Node { } fn main() -> Result<(), Box> { - // 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 manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR")); + let config_path = manifest_dir.join("vendor/rbs/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.", + "Failed to find config.yml at {:?}: {}", config_path, e ) })?; diff --git a/rust/ruby-rbs/vendor/rbs/config.yml b/rust/ruby-rbs/vendor/rbs/config.yml new file mode 120000 index 000000000..0ecb7253d --- /dev/null +++ b/rust/ruby-rbs/vendor/rbs/config.yml @@ -0,0 +1 @@ +../../../../config.yml \ No newline at end of file