@@ -129,85 +129,6 @@ fn auto_gen_schema_bindings_from_c() {
129129 }
130130}
131131
132- fn auto_gen_value_bindings_from_c ( ) {
133- let mut base_dir = env:: current_dir ( )
134- . unwrap_or ( "Failed to get path of //ten_rust/src" . into ( ) ) ;
135- base_dir. pop ( ) ;
136- base_dir. pop ( ) ;
137-
138- let mut value_header = base_dir. clone ( ) ;
139- value_header
140- . push ( "include_internal/ten_utils/value/bindings/rust/value_proxy.h" ) ;
141- if !value_header. exists ( ) {
142- println ! ( "Path of value_proxy.h: {}" , value_header. to_str( ) . unwrap( ) ) ;
143- panic ! ( "The //include_internal/ten_utils/value/bindings/rust/value_proxy.h does not exist." ) ;
144- }
145-
146- println ! ( "cargo:rerun-if-changed={}" , value_header. to_str( ) . unwrap( ) ) ;
147-
148- base_dir. push ( "include" ) ;
149-
150- let binding_gen = bindgen:: Builder :: default ( )
151- . clang_arg ( format ! ( "-I{}" , base_dir. to_str( ) . unwrap( ) ) )
152- . no_copy ( "ten_value_t" )
153- . header ( value_header. to_str ( ) . unwrap ( ) )
154- . parse_callbacks ( Box :: new ( bindgen:: CargoCallbacks :: new ( ) ) )
155- . generate ( )
156- . expect ( "Unable to generate bindings" ) ;
157-
158- let value_dir = Path :: new ( "src/value/" ) ;
159- let generated_bindings = value_dir. join ( "bindings.rs" ) ;
160- let temp_bindings = value_dir. join ( format ! ( "bindings_{}.rs.tmp" , id( ) ) ) ;
161-
162- binding_gen
163- . write_to_file ( & temp_bindings)
164- . expect ( "Unable to write bindings into file." ) ;
165-
166- // Add some rules to the bindings file to disable clippy lints.
167- let bindings_content = fs:: read_to_string ( & temp_bindings)
168- . expect ( "Unable to read generated bindings" ) ;
169- let disabled_clippy_lints = [
170- "#![allow(non_upper_case_globals)]" ,
171- "#![allow(non_camel_case_types)]" ,
172- "#![allow(non_snake_case)]" ,
173- "#![allow(dead_code)]" ,
174- "#![allow(improper_ctypes)]" ,
175- "#![allow(improper_ctypes_definitions)]" ,
176- "#![allow(clippy::upper_case_acronyms)]" ,
177- ] ;
178- let new_bindings_content =
179- disabled_clippy_lints. join ( "\n " ) + "\n \n " + & bindings_content;
180- fs:: write ( & temp_bindings, new_bindings_content)
181- . expect ( "Unable to add clippy lint rules to the generated bindings." ) ;
182-
183- let max_retries = 5 ;
184- // 500 milliseconds delay between retries.
185- let retry_delay = Duration :: from_millis ( 500 ) ;
186-
187- for attempt in 1 ..=max_retries {
188- // Atomically move the temporary file to the target file.
189- match fs:: rename ( & temp_bindings, & generated_bindings) {
190- Ok ( _) => {
191- println ! ( "File renamed successfully." ) ;
192- break ;
193- }
194- Err ( e) if attempt < max_retries => {
195- println ! (
196- "Attempt {}/{} failed: {}. Retrying..." ,
197- attempt, max_retries, e
198- ) ;
199- thread:: sleep ( retry_delay) ;
200- }
201- Err ( e) => {
202- panic ! (
203- "Unable to move temporary bindings to final destination after {} attempts: {}" ,
204- max_retries, e
205- ) ;
206- }
207- }
208- }
209- }
210-
211132// The current auto-detection only supports limited environment combinations;
212133// for example, cross-compilation is not supported.
213134fn auto_detect_utils_library_path ( ) -> PathBuf {
@@ -257,7 +178,6 @@ fn auto_detect_utils_library_path() -> PathBuf {
257178
258179fn main ( ) {
259180 auto_gen_schema_bindings_from_c ( ) ;
260- auto_gen_value_bindings_from_c ( ) ;
261181
262182 // If the auto-detected utils library path is incorrect, we can specify it
263183 // using the environment variable.
0 commit comments