利用者:AlexK/Gsoc2012/Building Blender for Android
目次
Building Blender for Android
Preparation
Currently Android can be build on linux and probably on Mac (isn't tested). There won't be Windows support in near future because we should use gcc-like compile, and it will be troublesome to support Windows environment (paths, scripts). Also, you have to have real Android 2.2 or higher device, in order to compile and test Blender as emulator doesn't support OpenGL ES 2.0. Beware that Android port is a work in progress: a. There is no graphic output yet. b. Build system might be broken, but I will try to make sure that it is compilable every Friday
Installing Android SDK and JDK
- Most Android Apps uses Java, but lucky for us, we can keep to minimum.
- Use this to install JDK 6, Apache Ant and then Android SDK
- JDJ and Ant can be downloaded through distro's repository
- http://developer.android.com/sdk/installing.html
- Note, we don't need Eclipse, because Java IDE is unnessory for us.
- You need :"apt-get install ia32-libs" if linux is x64
- Add following paths to PATH
<<Path to Android SDK>>/android-sdk-linux/tools/
<<Path to Android SDK>>/android-sdk-linux/platform-tools/
- Follow this guid to connect real Android device
- Skip step 1
- Skip step 3 if you are on Mac
- Run "android" command from <<Path to Android SDK>>/android-sdk-linux/tools/
- Install SDK 13
- SDK 10
- To test if it is succesfully set up, run
adb devices
Installing Android NDK
Install NDK (I recommend r7b version, because it is what I use and with which all libs are compiled)
- r7b linux: http://dl.google.com/android/ndk/android-ndk-r7b-linux-x86.tar.bz2
- new: http://developer.android.com/sdk/ndk/index.html
Also add it to PATH
<<Path to Android NDK>>/android-ndk-r7b
- Now create standalong toolchain
- Remember its path
<<Path to Android NDK>>/android-ndk-r7b/build/tools/make-standalone-toolchain.sh --platform=android-9 --install-dir=/__absolute_path__/androidtc
- For lib compilations I used android-9
Compiling Blender
SVN and file system
You need to check out Swiss Cheese Branch and Android Libs
mkdir blender-sc
cd blender-sc
svn co https://svn.blender.org/svnroot/bf-blender/branches/soc-2012-swiss_cheese soc-2012-swiss_cheese
svn co https://svn.blender.org/svnroot/bf-blender/trunk/lib/android lib/android
Building Loader
First, we start building the loaded with SDL Go to lib/android/armv7-a_9/aghosty-sdl/
It is easily compiled by
./deploy.sh
It takes care of multiple things:
- Building C code
- Cleaning and repackaging Java and apk
- Installing on the device
It is barebones that provides SDL interface, dynamic loader, and "nucleusbridge" "nucleusbridge" is used for executing makesdna/rna on device. Therefore, a device (or emulator will do) must connected
Due to system constrains, everything is loaded dynamically. If library isn't found, BlenderPlayer app will simply exit. First you need to install Python internals (latter will be bundled together):
http://code.google.com/p/python-for-android/downloads/list Python3ForAndroid_r6.apk
Otherwise, program will crash.
Then place all libs on device by executing from aghosty-sdl
./pushlibs.sh
Then open the app on your device and run following on the computer.
adb logcat
It should show how program is loading, and which lib have been loaded and which aren't found.
Building Blender
Create a folder on the same level as soc-2012-swiss_cheese and lib. For example "abuild"
mkdir abuild
cd abuild
Generate Cmake file in build folder
cmake -DCMAKE_TOOLCHAIN_FILE=../soc-2012-swiss_cheese/build_files/cmake/config/blender_android.cmake ../soc-2012-swiss_cheese -DTOOLCHAIN_PATH=/<<your_toolchain_path>>
now run make
make
When it successively compiled, push it to device
adb push /lib/libblender.so /data/data/org.blender.app/libblender.so
Push a Blend file to /sdcard/test.blend
adb push /path/to/file/for/render.blend /sdcard/test.blend
And run your app. You can use:
adb logcat
or
adb shell
cat /sdcard/out.txt
cat /sdcard/err.txt
Notes
If something failed, irc me. Probably I already had that problem and forgot to mention here. ndk-gdb is very poor because it goes through all java hoops and don't have a source and good backtrace. The build system is not optimized. You can improve performance by adding C flags inside cmake:
-march=armv7-a -mfloat-abi=softfp -mthumb