Skip to content

Commit

Permalink
Say hello to apitrace for 0 A.D.
Browse files Browse the repository at this point in the history
Apitrace can be used to trace GL call on Android.
To enable it add "CONFIG+=apitrace" to qmake parameters.
  • Loading branch information
bog-dan-ro committed Dec 29, 2014
1 parent f698af5 commit 3c75fb9
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 10 deletions.
33 changes: 33 additions & 0 deletions build/android/apitrace-android.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5abf0f0..9e8c416 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -243,11 +243,11 @@ if (WIN32 OR APPLE)
else ()
set (DOC_INSTALL_DIR share/doc/${CMAKE_PROJECT_NAME})
set (LIB_INSTALL_DIR lib${LIB_SUFFIX}/${CMAKE_PROJECT_NAME})
- if (ARCH_SUBDIR)
- set (LIB_ARCH_INSTALL_DIR lib/${ARCH_SUBDIR}/${CMAKE_PROJECT_NAME})
- else ()
+# if (ARCH_SUBDIR)
+# set (LIB_ARCH_INSTALL_DIR lib/${ARCH_SUBDIR}/${CMAKE_PROJECT_NAME})
+# else ()
set (LIB_ARCH_INSTALL_DIR lib${LIB_SUFFIX}/${CMAKE_PROJECT_NAME})
- endif ()
+# endif ()
endif ()

set (SCRIPTS_INSTALL_DIR ${LIB_INSTALL_DIR}/scripts)
diff --git a/wrappers/CMakeLists.txt b/wrappers/CMakeLists.txt
index 36a77a4..07498bf 100644
--- a/wrappers/CMakeLists.txt
+++ b/wrappers/CMakeLists.txt
@@ -444,7 +444,7 @@ if (ENABLE_EGL AND NOT WIN32 AND NOT APPLE)

