diff --git a/.github/workflows/compile-shared-libraries.yml b/.github/workflows/compile-shared-libraries.yml new file mode 100644 index 0000000..71255f7 --- /dev/null +++ b/.github/workflows/compile-shared-libraries.yml @@ -0,0 +1,30 @@ +name: Cross-Compile Shared Libraries + +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Cross-Compile with xgo + uses: crazy-max/ghaction-xgo@v3.1.0 + with: + xgo_version: latest + go_version: 1.22.0 + dest: dist + pkg: sharedlibrary + prefix: cosmium + targets: linux/amd64,linux/arm64,windows/amd64,windows/arm64,darwin/amd64,darwin/arm64 + v: true + buildmode: c-shared + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: shared-libraries + path: dist/* diff --git a/Makefile b/Makefile index 8b2fdbf..4a21e1f 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,8 @@ SERVER_LOCATION=./cmd/server SHARED_LIB_LOCATION=./sharedlibrary SHARED_LIB_OPT=-buildmode=c-shared +XGO_TARGETS=linux/amd64,linux/arm64,windows/amd64,windows/arm64,darwin/amd64,darwin/arm64 +GOVERSION=1.22.0 DIST_DIR=dist @@ -43,6 +45,11 @@ build-sharedlib-linux-amd64: @echo "Building shared library for Linux x64..." @GOOS=linux GOARCH=amd64 $(GOBUILD) $(SHARED_LIB_OPT) -o $(DIST_DIR)/$(BINARY_NAME)-linux-amd64.so $(SHARED_LIB_LOCATION) +xgo-compile-sharedlib: + @echo "Building shared libraries using xgo..." + @mkdir -p $(DIST_DIR) + @xgo -targets=$(XGO_TARGETS) -go $(GOVERSION) -buildmode=c-shared -dest=$(DIST_DIR) -out=$(BINARY_NAME) -pkg=$(SHARED_LIB_LOCATION) . + generate-parser-nosql: pigeon -o ./parsers/nosql/nosql.go ./parsers/nosql/nosql.peg