HedgeroidGuide.wiki
changeset 119 cd022c242e50
child 120 230afa501524
equal deleted inserted replaced
118:a854206ba50c 119:cd022c242e50
       
     1 #summary Instructions for building Hedgewars for Android
       
     2 = Hedgewars for Android =
       
     3 == Introduction ==
       
     4 
       
     5 This guide will take you through the steps needed to succesfully compile Hedgewars for Android
       
     6 
       
     7 ==Download==
       
     8 
       
     9 We need to download four packages:
       
    10 
       
    11 * [http://code.google.com/p/hedgewars/ Hedgewars Source]<br>
       
    12 * [http://developer.android.com/sdk/index.html Android SDK] (Latest version will do)<br>
       
    13 * [http://developer.android.com/sdk/ndk/index.html Android NDK] (current version is r5b but anything up will probably work)<br>
       
    14 * [http://freepascal.org/down/source/sources.var FreePascal] (Latest (stable) version will do)<br>
       
    15 * [http://www.libsdl.org/tmp/android-project.zip SDL]<br>
       
    16 * [http://www.lua.org/ftp/lua-5.1.4.tar.gz Lua] (Current version is 5.1.4 but anything higher will probably work)<br>
       
    17 
       
    18 ==Hedgewars Source==
       
    19 
       
    20 Using mercurial you can pull the hedgeroid branch using
       
    21 {{{
       
    22 hg clone https://hedgewars.googlecode.com/hg/ hedgewars
       
    23 hg up hedgeroid
       
    24 }}}
       
    25 
       
    26 ==Android SDK==
       
    27 
       
    28 Download the latest version using the link above. And unzip it at a place you can remember, I’ll refer to the location with `<`SDK`>`. Once you’ve unzipped/extracted the tar navigate to `<`SDK`>`/tools and execute ‘android’. This should bring up a GUI select ‘Available packages’, then ‘Android Repository’ and check atleast SDK Platform Android 1.6 / 2.1 / 2.2. I would recommend checking all of them, but it’s up to you. Next select ‘Install Selected’ press ‘Next’ a couple of times and you should have the SDK installed.
       
    29 
       
    30 Optionally you could add `<`SDK`>`/platform-tools to your PATH, this makes it easier to use ‘adb’. Adb is the main program to communicate with Android, think logging/pushing and pulling files/shell.
       
    31 
       
    32 If you do not have a real android device you can create an emulator if you do I’d skip this and continue at Android NDK
       
    33 
       
    34 You can use either the GUI, run android and follow the signs or from cli
       
    35 
       
    36 {{{android create avd -n <name> -t 4}}}
       
    37 -n is a name of your choice -t stands for the target ID
       
    38 
       
    39 See this for more information
       
    40 
       
    41 To run the emulator navigate to `<`SDK`>`/tools and run
       
    42 
       
    43 {{{emulator -avd <name>}}}
       
    44 where `<`name`>` is the same name as when you created it with the line above.
       
    45 
       
    46 ==Android NDK==
       
    47 
       
    48 Download and untar it, ill refer to the ndk as `<`NDK`>`. That’s it :)
       
    49 
       
    50 ==FreePascal==
       
    51 
       
    52 We need to download the sources from the Freepascal website and compile the crosscompiler. I have grabbed the latest stable release 2.4.4 , though any version will work. Once downloaded, extract the  tar/zip and place the files in a known directory. I will refer to the directory  with `<`fpc`>` from now on. Next navigate to the `<`fpc`>` directory and compile it, for this various tools are needed, ‘make’ for instance. But also a fpc compiler for your system. Some apt-get/aptitude magic will solve these problems, make a comment if you run in to problems. Use this to compile the crosscompiler:
       
    53 
       
    54 {{{
       
    55 make crossinstall CPU_TARGET=arm OS_TARGET=linux CROSSBINDIR=<ndk>/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin BINUTILSPREFIX=arm-linux-androideabi- OPT=-dFPC_ARMEL INSTALL_PREFIX=<fpc>/fpc_install
       
    56 }}}
       
    57 
       
    58 ==Lua==
       
    59 
       
    60 For the missions hedgewars uses Lua as it’s scripting environment. Lua almost completely works out of the box only a few files need to be modified I’ve added these to the repo so all we need to do for now is download the tar.gz, extract and decompress the tar somewhere we’ll use it in the final step.
       
    61 
       
    62 
       
    63 
       
    64 ==SDL==
       
    65 
       
    66 Last thing we need is SDL, download the android-project.zip from the link above. unzip/tar it to some location. and that’s it :) After the ‘FINAL’ step (after running cmake .) you can remove this directory if you want
       
    67 
       
    68 ==Final==
       
    69 
       
    70 Next we will create the scripts to compile hedgewars and move SDL directories first you’ll need to make sure cmake knows where all the compilers are
       
    71 
       
    72 open hedgeroid/project_files/Android-build/CMakeLists.txt with your favorite editor and change the first five lines.
       
    73 
       
    74 Change 
       
    75 
       
    76 {{{/home/richard/SoftDev/what/ever}}}
       
    77 
       
    78 to the location where you have stored the Android NDK/SDK, FPC crosscompiler, SDL (android-project) and LUA
       
    79 
       
    80 Only the first 3 lines are needed. The forth and fifth moves the SDL and Lua directories for you if you do not want to do it manually (It’s recommended you let cmake handle this and change these lines!)
       
    81 
       
    82 Next you can use cmake to create the scripts
       
    83 
       
    84 {{{
       
    85 cd <hedgewars-root>
       
    86 cmake .
       
    87 }}}
       
    88 And that’s it. To compile:
       
    89 
       
    90 {{{
       
    91 cd <hedgewars-root>/project_files/Android-build/
       
    92 ./complete_build.sh
       
    93 }}}
       
    94 and it should be installed on your emulator/device if it was connected.
       
    95 
       
    96 On the device/emulator start the application up :)
       
    97 
       
    98 
       
    99 TODO verify that it works on Windows and OS X add dependency list of utilities (ant, fpc compiler for host, make etcetc)