Skip to content

Commit

Permalink
all: use github.com/ebitengine/gomobile instead of golang.org/x/mobile
Browse files Browse the repository at this point in the history
Closes #2748
  • Loading branch information
hajimehoshi committed Feb 23, 2024
1 parent 5f08bbf commit e1aa936
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 21 deletions.
18 changes: 9 additions & 9 deletions cmd/ebitenmobile/gomobile.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"runtime/debug"

// Add a dependency on gomobile in order to get the version via debug.ReadBuildInfo().
_ "golang.org/x/mobile/geom"
_ "github.com/ebitengine/gomobile/geom"
exec "golang.org/x/sys/execabs"
)

Expand Down Expand Up @@ -135,8 +135,8 @@ func prepareGomobileCommands() (string, error) {
package %s
import (
_ "golang.org/x/mobile/cmd/gobind"
_ "golang.org/x/mobile/cmd/gomobile"
_ "github.com/ebitengine/gomobile/cmd/gobind"
_ "github.com/ebitengine/gomobile/cmd/gomobile"
)
`, buildtags, modname)), 0644); err != nil {
return tmp, err
Expand All @@ -147,27 +147,27 @@ import (
return tmp, err
}

// To record gomobile to go.sum for Go 1.16 and later, go-get gomobile instead of golang.org/x/mobile (#1487).
// To record gomobile to go.sum for Go 1.16 and later, go-get gomobile instead of github.com/ebitengine/gomobile (#1487).
// This also records gobind as gomobile depends on gobind indirectly.
// Using `...` doesn't work on Windows since mobile/internal/mobileinit cannot be compiled on Windows w/o Cgo (#1493).
if err := runGo("get", "golang.org/x/mobile/cmd/gomobile@"+h); err != nil {
if err := runGo("get", "github.com/ebitengine/gomobile/cmd/gomobile@"+h); err != nil {
return tmp, err
}
if localgm := os.Getenv("EBITENMOBILE_GOMOBILE"); localgm != "" {
if !filepath.IsAbs(localgm) {
localgm = filepath.Join(pwd, localgm)
}
if err := runGo("mod", "edit", "-replace=golang.org/x/mobile="+localgm); err != nil {
if err := runGo("mod", "edit", "-replace=github.com/ebitengine/gomobile="+localgm); err != nil {
return tmp, err
}
}
if err := runGo("mod", "tidy"); err != nil {
return tmp, err
}
if err := runGo("build", "-o", exe(filepath.Join("bin", "gomobile")), "golang.org/x/mobile/cmd/gomobile"); err != nil {
if err := runGo("build", "-o", exe(filepath.Join("bin", "gomobile")), "github.com/ebitengine/gomobile/cmd/gomobile"); err != nil {
return tmp, err
}
if err := runGo("build", "-o", exe(filepath.Join("bin", "gobind-original")), "golang.org/x/mobile/cmd/gobind"); err != nil {
if err := runGo("build", "-o", exe(filepath.Join("bin", "gobind-original")), "github.com/ebitengine/gomobile/cmd/gobind"); err != nil {
return tmp, err
}

Expand Down Expand Up @@ -212,7 +212,7 @@ func gomobileHash() (string, error) {
return "", fmt.Errorf("ebitenmobile: debug.ReadBuildInfo failed")
}
for _, m := range info.Deps {
if m.Path == "golang.org/x/mobile" {
if m.Path == "github.com/ebitengine/gomobile" {
return m.Version, nil
}
}
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/hajimehoshi/ebiten/v2
go 1.18

require (
github.com/ebitengine/gomobile v0.0.0-20240223151600-9f1d75a9f41c
github.com/ebitengine/hideconsole v1.0.0
github.com/ebitengine/oto/v3 v3.2.0-alpha.4
github.com/ebitengine/purego v0.7.0-alpha.1
Expand All @@ -14,7 +15,6 @@ require (
github.com/jfreymuth/oggvorbis v1.0.5
github.com/kisielk/errcheck v1.6.3
golang.org/x/image v0.15.0
golang.org/x/mobile v0.0.0-20240213143359-d1f7d3436075
golang.org/x/sync v0.6.0
golang.org/x/sys v0.17.0
golang.org/x/text v0.14.0
Expand All @@ -23,6 +23,5 @@ require (

require (
github.com/jfreymuth/vorbis v1.0.2 // indirect
golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63 // indirect
golang.org/x/mod v0.15.0 // indirect
)
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
github.com/ebitengine/gomobile v0.0.0-20240223151600-9f1d75a9f41c h1:fIrdax248gvTVn/QL+U0taS0Fs9SVKKSpXxiibMs6p4=
github.com/ebitengine/gomobile v0.0.0-20240223151600-9f1d75a9f41c/go.mod h1:8SdR2+sMMmYsei+c0ZW+AmJx2W6dPeSixWWSKRkJppA=
github.com/ebitengine/hideconsole v1.0.0 h1:5J4U0kXF+pv/DhiXt5/lTz0eO5ogJ1iXb8Yj1yReDqE=
github.com/ebitengine/hideconsole v1.0.0/go.mod h1:hTTBTvVYWKBuxPr7peweneWdkUwEuHuB3C1R/ielR1A=
github.com/ebitengine/oto/v3 v3.2.0-alpha.4 h1:aaUdcbEDUV1oErHDv/Cd0IAjQaQPChZuvO8Cn/kQHE8=
Expand Down Expand Up @@ -27,13 +29,9 @@ github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63 h1:3AGKexOYqL+ztdWdkB1bDwXgPBuTS/S8A4WzuTvJ8Cg=
golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63/go.mod h1:UH99kUObWAZkDnWqppdQe5ZhPYESUw8I0zVV1uWBR+0=
golang.org/x/image v0.1.0/go.mod h1:iyPr49SD/G/TBxYVB/9RRtGUT5eNbo2u4NamWeQcD5c=
golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8=
golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
golang.org/x/mobile v0.0.0-20240213143359-d1f7d3436075 h1:iZzqyDd8gFkJZpsJNzveyScRBcQlsveheh6Q77LzhPY=
golang.org/x/mobile v0.0.0-20240213143359-d1f7d3436075/go.mod h1:Y8Bnziw2dX69ZhYuqQB8Ihyjks1Q6fMmbg17j9+ISNA=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
Expand Down
2 changes: 1 addition & 1 deletion internal/graphicsdriver/opengl/gl/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package gl
// Context is a context for OpenGL (ES) functions.
//
// Context is basically the same as gomobile's gl.Context.
// See https://pkg.go.dev/golang.org/x/mobile/gl#Context
// See https://pkg.go.dev/github.com/ebitengine/gomobile/gl#Context
type Context interface {
LoadFunctions() error
IsES() bool
Expand Down
2 changes: 1 addition & 1 deletion internal/ui/ui_android.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ import (
"errors"
"fmt"

"golang.org/x/mobile/app"
"github.com/ebitengine/gomobile/app"

"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/opengl"
Expand Down
2 changes: 1 addition & 1 deletion internal/vibrate/vibrate_android.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package vibrate
import (
"time"

"golang.org/x/mobile/app"
"github.com/ebitengine/gomobile/app"
)

/*
Expand Down
6 changes: 3 additions & 3 deletions mobile/jvm_android.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
package mobile

import (
"golang.org/x/mobile/app"
"github.com/ebitengine/gomobile/app"
)

// RunOnJVM runs fn on a new goroutine locked to an OS thread with a JNIEnv.
//
// RunOnJVM is a wrapper of golang.org/x/mobile/app's RunOnJVM.
// RunOnJVM is preferable in order to reduce a direct dependency on golang.org/x/mobile in your application.
// RunOnJVM is a wrapper of github.com/ebitengine/gomobile/app's RunOnJVM.
// RunOnJVM is preferable in order to reduce a direct dependency on github.com/ebitengine/gomobile in your application.
//
// RunOnJVM blocks until the call to fn is complete. Any Java
// exception or failure to attach to the JVM is returned as an error.
Expand Down

0 comments on commit e1aa936

Please sign in to comment.