From d7a9193e5283c07780e4d43227542832a842a42f Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 18 Nov 2019 02:18:10 +0900 Subject: [PATCH] mobile: Enable to compile in non-mobile environments This was necessary to show API documents on godoc.org and pkg.go.dev. --- mobile/impl_mobile.go | 25 +++++++++++++++++++++++++ mobile/impl_notmobile.go | 22 ++++++++++++++++++++++ mobile/mobile.go | 5 +---- 3 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 mobile/impl_mobile.go create mode 100644 mobile/impl_notmobile.go diff --git a/mobile/impl_mobile.go b/mobile/impl_mobile.go new file mode 100644 index 000000000..a6bfb108d --- /dev/null +++ b/mobile/impl_mobile.go @@ -0,0 +1,25 @@ +// Copyright 2019 The Ebiten Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build android ios + +package mobile + +import ( + "github.com/hajimehoshi/ebiten/mobile/ebitenmobileview" +) + +func setGame(game Game) { + ebitenmobileview.SetGame(game) +} diff --git a/mobile/impl_notmobile.go b/mobile/impl_notmobile.go new file mode 100644 index 000000000..8d211bd97 --- /dev/null +++ b/mobile/impl_notmobile.go @@ -0,0 +1,22 @@ +// Copyright 2019 The Ebiten Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build !android +// +build !ios + +package mobile + +func setGame(game Game) { + panic("mobile: setGame is not implemented in this environment") +} diff --git a/mobile/mobile.go b/mobile/mobile.go index b1a14d33b..3d7eda11d 100644 --- a/mobile/mobile.go +++ b/mobile/mobile.go @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build android ios - // Package mobile provides functions for mobile platforms (Android and iOS). // // This package is used when you use `ebitenmobile bind`. @@ -23,7 +21,6 @@ package mobile import ( "github.com/hajimehoshi/ebiten" - "github.com/hajimehoshi/ebiten/mobile/ebitenmobileview" ) // Game defines necessary functions for a mobile game. @@ -49,5 +46,5 @@ type Game interface { // // SetGame can be called anytime. Until SetGame is called, the game does not start. func SetGame(game Game) { - ebitenmobileview.SetGame(game) + setGame(game) }