Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 142 additions & 0 deletions .github/workflows/kos-go.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: KOS-Go Checks

on:
push:
paths:
- 'packages/kos-go/kos_mobile/**'
branches:
- develop
pull_request:
Comment thread
coderabbitai[bot] marked this conversation as resolved.
branches:
- develop

jobs:
Comment thread
coderabbitai[bot] marked this conversation as resolved.
build-go-linux:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.21'

- name: RustUp
uses: klever-io/kos-rs/.github/actions/rustup@develop
with:
with_cache: true

- name: Build Linux Go bindings
run: make build-go

- name: Copy .so to Go package
run: |
mkdir -p packages/kos-go/kos_mobile/lib/linux-amd64
cp target/release/libkos_mobile.so packages/kos-go/kos_mobile/lib/linux-amd64/

- name: Commit and push changes
if: github.event_name != 'push' || !contains(github.event.head_commit.message, '[skip ci]')
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Update Linux Go bindings library"
file_pattern: "packages/kos-go/kos_mobile/lib/linux-amd64/libkos_mobile.so"

Comment thread
coderabbitai[bot] marked this conversation as resolved.
- name: Run Go tests
run: |
cd packages/kos-go
make test

build-go-linux-musl:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.21'

- name: RustUp
uses: klever-io/kos-rs/.github/actions/rustup@develop
with:
with_cache: true

- name: Install musl tools
run: sudo apt-get update && sudo apt-get install -y musl-tools

- name: Build Linux musl Go bindings
run: |
rustup target add x86_64-unknown-linux-musl
make build-go-musl

Comment thread
klever-patrick marked this conversation as resolved.
- name: Copy .so to Go package
run: |
mkdir -p packages/kos-go/kos_mobile/lib/linux-amd64
cp target/x86_64-unknown-linux-musl/release/libkos_mobile.so packages/kos-go/kos_mobile/lib/linux-musl-amd64/

Comment thread
coderabbitai[bot] marked this conversation as resolved.
- name: Commit and push changes
if: github.event_name != 'push' || !contains(github.event.head_commit.message, '[skip ci]')
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Update Linux musl Go bindings library"
file_pattern: "packages/kos-go/kos_mobile/lib/linux-musl-amd64/libkos_mobile.so"

- name: Run Go tests
run: |
cd packages/kos-go
make test-linux-musl

build-go-mac:
runs-on: [ "macos-14" ]
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.21'

- name: Install Rust toolchain
shell: bash
run: |
set -e
rustup component add --toolchain stable rustfmt clippy
rustup default stable

- name: Setup protobuf
run: brew install protobuf

- name: Build Mac Go bindings
run: make build-go

- name: Copy dylib to Go package
run: |
mkdir -p packages/kos-go/kos_mobile/lib/darwin-aarch64
cp target/release/libkos_mobile.dylib packages/kos-go/kos_mobile/lib/darwin-aarch64/

- name: Commit and push changes
if: github.event_name != 'push' || !contains(github.event.head_commit.message, '[skip ci]')
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Update macOS Go bindings library"
file_pattern: "packages/kos-go/kos_mobile/lib/darwin-aarch64/libkos_mobile.dylib"

- name: Run Go tests
run: |
cd packages/kos-go
make test
70 changes: 1 addition & 69 deletions .github/workflows/pull-develop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ on:
- '**/*.md'
- '.gitignore'
- '.github/**'
- 'packages/kos-go/kos_mobile/lib/**'

jobs:
format:
Expand Down Expand Up @@ -66,72 +67,3 @@ jobs:

- name: Build
run: make webpack-npm

build-go-linux:
needs: [ format ]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: RustUp
uses: klever-io/kos-rs/.github/actions/rustup@develop
with:
with_cache: true

- name: Build Linux Go bindings
run: make build-go

- name: Copy .so to Go package
run: |
mkdir -p packages/kos-go/kos_mobile/lib/linux-amd64
cp target/release/libkos_mobile.so packages/kos-go/kos_mobile/lib/linux-amd64/

- name: Run Go tests
run: |
cd packages/kos-go
make test

