-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build-all
executable file
·50 lines (43 loc) · 1.54 KB
/
build-all
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
set -e
GOPATH=$(go env GOPATH)
TARGETS=${TARGETS:-linux/386,linux/amd64,linux/arm-5,linux/arm-6,linux/arm-7,linux/arm64,darwin/*,windows/*}
v=$(grep 'Version =' calends.go | awk '{ print $4 }')
VERSION=$(echo v${v//\"/})
unset v
go get -v ./...
go mod vendor
go install github.com/crazy-max/xgo@latest
${GOPATH}/bin/xgo -buildmode=c-shared -dest=$(pwd)/dist/ -out=libcalends-${VERSION} -targets=${TARGETS} github.com/danhunsaker/calends/libcalends
${GOPATH}/bin/xgo -dest=$(pwd)/dist/bin/ -out=calends-${VERSION} -targets=${TARGETS} ./cli
GOOS=js GOARCH=wasm go build -o=$(pwd)/dist/calends-${VERSION}.wasm github.com/danhunsaker/calends/wasm
for h in $(find dist/ -name '*.h')
do
dir=${h/.h/}
mkdir -p ${dir}
mv ${dir}.h ${dir}/libcalends.h
echo "#define FFI_SCOPE \"CALENDS\"" > ${dir}/calends-phpffi.h
# Linux
[ -e ${dir}.so ] && (
mv ${dir}.so ${dir}/libcalends.so
echo "#define FFI_LIB \"libcalends.so\"" >> ${dir}/calends-phpffi.h
)
# Darwin
[ -e ${dir}.dylib ] && (
mv ${dir}.dylib ${dir}/libcalends.dylib
echo "#define FFI_LIB \"libcalends.dylib\"" >> ${dir}/calends-phpffi.h
)
# Windows
[ -e ${dir}.dll ] && (
mv ${dir}.dll ${dir}/libcalends.dll
echo "#define FFI_LIB \"libcalends.dll\"" >> ${dir}/calends-phpffi.h
)
cpp -P -D"__attribute__(ARGS)=" ${dir}/libcalends.h | egrep -v '_Complex|^static inline .*\{$|return |^\}$' >> ${dir}/calends-phpffi.h
if [ -e ${dir}/libcalends.dll ]
then
zip -j ${dir}.zip ${dir}/*
else
tar czvf ${dir}.tgz -C ${dir} .
fi
rm -rf ${dir}
done