Skip to content

Commit 1d123e6

Browse files
authored
Merge pull request #2840 from ruby/crates-0.2.0
Crates 0.1.1
2 parents 8c44301 + e3aaaef commit 1d123e6

File tree

8 files changed

+28
-47
lines changed

8 files changed

+28
-47
lines changed

rust/Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/ruby-rbs-sys/Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
[package]
22
name = "ruby-rbs-sys"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
edition = "2024"
55
license = "BSD-2-Clause"
66
description = "Low-level FFI bindings for RBS -- the type signature language for Ruby programs"
77
homepage = "https://github.com/ruby/rbs"
88
repository = "https://github.com/ruby/rbs.git"
99
readme = "../../README.md"
10+
include = [
11+
"src/**/*",
12+
"vendor/**/*",
13+
"build.rs",
14+
"wrapper.h",
15+
"Cargo.toml",
16+
]
1017

1118
[lib]
1219
doctest = false

rust/ruby-rbs-sys/build.rs

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ use std::{
66
};
77

88
fn main() -> Result<(), Box<dyn Error>> {
9-
let root = root_dir()?;
10-
let include = root.join("include");
11-
let src = root.join("src");
9+
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
10+
let vendor_rbs = manifest_dir.join("vendor/rbs");
11+
let include = vendor_rbs.join("include");
12+
let c_src = vendor_rbs.join("src");
1213

13-
build(&include, &src)?;
14+
build(&include, &c_src)?;
1415

1516
let bindings = generate_bindings(&include)?;
1617
write_bindings(&bindings)?;
@@ -32,38 +33,6 @@ fn build(include_dir: &Path, src_dir: &Path) -> Result<(), Box<dyn Error>> {
3233
Ok(())
3334
}
3435

35-
fn root_dir() -> Result<PathBuf, Box<dyn Error>> {
36-
// Allow overriding via environment variable (useful for packaging)
37-
if let Ok(source_dir) = env::var("RBS_SOURCE_DIR") {
38-
let root = PathBuf::from(source_dir);
39-
let include_dir = root.join("include");
40-
let src_dir = root.join("src");
41-
42-
if include_dir.exists() && src_dir.exists() {
43-
return Ok(root);
44-
} else {
45-
return Err(format!(
46-
"RBS_SOURCE_DIR is set to {:?}, but include/ and src/ directories not found",
47-
root
48-
)
49-
.into());
50-
}
51-
}
52-
53-
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
54-
55-
// Try workspace structure (development)
56-
if let Some(workspace_root) = manifest_dir.ancestors().nth(2) {
57-
let include_dir = workspace_root.join("include");
58-
let src_dir = workspace_root.join("src");
59-
60-
if include_dir.exists() && src_dir.exists() {
61-
return Ok(workspace_root.to_path_buf());
62-
}
63-
}
64-
65-
Err("Cannot find include/ and src/ directories. Set RBS_SOURCE_DIR environment variable to the repository root.".into())
66-
}
6736

6837
fn source_files<P: AsRef<Path>>(root_dir: P) -> Result<Vec<String>, Box<dyn Error>> {
6938
let mut files = Vec::new();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../include

rust/ruby-rbs-sys/vendor/rbs/src

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../src

rust/ruby-rbs/Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
[package]
22
name = "ruby-rbs"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
edition = "2024"
55
license = "BSD-2-Clause"
66
description = "Rust bindings for RBS -- the type signature language for Ruby programs"
77
homepage = "https://github.com/ruby/rbs"
88
repository = "https://github.com/ruby/rbs.git"
99
readme = "../../README.md"
10+
include = [
11+
"src/**/*",
12+
"vendor/**/*",
13+
"build.rs",
14+
"Cargo.toml",
15+
]
1016

1117
[dependencies]
1218
ruby-rbs-sys = { version = "0.1", path = "../ruby-rbs-sys" }

rust/ruby-rbs/build.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,12 @@ impl Node {
5151
}
5252

5353
fn main() -> Result<(), Box<dyn Error>> {
54-
// Allow overriding the source directory via environment variable (useful for packaging)
55-
let config_path = if let Ok(source_dir) = env::var("RBS_SOURCE_DIR") {
56-
Path::new(&source_dir).join("config.yml")
57-
} else {
58-
Path::new(env!("CARGO_MANIFEST_DIR")).join("../../config.yml")
59-
};
54+
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
55+
let config_path = manifest_dir.join("vendor/rbs/config.yml");
6056

6157
let config_path = config_path.canonicalize().map_err(|e| {
6258
format!(
63-
"Failed to find config.yml at {:?}: {}. Set RBS_SOURCE_DIR environment variable to the repository root.",
59+
"Failed to find config.yml at {:?}: {}",
6460
config_path, e
6561
)
6662
})?;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../config.yml

0 commit comments

Comments
 (0)