From b5ca575c6f8e7f88844354daec969c91a69748a9 Mon Sep 17 00:00:00 2001 From: Jeremie Fraeys Date: Mon, 23 Mar 2026 15:21:25 -0400 Subject: [PATCH] feat(scripts/dev): extend native detection for both C++ and Rust libraries Update detect-native.go to detect and report both C++ and Rust native libs: - Split library detection into C++ (native/build/) and Rust (native_rust/target/release/) sections - Display separate '=== C++ Native Libraries ===' and '=== Rust Native Libraries ===' headers - Check for both .so and .dylib extensions for each platform - Update help text to show 'make native-build' for C++ and 'make rust-build' for Rust - Show benchmark file availability for both implementations --- scripts/dev/detect-native.go | 63 ++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 9 deletions(-) diff --git a/scripts/dev/detect-native.go b/scripts/dev/detect-native.go index 5c3e9da..69f9413 100644 --- a/scripts/dev/detect-native.go +++ b/scripts/dev/detect-native.go @@ -18,6 +18,22 @@ func main() { // Check for native libraries checkNativeLibs() + + // Show native comparison if available + _, cppErr := os.Stat("native_cpp_benchmark_results.txt") + _, rustErr := os.Stat("native_rust_benchmark_results.txt") + + if cppErr == nil { + fmt.Println() + fmt.Println("C++ native library benchmarks available at: native_cpp_benchmark_results.txt") + } + if rustErr == nil { + fmt.Println("Rust native library benchmarks available at: native_rust_benchmark_results.txt") + } + if cppErr == nil || rustErr == nil { + fmt.Println("To compare Go vs Native:") + fmt.Println(" make benchmark-compare") + } } func cgoEnabled() bool { @@ -31,8 +47,8 @@ func cgoEnabled() bool { } func checkNativeLibs() { - // Check for native library files - libPaths := []string{ + // Check for C++ native library files + cppLibPaths := []string{ "native/build/libdataset_hash.so", "native/build/libdataset_hash.dylib", "native/build/libdataset_hash.dll", @@ -41,20 +57,49 @@ func checkNativeLibs() { "native/build/libstreaming_io.so", } - found := false - for _, path := range libPaths { + // Check for Rust native library files + rustLibPaths := []string{ + "native_rust/target/release/libdataset_hash.so", + "native_rust/target/release/libdataset_hash.dylib", + "native_rust/target/release/libdataset_hash.dll", + "native_rust/target/release/libqueue_index.so", + "native_rust/target/release/libqueue_index.dylib", + "native_rust/target/release/libqueue_index.dll", + } + + foundCpp := false + foundRust := false + + fmt.Println("=== C++ Native Libraries ===") + for _, path := range cppLibPaths { if _, err := os.Stat(path); err == nil { fmt.Printf("Found: %s\n", path) - found = true + foundCpp = true } } - if !found { - fmt.Println("✗ No native libraries found in native/build/") + if !foundCpp { + fmt.Println("✗ No C++ native libraries found") + } + + fmt.Println() + fmt.Println("=== Rust Native Libraries ===") + for _, path := range rustLibPaths { + if _, err := os.Stat(path); err == nil { + fmt.Printf("Found: %s\n", path) + foundRust = true + } + } + + if !foundRust { + fmt.Println("✗ No Rust native libraries found") + } + + if !foundCpp && !foundRust { fmt.Println() fmt.Println("To use native libraries:") - fmt.Println(" 1. Build native libs: cd native && mkdir -p build && cd build && cmake .. && make") - fmt.Println(" 2. Build Go with native: go build -tags native_libs ./...") + fmt.Println(" C++: make native-build") + fmt.Println(" Rust: make rust-build") fmt.Println() fmt.Println("Current implementation: Go standard library") }