Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS native porting #4

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
9dfe41b
issue #1 add iOS configuration.
outlandkarasu Dec 20, 2020
e11fb73
issue #1 setup OpenGL static declration for iOS.
outlandkarasu Dec 21, 2020
8d04594
issue #1 fix compile errors.
outlandkarasu Dec 21, 2020
4f96177
Merge pull request #2 from outlandkarasu/1-add-ios-configuration
outlandkarasu Dec 21, 2020
4b84ea8
issue #3 add build shell for iOS Universal Library.
outlandkarasu Dec 21, 2020
002f56d
Merge pull request #4 from outlandkarasu/3-add-ios-build-shell
outlandkarasu Dec 21, 2020
44c2b2d
issue #5 add download and build libraries shell.
outlandkarasu Dec 21, 2020
2eebbdb
issue #5 split shells.
outlandkarasu Dec 21, 2020
ac6f4ad
issue #5 add bindbc-sdl submodule.
outlandkarasu Dec 21, 2020
87aa1ea
issue #5 remove lipo.
outlandkarasu Dec 21, 2020
8bff93d
issue #5 rename shells.
outlandkarasu Dec 21, 2020
393cc44
Merge pull request #6 from outlandkarasu/5-add-library-build-shell
outlandkarasu Dec 21, 2020
c8694a9
issue #7 add Xcode project.
outlandkarasu Dec 21, 2020
c993842
issue #7 remove unused entries.
outlandkarasu Dec 21, 2020
672023d
issue #7 add Xcode library dependencies.
outlandkarasu Dec 21, 2020
d874d8b
issue #7 fix resource groups.
outlandkarasu Dec 21, 2020
41b4a19
issue #7 add druntime copy.
outlandkarasu Dec 22, 2020
85bb0f7
issue #7 fix bindbc-sdl build shell.
outlandkarasu Dec 22, 2020
a24a0a2
Merge pull request #8 from outlandkarasu/7-add-xcode-project
outlandkarasu Dec 22, 2020
5f40709
issue #9 add main function for iOS.
outlandkarasu Dec 22, 2020
a5c0524
Merge pull request #10 from outlandkarasu/9-replace-main-function
outlandkarasu Dec 22, 2020
9bf969c
issue #11 add OpenGL ES version.
outlandkarasu Dec 22, 2020
01ca231
issue #11 fit landscape window.
outlandkarasu Dec 22, 2020
4097468
Merge pull request #12 from outlandkarasu/11-fix-opengl-error
outlandkarasu Dec 22, 2020
6a0698c
issue #13 add iOS build shells.
outlandkarasu Jan 2, 2021
3588fec
issue #13 fix run with console.
outlandkarasu Jan 2, 2021
ea9c01f
issue #13 add virtualpad input backend.
outlandkarasu Jan 2, 2021
f8a4069
issue #13 fix pad position.
outlandkarasu Jan 2, 2021
67487c5
issue #13 move button definitions to input module.
outlandkarasu Jan 2, 2021
8a22102
issue #13 fix position translation.
outlandkarasu Jan 2, 2021
026f8e8
issue #13 fill buttons on pressed.
outlandkarasu Jan 2, 2021
21fa209
issue #13 fix position.
outlandkarasu Jan 2, 2021
d2f83dc
Merge pull request #14 from outlandkarasu/13-add-virtual-gamepad
outlandkarasu Jan 2, 2021
e3f18e6
issue #15 add exit button.
outlandkarasu Jan 2, 2021
6a3345c
issue #15 add pause button.
outlandkarasu Jan 2, 2021
9d632d2
Merge pull request #16 from outlandkarasu/15-add-pause-and-escape
outlandkarasu Jan 2, 2021
d0fe720
issue #17 move ios dirs.
outlandkarasu Jan 3, 2021
6e577c1
issue #17 add iOS app icon set.
outlandkarasu Jan 3, 2021
c7259fa
issue #17 fix build dir.
outlandkarasu Jan 3, 2021
751626f
issue #17 update gitignore.
outlandkarasu Jan 3, 2021
7d7ca9d
Merge pull request #18 from outlandkarasu/17-move-ios-dirs
outlandkarasu Jan 3, 2021
fc21c8f
issue #19 add build instructions.
outlandkarasu Jan 3, 2021
e0bdfba
Merge pull request #20 from outlandkarasu/19-add-ios-readme
outlandkarasu Jan 3, 2021
868e480
issue #21 fix dub options.
outlandkarasu Jan 3, 2021
7a33272
issue #21 fix dub.json sourcePaths.
outlandkarasu Jan 3, 2021
e8a5cdc
Merge pull request #22 from outlandkarasu/21-fix-dub-build-options
outlandkarasu Jan 3, 2021
304c3a7
issue #21 add win64 configuration.
outlandkarasu Jan 3, 2021
213be6f
Merge pull request #23 from outlandkarasu/21-add-win64-configuration
outlandkarasu Jan 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ tt-test-*
*.lib
*.obj
*.lst
*.sln
*.sln

