@@ -6,11 +6,12 @@ use std::{
66} ;
77
88fn 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
6837fn source_files < P : AsRef < Path > > ( root_dir : P ) -> Result < Vec < String > , Box < dyn Error > > {
6938 let mut files = Vec :: new ( ) ;
0 commit comments