Android compilation added.

This commit is contained in:
Tulioh 2014-12-19 00:56:55 -02:00
parent 997daa2d49
commit b3b314f01b
27 changed files with 2075 additions and 76 deletions

View File

@ -32,14 +32,14 @@ endif()
add_definitions(-D"VERSION=\\"${VERSION}\\"") add_definitions(-D"VERSION=\\"${VERSION}\\"")
if(NOT __ANDROID__) if(ANDROID)
set(executable_SOURCES set(executable_SOURCES
src/android.cpp android/android.cpp
src/main.cpp src/main.cpp
) )
# add shared library for android # add shared library for android
add_executable(${PROJECT_NAME} ${framework_SOURCES} ${client_SOURCES} ${executable_SOURCES}) add_library(${PROJECT_NAME} SHARED ${framework_SOURCES} ${client_SOURCES} ${executable_SOURCES})
else() else()
set(executable_SOURCES set(executable_SOURCES
src/main.cpp src/main.cpp

View File

@ -1,26 +0,0 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="otclientmob.tuliohdev.com.otclientmob">
<application android:allowBackup="true"
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme"
android:hasCode="false"> <!-- This .apk has no Java code itself, so set hasCode to false. -->
<!-- Our activity is the built-in NativeActivity framework class.
This will take care of integrating with our NDK code. -->
<activity android:name="android.app.NativeActivity"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
<!-- Tell NativeActivity the name of or .so -->
<meta-data android:name="android.app.lib_name"
android:value="native-activity" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -3,8 +3,8 @@
void android_main( struct android_app* state ) { void android_main( struct android_app* state ) {
int argc = 0; int argc = 0;
char* argv[] = char[1]; const char* argv[1];
argv[0] = ""; argv[0] = NULL;
main(argc, argv); main(argc, argv);
} }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
#!/bin/sh
mkdir ../build && cd ../build
cmake -DCMAKE_TOOLCHAIN_FILE=../android/android.toolchain.cmake -DANDROID_ABI=armeabi -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.6 ..
make
cd ../ && rm -r build && mkdir build && cd build

View File

@ -1,11 +0,0 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-10

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

33
android/project/.project Normal file
View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>NativeActivity</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,4 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.source=1.6

View File

@ -0,0 +1,6 @@
/** Automatically generated file. DO NOT MODIFY */
package com.example.native_activity;
public final class BuildConfig {
public final static boolean DEBUG = true;
}

View File

@ -0,0 +1,46 @@
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.example.native_activity;
public final class R {
public static final class attr {
}
public static final class dimen {
/** Default screen margins, per the Android Design guidelines.
Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
*/
public static final int activity_horizontal_margin=0x7f040000;
public static final int activity_vertical_margin=0x7f040001;
}
public static final class drawable {
public static final int ic_launcher=0x7f020000;
}
public static final class id {
public static final int action_settings=0x7f080001;
public static final int jniText=0x7f080000;
}
public static final class layout {
public static final int activity_my=0x7f030000;
}
public static final class menu {
public static final int my=0x7f070000;
}
public static final class string {
public static final int action_settings=0x7f050002;
public static final int app_name=0x7f050000;
public static final int hello_world=0x7f050001;
}
public static final class style {
/** Base application theme.
Customize your theme here.
*/
public static final int AppTheme=0x7f060000;
}
}

View File

@ -0,0 +1,10 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
# location of the SDK. This is only used by Ant
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=/opt/android-sdk/sdk

View File

@ -0,0 +1,20 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

View File

@ -0,0 +1,14 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-16

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -1,4 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<resources>
<string name="app_name">OTClientMob</string>
</resources>

View File

@ -1,17 +1,7 @@
#!/bin/sh #!/bin/sh
mkdir build && cd build mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_CMAKE/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a .. cmake -DBOOST_ROOT=/home/tulio/Libraries/android-libs/boost -DCMAKE_TOOLCHAIN_FILE=$ANDROID_CMAKE/android.toolchain.cmake -DANDROID_ABI=x86 ..
make make
cd ../ && rm -r build && mkdir build && cd build cd ../ && rm -r build && mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_CMAKE/android.toolchain.cmake -DANDROID_ABI=armeabi ..
make
cd ../ && rm -r build && mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_CMAKE/android.toolchain.cmake -DANDROID_ABI=x86 ..
make
cd ../ && rm -r build

View File

@ -126,10 +126,10 @@ set(framework_SOURCES ${framework_SOURCES}
# crash handler # crash handler
${CMAKE_CURRENT_LIST_DIR}/platform/crashhandler.h ${CMAKE_CURRENT_LIST_DIR}/platform/crashhandler.h
${CMAKE_CURRENT_LIST_DIR}/platform/unixcrashhandler.cpp #${CMAKE_CURRENT_LIST_DIR}/platform/unixcrashhandler.cpp
${CMAKE_CURRENT_LIST_DIR}/platform/win32crashhandler.cpp ${CMAKE_CURRENT_LIST_DIR}/platform/win32crashhandler.cpp
${CMAKE_CURRENT_LIST_DIR}/platform/win32platform.cpp ${CMAKE_CURRENT_LIST_DIR}/platform/win32platform.cpp
${CMAKE_CURRENT_LIST_DIR}/platform/unixplatform.cpp #${CMAKE_CURRENT_LIST_DIR}/platform/unixplatform.cpp
${CMAKE_CURRENT_LIST_DIR}/platform/platform.cpp ${CMAKE_CURRENT_LIST_DIR}/platform/platform.cpp
${CMAKE_CURRENT_LIST_DIR}/platform/platform.h ${CMAKE_CURRENT_LIST_DIR}/platform/platform.h
) )
@ -206,7 +206,12 @@ if(WIN32)
endif() endif()
set(Boost_USE_MULTITHREADED ON) set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_LIBS ${USE_STATIC_LIBS}) set(Boost_USE_STATIC_LIBS ${USE_STATIC_LIBS})
if(ANDROID)
else()
find_package(Boost 1.48.0 COMPONENTS ${REQUIRED_BOOST_COMPONENTS} REQUIRED) find_package(Boost 1.48.0 COMPONENTS ${REQUIRED_BOOST_COMPONENTS} REQUIRED)
endif()
#find lua #find lua
if(LUAJIT) if(LUAJIT)
@ -226,8 +231,10 @@ find_package(PhysFS REQUIRED)
find_package(OpenSSL REQUIRED) find_package(OpenSSL REQUIRED)
# android already has zlib # android already has zlib
if(NOT __ANDROID__) if(NOT ANDROID)
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)
else()
set(framework_LIBRARIES ${framework_LIBRARIES} android)
endif() endif()
set(framework_LIBRARIES ${framework_LIBRARIES} set(framework_LIBRARIES ${framework_LIBRARIES}
@ -296,18 +303,26 @@ endif()
if(FRAMEWORK_GRAPHICS) if(FRAMEWORK_GRAPHICS)
set(OPENGLES "OFF" CACHE "Use OpenGL ES 1.0 or 2.0 (for mobiles devices)" STRING) set(OPENGLES "OFF" CACHE "Use OpenGL ES 1.0 or 2.0 (for mobiles devices)" STRING)
if(OPENGLES STREQUAL "2.0") if(OPENGLES STREQUAL "2.0" OR ANDROID_NATIVE_API_LEVEL VERSION_GREATER 7)
if(NOT ANDROID)
find_package(OpenGLES2 REQUIRED) find_package(OpenGLES2 REQUIRED)
find_package(EGL REQUIRED) find_package(EGL REQUIRED)
set(framework_DEFINITIONS ${framework_DEFINITIONS} -DOPENGL_ES=2)
set(framework_INCLUDE_DIRS ${framework_INCLUDE_DIRS} ${EGL_INCLUDE_DIR} ${OPENGLES2_INCLUDE_DIR}) set(framework_INCLUDE_DIRS ${framework_INCLUDE_DIRS} ${EGL_INCLUDE_DIR} ${OPENGLES2_INCLUDE_DIR})
set(framework_LIBRARIES ${framework_LIBRARIES} ${EGL_LIBRARY} ${OPENGLES2_LIBRARY}) set(framework_LIBRARIES ${framework_LIBRARIES} ${EGL_LIBRARY} ${OPENGLES2_LIBRARY})
ELSEif(OPENGLES STREQUAL "1.0") else()
set(framework_LIBRARIES ${framework_LIBRARIES} GLESv2)
endif()
set(framework_DEFINITIONS ${framework_DEFINITIONS} -DOPENGL_ES=2)
ELSEif(OPENGLES STREQUAL "1.0" OR ANDROID_NATIVE_API_LEVEL VERSION_LESS 8)
if(NOT ANDROID)
find_package(OpenGLES1 REQUIRED) find_package(OpenGLES1 REQUIRED)
find_package(EGL REQUIRED) find_package(EGL REQUIRED)
set(framework_DEFINITIONS ${framework_DEFINITIONS} -DOPENGL_ES=1)
set(framework_INCLUDE_DIRS ${framework_INCLUDE_DIRS} ${EGL_INCLUDE_DIR} ${OPENGLES1_INCLUDE_DIR}) set(framework_INCLUDE_DIRS ${framework_INCLUDE_DIRS} ${EGL_INCLUDE_DIR} ${OPENGLES1_INCLUDE_DIR})
set(framework_LIBRARIES ${framework_LIBRARIES} ${EGL_LIBRARY} ${OPENGLES1_LIBRARY}) set(framework_LIBRARIES ${framework_LIBRARIES} ${EGL_LIBRARY} ${OPENGLES1_LIBRARY})
else()
set(framework_LIBRARIES ${framework_LIBRARIES} GLESv1_CM)
endif()
set(framework_DEFINITIONS ${framework_DEFINITIONS} -DOPENGL_ES=1)
else() else()
## TODO: CMake Documentation says that this is not the right ## TODO: CMake Documentation says that this is not the right
# Thing for Mac OS X, but it works for now. # Thing for Mac OS X, but it works for now.
@ -345,7 +360,7 @@ if(FRAMEWORK_GRAPHICS)
) )
endif() endif()
else() elseif(NOT ANDROID)
set(framework_LIBRARIES ${framework_LIBRARIES} X11) set(framework_LIBRARIES ${framework_LIBRARIES} X11)
endif() endif()
@ -445,6 +460,8 @@ if(FRAMEWORK_GRAPHICS)
${CMAKE_CURRENT_LIST_DIR}/platform/win32window.h ${CMAKE_CURRENT_LIST_DIR}/platform/win32window.h
${CMAKE_CURRENT_LIST_DIR}/platform/x11window.cpp ${CMAKE_CURRENT_LIST_DIR}/platform/x11window.cpp
${CMAKE_CURRENT_LIST_DIR}/platform/x11window.h ${CMAKE_CURRENT_LIST_DIR}/platform/x11window.h
${CMAKE_CURRENT_LIST_DIR}/platform/sdlplatform.cpp
${CMAKE_CURRENT_LIST_DIR}/platform/sdlplatform.h
# window input # window input
${CMAKE_CURRENT_LIST_DIR}/input/mouse.cpp ${CMAKE_CURRENT_LIST_DIR}/input/mouse.cpp