.DS_Store

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "ios-libs/bindbc-sdl"]
path = ios/libs/bindbc-sdl
url = https://github.com/BindBC/bindbc-sdl.git
2 changes: 2 additions & 0 deletions dist/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/tt.app

73 changes: 67 additions & 6 deletions dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
{
"name": "wasm_debug",
"targetPath": "web",
"sourceFiles": [
"src/**.d"
"sourcePaths": [
"src"
],
"dependencies": {"runtime": {"path": "runtime"}},
"dflags": ["-i=.", "-i=std"],
Expand All @@ -29,8 +29,8 @@
{
"name": "wasm",
"targetPath": "web",
"sourceFiles": [
"src/**.d"
"sourcePaths": [
"src"
],
"dependencies": {"runtime": {"path": "runtime"}},
"dflags": ["-i=.", "-i=std", "-L=-allow-undefined"],
Expand All @@ -43,8 +43,10 @@
{
"name": "win32",
"platforms": ["windows-x86"],
"sourcePaths": [
"src"
],
"sourceFiles": [
"src/**.d",
"resource/tt.res"
],
"importPaths": [
Expand Down Expand Up @@ -73,6 +75,65 @@
"bindbc-opengl": "dynamicBC",
"bindbc-sdl": "dynamicBC"
}
},
{
"name": "win64",
"platforms": ["windows-x86_64"],
"sourcePaths": [
"src"
],
"sourceFiles": [
"resource/tt.res"
],
"importPaths": [
"lib"
],
"copyFiles": [
"lib/SDL2-2.0.12/lib/x64/SDL2.dll",
"lib/SDL2-2.0.12/README-SDL.txt",
"lib/SDL2_mixer-2.0.4/lib/x64/SDL2_mixer.dll",
"lib/SDL2_mixer-2.0.4/lib/x64/libvorbis-0.dll",
"lib/SDL2_mixer-2.0.4/lib/x64/libvorbisfile-3.dll",
"lib/SDL2_mixer-2.0.4/lib/x64/libogg-0.dll"
],
"dependencies": {
"bindbc-opengl": "~>0.13.0",
"bindbc-sdl": "~>0.19.0"
},
"versions": [
"BindBC",
"GL_32",
"GL_Batching",
"SDL_Mixer",
"InputBackendSDL"
],
"subConfigurations": {
"bindbc-opengl": "dynamicBC",
"bindbc-sdl": "dynamicBC"
}
},
{
"name": "iOS",
"targetType": "staticLibrary",
"sourcePaths": [
"src"
],
"dependencies": {
"bindbc-sdl": "~>0.19.0"
},
"versions": [
"IOS",
"BindBC",
"GL_32",
"GL_Batching",
"SDL_2012",
"SDL_Mixer",
"InputBackendSDLTouch",
"BindGL_Static"
],
"subConfigurations": {
"bindbc-sdl": "staticBC"
}
}
]
}
}
42 changes: 42 additions & 0 deletions ios/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# iOS build instructions

## Prerequire

* for building
* LDC2 (>=1.24.0)
* Xcode (>=12.3)
* Apple account registration for App signing.
* Git
* curl
* for running
* iPhone/iPad/iPod touch (>= iOS 14.3)
* iOS Simulator

## Instructions

### Download and build libraries

Change directory to `libs/` and run follow shells.

1. `00_copy_druntimes.sh`
* Copy druntime and phobos library files from LDC2 directory.
1. `01_download-and-build-SDL2.sh`
* Download a SDL2 source tarball and build using iOS configuration.
1. `02_download-and-build-SDL2_mixer.sh`
* Download a SDL2_mixer source tarball and build using iOS configuration.
1. `03_build-bindbc-sdl.sh`
* Update bindbc-sdl from Github repository and build with patching to dub.sdl.

### Build tt.app

Change directory to this file directory.

1. `build-ios.sh`
* Compile `libtt.a` object files.
* Merge dependency libraries.
* Build `project/build/tt.app` for iPhone simulator.
1. Build for real iOS devices using Xcode.
* Setting up signing capability in target configuration.
* It need Apple developer registration and private key for App signing.
* Build target `tt` for iOS arm64 architecture.

32 changes: 32 additions & 0 deletions ios/build-ios.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

cd `dirname $0`

IOS_DIR=`pwd`
LIBS_DIR=${IOS_DIR}/libs
BUILD_DIR=${IOS_DIR}/project/build

cd ../

DIST_DIR=`pwd`/dist

dub build --compiler=ldc2 --arch=arm64-apple-ios --config=iOS || exit $?
libtool -static -o ${LIBS_DIR}/libtt-ios-arm64.a ${DIST_DIR}/libtt.a ${LIBS_DIR}/*-arm64.a &> /dev/null || exit $?

dub build --compiler=ldc2 --arch=x86_64-apple-ios --config=iOS || exit $?
libtool -static -o ${LIBS_DIR}/libtt-ios-x86_64.a ${DIST_DIR}/libtt.a ${LIBS_DIR}/*-x86_64.a &> /dev/null || exit $?

xcrun -sdk iphoneos lipo -create \
${LIBS_DIR}/libtt-ios-arm64.a \
${LIBS_DIR}/libtt-ios-x86_64.a \
-output ${LIBS_DIR}/libtt-ios.a \
&> /dev/null

xcodebuild -project ${IOS_DIR}/project/tt.xcodeproj \
-scheme tt \
-sdk iphonesimulator \
clean build \
CONFIGURATION_BUILD_DIR=${BUILD_DIR} \
ARCHS=x86_64 \
ONLY_ACTIVE_ARCH=NO

5 changes: 5 additions & 0 deletions ios/libs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/SDL
/SDL2-*
/SDL2_mixer-*
/*.a

16 changes: 16 additions & 0 deletions ios/libs/00_copy_druntimes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

cd `dirname $0`

LIBS_DIR=`pwd`

LDC2_HOME=`which ldc2`
LDC2_HOME=`dirname $LDC2_HOME`
LDC2_HOME=`dirname $LDC2_HOME`

cp ${LDC2_HOME}/lib-ios-arm64/libdruntime-ldc.a ${LIBS_DIR}/libdruntime-ldc-arm64.a
cp ${LDC2_HOME}/lib-ios-x86_64/libdruntime-ldc.a ${LIBS_DIR}/libdruntime-ldc-x86_64.a

cp ${LDC2_HOME}/lib-ios-arm64/libphobos2-ldc.a ${LIBS_DIR}/libphobos2-ldc-arm64.a
cp ${LDC2_HOME}/lib-ios-x86_64/libphobos2-ldc.a ${LIBS_DIR}/libphobos2-ldc-x86_64.a

35 changes: 35 additions & 0 deletions ios/libs/01_download-and-build-SDL2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh

cd `dirname $0`

LIBS_DIR=`pwd`
SDL2_VERSION=2.0.12
SDL2_BASE_NAME=SDL2-${SDL2_VERSION}

curl -L -O https://www.libsdl.org/release/${SDL2_BASE_NAME}.tar.gz
tar xvzf ./${SDL2_BASE_NAME}.tar.gz
rm -f ./${SDL2_BASE_NAME}.tar.gz

xcodebuild \
-project ./${SDL2_BASE_NAME}/Xcode-iOS/SDL/SDL.xcodeproj \
-scheme libSDL-iOS \
-sdk iphoneos \
clean build \
CONFIGURATION_BUILD_DIR=${LIBS_DIR} \
ARCHS=arm64 \
ONLY_ACTIVE_ARCH=NO
mv ${LIBS_DIR}/libSDL2.a ${LIBS_DIR}/libSDL2-arm64.a

xcodebuild \
-project ./${SDL2_BASE_NAME}/Xcode-iOS/SDL/SDL.xcodeproj \
-scheme libSDL-iOS \
-sdk iphonesimulator \
clean build \
CONFIGURATION_BUILD_DIR=${LIBS_DIR} \
ARCHS=x86_64 \
ONLY_ACTIVE_ARCH=NO
mv ${LIBS_DIR}/libSDL2.a ${LIBS_DIR}/libSDL2-x86_64.a

mkdir -p ./SDL/include
cp -r ./${SDL2_BASE_NAME}/include/* ./SDL/include

33 changes: 33 additions & 0 deletions ios/libs/02_download-and-build-SDL2_mixer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh

cd `dirname $0`

LIBS_DIR=`pwd`

SDL2_MIXER_VERSION=2.0.4
SDL2_MIXER_BASE_NAME=SDL2_mixer-${SDL2_MIXER_VERSION}

curl -L -O https://www.libsdl.org/projects/SDL_mixer/release/${SDL2_MIXER_BASE_NAME}.tar.gz
tar xvzf ./${SDL2_MIXER_BASE_NAME}.tar.gz
rm -f ./${SDL2_MIXER_BASE_NAME}.tar.gz

xcodebuild \
-project ./${SDL2_MIXER_BASE_NAME}/Xcode-iOS/SDL_mixer.xcodeproj \
-scheme libSDL_mixer-iOS \
-sdk iphoneos \
clean build \
CONFIGURATION_BUILD_DIR=${LIBS_DIR} \
ARCHS=arm64 \
ONLY_ACTIVE_ARCH=NO
mv ${LIBS_DIR}/libSDL2_mixer.a ${LIBS_DIR}/libSDL2_mixer-arm64.a

xcodebuild \
-project ./${SDL2_MIXER_BASE_NAME}/Xcode-iOS/SDL_mixer.xcodeproj \
-scheme libSDL_mixer-iOS \
-sdk iphonesimulator \
clean build \
CONFIGURATION_BUILD_DIR=${LIBS_DIR} \
ARCHS=x86_64 \
ONLY_ACTIVE_ARCH=NO
mv ${LIBS_DIR}/libSDL2_mixer.a ${LIBS_DIR}/libSDL2_mixer-x86_64.a

25 changes: 25 additions & 0 deletions ios/libs/03_build-bindbc-sdl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh

cd `dirname $0`

LIBS_DIR=`pwd`

git submodule update

cat >> ${LIBS_DIR}/bindbc-sdl/dub.sdl <<EOS
configuration "staticBCwithMixer" {
dflags "-betterC"
versions "BindSDL_Static" "SDL_2012" "SDL_Mixer"
excludedSourceFiles "source/bindbc/sdl/dynload.d"
}
EOS

cd ${LIBS_DIR}/bindbc-sdl
dub build --compiler=ldc2 --arch=arm64-apple-ios --config=staticBCwithMixer
mv lib/libBindBC_SDL.a ${LIBS_DIR}/libBindBC_SDL-arm64.a

dub build --compiler=ldc2 --arch=x86_64-apple-ios --config=staticBCwithMixer
mv lib/libBindBC_SDL.a ${LIBS_DIR}/libBindBC_SDL-x86_64.a

cd ${LIBS_DIR}/bindbc-sdl && git reset --hard

1 change: 1 addition & 0 deletions ios/libs/bindbc-sdl
Submodule bindbc-sdl added at ed061a
3 changes: 3 additions & 0 deletions ios/project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
xcuserdata/
build/

Loading