@@ -23,11 +23,9 @@ const HEADER: &str = r"//
2323// Contributors:
2424// ZettaScale Zenoh Team, <[email protected] > 2525//
26+
27+ #pragma once
2628// clang-format off
27- #ifdef DOCS
28- #define ALIGN(n)
29- #define ZENOHC_API
30- #endif
3129" ;
3230
3331enum SplitRule {
@@ -568,6 +566,21 @@ impl FunctionSignature {
568566}
569567
570568pub fn split_bindings ( genetation_path : impl AsRef < Path > ) -> Result < Vec < PathBuf > , String > {
569+ let headers_by_file = HashMap :: from ( [
570+ (
571+ "zenoh_commons.h" ,
572+ vec ! [
573+ "zenoh_def.h" ,
574+ "zenoh_configure.h" ,
575+ "zenoh_opaque.h" ,
576+ "zenoh_includes.h" ,
577+ ] ,
578+ ) ,
579+ (
580+ "zenoh_opaque.h" ,
581+ vec ! [ "zenoh_def.h" , "zenoh_configure.h" , "zenoh_includes.h" ] ,
582+ ) ,
583+ ] ) ;
571584 let bindings = std:: fs:: read_to_string ( & genetation_path) . unwrap ( ) ;
572585 let split_guide = SplitGuide :: from_yaml ( SPLITGUIDE_PATH ) ;
573586 let mut files = split_guide
@@ -586,9 +599,17 @@ pub fn split_bindings(genetation_path: impl AsRef<Path>) -> Result<Vec<PathBuf>,
586599 ( path as & Path , BufWriter :: new ( file) )
587600 } )
588601 . collect :: < HashMap < _ , _ > > ( ) ;
589- for file in files. values_mut ( ) {
602+ for ( path , file) in files. iter_mut ( ) {
590603 file. write_all ( HEADER . as_bytes ( ) )
591604 . map_err ( |e| e. to_string ( ) ) ?;
605+ if let Some ( n) = path. file_name ( ) . and_then ( |p| p. to_str ( ) ) {
606+ if let Some ( headers) = headers_by_file. get ( n) {
607+ for h in headers {
608+ file. write_all ( format ! ( "#include \" {h}\" \n " ) . as_bytes ( ) )
609+ . map_err ( |e| e. to_string ( ) ) ?;
610+ }
611+ }
612+ }
592613 }
593614 let mut records = group_tokens ( Tokenizer {
594615 filename : genetation_path. as_ref ( ) ,
0 commit comments