Difference between revisions of "Compiling ScummVM/iPhone"

From ScummVM :: Wiki
Jump to navigation Jump to search
(Stub out XCode instructions till they are up to date.)
(→‎Unofficial SDK: Update cross-compilation instructions.)
Line 5: Line 5:
'''TODO:''' Describe how to use XCode and create_project to compile for iOS using the official Apple toolchain.
'''TODO:''' Describe how to use XCode and create_project to compile for iOS using the official Apple toolchain.


= Unofficial SDK =
= Cross-Compilation =


== Setup ==
Please note binaries generated with these instructions only work with jailbroken devices.
 
== Toolchain Setup ==


=== Toolchain ===
=== Toolchain ===
First, you'll need to set up the [http://www.saurik.com/id/4 toolchain]. Earlier versions than the one linked will NOT work.


=== Environment variables ===
First you need to set up a toolchain for cross-compilation. On our buildbot we use [https://github.com/lordhoto/ios-toolchain this toolchain]. It is based on LLVM/Clang and contains instructions on how to set it up.
You'll need to set some environment variables for both the external libraries, and ScummVM itself. This is so the right compiler and libraries will be used.
 
=== External libs ===
 
In the previously linked toolchain a script to compile all libraries used by the iOS version of ScummVM is contained. Please refer to the toolchain's README file on how to build them.


<pre>
== Building ScummVM ==
export SDKROOT=<your toolkit directory>
export SYSROOT="$SDKROOT/sys"
export BUILDENV="$SDKROOT/pre"
export FDIR="$SYSROOT"
export CC="$BUILDENV/bin/arm-apple-darwin9-gcc -v"
export CXX="$BUILDENV/bin/arm-apple-darwin9-g++"
export LD=$CC
export SHAREDOPTS="-isysroot $SYSROOT -fobjc-abi-version=2 -I$SDKROOT/include"
export FRAMEWORKS="-F$FDIR/System/Library/PrivateFrameworks/ -F$FDIR/System/Library/Frameworks/"
export LDFLAGS="-L$BUILDENV/arm-apple-darwin9/lib/ $FRAMEWORKS $SHAREDOPTS -bind_at_load -lobjc"
export CXXFLAGS="-I$SYSROOT/usr/include $SHAREDOPTS"
export OBJCFLAGS="-I$SYSROOT/usr/include/ $SHAREDOPTS --std=c99"
export CFLAGS="$CXXFLAGS"
export AS=$SDKROOT/pre/bin/arm-apple-darwin9-as
</pre>


=== Configuration ===


=== External libs ===
Before we can compile ScummVM we need to configure the source tree for building. This is usually only required once or when you want to alter build options.
Then, set up any of the external libs you might want. Meaning libMAD for MP3 playback, libFLAC for FLAC support and/or Tremor for Ogg support.
 
==== Choosing an iOS target ====
 
We feature two different iOS backends:
* ''iphone'': Our legacy iOS backend, which supports all iOS3+ devices.
* ''ios7'': Our modern iOS7+ backend, which only supports iOS7+ devices but features better integration for these.


Note that you only need to add these if you need support for those filetypes. ScummVM itself will run fine without them. You can also download the already compiled libraries from the link in the Official SDK section above.
Depending on which backend you use you will need to use a different value for the ''TARGET'' environment variable.


The below should usually do the trick for these:
* For ''iphone'' use:
<pre>
<source lang="bash">
./configure --host=arm-darwin --prefix=$SDKROOT/sys/
export TARGET=arm-apple-darwin9
make && make install
</source>
</pre>


=== ScummVM ===
* For ''ios7'' use:
<source lang="bash">
export TARGET=arm-apple-darwin11
</source>


Then, we need to configure ScummVM itself.
==== Setting up the Environment ====


<pre>
<source lang="bash">
./configure --host=iphone \
export PATH="$IOS_TOOLCHAIN_BASE/bin:$IOS_TOOLCHAIN_BASE/$TARGET/bin:$IOS_TOOLCHAIN_BASE/$TARGET/usr/bin:$PATH"
--disable-mt32emu --disable-scalers  --enable-release \
export CPPFLAGS="-isystem $IOS_TOOLCHAIN_BASE/$TARGET/usr/include"
--with-flac-prefix=/$SYSROOT/usr/local \
export LDFLAGS="-L$IOS_TOOLCHAIN_BASE/$TARGET/usr/lib"
--with-mad-prefix=/$SYSROOT/usr/local \
</source>
--with-tremor-prefix=/$SYSROOT/usr/local
Where ''IOS_TOOLCHAIN_BASE'' contains the directory where you installed the toolchain. And ''TRAGET'' has been setup from the previous step.
</pre>


Note that the --with-flac-prefix (and the rest) is only necessary if you want to include support for that specific library.
'''NOTE''': If you quit the shell you are using when configuring ScummVM and pick up compilation later, you will need to re-export only the ''PATH'' variable like described above.


If you've installed the external libs in any other place than $SYSROOT/usr/local, you need to use that location instead.
==== Configuring the Build ====


== Compiling ==
Then configure ScummVM for the iOS version you want to target.


Now, we can start the compile:
First, navigate to a path where you want your build files to be located (this can be the ScummVM root directory but does not have to be).
Then run the following:
<source lang="bash">
./path/to/scummvm/configure --host=ios7 --with-staticlib-prefix=$IOS_TOOLCHAIN_BASE/$TARGET/usr
</source>
Replace ''ios7'' with ''iphone'' if you want to build the older version of our iOS backend.


<pre>
=== Compilation ===
make iphone
</pre>


Lastly, we want to make a ScummVM.app bundle:
You can simple compile ScummVM with running make:
<source lang="bash">
make iphone
</source>
If you simply want to test whether changes you made compile but do not plan to use the binary for deployment you can also simply run ''make''.


<pre>
Please note that if you want to deploy ScummVM on your iOS device you will need to generate a bundle file. For this run either:
make iphonebundle
<source lang="bash">
</pre>
make ios7bundle
</source>
for the ''ios7'' backend. Or
<source lang="bash">
make iphonebundle
</source>
for the ''iphone'' backend.


Then simply upload the whole ScummVM.app directory to your device under the /Applications folder, and you're done!
Then simply upload the whole ScummVM.app directory to your device under the /Applications folder, and you're done!

Revision as of 15:14, 30 March 2016

This page explains how to compile your own version of ScummVM using the iPhone backend.

Using XCode

TODO: Describe how to use XCode and create_project to compile for iOS using the official Apple toolchain.

Cross-Compilation

Please note binaries generated with these instructions only work with jailbroken devices.

Toolchain Setup

Toolchain

First you need to set up a toolchain for cross-compilation. On our buildbot we use this toolchain. It is based on LLVM/Clang and contains instructions on how to set it up.

External libs

In the previously linked toolchain a script to compile all libraries used by the iOS version of ScummVM is contained. Please refer to the toolchain's README file on how to build them.

Building ScummVM

Configuration

Before we can compile ScummVM we need to configure the source tree for building. This is usually only required once or when you want to alter build options.

Choosing an iOS target

We feature two different iOS backends:

  • iphone: Our legacy iOS backend, which supports all iOS3+ devices.
  • ios7: Our modern iOS7+ backend, which only supports iOS7+ devices but features better integration for these.

Depending on which backend you use you will need to use a different value for the TARGET environment variable.

  • For iphone use:
export TARGET=arm-apple-darwin9
  • For ios7 use:
export TARGET=arm-apple-darwin11

Setting up the Environment

export PATH="$IOS_TOOLCHAIN_BASE/bin:$IOS_TOOLCHAIN_BASE/$TARGET/bin:$IOS_TOOLCHAIN_BASE/$TARGET/usr/bin:$PATH"
export CPPFLAGS="-isystem $IOS_TOOLCHAIN_BASE/$TARGET/usr/include"
export LDFLAGS="-L$IOS_TOOLCHAIN_BASE/$TARGET/usr/lib"

Where IOS_TOOLCHAIN_BASE contains the directory where you installed the toolchain. And TRAGET has been setup from the previous step.

NOTE: If you quit the shell you are using when configuring ScummVM and pick up compilation later, you will need to re-export only the PATH variable like described above.

Configuring the Build

Then configure ScummVM for the iOS version you want to target.

First, navigate to a path where you want your build files to be located (this can be the ScummVM root directory but does not have to be). Then run the following:

./path/to/scummvm/configure --host=ios7 --with-staticlib-prefix=$IOS_TOOLCHAIN_BASE/$TARGET/usr

Replace ios7 with iphone if you want to build the older version of our iOS backend.

Compilation

You can simple compile ScummVM with running make:

make iphone

If you simply want to test whether changes you made compile but do not plan to use the binary for deployment you can also simply run make.

Please note that if you want to deploy ScummVM on your iOS device you will need to generate a bundle file. For this run either:

make ios7bundle

for the ios7 backend. Or

make iphonebundle

for the iphone backend.

Then simply upload the whole ScummVM.app directory to your device under the /Applications folder, and you're done!