Skip to content

Commit

Permalink
fix: resolved gomobile issue
Browse files Browse the repository at this point in the history
  • Loading branch information
baizon committed Aug 26, 2024
1 parent 3ddb71d commit 684e62e
Show file tree
Hide file tree
Showing 125 changed files with 44,622 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ env:
# https://docs.github.com/en/packages/guides/pushing-and-pulling-docker-images
#
# Keep this in sync with default in scripts/github-ci.sh.
CI_IMAGE: ghcr.io/bitboxswiss/bitbox-wallet-app-ci:23
CI_IMAGE: ghcr.io/bitboxswiss/bitbox-wallet-app-ci:24
GITHUB_BUILD_DIR: ${{github.workspace}}

jobs:
Expand Down
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ linters:
- wsl
- execinquery
- ireturn
- copyloopvar
- intrange
- wrapcheck
- varnamelen
- tagliatelle
Expand Down
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ envinit:
go install github.com/vektra/mockery/v2@latest
go install github.com/matryer/moq@latest
go install golang.org/x/tools/cmd/goimports@latest
go install golang.org/x/mobile/cmd/gomobile@latest
# The gomobile/gobind libs are also needed when using `gomobile bind`, but it's not compatible with vendoring:
# https://github.com/golang/go/issues/50994#issuecomment-1032754206
GO111MODULE=off go get -u golang.org/x/mobile/cmd/gomobile
# TODO: replace with go install golang.org/x/mobile/cmd/gomobile@latest once https://github.com/golang/mobile/pull/105 is merged.
git clone https://github.com/BitBoxSwiss/mobile.git && cd /tmp/mobile/cmd/gomobile && go install .
gomobile init
# Initializiation on MacOS
# - run make from $GOPATH/src/github.com/BitBoxSwiss/bitbox-wallet-app
Expand Down
2 changes: 2 additions & 0 deletions android-env.mk.inc
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export ANDROID_SDK_ROOT := /opt/android-sdk
export ANDROID_NDK_HOME := /opt/android-sdk/ndk/21.2.6472646
# gomodcache location for gomobile build pkgs. Set to tmp folder, because writing access is needed.
export GOMODCACHE_ROOT := /tmp/gomodcache/pkg/mod
3 changes: 2 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ environment:
GOTOOLCHAIN: local
PLATFORM: amd64
COMPILER: msvc

# https://www.appveyor.com/docs/windows-images-software/#golang
# If you change this, also change the GOROOT variable above to point to the right installation folder.
stack: go 1.22

install:
Expand Down
9 changes: 4 additions & 5 deletions backend/mobileserver/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
include ../../android-env.mk.inc

# go mod makes the Android build hang forever. Remove this once we move to go modules in a controlled fashion.
# Probably a variation of https://github.com/golang/go/issues/27234 - solution is to build it using vendored deps
# by turning off GO111MODULE. See also: https://github.com/golang/go/issues/34181#issuecomment-640260162
# GOMODCACHE to /tmp directory, because gomobile needs to write pkgs.
# Also set -glflags to fix the vendor issue with gomobile, see: https://github.com/golang/go/issues/67927#issuecomment-2241523694
build-android:
GO111MODULE=off ANDROID_HOME=${ANDROID_SDK_ROOT} gomobile bind -x -a -ldflags="-s -w" -target android .
GOMODCACHE=${GOMODCACHE_ROOT} ANDROID_HOME=${ANDROID_SDK_ROOT} gomobile bind -x -a -glflags="-mod=readonly" -ldflags="-s -w" -target android .
build-ios:
GO111MODULE=off gomobile bind -x -a -ldflags="-s -w" -target ios,iossimulator .
GOMODCACHE=${GOMODCACHE_ROOT} gomobile bind -x -a -glflags="-mod=readonly" -ldflags="-s -w" -target ios,iossimulator .
clean:
rm -f mobileserver.aar mobileserver-sources.jar
9 changes: 9 additions & 0 deletions backend/mobileserver/implicit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This file imports the packages required by gomobile so they can be vendored.

package mobileserver

import (
_ "golang.org/x/mobile/bind"
_ "golang.org/x/mobile/bind/java"
_ "golang.org/x/mobile/bind/objc"
)
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ require (
github.com/stretchr/testify v1.9.0
go.etcd.io/bbolt v1.3.10
golang.org/x/crypto v0.26.0
golang.org/x/mobile v0.0.0-20240716161057-1ad2df20a8b6
golang.org/x/net v0.28.0
)

Expand Down Expand Up @@ -54,8 +55,10 @@ require (
github.com/tklauser/numcpus v0.8.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.23.0 // indirect
golang.org/x/tools v0.23.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
Expand Down
67 changes: 67 additions & 0 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/github-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if [ "$OS_NAME" == "linux" ]; then
# Which docker image to use to run the CI. Defaults to Docker Hub.
# Overwrite with CI_IMAGE=docker/image/path environment variable.
# Keep this in sync with .github/workflows/ci.yml.
: "${CI_IMAGE:=shiftcrypto/bitbox-wallet-app:23}"
: "${CI_IMAGE:=shiftcrypto/bitbox-wallet-app:24}"
# Time image pull to compare in the future.
time docker pull "$CI_IMAGE"

Expand Down
27 changes: 27 additions & 0 deletions vendor/golang.org/x/mobile/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions vendor/golang.org/x/mobile/PATENTS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions vendor/golang.org/x/mobile/bind/bind.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 684e62e

Please sign in to comment.