fetch_ml/scripts/dev/detect-native.go

61 lines
1.5 KiB
Go

// Native library detection - simple version that works without build tags
package main
import (
"fmt"
"os"
"os/exec"
"runtime"
"strings"
)
func main() {
fmt.Println("=== Native Library Detection ===")
fmt.Printf("Go Version: %s\n", runtime.Version())
fmt.Printf("Architecture: %s/%s\n", runtime.GOOS, runtime.GOARCH)
fmt.Printf("CGO Enabled: %v\n", cgoEnabled())
fmt.Println()
// Check for native libraries
checkNativeLibs()
}
func cgoEnabled() bool {
// Try to detect CGO by checking if we can import runtime/cgo
cmd := exec.Command("go", "env", "CGO_ENABLED")
out, err := cmd.Output()
if err != nil {
return false
}
return strings.TrimSpace(string(out)) == "1"
}
func checkNativeLibs() {
// Check for native library files
libPaths := []string{
"native/build/libdataset_hash.so",
"native/build/libdataset_hash.dylib",
"native/build/libdataset_hash.dll",
"native/build/libqueue_index.so",
"native/build/libartifact_scanner.so",
"native/build/libstreaming_io.so",
}
found := false
for _, path := range libPaths {
if _, err := os.Stat(path); err == nil {
fmt.Printf("Found: %s\n", path)
found = true
}
}
if !found {
fmt.Println("✗ No native libraries found in native/build/")
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()
fmt.Println("Current implementation: Go standard library")
}
}