View File

@ -35,7 +35,7 @@
#if defined(_MSC_VER) && _MSC_VER >= 1300 #if defined(_MSC_VER) && _MSC_VER >= 1300
#define swap16(data) _byteswap_ushort(data) #define swap16(data) _byteswap_ushort(data)
#define swap32(data) _byteswap_ulong(data) #define swap32(data) _byteswap_ulong(data)
#elif __linux__ #elif __linux__ && !defined ANDROID
#include <byteswap.h> #include <byteswap.h>
#define swap16(data) bswap_16(data) #define swap16(data) bswap_16(data)
#define swap32(data) bswap_32(data) #define swap32(data) bswap_32(data)

View File

@ -25,6 +25,9 @@
#ifdef WIN32 #ifdef WIN32
#include "win32window.h" #include "win32window.h"
WIN32Window window; WIN32Window window;
#elif defined ANDROID
#include "sdlplatform.h"
SDLPlatform window;
#else #else
#include "x11window.h" #include "x11window.h"
#include <framework/core/clock.h> #include <framework/core/clock.h>

View File

@ -0,0 +1,75 @@
#include "sdlplatform.h"
void SDLPlatform::init() {
}
void SDLPlatform::terminate() {
}
void SDLPlatform::move(const Point& pos) {
}
void SDLPlatform::resize(const Size& size) {
}
void SDLPlatform::show() {
}
void SDLPlatform::hide() {
}
void SDLPlatform::maximize() {
}
void SDLPlatform::poll() {
}
void SDLPlatform::swapBuffers() {
}
void SDLPlatform::showMouse() {
}
void SDLPlatform::hideMouse() {
}
int SDLPlatform::internalLoadMouseCursor(const ImagePtr& image, const Point& hotSpot) {
return 0;
}
void SDLPlatform::setMouseCursor(int cursorId) {
}
void SDLPlatform::restoreMouseCursor() {
}
void SDLPlatform::setTitle(const std::string& title) {
}
void SDLPlatform::setMinimumSize(const Size& minimumSize) {
}
void SDLPlatform::setFullscreen(bool fullscreen) {
}
void SDLPlatform::setVerticalSync(bool enable) {
}
void SDLPlatform::setIcon(const std::string& iconFile) {
}
void SDLPlatform::setClipboardText(const std::string& text) {
}
Size SDLPlatform::getDisplaySize() {
Size TODO;
return TODO;
}
std::string SDLPlatform::getClipboardText() {
return nullptr;
}
std::string SDLPlatform::getPlatformType() {
return nullptr;
}

View File

@ -0,0 +1,39 @@
#ifndef SDL_PLATFORM_H
#define SDL_PLATFORM_H
#include "platformwindow.h"
class SDLPlatform : public PlatformWindow
{
public:
void init();
void terminate();
void move(const Point& pos);
void resize(const Size& size);
void show();
void hide();
void maximize();
void poll();
void swapBuffers();
void showMouse();
void hideMouse();
void setMouseCursor(int cursorId);
void restoreMouseCursor();
void setTitle(const std::string& title);
void setMinimumSize(const Size& minimumSize);
void setFullscreen(bool fullscreen);
void setVerticalSync(bool enable);
void setIcon(const std::string& iconFile);
void setClipboardText(const std::string& text);
Size getDisplaySize();
std::string getClipboardText();
std::string getPlatformType();
protected:
int internalLoadMouseCursor(const ImagePtr& image, const Point& hotSpot);
};
#endif

View File

@ -20,7 +20,7 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#ifndef WIN32 #if !defined WIN32 && !defined ANDROID
#include "x11window.h" #include "x11window.h"
#include <framework/core/resourcemanager.h> #include <framework/core/resourcemanager.h>