[feat] add shared lib build script

This commit is contained in:
Anton Nesterov 2024-08-29 22:35:08 +02:00
parent dad8d46e9b
commit 9572a7e549
No known key found for this signature in database
GPG key ID: 59121E8AE2851FB5
3 changed files with 2 additions and 7 deletions

View file

@ -1,5 +0,0 @@
build-lib:
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -o ../lib/libdal-arm64.dylib -buildmode=c-shared ./dal.go
for arch in amd64 arm64; do\
CC=x86_64-unknown-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=$${arch} go build -o ../lib/libdal-$${arch}.so -buildmode=c-shared ./dal.go;\
done

View file

@ -3,7 +3,7 @@
*/
import { dlopen, FFIType, suffix, ptr, toBuffer } from "bun:ffi";
const libname = `lib/clib.${suffix}`;
const libname = `../clib/clib.${suffix}`;
const libpath = libname;
const {

View file

@ -27,7 +27,7 @@
"fmt": "prettier --write .",
"build": "tsc",
"prepublish": "tsc",
"preinstall": "cd binding && go build -buildmode=c-archive -o dal.a ./dal.go",
"preinstall": "cd binding && go build -buildmode=c-archive -o dal.a ./dal.go && cd ../clib && go build -o ./clib.dylib -buildmode=c-shared ./main.go",
"postinstall": "node-gyp configure build"
}
}