@@ -272,10 +272,15 @@ fn main() {
272
272
. allowlist_type ( "ggml_.*" )
273
273
. allowlist_function ( "llama_.*" )
274
274
. allowlist_type ( "llama_.*" )
275
- . allowlist_function ( "mtmd_.*" )
276
- . allowlist_type ( "mtmd_.*" )
277
275
. prepend_enum_name ( false ) ;
278
276
277
+ // Configure mtmd feature if enabled
278
+ if cfg ! ( feature = "mtmd" ) {
279
+ bindings_builder = bindings_builder
280
+ . allowlist_function ( "mtmd_.*" )
281
+ . allowlist_type ( "mtmd_.*" ) ;
282
+ }
283
+
279
284
// Configure Android-specific bindgen settings
280
285
if matches ! ( target_os, TargetOs :: Android ) {
281
286
// Detect Android NDK from environment variables
@@ -440,11 +445,14 @@ fn main() {
440
445
config. define ( "LLAMA_BUILD_TESTS" , "OFF" ) ;
441
446
config. define ( "LLAMA_BUILD_EXAMPLES" , "OFF" ) ;
442
447
config. define ( "LLAMA_BUILD_SERVER" , "OFF" ) ;
448
+ config. define ( "LLAMA_BUILD_TOOLS" , "OFF" ) ;
443
449
config. define ( "LLAMA_CURL" , "OFF" ) ;
444
450
445
- // Required for mtmd.rs
446
- config. define ( "LLAMA_BUILD_COMMON" , "ON" ) ;
447
- config. define ( "LLAMA_BUILD_TOOLS" , "ON" ) ;
451
+ if cfg ! ( feature = "mtmd" ) {
452
+ config. define ( "LLAMA_BUILD_COMMON" , "ON" ) ;
453
+ // mtmd support in llama-cpp is within the tools directory
454
+ config. define ( "LLAMA_BUILD_TOOLS" , "ON" ) ;
455
+ }
448
456
449
457
// Pass CMAKE_ environment variables down to CMake
450
458
for ( key, value) in env:: vars ( ) {
@@ -634,63 +642,6 @@ fn main() {
634
642
635
643
let build_dir = config. build ( ) ;
636
644
637
- let lib_dir = out_dir. join ( "lib" ) ;
638
- debug_log ! ( "Lib directory: {}" , lib_dir. display( ) ) ;
639
-
640
- // Copy common library
641
- let common_lib_src = build_dir. join ( "build/common/libcommon.a" ) ;
642
- debug_log ! (
643
- "Looking for common library at: {}" ,
644
- common_lib_src. display( )
645
- ) ;
646
- if common_lib_src. exists ( ) {
647
- let common_lib_dst = lib_dir. join ( "libcommon.a" ) ;
648
- std:: fs:: copy ( & common_lib_src, & common_lib_dst) . unwrap_or_else ( |e| {
649
- panic ! ( "Failed to copy {common_lib_src:?} to {common_lib_dst:?}: {e:?}" ) ;
650
- } ) ;
651
- debug_log ! ( "Copied common library: {}" , common_lib_dst. display( ) ) ;
652
- } else {
653
- debug_log ! ( "Common library not found at: {}" , common_lib_src. display( ) ) ;
654
- }
655
-
656
- // Copy mtmd static library
657
- let mtmd_static_src = build_dir. join ( "build/tools/mtmd/libmtmd_static.a" ) ;
658
- debug_log ! (
659
- "Looking for mtmd static library at: {}" ,
660
- mtmd_static_src. display( )
661
- ) ;
662
- if mtmd_static_src. exists ( ) {
663
- let mtmd_static_dst = lib_dir. join ( "libmtmd_static.a" ) ;
664
- std:: fs:: copy ( & mtmd_static_src, & mtmd_static_dst) . unwrap_or_else ( |e| {
665
- panic ! ( "Failed to copy {mtmd_static_src:?} to {mtmd_static_dst:?}: {e:?}" ) ;
666
- } ) ;
667
- debug_log ! ( "Copied mtmd static library: {}" , mtmd_static_dst. display( ) ) ;
668
- } else {
669
- debug_log ! (
670
- "Mtmd static library not found at: {}" ,
671
- mtmd_static_src. display( )
672
- ) ;
673
- }
674
-
675
- // Copy mtmd audio library
676
- let mtmd_audio_src = build_dir. join ( "build/tools/mtmd/libmtmd_audio.a" ) ;
677
- debug_log ! (
678
- "Looking for mtmd audio library at: {}" ,
679
- mtmd_audio_src. display( )
680
- ) ;
681
- if mtmd_audio_src. exists ( ) {
682
- let mtmd_audio_dst = lib_dir. join ( "libmtmd_audio.a" ) ;
683
- std:: fs:: copy ( & mtmd_audio_src, & mtmd_audio_dst) . unwrap_or_else ( |e| {
684
- panic ! ( "Failed to copy {mtmd_audio_src:?} to {mtmd_audio_dst:?}: {e:?}" ) ;
685
- } ) ;
686
- debug_log ! ( "Copied mtmd audio library: {}" , mtmd_audio_dst. display( ) ) ;
687
- } else {
688
- debug_log ! (
689
- "Mtmd audio library not found at: {}" ,
690
- mtmd_audio_src. display( )
691
- ) ;
692
- }
693
-
694
645
// Search paths
695
646
println ! ( "cargo:rustc-link-search={}" , out_dir. join( "lib" ) . display( ) ) ;
696
647
println ! (
0 commit comments