diff --git a/.github/workflows/go-test.yaml b/.github/workflows/go-test.yaml index 681371d6..b7af262b 100644 --- a/.github/workflows/go-test.yaml +++ b/.github/workflows/go-test.yaml @@ -36,9 +36,6 @@ jobs: uses: actions/setup-go@v2 with: go-version: 1.22 - - uses: korandoru/setup-zig@v1 - with: - zig-version: master - name: Ready msys2 uses: msys2/setup-msys2@v2 with: @@ -49,3 +46,36 @@ jobs: if: matrix.os == 'windows-latest' - name: Go code test run: go test ./... + + cross-compile-test: + runs-on: macos-12 + defaults: + run: + working-directory: "go" + steps: + - name: Git checkout + uses: actions/checkout@v2 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.22 + - uses: korandoru/setup-zig@v1 + with: + zig-version: master + - name: Set output + id: macos_sdk + run: echo "path=$(xcrun --show-sdk-path)" >> $GITHUB_OUTPUT + - name: Go cross compile test on Windows + run: | + CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC='zig cc -target x86_64-windows-gnu' go build ./... + - name: Go cross compile test on Linux + run: | + CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC='zig cc -target x86_64-linux-musl' go build ./... + CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC='zig cc -target aarch64-linux-musl' go build ./... + - name: Go cross compile test on Macos + run: | + export SDK_PATH=$(xcrun --show-sdk-path) + CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC='zig cc -target x86_64-macos-none -F'"${SDK_PATH}"'/System/Library/Frameworks' go build ./... + CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 CC='zig cc -target aarch64-macos-none -F'"${SDK_PATH}"'/System/Library/Frameworks' go build ./... + env: + SDK_PATH: ${{ steps.macos_sdk.outputs.path }} diff --git a/go/plugin/plugin.c b/go/plugin/plugin.c new file mode 100644 index 00000000..5552d0f8 --- /dev/null +++ b/go/plugin/plugin.c @@ -0,0 +1,9 @@ +#include +#include + +extern char *kcl_go_plugin_proxy_func(char *method, char *args_json, + char *kwargs_json); + +uint64_t kcl_go_plugin_get_proxy_func_ptr() { + return (uint64_t)(kcl_go_plugin_proxy_func); +} diff --git a/go/plugin/plugin.go b/go/plugin/plugin.go index ca5f2b93..d63c9d68 100644 --- a/go/plugin/plugin.go +++ b/go/plugin/plugin.go @@ -8,14 +8,8 @@ package plugin /* #include #include -char* kcl_go_capi_InvokeJsonProxy( - char* method, - char* args_json, - char* kwargs_json -); -static uint64_t kcl_go_capi_getInvokeJsonProxyPtr() { - return (uint64_t)(kcl_go_capi_InvokeJsonProxy); -} + +uint64_t kcl_go_plugin_get_proxy_func_ptr(); */ import "C" import ( @@ -26,8 +20,8 @@ import ( const CgoEnabled = true -//export kcl_go_capi_InvokeJsonProxy -func kcl_go_capi_InvokeJsonProxy(_method, _args_json, _kwargs_json *C.char) (result_json *C.char) { +//export kcl_go_plugin_proxy_func +func kcl_go_plugin_proxy_func(_method, _args_json, _kwargs_json *C.char) (result_json *C.char) { var method, args_json, kwargs_json string if _method != nil { @@ -45,7 +39,7 @@ func kcl_go_capi_InvokeJsonProxy(_method, _args_json, _kwargs_json *C.char) (res } func GetInvokeJsonProxyPtr() uint64 { - ptr := uint64(C.kcl_go_capi_getInvokeJsonProxyPtr()) + ptr := uint64(C.kcl_go_plugin_get_proxy_func_ptr()) return ptr }