From c77b8a34962a2e379538f553d43e97fa5eadee0d Mon Sep 17 00:00:00 2001 From: Jonathan De Wachter Date: Mon, 23 Sep 2013 16:15:41 +0200 Subject: [PATCH] [Android] Moved getActivity(ActivitySttates*) to the system module Somehow this function gets stripped by compilators if I put this in the main module (which is what we want). To solve this issue (and to avoid additional dependencies on sfml-window), I moved it to the system module since all SFML modules depend on it. --- src/SFML/Audio/CMakeLists.txt | 2 +- src/SFML/Audio/SoundFile.cpp | 2 +- src/SFML/CMakeLists.txt | 4 ++-- src/SFML/Graphics/Font.cpp | 2 +- src/SFML/Graphics/Image.cpp | 2 +- src/SFML/Main/MainAndroid.cpp | 14 +++++++++-- .../{Window => System}/Android/Activity.cpp | 23 +++++++++++-------- .../{Window => System}/Android/Activity.hpp | 3 ++- src/SFML/System/CMakeLists.txt | 8 +++++++ src/SFML/Window/Android/EglContext.cpp | 2 +- src/SFML/Window/Android/InputImpl.cpp | 2 +- src/SFML/Window/Android/VideoModeImpl.cpp | 2 +- src/SFML/Window/Android/WindowImplAndroid.cpp | 2 +- src/SFML/Window/CMakeLists.txt | 4 +--- 14 files changed, 47 insertions(+), 25 deletions(-) rename src/SFML/{Window => System}/Android/Activity.cpp (72%) rename src/SFML/{Window => System}/Android/Activity.hpp (97%) diff --git a/src/SFML/Audio/CMakeLists.txt b/src/SFML/Audio/CMakeLists.txt index f9ea919b1..a1a3737c7 100644 --- a/src/SFML/Audio/CMakeLists.txt +++ b/src/SFML/Audio/CMakeLists.txt @@ -64,6 +64,6 @@ sfml_add_library(sfml-audio else() sfml_add_library(sfml-audio SOURCES ${SRC} - DEPENDS sfml-system sfml-window + DEPENDS sfml-system EXTERNAL_LIBS ${AUDIO_EXT_LIBS}) endif() diff --git a/src/SFML/Audio/SoundFile.cpp b/src/SFML/Audio/SoundFile.cpp index 59d3037d1..a16b24206 100644 --- a/src/SFML/Audio/SoundFile.cpp +++ b/src/SFML/Audio/SoundFile.cpp @@ -27,7 +27,7 @@ //////////////////////////////////////////////////////////// #include #ifdef SFML_SYSTEM_ANDROID - #include + #include #include #endif #include diff --git a/src/SFML/CMakeLists.txt b/src/SFML/CMakeLists.txt index 35da00de7..35246e5e7 100644 --- a/src/SFML/CMakeLists.txt +++ b/src/SFML/CMakeLists.txt @@ -41,11 +41,11 @@ set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Modules/") set(LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/lib") # add the modules subdirectories -add_subdirectory(System) -add_subdirectory(Window) +add_subdirectory(System) if(SFML_OS_WINDOWS OR SFML_OS_ANDROID OR SFML_OS_IOS) add_subdirectory(Main) endif() +add_subdirectory(Window) add_subdirectory(Network) add_subdirectory(Graphics) if(NOT SFML_OS_IOS OR NOT (SFML_OS_ANDROID AND ${ANDROID_ABI} MATCHES "mips")) diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index 3fe4537a2..d4655953d 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -28,7 +28,7 @@ #include #include #ifdef SFML_SYSTEM_ANDROID - #include + #include #include #endif #include diff --git a/src/SFML/Graphics/Image.cpp b/src/SFML/Graphics/Image.cpp index 1441e920a..215378a0d 100644 --- a/src/SFML/Graphics/Image.cpp +++ b/src/SFML/Graphics/Image.cpp @@ -28,7 +28,7 @@ #include #include #ifdef SFML_SYSTEM_ANDROID - #include + #include #include #endif #include diff --git a/src/SFML/Main/MainAndroid.cpp b/src/SFML/Main/MainAndroid.cpp index 052bc04f8..ab050968b 100644 --- a/src/SFML/Main/MainAndroid.cpp +++ b/src/SFML/Main/MainAndroid.cpp @@ -23,13 +23,24 @@ //////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////// +// Android specific: we define the ANativeActivity_onCreate +// entry point, handling all the native activity stuff, then +// we call the user defined (and poratble) main function in +// an external thread so developers can keep a portable code +//////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// #include #ifdef SFML_SYSTEM_ANDROID -#include #include #include +#include #include #include #include @@ -41,7 +52,6 @@ namespace sf { namespace priv { - Keyboard::Key mapAndroidKeyToSFMLKey(int32_t key) { switch (key) diff --git a/src/SFML/Window/Android/Activity.cpp b/src/SFML/System/Android/Activity.cpp similarity index 72% rename from src/SFML/Window/Android/Activity.cpp rename to src/SFML/System/Android/Activity.cpp index 236b1b06a..11deab33a 100644 --- a/src/SFML/Window/Android/Activity.cpp +++ b/src/SFML/System/Android/Activity.cpp @@ -1,6 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com) // Copyright (C) 2013 Jonathan De Wachter (dewachter.jonathan@gmail.com) // // This software is provided 'as-is', without any express or implied warranty. @@ -22,20 +23,24 @@ // //////////////////////////////////////////////////////////// -#include + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include namespace sf { -namespace priv +namespace priv { - ActivityStates* getActivity(ActivityStates* initializedStates) - { - static ActivityStates* states = NULL; +ActivityStates* getActivity(ActivityStates* initializedStates) +{ + static ActivityStates* states = NULL; - if (!states) - states = initializedStates; + if (!states) + states = initializedStates; - return states; - } + return states; +} } } diff --git a/src/SFML/Window/Android/Activity.hpp b/src/SFML/System/Android/Activity.hpp similarity index 97% rename from src/SFML/Window/Android/Activity.hpp rename to src/SFML/System/Android/Activity.hpp index 7de7875a3..038fa7fec 100644 --- a/src/SFML/Window/Android/Activity.hpp +++ b/src/SFML/System/Android/Activity.hpp @@ -70,7 +70,8 @@ struct ActivityStates bool updated; }; -SFML_WINDOW_API ActivityStates* getActivity(ActivityStates* initializedStates=NULL); +SFML_SYSTEM_API ActivityStates* getActivity(ActivityStates* initializedStates=NULL); + } // namespace priv } // namespace sf diff --git a/src/SFML/System/CMakeLists.txt b/src/SFML/System/CMakeLists.txt index 7aa88d877..f5b32e0a3 100644 --- a/src/SFML/System/CMakeLists.txt +++ b/src/SFML/System/CMakeLists.txt @@ -66,6 +66,14 @@ else() ${SRCROOT}/Unix/ThreadLocalImpl.cpp ${SRCROOT}/Unix/ThreadLocalImpl.hpp ) + + if(ANDROID) + set(PLATFORM_SRC ${PLATFORM_SRC} + ${SRCROOT}/Android/Activity.hpp + ${SRCROOT}/Android/Activity.cpp + ) + endif() + source_group("unix" FILES ${PLATFORM_SRC}) endif() diff --git a/src/SFML/Window/Android/EglContext.cpp b/src/SFML/Window/Android/EglContext.cpp index 5d6e4e6dc..bf02706f7 100644 --- a/src/SFML/Window/Android/EglContext.cpp +++ b/src/SFML/Window/Android/EglContext.cpp @@ -27,7 +27,7 @@ // Headers //////////////////////////////////////////////////////////// #include -#include +#include #include #include #include diff --git a/src/SFML/Window/Android/InputImpl.cpp b/src/SFML/Window/Android/InputImpl.cpp index e99cb73e1..aa608823a 100644 --- a/src/SFML/Window/Android/InputImpl.cpp +++ b/src/SFML/Window/Android/InputImpl.cpp @@ -26,7 +26,7 @@ // Headers //////////////////////////////////////////////////////////// #include -#include +#include #include #include diff --git a/src/SFML/Window/Android/VideoModeImpl.cpp b/src/SFML/Window/Android/VideoModeImpl.cpp index 2d701602f..14f268ae5 100644 --- a/src/SFML/Window/Android/VideoModeImpl.cpp +++ b/src/SFML/Window/Android/VideoModeImpl.cpp @@ -26,7 +26,7 @@ // Headers //////////////////////////////////////////////////////////// #include -#include +#include #include #include #include diff --git a/src/SFML/Window/Android/WindowImplAndroid.cpp b/src/SFML/Window/Android/WindowImplAndroid.cpp index 8ffe3aca9..da61ed63f 100644 --- a/src/SFML/Window/Android/WindowImplAndroid.cpp +++ b/src/SFML/Window/Android/WindowImplAndroid.cpp @@ -29,7 +29,7 @@ #include // important to be included first (conflict with None) #include #include -#include +#include #include diff --git a/src/SFML/Window/CMakeLists.txt b/src/SFML/Window/CMakeLists.txt index fedd7a500..eb2233b5d 100644 --- a/src/SFML/Window/CMakeLists.txt +++ b/src/SFML/Window/CMakeLists.txt @@ -148,9 +148,7 @@ elseif(ANDROID) ${SRCROOT}/Android/InputImpl.hpp ${SRCROOT}/Android/InputImpl.cpp ${SRCROOT}/Android/JoystickImpl.hpp - ${SRCROOT}/Android/JoystickImpl.cpp - ${SRCROOT}/Android/Activity.hpp - ${SRCROOT}/Android/Activity.cpp) + ${SRCROOT}/Android/JoystickImpl.cpp) source_group("android" FILES ${PLATFORM_SRC}) endif()