Difference between revisions of "Compile ECWolf on Android"

From ECWolf Wiki
 
Line 1: Line 1:
This guide will demonstrate how to cross compile ECWolf for Android.  Note that at the moment only ARM is supported by the build system.
+
This guide will demonstrate how to cross compile ECWolf for Android.
 
== Compile for host ==
 
== Compile for host ==
 
The build system for ECWolf generates some files by building tools.  Since we will be cross compiling, we can not actually run the tools on the host.  To work around this, first build ECWolf for your host system.  Linux is known to work as a host.
 
The build system for ECWolf generates some files by building tools.  Since we will be cross compiling, we can not actually run the tools on the host.  To work around this, first build ECWolf for your host system.  Linux is known to work as a host.
Line 12: Line 12:
 
The following are required in order to build ECWolf for Android.  The build process will not be using Eclipse or Android Studio so it doesn't matter which SDK you download.
 
The following are required in order to build ECWolf for Android.  The build process will not be using Eclipse or Android Studio so it doesn't matter which SDK you download.
  
* [http://www.oracle.com/technetwork/java/javase/downloads/index.html Java JDK] 6, 7, or 8
+
* [http://www.oracle.com/technetwork/java/javase/downloads/index.html Java JDK] 8
* [http://developer.android.com/sdk/index.html Android SDK]
+
* [http://developer.android.com/sdk/index.html Android SDK] 19.1.0
* [http://developer.android.com/tools/sdk/ndk/index.html Android NDK]
+
* [http://developer.android.com/tools/sdk/ndk/index.html Android NDK] r14b
* [http://www.mogaanywhere.com/developers/ MOGA Android SDK]
+
* [http://cmake.org/ CMake] 3.6
* [http://cmake.org/ CMake] 2.8 (CMake GUI recommended)
 
* [http://www.libsdl.org/ libsdl] 1.2
 
* [http://maniacsvault.net/ecwolf/files/tools/dev/ SDL_mixer for ECWolf] (Standard [http://www.libsdl.org/projects/SDL_mixer/release-1.2.html SDL_mixer] 1.2 will also work, but features will be disabled.)
 
  
For your convenience, pre-built SDL libraries are available [http://maniacsvault.net/ecwolf/files/tools/SDL_1.2-android.7z here].
+
It is highly recommended to use the vendored copies of all third party libraries.
  
 
=== Setting up the Android SDK ===
 
=== Setting up the Android SDK ===
 
After downloading the SDK, start the ''Android SDK Manager'' and select download the 4.4 SDK, Android SDK Tools, Android SDK Platform-tools, Android SDK Build-tools, and Android Support Library.
 
After downloading the SDK, start the ''Android SDK Manager'' and select download the 4.4 SDK, Android SDK Tools, Android SDK Platform-tools, Android SDK Build-tools, and Android Support Library.
 
Next, generate a standalone toolchain for the NDK.  There is a script make-standalone-toolchain which can do this easily.  On Linux execute this from the NDK directory.  You may change the install-dir to any location of your preference.
 
build/tools/make-standalone-release.sh --platform=android-12 --install-dir=~/android-toolchain
 
  
 
You will also need to set up a signing key. You may generate a self signing key.  The file name of the keystore and the alias may be changed as you will, but be sure to remember them for the next step.
 
You will also need to set up a signing key. You may generate a self signing key.  The file name of the keystore and the alias may be changed as you will, but be sure to remember them for the next step.
Line 32: Line 26:
  
 
== Configuring CMake ==
 
== Configuring CMake ==
Configure CMake to use Makefiles and specify native compilers.  You will want to set the C and C++ compiler to the ones in the android toolchain bin directory.  They will be called arm-*-androidabi-gcc and arm-*-androidabi-g++.
+
If using the CMake GUI, populate the source and build directories, but before clicking configure we'll want to input a few variables. You can use the "Add Entry" to fill in these valuesIf using the command line use "-DVARIABLE=VALUE".
 
 
The configuration will error looking for SDL.  Before specifying the locations for SDL, be sure to set the ANDROID option and FORCE_CROSSCOMPILE.
 
 
 
The next time, it should error for the ANDROID_SDK.  First set IMPORT_EXECUTBALES to the ImportExecutables.cmake file that can be found in your native ECWolf build directory.  Then set ANDROID_SDK to the location of android.jar in your 4.4 SDKThis will be something like sdk/platforms/android-19.  Set ANDROID_SDK_TOOLS to the build-tools for your platform in the sdk directory (sdk/build-tools/android-4.4W).
 
 
 
Configure again and it should now be looking for SDL_mixer.  Also set ANDROID_MOGA_CONTROLLER_JAR to the location of com.bda.controller.jar from the MOGA SDK.  ANDROID_SIGN_KEYNAME should be set your your key alias, ANDROID_SIGN_KEYSTORE to your keystore file, and ANDROID_SIGN_STOREPASS to the password for your key store.
 
  
Check that all other ANDROID_* values are filled in and provide them accordingly if need be.
+
{| class="wikitable"
 +
! Variable !! Type !! Value
 +
|-
 +
| FORCE_CROSSCOMPILE || BOOL || '''ON'''
 +
|-
 +
| IMPORT_EXECUTABLES || FILEPATH || ''Location of ImportExecutables.cmake from your native build.''
 +
|-
 +
| CMAKE_SYSTEM_NAME || STRING || '''Android'''
 +
|-
 +
| CMAKE_SYSTEM_VERSION || STRING || ''NDK API version. Use 21 if you don't know.''
 +
|-
 +
| CMAKE_ANDROID_NDK || PATH || ''Location of Android NDK (i.e. ndk-r14b or ndk-bundle directory).''
 +
|-
 +
| CMAKE_ANDROID_ARCH_ABI || STRING || ''Architecture. Typically armeabi-v7a. (See [https://cmake.org/cmake/help/v3.12/variable/CMAKE_ANDROID_ARCH_ABI.html#variable:CMAKE_ANDROID_ARCH_ABI docs].)''
 +
|-
 +
| ANDROID_SDK || PATH || ''Location to Android SDK (i.e. platforms/android-19). This path should contain android.jar.''
 +
|-
 +
| ANDROID_SDK_TOOLS || PATH || ''Location of Android build tools (i.e. build-tools/19.1.0). This path should contain aapt among other tools.''
 +
|-
 +
| ANDROID_SIGN_KEYSTORE || FILEPATH || ''Location of your keystore file.''
 +
|-
 +
| ANDROID_SIGN_KEYNAME || STRING || ''Key alias. In the example above: android''
 +
|-
 +
| ANDROID_SIGN_STOREPASS || STRING || ''Password given for your keystore.''
 +
|-
 +
| INTERNAL_SDL || BOOL || '''ON'''
 +
|-
 +
| INTERNAL_SDL_MIXER || BOOL || '''ON'''
 +
|-
 +
| INTERNAL_SDL_MIXER_CODECS || BOOL || '''ON'''
 +
|-
 +
| INTERNAL_SDL_NET || BOOL || '''ON'''
 +
|}
 +
Now click "Configure" and in the dialog that appears select Makefiles and default compilers.  If done correctly CMake should automatically find your NDK compilers and configuration should be successful.
  
 
== Compiling ==
 
== Compiling ==

Latest revision as of 01:24, 28 August 2018

This guide will demonstrate how to cross compile ECWolf for Android.

Compile for host

The build system for ECWolf generates some files by building tools. Since we will be cross compiling, we can not actually run the tools on the host. To work around this, first build ECWolf for your host system. Linux is known to work as a host.

It is recommended to use Makefiles for this step, although IDE project files may work as well.

Dependencies

The following are required in order to build ECWolf for Android. The build process will not be using Eclipse or Android Studio so it doesn't matter which SDK you download.

It is highly recommended to use the vendored copies of all third party libraries.

Setting up the Android SDK

After downloading the SDK, start the Android SDK Manager and select download the 4.4 SDK, Android SDK Tools, Android SDK Platform-tools, Android SDK Build-tools, and Android Support Library.

You will also need to set up a signing key. You may generate a self signing key. The file name of the keystore and the alias may be changed as you will, but be sure to remember them for the next step.

keytool -genkey -v -keystore android.keystore -alias android -keyalg RSA -keysize 2048 -validity 10000

Configuring CMake

If using the CMake GUI, populate the source and build directories, but before clicking configure we'll want to input a few variables. You can use the "Add Entry" to fill in these values. If using the command line use "-DVARIABLE=VALUE".

Variable Type Value
FORCE_CROSSCOMPILE BOOL ON
IMPORT_EXECUTABLES FILEPATH Location of ImportExecutables.cmake from your native build.
CMAKE_SYSTEM_NAME STRING Android
CMAKE_SYSTEM_VERSION STRING NDK API version. Use 21 if you don't know.
CMAKE_ANDROID_NDK PATH Location of Android NDK (i.e. ndk-r14b or ndk-bundle directory).
CMAKE_ANDROID_ARCH_ABI STRING Architecture. Typically armeabi-v7a. (See docs.)
ANDROID_SDK PATH Location to Android SDK (i.e. platforms/android-19). This path should contain android.jar.
ANDROID_SDK_TOOLS PATH Location of Android build tools (i.e. build-tools/19.1.0). This path should contain aapt among other tools.
ANDROID_SIGN_KEYSTORE FILEPATH Location of your keystore file.
ANDROID_SIGN_KEYNAME STRING Key alias. In the example above: android
ANDROID_SIGN_STOREPASS STRING Password given for your keystore.
INTERNAL_SDL BOOL ON
INTERNAL_SDL_MIXER BOOL ON
INTERNAL_SDL_MIXER_CODECS BOOL ON
INTERNAL_SDL_NET BOOL ON

Now click "Configure" and in the dialog that appears select Makefiles and default compilers. If done correctly CMake should automatically find your NDK compilers and configuration should be successful.

Compiling

Now open up a terminal and go to your build directory. Run make and ECWolf should proceed to build. If all is successful you should have a signed ecwolf.apk in the build directory ready to be installed.

Installing and running

At this point you can manually transfer the apk to your device and run, or you an hook it up to your computer with USB debugging. Run the following command to install and run the application through adb.

make runadb

Install your game data to /sdcard/Beloko/Wolf3d/FULL/.