//go:build cgo && native_libs // +build cgo,native_libs package worker // #cgo LDFLAGS: -L${SRCDIR}/../../native/build -Wl,-rpath,${SRCDIR}/../../native/build -ldataset_hash // #include "../../native/dataset_hash/dataset_hash.h" // #include import "C" import ( "errors" "unsafe" "github.com/jfraeys/fetch_ml/internal/manifest" ) // dirOverallSHA256HexNative implementation with native library. func dirOverallSHA256HexNative(root string) (string, error) { ctx := C.fh_init(0) // 0 = auto-detect threads if ctx == nil { return "", errors.New("failed to initialize native hash context") } defer C.fh_cleanup(ctx) croot := C.CString(root) defer C.free(unsafe.Pointer(croot)) result := C.fh_hash_directory_combined(ctx, croot) if result == nil { err := C.fh_last_error(ctx) if err != nil { return "", errors.New(C.GoString(err)) } return "", errors.New("native hash failed") } defer C.fh_free_string(result) return C.GoString(result), nil } // GetSIMDImplName returns the native SHA256 implementation name. func GetSIMDImplName() string { return C.GoString(C.fh_get_simd_impl_name()) } // HasSIMDSHA256 returns true if SIMD SHA256 is available. func HasSIMDSHA256() bool { return C.fh_has_simd_sha256() == 1 } // ScanArtifactsNative falls back to Go implementation. func ScanArtifactsNative(runDir string) (*manifest.Artifacts, error) { return ScanArtifacts(runDir) } // ExtractTarGzNative falls back to Go implementation. func ExtractTarGzNative(archivePath, dstDir string) error { return ExtractTarGz(archivePath, dstDir) }