@@ -450,13 +450,31 @@ pub mod common {
450
450
451
451
let bindings = Builder :: default ( )
452
452
. clang_arg (
453
- subdir ( base_dir_path. as_ref ( ) . join ( HOST_DIRNAME ) . join ( "include" ) ) . and_then (
454
- |p| {
453
+ subdir ( base_dir_path. as_ref ( ) . join ( HOST_DIRNAME ) . join ( "include" ) )
454
+ . and_then ( |p| {
455
455
p. to_str ( )
456
456
. map ( |s| format ! ( "-I{}" , s) )
457
457
. ok_or_else ( || anyhow ! ( "Could not convert path to string" ) )
458
- } ,
459
- ) ?,
458
+ } )
459
+ . or_else ( |_| {
460
+ // Fallback for Simics 7.28.0+ where Python headers are in separate package (1033)
461
+ println ! ( "cargo:warning=Traditional Python include path not found, trying Simics Python package fallback" ) ;
462
+ let parent_dir = base_dir_path. as_ref ( ) . parent ( ) . unwrap ( ) ;
463
+ let python_include_path = parent_dir
464
+ . join ( "simics-python-7.10.0" )
465
+ . join ( HOST_DIRNAME )
466
+ . join ( "include" ) ;
467
+ if python_include_path. exists ( ) {
468
+ subdir ( & python_include_path)
469
+ . and_then ( |p| {
470
+ p. to_str ( )
471
+ . map ( |s| format ! ( "-I{}" , s) )
472
+ . ok_or_else ( || anyhow ! ( "Could not convert path to string" ) )
473
+ } )
474
+ } else {
475
+ bail ! ( "Python include directory not found at {}" , python_include_path. display( ) )
476
+ }
477
+ } ) ?,
460
478
)
461
479
. clang_arg ( format ! ( "-I{}" , & wrapper_include_path) )
462
480
. clang_arg ( "-fretain-comments-from-system-headers" )
@@ -778,7 +796,18 @@ pub mod common {
778
796
. join ( HOST_DIRNAME )
779
797
. join ( "sys" )
780
798
. join ( "lib" )
781
- . canonicalize ( ) ?;
799
+ . canonicalize ( )
800
+ . or_else ( |_| {
801
+ // Fallback for Simics 7.28.0+ where libpython is in separate package (1033)
802
+ println ! ( "cargo:warning=Traditional libpython path not found, trying Simics Python package fallback" ) ;
803
+ let parent_dir = base_dir_path. parent ( ) . unwrap ( ) ;
804
+ parent_dir
805
+ . join ( "simics-python-7.10.0" )
806
+ . join ( HOST_DIRNAME )
807
+ . join ( "sys" )
808
+ . join ( "lib" )
809
+ . canonicalize ( )
810
+ } ) ?;
782
811
783
812
let libpython = sys_lib_dir. join (
784
813
read_dir ( & sys_lib_dir) ?
0 commit comments