build-go-mac:
needs: [ format ]
runs-on: [ "macos-14" ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Install Rust toolchain
shell: bash
run: |
set -e
rustup component add --toolchain stable rustfmt clippy
rustup default stable

- name: Setup protobuf
run: brew install protobuf

- name: Build Mac Go bindings
run: make build-go

- name: Copy dylib to Go package
run: |
mkdir -p packages/kos-go/kos_mobile/lib/darwin-aarch64
cp target/release/libkos_mobile.dylib packages/kos-go/kos_mobile/lib/darwin-aarch64/

- name: Run Go tests
run: |
cd packages/kos-go
make test
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ build-ios:

build-go:
cargo install uniffi-bindgen-go --git https://github.com/NordSecurity/uniffi-bindgen-go --tag v0.4.0+v0.28.3 && \
cargo build --release --package kos-mobile && uniffi-bindgen-go --library target/release/libkos_mobile.a --out-dir ./packages/kos-go
cargo build --release --package kos-mobile && uniffi-bindgen-go --library target/release/libkos_mobile.a --out-dir ./packages/kos-go

build-go-musl:
cargo install uniffi-bindgen-go --git https://github.com/NordSecurity/uniffi-bindgen-go --tag v0.4.0+v0.28.3 && \
RUSTFLAGS="-C target-feature=-crt-static" cargo build --release --target x86_64-unknown-linux-musl --package kos-mobile && \
uniffi-bindgen-go --library target/x86_64-unknown-linux-musl/release/libkos_mobile.a --out-dir ./packages/kos-go

test-ios: build-ios
cd packages/kos-mobile/ios/framework/KOSMobile && xcodebuild \
Expand Down
2 changes: 2 additions & 0 deletions packages/kos-go/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor
bin
38 changes: 21 additions & 17 deletions packages/kos-go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,25 @@ test-darwin-arm64:
GOARCH=arm64 \
go test $(TEST_FLAGS) ./...

.PHONY: build-all
build-all: build-linux-amd64 build-darwin-arm64
@echo "Built all platforms"

.PHONY: test-all
test-all:
@echo "Testing all available platforms..."
@if [ -d "kos_mobile/lib/linux-amd64" ]; then \
echo "Testing Linux AMD64..."; \
$(MAKE) test-linux-amd64; \
fi
@if [ -d "kos_mobile/lib/darwin-aarch64" ]; then \
echo "Testing Darwin ARM64..."; \
$(MAKE) test-darwin-arm64; \
fi
.PHONY: build-linux-musl
build-linux-musl:
LD_LIBRARY_PATH=$(PWD)/kos_mobile/lib/linux-amd64 \
CGO_ENABLED=1 \
CGO_LDFLAGS="-lm" \
GOOS=linux \
GOARCH=amd64 \
GOFLAGS="-tags=musl" \
go build $(BUILD_FLAGS) -o bin/kos-linux-musl ./...

.PHONY: test-linux-musl
test-linux-musl:
LD_LIBRARY_PATH=$(PWD)/kos_mobile/lib/linux-amd64 \
CGO_ENABLED=1 \
CGO_LDFLAGS="-lm" \
GOOS=linux \
GOARCH=amd64 \
GOFLAGS="-tags=musl" \
go test $(TEST_FLAGS) ./...

Comment thread
klever-patrick marked this conversation as resolved.
.PHONY: check-lib
check-lib:
Expand All @@ -143,10 +147,10 @@ help:
@echo " check-lib - Verify library exists for current platform"
@echo ""
@echo "Cross-platform targets:"
@echo " build-all - Build for all platforms"
@echo " build-linux-amd64 - Build for Linux AMD64"
@echo " build-linux-musl - Build for Linux with musl"
@echo " build-darwin-arm64 - Build for macOS ARM64"
@echo " test-all - Test all available platforms"
@echo " test-linux-amd64 - Test Linux AMD64"
@echo " test-linux-musl - Test Linux with musl"
@echo " test-darwin-amd64 - Test macOS AMD64"
@echo " test-darwin-arm64 - Test macOS ARM64"
1 change: 1 addition & 0 deletions packages/kos-go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
16 changes: 16 additions & 0 deletions packages/kos-go/kos_mobile/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
*.test

*.out
coverage.*
*.coverprofile
profile.cov

vendor/

go.work
go.work.sum

.env

.idea/
.vscode/
10 changes: 5 additions & 5 deletions packages/kos-go/kos_mobile/cgo.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package kos_mobile

/*
#cgo CFLAGS: -I.
#cgo linux LDFLAGS: -L./lib/linux-amd64 -lkos_mobile -Wl,-rpath,${SRCDIR}/lib/linux-amd64
#cgo darwin,amd64 LDFLAGS: -L./lib/darwin-amd64 -lkos_mobile -Wl,-rpath,${SRCDIR}/lib/darwin-amd64
#cgo darwin,arm64 LDFLAGS: -L./lib/darwin-aarch64 -lkos_mobile -Wl,-rpath,${SRCDIR}/lib/darwin-aarch64

#cgo CFLAGS: -I. -I${SRCDIR}
#cgo linux,!musl LDFLAGS: -L${SRCDIR}/lib/linux-amd64 -lkos_mobile -Wl,-rpath,${SRCDIR}/lib/linux-amd64
#cgo linux,musl LDFLAGS: -L${SRCDIR}/lib/linux-musl-amd64 -lkos_mobile -Wl,-rpath,${SRCDIR}/lib/linux-musl-amd64
#cgo darwin,amd64 LDFLAGS: -L${SRCDIR}/lib/darwin-amd64 -lkos_mobile -Wl,-rpath,${SRCDIR}/lib/darwin-amd64
#cgo darwin,arm64 LDFLAGS: -L${SRCDIR}/lib/darwin-aarch64 -lkos_mobile -Wl,-rpath,${SRCDIR}/lib/darwin-aarch64
#include "kos_mobile.h"
#include <stdlib.h>
*/
Expand Down
Binary file not shown.
Binary file modified packages/kos-go/kos_mobile/lib/linux-amd64/libkos_mobile.so
Binary file not shown.
Binary file not shown.
Loading