Changes between Version 133 and Version 134 of AndroidPort


Ignore:
Timestamp:
Jan 20, 2012, 3:35:01 PM (12 years ago)
Author:
Anders Feder
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AndroidPort

    v133 v134  
    196196Then download the game source code into the `jni/src` directory under the project directory, e.g.:
    197197
     198=== Building the application ===
     199The native library (i.e. the actual game) is built using the standard Premake build system as follows. 
     200
     201First install a standalone toolchain:
     202
     203{{{
     204$ ~/android/android-ndk-r7-crystax-4/build/tools/make-standalone-toolchain.sh --platform=android-14 --install-dir=$HOME/android/toolchain
     205}}}
     206
     207
     208Set up external libraries with the new toolchain somehow, or do an ugly hack that will at least let it start compiling enough for now:
     209
     210{{{
     211$ ln -s /usr/include/boost ~/android/toolchain/sysroot/usr/include/
     212$ ln -s /usr/include/iconv.h ~/android/toolchain/sysroot/usr/include/
     213}}}
     214
     215
     216Download the game from SVN to any location, as normal.
     217
    198218{{{
    199219$ svn co http://svn.wildfiregames.com/public/ps/trunk/ ~/android/0ad/jni/src
    200220}}}
    201 Open the file `Android.mk` in the `jni/src` directory under the project directory in a text editor, e.g.:
    202 
    203 {{{
    204 $ nano -w ~/android/0ad/jni/src/Android.mk
    205 }}}
    206 Add the full path of the `jni/src/source` directory to the `LOCAL_C_INCLUDES` declaration, e.g.:
    207 
    208 {{{
    209 LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include \
    210         /home/youruser/android/0ad/jni/src/source
    211 }}}
    212 Add the `source/main.cpp` file to the `LOCAL_SRC_FILES` declaration:
    213 
    214 {{{
    215 # Add your application source files here...
    216 LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.cpp \
    217         source/main.cpp
    218 }}}
    219 Then save the file and exit the text editor.
    220 
    221 === Installing replacement libraries ===
    222 The Android platform provides only a very minimal C++ runtime support library (/system/lib/libstdc++) and corresponding headers for it in the NDK. To compile the game with the Standard C++ Library, we have to explicitly instruct `ndk-build` to compile against the GNU STL runtime. We also have to explicitly enable support for exceptions, and set the `CONFIG2_GLES` flag so the game is compiled to target the OpenGL ES API.
    223 
    224 Create a new file called `Application.mk` under the `jni` directory in the project directory, e.g.:
    225 
    226 {{{
    227 $ nano -w ~/android/0ad/jni/Application.mk
    228 }}}
    229 Insert these three lines in the file, substituting the part after the `:=` on the first line with the full path of your project directory:
    230 
    231 {{{
    232 APP_PROJECT_PATH := /home/youruser/android/0ad
    233 APP_STL := gnustl_static
    234 APP_CPPFLAGS += -fexceptions -DCONFIG2_GLES
    235 }}}
    236 Then save the file and exit the text editor.
    237 
    238 Download the following libraries to the working directory and then unpack them there:
    239 
    240  * [http://www.boost.org/users/download/#live Boost] (latest version)
    241  * [https://developer.mozilla.org/en/SpiderMonkey/1.8.5 SpiderMonkey] (1.8.5)
    242 
    243 Move the source code directory of each library into a new directory called `jni/lib` under the project directory, e.g.:
    244 
    245 {{{
    246 $ cd ~/android
    247 $ mkdir 0ad/jni/lib
    248 $ mv boost_1_48_0/boost ~/android/0ad/jni/lib/boost
    249 $ mv js-1.8.5/js/src ~/android/0ad/jni/lib/js
    250 }}}
    251 Also copy the SDL source code into the new directory:
    252 
    253 {{{
    254 $ cp -r ~/android/0ad/jni/SDL/src ~/android/0ad/jni/lib/SDL
    255 }}}
    256 Open the file `Android.mk` in the `jni/src` directory under the project directory in a text editor, e.g.:
    257 
    258 {{{
    259 $ nano -w ~/android/0ad/jni/src/Android.mk
    260 }}}
    261 Add the full path of the new directory to the `LOCAL_C_INCLUDES` declaration, e.g.:
    262 
    263 {{{
    264 LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include \
    265         /home/youruser/android/0ad/jni/src/source \
    266         /home/youruser/android/0ad/jni/lib
    267 }}}
    268 Then save the file and exit the text editor.
    269 
    270 Now we must build !SpiderMonkey. Change directory to the !SpiderMonkey source code directory, e.g.:
    271 
    272 {{{
    273 $ cd ~/android/0ad/jni/lib/js
    274 }}}
    275 Then execute the following commands to compile !SpiderMonkey as a static library:
    276 
    277 {{{
    278 $ ./configure --disable-shared-js
    279 $ make
    280 }}}
    281 === Building the application ===
    282 The native library (i.e. the actual game) is built by running the `ndk-build` command in the project directory, e.g.:
    283 
    284 {{{
    285 $ cd ~/android/0ad/
    286 $ ~/android/android-ndk-r7-crystax-4/ndk-build
    287 }}}
    288 === Alternative approach ===
    289 Build using the standard Premake build system thusly:
    290 
    291  1. Do "Setting up your workstation" as above.
    292  1. Install a standalone toolchain:
    293 {{{
    294 ~/android/android-ndk-r7-crystax-4/build/tools/make-standalone-toolchain.sh --platform=android-14 --install-dir=$HOME/android/toolchain
    295 }}}
    296  1. Set up external libraries with the new toolchain somehow, or do an ugly hack that will at least let it start compiling enough for now:
    297 {{{
    298 ln -s /usr/include/boost ~/android/toolchain/sysroot/usr/include/
    299 ln -s /usr/include/iconv.h ~/android/toolchain/sysroot/usr/include/
    300 }}}
    301  1. Download the game from SVN to any location, as normal.
    302  1. Build the game as normal, but with
    303 {{{
    304 HOSTTYPE=arm
    305 ./update-workspaces.sh --gles
    306 PATH=~/android/toolchain/bin:$PATH
    307 CXX=arm-linux-androideabi-g++
    308 make config=debug -k pyrogenesis
    309 }}}
    310  1. See loads of build errors.
    311  1. Fix all the build errors.
    312  1. Fix the build system.
     221
     222
     223Build the game as normal, but with:
     224
     225{{{
     226$ cd ~/android/0ad/build/workspaces
     227$ HOSTTYPE=arm
     228$ ./update-workspaces.sh --gles
     229$ PATH=~/android/toolchain/bin:$PATH
     230$ CXX=arm-linux-androideabi-g++
     231$ make config=debug -k pyrogenesis
     232}}}
     233See loads of build errors.
     234
     235Fix all the build errors.
     236
     237Fix the build system.