cmd/ebitenmobile: update gomobile version (reland)

This switches from .framework to .xcframwork for iOS.

Closes #1922
This commit is contained in:
Hajime Hoshi 2022-01-05 02:27:17 +09:00
parent c67e4385de
commit 116203c5a5
4 changed files with 52 additions and 63 deletions

View File

@ -113,4 +113,4 @@ jobs:
if: ${{ startsWith(matrix.os, 'macos-') && !startsWith(matrix.go, '1.15.') && !startsWith(matrix.go, '1.16.') }}
run: |
cd /tmp/go-inovation
ebitenmobile bind -target ios -o Inovation.framework -v github.com/hajimehoshi/go-inovation/mobile
ebitenmobile bind -target ios -o Inovation.xcframework -v github.com/hajimehoshi/go-inovation/mobile

View File

@ -23,7 +23,7 @@ import (
"runtime"
)
const gomobileHash = "5d9a33257ab559d10fa8c96087aed99bf8b6d868"
const gomobileHash = "4a8be17bd2e3f4793a871839e766cbea7e999464"
func runCommand(command string, args []string, env []string) error {
if buildX || buildN {

View File

@ -221,42 +221,61 @@ func doBind(args []string, flagset *flag.FlagSet, buildOS string) error {
}
if buildOS == "darwin" {
dir := filepath.Join(buildO, "Versions", "A")
if err := ioutil.WriteFile(filepath.Join(dir, "Headers", prefixUpper+"EbitenViewController.h"), []byte(replacePrefixes(objcH)), 0644); err != nil {
return err
}
// TODO: Remove 'Ebitenmobileview.objc.h' here. Now it is hard since there is a header file importing
// that header file.
fs, err := ioutil.ReadDir(filepath.Join(dir, "Headers"))
// TODO: Use os.ReadDir after Ebiten stops supporting Go 1.15.
f, err := os.Open(buildO)
if err != nil {
return err
}
var headerFiles []string
for _, f := range fs {
if strings.HasSuffix(f.Name(), ".h") {
headerFiles = append(headerFiles, f.Name())
defer f.Close()
names, err := f.Readdirnames(-1)
if err != nil {
return err
}
for _, name := range names {
if name == "Info.plist" {
continue
}
}
frameworkName := filepath.Base(buildO)
frameworkName = frameworkName[:len(frameworkName)-len(".xcframework")] + ".framework"
dir := filepath.Join(buildO, name, frameworkName, "Versions", "A")
w, err := os.OpenFile(filepath.Join(dir, "Modules", "module.modulemap"), os.O_WRONLY, 0644)
if err != nil {
return err
}
defer w.Close()
var mmVals = struct {
Module string
Headers []string
}{
Module: prefixUpper,
Headers: headerFiles,
}
if err := iosModuleMapTmpl.Execute(w, mmVals); err != nil {
return err
}
if err := ioutil.WriteFile(filepath.Join(dir, "Headers", prefixUpper+"EbitenViewController.h"), []byte(replacePrefixes(objcH)), 0644); err != nil {
return err
}
// TODO: Remove 'Ebitenmobileview.objc.h' here. Now it is hard since there is a header file importing
// that header file.
// TODO: Remove Ebitenmobileview.objc.h?
fs, err := ioutil.ReadDir(filepath.Join(dir, "Headers"))
if err != nil {
return err
}
var headerFiles []string
for _, f := range fs {
if strings.HasSuffix(f.Name(), ".h") {
headerFiles = append(headerFiles, f.Name())
}
}
w, err := os.OpenFile(filepath.Join(dir, "Modules", "module.modulemap"), os.O_WRONLY, 0644)
if err != nil {
return err
}
defer w.Close()
var mmVals = struct {
Module string
Headers []string
}{
Module: prefixUpper,
Headers: headerFiles,
}
if err := iosModuleMapTmpl.Execute(w, mmVals); err != nil {
return err
}
// TODO: Remove Ebitenmobileview.objc.h?
}
}
return nil

View File

@ -240,22 +240,6 @@ package mobile
//
// property->nAxes = 6;
// property->nHats = 1;
// } else if (controller.gamepad) {
// property->buttonMask |= (1 << kControllerButtonA);
// property->buttonMask |= (1 << kControllerButtonB);
// property->buttonMask |= (1 << kControllerButtonX);
// property->buttonMask |= (1 << kControllerButtonY);
// property->buttonMask |= (1 << kControllerButtonLeftShoulder);
// property->buttonMask |= (1 << kControllerButtonRightShoulder);
// // This button's detection actually does not happen.
// property->buttonMask |= (1 << kControllerButtonStart);
// property->nButtons += 7;
//
// vendor = kUSBVendorApple;
// product = 2;
// subtype = 2;
// property->nAxes = 0;
// property->nHats = 1;
// }
//
// const int kSDLHardwareBusBluetooth = 0x05;
@ -284,7 +268,7 @@ package mobile
//
// static void addController(GCController* controller) {
// // Ignore if the controller is not an actual controller.
// if (!controller.extendedGamepad && !controller.gamepad && controller.microGamepad) {
// if (!controller.extendedGamepad && controller.microGamepad) {
// return;
// }
//
@ -399,20 +383,6 @@ package mobile
// if (property.nHats) {
// controllerState->hat = getHatState(gamepad.dpad);
// }
// } else if (controller.gamepad) {
// GCGamepad* gamepad = controller.gamepad;
//
// int buttonCount = 0;
// controllerState->buttons[buttonCount++] = gamepad.buttonA.isPressed;
// controllerState->buttons[buttonCount++] = gamepad.buttonB.isPressed;
// controllerState->buttons[buttonCount++] = gamepad.buttonX.isPressed;
// controllerState->buttons[buttonCount++] = gamepad.buttonY.isPressed;
// controllerState->buttons[buttonCount++] = gamepad.leftShoulder.isPressed;
// controllerState->buttons[buttonCount++] = gamepad.rightShoulder.isPressed;
//
// if (property.nHats) {
// controllerState->hat = getHatState(gamepad.dpad);
// }
// }
// }
// }