set_target_properties (egltrace PROPERTIES
# avoid the default "lib" prefix
- PREFIX ""
+ #PREFIX ""
# Prevent symbol relocations internal to our wrapper library to be
# overwritten by the application.
LINK_FLAGS "-Wl,-Bsymbolic -Wl,-Bsymbolic-functions"
4 changes: 3 additions & 1 deletion build/android/qtcreator/android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<meta-data android:name="android.app.lib_name" android:value="main"/>
<meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
</activity>

</application>
Expand Down
31 changes: 26 additions & 5 deletions build/android/qtcreator/android/src/com/play0ad/Activity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.play0ad;

import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.net.LocalServerSocket;
import android.net.LocalSocket;
import android.os.Build;
Expand All @@ -25,11 +27,6 @@ public class Activity extends SDLActivity {
private static final String TAG = "pyrogenesis";
private Process m_debuggerProcess = null; // debugger process

static {
System.loadLibrary("gnustl_shared");
System.loadLibrary("main");
}

public void debugLog(String msg)
{
Log.i(TAG, "DEBUGGER: " + msg);
Expand Down Expand Up @@ -99,6 +96,30 @@ protected boolean prepareOnCreate(Bundle savedInstanceState) {

if (null == savedInstanceState) {
try {
ActivityInfo activityInfo = getPackageManager().getActivityInfo(getComponentName(), PackageManager.GET_META_DATA);
if (activityInfo.metaData.containsKey("android.app.qt_libs_resource_id")) {
int resourceId = activityInfo.metaData.getInt("android.app.qt_libs_resource_id");
for (String library: getResources().getStringArray(resourceId))
System.loadLibrary(library);
}

if (activityInfo.metaData.containsKey("android.app.bundled_libs_resource_id")) {
int resourceId = activityInfo.metaData.getInt("android.app.bundled_libs_resource_id");
for (String library: getResources().getStringArray(resourceId))
System.loadLibrary(library);
}

if (activityInfo.metaData.containsKey("android.app.bundled_libs_resource_id")) {
int resourceId = activityInfo.metaData.getInt("android.app.bundled_libs_resource_id");
for (String library: getResources().getStringArray(resourceId))
System.loadLibrary(library);
}

if (activityInfo.metaData.containsKey("android.app.lib_name") )
System.loadLibrary(activityInfo.metaData.getString("android.app.lib_name"));

Native.setenv("TRACE_FILE", "/sdcard/0ad/appdata/logs/pyrogenesis.trace", true);

Bundle extras = getIntent().getExtras();

if ( /*(ai.flags&ApplicationInfo.FLAG_DEBUGGABLE) != 0
Expand Down
12 changes: 10 additions & 2 deletions build/android/qtcreator/main.pro
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ LIBS += -L$$OUT_PWD -Wl,--start-group \
-L$$DEPENDENCIES_PATH/lib -lpng -ljpeg -lxml2 -lmozjs-24 \
-lgloox -lopenal -lcommon -lvorbisfile -lvorbis -logg \
-lminiupnpc -licui18n -licuio -licule -liculx -licuuc -licudata \
-lenet -lboost_filesystem -lboost_system -lcurl -lssl -lcrypto \
-lGLESv2 -lGLESv1_CM -lOpenSLES -landroid
-lenet -lboost_filesystem -lboost_system -lcurl -lssl -lcrypto

apitrace: exists($$DEPENDENCIES_PATH/lib/apitrace/wrappers/libegltrace.so) {
ANDROID_EXTRA_LIBS += $$DEPENDENCIES_PATH/lib/apitrace/wrappers/libegltrace.so
LIBS += -L$$DEPENDENCIES_PATH/lib/apitrace/wrappers -legltrace
} else {
LIBS += -lGLESv2 -lGLESv1_CM
}

LIBS += -lOpenSLES -landroid

DISTFILES += \
android/gradle/wrapper/gradle-wrapper.jar \
Expand Down
22 changes: 20 additions & 2 deletions build/android/setup-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ INSTALL_PREFIX=${FINAL_INSTALL_PREFIX}_temp
rm -fr $INSTALL_PREFIX
mkdir -p $INSTALL_PREFIX

build_apitrace=true
build_js=true
build_openssl=true
build_boost=true
Expand Down Expand Up @@ -182,10 +183,27 @@ if [ ! -d openal-soft ]; then
git clone git://repo.or.cz/openal-soft.git
fi

if [ ! -d apitrace ]; then
git clone https://github.com/apitrace/apitrace.git
fi

popd

mkdir -p temp

if [ "$build_apitrace" = "true" ]; then
rm -rf temp/apitrace
cp -a files/apitrace temp/
pushd temp/apitrace
git checkout f11d3c6
patch -p1 < ../../apitrace-android.patch
cmake -DCMAKE_TOOLCHAIN_FILE=../../android.toolchain.cmake -DANDROID_NDK=$NDK -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI="armeabi-v7a" \
-DANDROID_NATIVE_API_LEVEL=$PLATFORM -DANDROID_STL=gnustl_shared -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX .
make $JOBS
make install
popd
fi

if [ "$build_js" = "true" ]; then
rm -rf temp/mozjs-$MOZJS_VERSION
tar xvf ../../libraries/source/spidermonkey/mozjs-$MOZJS_VERSION.tar.bz2 -C temp/
Expand Down Expand Up @@ -347,7 +365,7 @@ if [ "$build_openal" = "true" ]; then
git checkout 93b6958
cmake -DCMAKE_TOOLCHAIN_FILE=../../android.toolchain.cmake -DANDROID_NDK=$NDK -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI="armeabi-v7a" \
-DANDROID_NATIVE_API_LEVEL=$PLATFORM -DALSOFT_UTILS=OFF -DALSOFT_NO_CONFIG_UTIL=ON -DALSOFT_EXAMPLES=OFF -DLIBTYPE=STATIC \
-DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX .
-DANDROID_STL=gnustl_shared -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX .
make $JOBS
make install
cp libcommon.a $INSTALL_PREFIX/lib
Expand All @@ -361,7 +379,7 @@ if [ "$build_miniupnpc" = "true" ]; then
patch miniwget.c < ../../miniupnpc-android.patch
cmake -DCMAKE_TOOLCHAIN_FILE=../../android.toolchain.cmake -DANDROID_NDK=$NDK -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI="armeabi-v7a" \
-DANDROID_NATIVE_API_LEVEL=$PLATFORM -DUPNPC_BUILD_STATIC=ON -DUPNPC_BUILD_SHARED=OFF -DUPNPC_BUILD_TESTS=OFF \
-DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX .
-DANDROID_STL=gnustl_shared -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX .
make $JOBS
make install
cp portlistingparse.h $INSTALL_PREFIX/include
Expand Down

0 comments on commit 3c75fb9

Please sign in to comment.