hajimehoshi / ebiten

Ebitengine - A dead simple 2D game engine for Go
https://ebitengine.org
Apache License 2.0
10.81k stars 650 forks source link

ebitenmobile fails in vendor mode and has no option to disable vendor mod #1989

Open kordax opened 2 years ago

kordax commented 2 years ago

Hi, I have next problem while executing

ebitenmobile bind -a -x -v -target android -javapkg net.isoftservices.client -o ./android/app/libs/client.aar ./src/game/android

Output is:

ebitenmobile bind -a -x -v -target android -javapkg net.isoftservices.client -o ./android/app/libs/client.aar ./src/game/android
PATH=/tmp/ebitenmobile-2356515294/bin:/home/kordax/.nvm/versions/node/v16.13.1/bin:/home/kordax/yandex-cloud/bin:/home/kordax/.symfony/bin:/mnt/extended_partition/Applications/anaconda3/bin:/home/kordax/go/bin:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/home/kordax/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/opt/apache-cxf/bin:/opt/protoc/bin
cd /tmp/ebitenmobile-2356515294
GO111MODULE=on go mod init ebitenmobiletemporary
GO111MODULE=on go get golang.org/x/mobile/cmd/gomobile@5d9a33257ab559d10fa8c96087aed99bf8b6d868
GO111MODULE=on go mod tidy
GO111MODULE=on go build -o bin/gomobile golang.org/x/mobile/cmd/gomobile
GO111MODULE=on go build -o bin/gobind-original golang.org/x/mobile/cmd/gobind
GO111MODULE=on go build -o bin/gobind -tags ebitenmobilegobind src/gobind.go
gomobile init
GOMOBILE=/home/kordax/go/pkg/gomobile
WORK=/tmp/gomobile-work-819293218
GOOS=android CGO_ENABLED=1 /tmp/ebitenmobile-2356515294/bin/gobind -lang=go,java -outdir=$WORK -javapkg=net.isoftservices.client octopus/parts/webgames/bin/shooters-go-client/src/game/android github.com/hajimehoshi/ebiten/v2/mobile/ebitenmobileview
unable to import bind: [-: cannot find package "." in:
    /home/kordax/Projects/maxbet/octopus/vendor/golang.org/x/mobile/bind]
unable to import bind: [-: cannot find package "." in:
    /home/kordax/Projects/maxbet/octopus/vendor/golang.org/x/mobile/bind]
unable to import bind: [-: cannot find package "." in:
    /home/kordax/Projects/maxbet/octopus/vendor/golang.org/x/mobile/bind]
"golang.org/x/mobile/bind" is not found; run go get golang.org/x/mobile/bind: [-: cannot find package "." in:
    /home/kordax/Projects/maxbet/octopus/vendor/golang.org/x/mobile/bind]
2022/02/10 17:03:37 exit status 1
rm -r -f "$WORK"
gomobile: /tmp/ebitenmobile-2356515294/bin/gobind -lang=go,java -outdir=/tmp/gomobile-work-819293218 -javapkg=net.isoftservices.client octopus/parts/webgames/bin/shooters-go-client/src/game/android github.com/hajimehoshi/ebiten/v2/mobile/ebitenmobileview failed: exit status 1

The problem is that ebitenmobile doesn't support -mod mod or -mod readonly and therefore it fails on Gobind when vendor dir is present in the root project's structure. The current Gomobile package doesn't contain bind and cmd packages in vendor mode and I cannot explicitly force vendor mod for bind/cmd packages using _ import.

$ ls -F vendor/golang.org/x/mobile/
app/  asset/  AUTHORS  CONTRIBUTORS  event/  geom/  gl/  internal/  LICENSE  PATENTS

Is it possible to ignore the vendor directory somehow? It works fine if there's no vendor directory in the project.

This problem is not as easy as it seems to be, because potentially the Gobind itself can be incapable of such an option.

hajimehoshi commented 2 years ago

The current Gomobile package doesn't contain bind and cmd packages in vendor mode and I cannot explicitly force vendor mod for bind/cmd packages using _ import.

I'm not sure the situation, but is this your vendor directory? Is it possible to include cmd in your vendor?

kordax commented 2 years ago

I can do this, but it will be gone with the next go mod vendor command.

hajimehoshi commented 2 years ago

I think this is not an issue in Ebiten but in gomobile. A regular gomobile-bind caused the same error.

hajimehoshi commented 2 years ago

https://github.com/golang/go/issues/34181

kordax commented 2 years ago

Yep, looks like it's gobind issue:

gobind -lang=go,java -outdir=/tmp/gomobile-work-1386653115 -javapkg=net.isoftservices.client ./src/game/android
unable to import bind: [-: cannot find package "." in:
    /home/kordax/Projects/maxbet/octopus/vendor/golang.org/x/mobile/bind]
unable to import bind: [-: cannot find package "." in:
    /home/kordax/Projects/maxbet/octopus/vendor/golang.org/x/mobile/bind]
unable to import bind: [-: cannot find package "." in:
    /home/kordax/Projects/maxbet/octopus/vendor/golang.org/x/mobile/bind]
"golang.org/x/mobile/bind" is not found; run go get golang.org/x/mobile/bind: [-: cannot find package "." in:
    /home/kordax/Projects/maxbet/octopus/vendor/golang.org/x/mobile/bind]