HedgeroidGuide.wiki
changeset 213 a2be6fe1d509
parent 211 2aebd9de1a5e
child 298 9eb97ce0fec8
equal deleted inserted replaced
212:d47acc7f7185 213:a2be6fe1d509
    13 * [http://developer.android.com/sdk/ndk/index.html Android NDK] (current version is r5b but anything up will probably work)<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>
    14 * ~~[http://freepascal.org/down/source/sources.var FreePascal] (Latest (stable) version will do)~~<br>
    15 * [http://sourceforge.net/projects/p-tools/ p-tools] (Fixed freepascal compiler, read below which to download)<br>
    15 * [http://sourceforge.net/projects/p-tools/ p-tools] (Fixed freepascal compiler, read below which to download)<br>
    16 * [http://ant.apache.org/ Ant] (Linux distro should just use their package manager to get it, version isn't really important)<br>
    16 * [http://ant.apache.org/ Ant] (Linux distro should just use their package manager to get it, version isn't really important)<br>
    17 * Java compiler, make sure you get JDK (not JRE) version 6 and up
    17 * Java compiler, make sure you get JDK (not JRE) version 6 and up
       
    18 * [http://www.cmake.org/ Cmake]
       
    19 * You will also need qt4 although this is not strictly required for the android build it is needed for the desktop frontend
    18 
    20 
    19 ==Hedgewars Source==
    21 ==Hedgewars Source==
    20 
    22 
    21 Using mercurial you can pull the hedgeroid branch using
    23 Using mercurial you can pull the hedgeroid branch using
    22 {{{
    24 {{{
    23 hg clone https://hedgewars.googlecode.com/hg/ hedgewars
    25 hg clone https://hedgewars.googlecode.com/hg/ hedgewars
    24 }}}
    26 }}}
    25 
    27 
    26 ==Android SDK==
    28 ==Android SDK==
    27 
    29 
    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.
    30 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.2 / 4.0. 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 
    31 
    30 Optionally you could permanently 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.
    32 Optionally you could permanently 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 
    33 
    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
    34 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 
    35 
    43 To run the emulator navigate to `<`SDK`>`/tools and run
    45 To run the emulator navigate to `<`SDK`>`/tools and run
    44 
    46 
    45 {{{emulator -avd <name>}}}
    47 {{{emulator -avd <name>}}}
    46 where `<`name`>` is the same name as when you created it with the line above.
    48 where `<`name`>` is the same name as when you created it with the line above.
    47 
    49 
       
    50 Note when using ant:
       
    51 Ant needs a JDK, but tries to use a JRE sometimes (there is usually a separate JRE installation outside the JDK). If you get an error about missing tools.jar, make sure Ant is actually attempting to use the JDK. You can coax it to cooperate by setting the JAVA_HOME environment variable to point to the JDK directory.
       
    52 
    48 ==Android NDK==
    53 ==Android NDK==
    49 
    54 
    50 Download and untar it, ill refer to the ndk as `<`NDK`>`. That’s it :)
    55 Download and untar it, ill refer to the ndk as `<`NDK`>`. That’s it :)
    51 
    56 
    52 ==!FreePascal ==
    57 ==!FreePascal ==
    53 
    58 
    54 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.~~ _Because of a bug in the latest fpc sources I recommend you download the p-tools repository/tar. In this link http://sourceforge.net/projects/p-tools/ find the directory fpc4android when I refer to `<`fpc`>` I mean this directory_. 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:
    59 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.~~ _Because of a bug in the latest fpc sources I recommend you download the p-tools repository/tar. Follow this link http://sourceforge.net/projects/p-tools/ and find the directory fpc4android in their source repository. Download a tarball and extract it to a new directory, which will be called '<'fpc'>' from now on._ 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:
    55 
    60 
    56 {{{
    61 {{{
    57 make crossinstall CPU_TARGET=arm OS_TARGET=linux CROSSBINDIR=<ndk>/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin OPT=-dFPC_ARMEL BINUTILSPREFIX=arm-linux-androideabi- INSTALL_PREFIX=<fpc>/fpc_install
    62 make crossinstall CPU_TARGET=arm OS_TARGET=linux CROSSBINDIR=<ndk>/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin OPT=-dFPC_ARMEL BINUTILSPREFIX=arm-linux-androideabi- INSTALL_PREFIX=<fpc>/fpc_install
    58 }}}
    63 }}}
    59 
    64 
    60 Note: The flag CROSSBINDDIR points to the ndk/toolchain/../prebuilt/linux-x86/bin dir, change linux-x86 to your host machine, so for windows it would be 'windows' instead of linux-x86
    65 Note: The flag CROSSBINDDIR points to the ndk/toolchain/../prebuilt/linux-x86/bin dir, change linux-x86 to your host machine, so for windows it would be 'windows' instead of linux-x86
    61 
    66 
       
    67 Note2: On windows use forward slashes so '/' not '\'
    62 ==Final==
    68 ==Final==
    63 
    69 
    64 We will generate the Makefile.android, which is needed to compile hedgewars, download SDL and you’ll need to make sure cmake knows where all the compilers are
    70 We will generate the Makefile.android, which is needed to compile hedgewars, download SDL and you’ll need to make sure cmake knows where all the compilers are
    65 
    71 
    66 1.<br>
    72 1.<br>
    72 export PATH=$PATH:/home/xeli/SoftDev/android/fpc-2.4.4/compiler
    78 export PATH=$PATH:/home/xeli/SoftDev/android/fpc-2.4.4/compiler
    73 }}}
    79 }}}
    74 
    80 
    75 (Check google on how to do it for your specific OS if you don't know how)
    81 (Check google on how to do it for your specific OS if you don't know how)
    76 
    82 
       
    83 for windows the PATH var should include this, mind the order:
       
    84 {{{
       
    85     - %WINDIR%\System32 (for Java)<br>
       
    86     - <CMake>\bin<br>
       
    87     - <QtSDK>\mingw\bin<br>
       
    88     - <QtSDK>\Desktop\Qt\4.8.0\mingw\bin<br>
       
    89     - <fpc-win>\bin\i386-win32<br>
       
    90     - <fpc-android>\compiler<br>
       
    91     - <ndk><br>
       
    92     - <sdk>\platform-tools<br>
       
    93     - <ant>\bin<br>
       
    94     - <mercurial> (directory containing hg.exe, TortoiseHg dir in my case)<br>
       
    95 }}}
       
    96 
       
    97 
    77 2.<br>
    98 2.<br>
    78 Now we're gonna download sdl and a couple of its libraries, if you're on linux there's a script you can use
    99 Now we're gonna download sdl and a couple of its libraries, if you're on linux there's a script you can use
    79 {{{
   100 {{{
    80 cd <hedgewars-root>/project_files/Android-build
   101 cd <hedgewars-root>/project_files/Android-build
    81 chmod +x download_libs.sh (might not be needed)
   102 chmod +x download_libs.sh (might not be needed)
    82 ./download_libs.sh
   103 ./download_libs.sh
    83 }}}
   104 }}}
    84 This will download and unzip sdl to the expected folders
   105 This will download and unzip sdl to the expected folders
    85 
   106 
    86 TODO: make script for windows and verify if it works for osx
   107 On windows the script should work fine with Git Bash.
    87 
   108 
    88 
   109 
    89 3.<br>
   110 3.<br>
    90 Finally you can use cmake to create the scripts
   111 Finally you can use cmake to create the scripts
    91 
   112 
    92 {{{
   113 {{{
    93 cd <hedgewars-root>
   114 cd <hedgewars-root>
    94 cmake . -DANDROID=1
   115 cmake . -DANDROID=1
    95 }}}
   116 }}}
       
   117 
       
   118 on windows you will need some extra arguments:
       
   119 {{{
       
   120 cmake -G "MinGW Makefiles" -DCMAKE_INCLUDE_PATH="%CD%/misc/winutils/include" -DCMAKE_LIBRARY_PATH="%CD%/misc/winutils/lib" -DANDROID=1 .
       
   121 }}}
       
   122 
    96 And that’s it. To compile:
   123 And that’s it. To compile:
    97 
   124 
    98 {{{
   125 {{{
    99 cd <hedgewars-root>/project_files/Android-build/
   126 cd <hedgewars-root>/project_files/Android-build/
   100 make -f Makefile.android
   127 make -f Makefile.android
   104 On the device/emulator you can start the application up :)
   131 On the device/emulator you can start the application up :)
   105 
   132 
   106 
   133 
   107 
   134 
   108 
   135 
   109 TODO verify that it works on Windows and OS X add dependency list of utilities (ant, fpc compiler for host, make etcetc)
   136 TODO verify that it works on OS X, is the depencency list complete now?