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
This commit is contained in:
Jeremie Fraeys 2026-03-23 15:21:25 -04:00
parent f4cce2f610
commit b5ca575c6f
No known key found for this signature in database

View file

@ -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")
}