Squashed commit of the following:

commit 59e43a3c80f4af8998e4a14f6463bd7a91617d5f
Author: Ricardo Quesada <ricardoquesada@gmail.com>
Date:   Wed Mar 2 15:19:48 2016 -0800

    uses new naming convention for projects

    uses _ instead of -

commit f97ba56608d48b17909649c8617ba9047b566196
Author: Ricardo Quesada <ricardoquesada@gmail.com>
Date:   Wed Mar 2 14:49:22 2016 -0800

    fooling cmake for real

commit 20c2560f75eab952e5131b484284bf20cb07fe07
Author: Ricardo Quesada <ricardoquesada@gmail.com>
Date:   Wed Mar 2 14:43:05 2016 -0800

    fooling cmake

commit a0ada44bc82941830f6c71219a1492d28c28c306
Author: Ricardo Quesada <ricardoquesada@gmail.com>
Date:   Wed Mar 2 14:26:59 2016 -0800

    makes CMake for Mac happy

commit 656b4f5e2dd741215a4699db979fe1b0dce60298
Author: Ricardo Quesada <ricardoquesada@gmail.com>
Date:   Wed Mar 2 13:50:15 2016 -0800

    linux fix

commit fa98aeac8505c764f4a69f15c8a8ff1123fad2a3
Author: Ricardo Quesada <ricardoquesada@gmail.com>
Date:   Wed Mar 2 11:18:18 2016 -0800

    links correctly!

commit 9c56ce7143d3a35b44d33f246cec093ca9eaa7d9
Author: Ricardo Quesada <ricardoquesada@gmail.com>
Date:   Tue Mar 1 17:44:58 2016 -0800

    Squashed commit of the following:

    commit 2ef52723dae44204c047cb177d5a5670fb659c79
    Merge: 8a5c998 25cf1f1
    Author: Ricardo Quesada <ricardoquesada@gmail.com>
    Date:   Tue Mar 1 16:54:04 2016 -0800

        Merge branch 'v3' into cmake_android

    commit 8a5c9981192e344fffc9f14be5cb14f66eccfa24
    Author: Chaoren Lin <chaorenl@google.com>
    Date:   Thu Feb 11 18:34:46 2016 -0800

        Fix module name in Android template to match CMake project.

    commit be85e19e852a9d5fbd6c58cea60c75fe47a5a576
    Author: Chaoren Lin <chaorenl@google.com>
    Date:   Thu Feb 11 18:27:45 2016 -0800

        Add missing platform specific source file to CMake project.

    commit 705389ac6582107a381d0cbc56268eaa98ffc5c3
    Author: Chaoren Lin <chaorenl@google.com>
    Date:   Wed Feb 10 19:21:12 2016 -0800

        Find AndroidNdkModules.cmake relative to android.toolchain.cmake.

    commit a10075e2cb30af2e1f9a30da99efac880658ad6b
    Author: Chaoren Lin <chaorenl@google.com>
    Date:   Wed Feb 10 19:03:11 2016 -0800

        Remove cpp-empty-test from project templates.

    commit e070fcbf210b8628f75785e738202a80a95ac0ff
    Author: WenhaiLin <wenhai.lin@chukong-inc.com>
    Date:   Mon Aug 31 09:56:03 2015 +0800

        Fix CMake for Android Target
This commit is contained in:
Ricardo Quesada 2016-03-02 16:51:54 -08:00
parent 25cf1f103b
commit 028f8c28e1
26 changed files with 703 additions and 491 deletions

View File

@ -1,6 +1,7 @@
#/****************************************************************************
# Copyright (c) 2013 cocos2d-x.org
# Copyright (c) 2014 martell malone
# Copyright (c) 2015 Chukong Technologies Inc.
#
# http://www.cocos2d-x.org
#
@ -23,7 +24,7 @@
# THE SOFTWARE.
# ****************************************************************************/
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.1)
# It ensures that when Find*.cmake files included from cmake's Modules dir
# include another *.cmake file with relative path, that file will be included
# also from cmake's Modules dir, to not clash with per-project files.
@ -38,7 +39,7 @@ endif()
project (Cocos2d-X)
# The version number
set(COCOS2D_X_VERSION 3.10)
set(COCOS2D_X_VERSION 3.11)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules/")
include(CocosBuildHelpers)
@ -55,6 +56,7 @@ if(MINGW)
set(USE_PREBUILT_LIBS_DEFAULT OFF)
endif()
set(BUILD_CPP_EMPTY_TEST_DEFAULT ON)
set(BUILD_CPP_TESTS_DEFAULT ON)
set(BUILD_LUA_LIBS_DEFAULT ON)
set(BUILD_LUA_TESTS_DEFAULT ON)
@ -62,6 +64,7 @@ set(BUILD_JS_LIBS_DEFAULT ON)
set(BUILD_JS_TESTS_DEFAULT ON)
# TODO: fix test samples for MSVC
if(MSVC)
set(BUILD_CPP_EMPTY_TEST_DEFAULT OFF)
set(BUILD_CPP_TESTS_DEFAULT OFF)
set(BUILD_LUA_LIBS_DEFAULT OFF)
set(BUILD_LUA_TESTS_DEFAULT OFF)
@ -81,6 +84,7 @@ option(BUILD_EDITOR_SPINE "Build editor support for spine" ON)
option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" ON)
option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" ON)
option(BUILD_CPP_TESTS "Build TestCpp samples" ${BUILD_CPP_TESTS_DEFAULT})
option(BUILD_CPP_EMPTY_TEST "Build TestCpp samples" ${BUILD_CPP_EMPTY_TEST_DEFAULT})
option(BUILD_LUA_LIBS "Build lua libraries" ${BUILD_LUA_LIBS_DEFAULT})
option(BUILD_LUA_TESTS "Build TestLua samples" ${BUILD_LUA_TESTS_DEFAULT})
option(BUILD_JS_LIBS "Build js libraries" ${BUILD_JS_LIBS_DEFAULT})
@ -116,7 +120,7 @@ if(MSVC)
else()
set(CMAKE_C_FLAGS_DEBUG "-g -Wall -Wextra -DCOCOS2D_DEBUG=1")
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-deprecated-declarations -Wno-reorder")
if(CLANG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
@ -146,6 +150,8 @@ elseif(LINUX)
elseif(ANDROID)
ADD_DEFINITIONS (-DUSE_FILE32API)
set(PLATFORM_FOLDER android)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsigned-char -latomic")
else()
message( FATAL_ERROR "Unsupported platform, CMake will exit" )
endif()
@ -349,9 +355,13 @@ endif()
# libcocos2d.a
add_subdirectory(cocos)
# build cpp tests
if(BUILD_CPP_TESTS)
# build cpp-empty-test
if(BUILD_CPP_EMPTY_TEST)
add_subdirectory(tests/cpp-empty-test)
endif(BUILD_CPP_EMPTY_TEST)
# build cpp-tests
if(BUILD_CPP_TESTS)
add_subdirectory(tests/cpp-tests)
endif(BUILD_CPP_TESTS)

96
cmake/AndroidNdkGdb.cmake Normal file
View File

@ -0,0 +1,96 @@
# Copyright (c) 2014, Pavel Rojtberg
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# ------------------------------------------------------------------------------
# Usage:
# 1. place AndroidNdkGdb.cmake somewhere inside ${CMAKE_MODULE_PATH}
# 2. inside your project add
#
# include(AndroidNdkGdb)
# android_ndk_gdb_enable()
# # for each target
# add_library(MyLibrary ...)
# android_ndk_gdb_debuggable(MyLibrary)
# add gdbserver and general gdb configuration to project
# also create a mininal NDK skeleton so ndk-gdb finds the paths
#
# the optional parameter defines the path to the android project.
# uses PROJECT_SOURCE_DIR by default.
macro(android_ndk_gdb_enable)
if(ANDROID)
# create custom target that depends on the real target so it gets executed afterwards
add_custom_target(NDK_GDB ALL)
if(${ARGC})
set(ANDROID_PROJECT_DIR ${ARGV0})
else()
set(ANDROID_PROJECT_DIR ${PROJECT_SOURCE_DIR})
endif()
set(NDK_GDB_SOLIB_PATH ${ANDROID_PROJECT_DIR}/obj/local/${ANDROID_NDK_ABI_NAME}/)
file(MAKE_DIRECTORY ${NDK_GDB_SOLIB_PATH})
# 1. generate essential Android Makefiles
file(MAKE_DIRECTORY ${ANDROID_PROJECT_DIR}/jni)
if(NOT EXISTS ${ANDROID_PROJECT_DIR}/jni/Android.mk)
file(WRITE ${ANDROID_PROJECT_DIR}/jni/Android.mk "APP_ABI := ${ANDROID_NDK_ABI_NAME}\n")
endif()
if(NOT EXISTS ${ANDROID_PROJECT_DIR}/jni/Application.mk)
file(WRITE ${ANDROID_PROJECT_DIR}/jni/Application.mk "APP_ABI := ${ANDROID_NDK_ABI_NAME}\n")
endif()
# 2. generate gdb.setup
get_directory_property(PROJECT_INCLUDES DIRECTORY ${PROJECT_SOURCE_DIR} INCLUDE_DIRECTORIES)
string(REGEX REPLACE ";" " " PROJECT_INCLUDES "${PROJECT_INCLUDES}")
file(WRITE ${LIBRARY_OUTPUT_PATH}/gdb.setup "set solib-search-path ${NDK_GDB_SOLIB_PATH}\n")
file(APPEND ${LIBRARY_OUTPUT_PATH}/gdb.setup "directory ${PROJECT_INCLUDES}\n")
# 3. copy gdbserver executable
file(COPY ${ANDROID_NDK}/prebuilt/android-${ANDROID_ARCH_NAME}/gdbserver/gdbserver DESTINATION ${LIBRARY_OUTPUT_PATH})
endif()
endmacro()
# register a target for remote debugging
# copies the debug version to NDK_GDB_SOLIB_PATH then strips symbols of original
macro(android_ndk_gdb_debuggable TARGET_NAME)
if(ANDROID)
get_property(TARGET_LOCATION TARGET ${TARGET_NAME} PROPERTY LOCATION)
# create custom target that depends on the real target so it gets executed afterwards
add_dependencies(NDK_GDB ${TARGET_NAME})
# 4. copy lib to obj
add_custom_command(TARGET NDK_GDB POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${TARGET_LOCATION} ${NDK_GDB_SOLIB_PATH})
# 5. strip symbols
add_custom_command(TARGET NDK_GDB POST_BUILD COMMAND ${CMAKE_STRIP} ${TARGET_LOCATION})
endif()
endmacro()

View File

@ -0,0 +1,58 @@
# Copyright (c) 2014, Pavel Rojtberg
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
macro(android_ndk_import_module_cpufeatures)
if(ANDROID)
include_directories(${ANDROID_NDK}/sources/android/cpufeatures)
add_library(cpufeatures ${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c)
target_link_libraries(cpufeatures dl)
endif()
endmacro()
macro(android_ndk_import_module_native_app_glue)
if(ANDROID)
include_directories(${ANDROID_NDK}/sources/android/native_app_glue)
add_library(native_app_glue ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
target_link_libraries(native_app_glue log)
endif()
endmacro()
macro(android_ndk_import_module_ndk_helper)
if(ANDROID)
android_ndk_import_module_cpufeatures()
android_ndk_import_module_native_app_glue()
include_directories(${ANDROID_NDK}/sources/android/ndk_helper)
file(GLOB _NDK_HELPER_SRCS ${ANDROID_NDK}/sources/android/ndk_helper/*.cpp ${ANDROID_NDK}/sources/android/ndk_helper/gl3stub.c)
add_library(ndk_helper ${_NDK_HELPER_SRCS})
target_link_libraries(ndk_helper log android EGL GLESv2 cpufeatures native_app_glue)
unset(_NDK_HELPER_SRCS)
endif()
endmacro()

View File

@ -7,7 +7,8 @@ set(_chipmunk_inc_paths include)
set(_chipmunk_libs chipmunk libchipmunk)
set(_curl_inc curl/curl.h)
set(_curl_libs crypto ssl libeay32 ssleay32 curl libcurl_imp libcurl)
# order: curl, ssl, crypto
set(_curl_libs curl libcurl_imp libcurl ssl libeay32 ssleay32 crypto)
set(_freetype2_prefix FREETYPE)
set(_freetype2_inc ft2build.h freetype/freetype.h)
@ -89,6 +90,11 @@ if(LINUX)
list(APPEND all_prebuilt_libs fmod)
endif()
if(ANDROID)
list(APPEND all_prebuilt_libs zlib)
endif()
# END CONFIG
foreach(_lib ${all_prebuilt_libs})
@ -122,6 +128,7 @@ foreach(_lib ${all_prebuilt_libs})
endif()
foreach(_inc_name ${_${_lib}_inc})
unset(_inc_tmp CACHE)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
find_path(_inc_tmp ${_inc_name} PATH_SUFFIXES ${_suffixes} PATHS ${_dir} NO_DEFAULT_PATH)
if(_inc_tmp)
list(APPEND include_dirs ${_inc_tmp})
@ -135,6 +142,7 @@ foreach(_lib ${all_prebuilt_libs})
#message(STATUS "${_lib} ${_prefix}_INCLUDE_DIRS: ${${_prefix}_INCLUDE_DIRS}")
set(lib_dir_candidates
${_root}/prebuilt/${PLATFORM_FOLDER}/${ANDROID_ABI}
${_root}/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
${_root}/prebuilt/${PLATFORM_FOLDER}
${_root}/prebuilt/${PLATFORM_FOLDER}/release-lib
@ -148,6 +156,7 @@ foreach(_lib ${all_prebuilt_libs})
# find all libs
foreach(_lib_name ${_${_lib}_libs})
unset(_lib_tmp CACHE)
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
find_library(_lib_tmp ${_lib_name} PATHS ${_dir} NO_DEFAULT_PATH)
if(_lib_tmp)
list(APPEND libs ${_lib_tmp})

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
#/****************************************************************************
# Copyright (c) 2013 cocos2d-x.org
# Copyright (c) 2014 martell malone
# Copyright (c) 2015 Chukong Technologies Inc.
#
# http://www.cocos2d-x.org
#
@ -25,7 +26,7 @@
# this CMakeLists is to generate libcocos2d.a
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.1)
if(WINDOWS)
ADD_DEFINITIONS(-DUNICODE -D_UNICODE)
@ -86,21 +87,20 @@ set(COCOS_SRC cocos2d.cpp
include_directories(../external/xxtea)
include_directories(../external/clipper)
add_library(cocos2d ${COCOS_SRC})
add_library(cocos2dInternal ${COCOS_SRC})
set(PLATFORM_SPECIFIC_LIBS)
if(WINDOWS)
foreach(_pkg OPENGL GLEW GLFW3 VORBIS MPG123 OPENAL)
cocos_use_pkg(cocos2d ${_pkg})
cocos_use_pkg(cocos2dInternal ${_pkg})
endforeach()
list(APPEND PLATFORM_SPECIFIC_LIBS ws2_32 winmm)
elseif(LINUX)
foreach(_pkg OPENGL GLEW GLFW3 FMOD FONTCONFIG THREADS GTK3)
cocos_use_pkg(cocos2d ${_pkg})
foreach(_pkg OPENGL GLEW GLFW3 FMOD FONTCONFIG THREADS GTK3)
cocos_use_pkg(cocos2dInternal ${_pkg})
endforeach()
elseif(MACOSX OR APPLE)
cocos_use_pkg(cocos2d GLFW3)
cocos_use_pkg(cocos2dInternal GLFW3)
INCLUDE_DIRECTORIES ( /System/Library/Frameworks )
@ -125,42 +125,54 @@ elseif(MACOSX OR APPLE)
)
elseif(ANDROID)
set(PLATFORM_SPECIFIC_LIBS GLESv2 log android)
set(PLATFORM_SPECIFIC_LIBS GLESv1_CM GLESv2 EGL log android OpenSLES)
get_filename_component(__module_path "${CMAKE_TOOLCHAIN_FILE}" DIRECTORY)
include(${__module_path}/AndroidNdkModules.cmake)
android_ndk_import_module_cpufeatures()
else()
message( FATAL_ERROR "Unsupported platform, CMake will exit" )
endif()
foreach(pkg ZLIB MINIZIP JPEG PNG TIFF TinyXML2 FREETYPE WEBSOCKETS CURL FLATBUFFERS XXHASH)
cocos_use_pkg(cocos2d ${pkg})
cocos_use_pkg(cocos2dInternal ${pkg})
endforeach()
if(LINUX)
set(glfw_other_linker_flags X11)
endif(LINUX)
target_link_libraries(cocos2d ${PLATFORM_SPECIFIC_LIBS} ${glfw_other_linker_flags})
target_link_libraries(cocos2dInternal ${PLATFORM_SPECIFIC_LIBS} ${glfw_other_linker_flags})
if(USE_WEBP)
add_definitions(-DCC_USE_WEBP=1)
cocos_use_pkg(cocos2d WEBP)
cocos_use_pkg(cocos2dInternal WEBP)
else()
add_definitions(-DCC_USE_WEBP=0)
endif()
if(USE_CHIPMUNK)
cocos_use_pkg(cocos2d CHIPMUNK)
cocos_use_pkg(cocos2dInternal CHIPMUNK)
endif()
if(USE_BOX2D)
cocos_use_pkg(cocos2d Box2D)
cocos_use_pkg(cocos2dInternal Box2D)
endif()
if(USE_BULLET)
cocos_use_pkg(cocos2d BULLET)
cocos_use_pkg(cocos2dInternal BULLET)
endif()
if(USE_RECAST)
cocos_use_pkg(cocos2d RECAST)
cocos_use_pkg(cocos2dInternal RECAST)
endif()
ADD_LIBRARY(cocos2d cc_dummy.c)
if(ANDROID)
target_link_libraries(cocos2d -Wl,-whole-archive cocos2dxandroid_static -Wl,-no-whole-archive)
target_link_libraries(cocos2d cocos2dInternal cpufeatures)
else()
target_link_libraries(cocos2d cocos2dInternal)
endif()
set_target_properties(cocos2d

View File

@ -13,6 +13,14 @@ if(WINDOWS)
audio/win32/AudioPlayer.cpp
)
ELSEIF(ANDROID)
set(COCOS_AUDIO_PLATFORM_SRC
audio/android/AudioEngine-inl.cpp
audio/android/ccdandroidUtils.cpp
audio/android/cddSimpleAudioEngine.cpp
audio/android/jni/cddandroidAndroidJavaEngine.cpp
)
elseif(LINUX)
set(COCOS_AUDIO_PLATFORM_SRC
audio/linux/SimpleAudioEngine.cpp

View File

@ -27,7 +27,7 @@ THE SOFTWARE.
#include <stdlib.h>
#include <android/log.h>
#include <sys/system_properties.h>
#include "ccdandroidUtils.h"
#include "audio/android/ccdandroidUtils.h"
#include "audio/include/AudioEngine.h"
#include "platform/android/jni/JniHelper.h"

View File

@ -1,11 +1,15 @@
if(MACOSX OR APPLE)
set(COCOS_BASE_SPECIFIC_SRC
base/CCUserDefault-apple.mm)
endif()
base/CCUserDefault-apple.mm
)
# todo: android support via base/CCUserDefaultAndroid.cpp
# todo: also base/CCController-android.cpp
elseif(ANDROID)
set(COCOS_BASE_SPECIFIC_SRC
base/CCUserDefault-android.cpp
base/CCController-android.cpp
)
endif()
set(COCOS_BASE_SRC
base/CCAsyncTaskPool.cpp

3
cocos/cc_dummy.c Normal file
View File

@ -0,0 +1,3 @@
static void making_cmake_happy(void)
{
}

View File

@ -3,12 +3,20 @@ if(WINDOWS)
set(PLATFORM_LINK websockets)
elseif(LINUX)
set(PLATFORM_LINK websockets ssl crypto)
elseif(ANDROID)
set(PLATFORM_LINK websockets)
else()
set(PLATFORM_LINK websockets)
endif()
set(COCOS_NETWORK_SRC
if(ANDROID)
set(COCOS_NETWORK_PLATFORM_SRC
network/CCDownloader-android.cpp
)
endif()
set(COCOS_NETWORK_SRC
${COCOS_NETWORK_PLATFORM_SRC}
network/HttpClient.cpp
network/SocketIO.cpp
network/WebSocket.cpp
@ -16,6 +24,7 @@ set(COCOS_NETWORK_SRC
network/CCDownloader-curl.cpp
)
if(MSVC)
set(COCOS_NETWORK_LINK
libcurl_imp

0
cocos/network/HttpAsynConnection-apple.m Executable file → Normal file
View File

View File

@ -1,3 +1,26 @@
#/****************************************************************************
# Copyright (c) 2015 Chukong Technologies Inc.
#
# http://www.cocos2d-x.org
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# ****************************************************************************/
if(WINDOWS)
@ -42,21 +65,33 @@ set(COCOS_PLATFORM_SPECIFIC_SRC
elseif(ANDROID)
include_directories(
platform/android
)
set(COCOS_PLATFORM_SPECIFIC_SRC
platform/android/CCApplication-android.cpp
platform/android/CCCommon-android.cpp
platform/android/CCDevice-android.cpp
platform/android/CCGLViewImpl-android.cpp
platform/android/CCFileUtils-android.cpp
platform/android/CCEnhanceAPI-android.cpp
platform/android/jni/JniHelper.cpp
)
set(COCOS2DX_ANDROID_STATIC
platform/android/CCDevice-android.cpp
platform/android/javaactivity-android.cpp
platform/android/jni/TouchesJni.cpp
platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxAccelerometer.cpp
platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.cpp
platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp
platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp
platform/android/jni/JniHelper.cpp
platform/android/jni/TouchesJni.cpp
)
add_library(cocos2dxandroid_static STATIC ${COCOS2DX_ANDROID_STATIC})
set_property(TARGET cocos2dxandroid_static PROPERTY POSITION_INDEPENDENT_CODE TRUE)
endif()
#leave andatory external stuff here also

View File

@ -20,6 +20,12 @@ elseif(LINUX)
set(COCOS_UI_SPECIFIC_SRC
ui/UIEditBox/UIEditBoxImpl-linux.cpp
)
ELSEIF(ANDROID)
set(COCOS_UI_SPECIFIC_SRC
ui/UIEditBox/UIEditBoxImpl-android.cpp
ui/UIVideoPlayer-android.cpp
ui/UIWebViewImpl-android.cpp
)
endif()
#todo: android UIWebViewImpl and UIVideoPlayer

View File

@ -1,5 +1,6 @@
#/****************************************************************************
# Copyright (c) 2013-2014 cocos2d-x.org
# Copyright (c) 2015 Chukong Technologies Inc.
#
# http://www.cocos2d-x.org
#
@ -23,7 +24,7 @@
# ****************************************************************************/
cmake_policy(SET CMP0017 NEW)
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.1)
set(APP_NAME MyGame)
project (${APP_NAME})
@ -34,6 +35,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${COCOS2D_ROOT}/cmake/Modules/")
include(CocosBuildHelpers)
# libcocos2d
set(BUILD_CPP_EMPTY_TEST OFF CACHE BOOL "turn off build cpp-empty-test")
set(BUILD_CPP_TESTS OFF CACHE BOOL "turn off build cpp-tests")
set(BUILD_LUA_LIBS OFF CACHE BOOL "turn off build lua related targets")
set(BUILD_JS_LIBS OFF CACHE BOOL "turn off build js related targets")
@ -80,31 +82,35 @@ else()
endif(MSVC)
set(PLATFORM_SPECIFIC_SRC)
set(PLATFORM_SPECIFIC_HEADERS)
if(MACOSX OR APPLE)
set(PLATFORM_SPECIFIC_SRC
proj.ios_mac/ios/main.m
proj.ios_mac/ios/RootViewController.mm
proj.ios_mac/ios/AppController.mm
)
set(PLATFORM_SPECIFIC_HEADERS
proj.ios_mac/ios/RootViewController.h
proj.ios_mac/ios/AppController.h
)
set(PLATFORM_SPECIFIC_SRC
proj.ios_mac/ios/main.m
proj.ios_mac/ios/RootViewController.mm
proj.ios_mac/ios/AppController.mm
)
set(PLATFORM_SPECIFIC_HEADERS
proj.ios_mac/ios/RootViewController.h
proj.ios_mac/ios/AppController.h
)
elseif(LINUX) #assume linux
set(PLATFORM_SPECIFIC_SRC
proj.linux/main.cpp
)
set(PLATFORM_SPECIFIC_SRC
proj.linux/main.cpp
)
elseif ( WIN32 )
set(PLATFORM_SPECIFIC_SRC
proj.win32/main.cpp
)
set(PLATFORM_SPECIFIC_HEADERS
proj.win32/main.h
proj.win32/resource.h
)
set(PLATFORM_SPECIFIC_SRC
proj.win32/main.cpp
)
set(PLATFORM_SPECIFIC_HEADERS
proj.win32/main.h
proj.win32/resource.h
)
elseif(ANDROID)
set(PLATFORM_SPECIFIC_SRC
proj.android-studio/app/jni/hellocpp/main.cpp
)
endif()
include_directories(
@ -134,18 +140,13 @@ set(GAME_HEADERS
${PLATFORM_SPECIFIC_HEADERS}
)
if(GAME_HEADERS)
if ( WIN32 )
add_executable(${APP_NAME} WIN32 ${GAME_SRC} ${GAME_HEADERS})
else()
add_executable(${APP_NAME} ${GAME_SRC} ${GAME_HEADERS})
endif ( WIN32 )
if( ANDROID )
add_library(${APP_NAME} SHARED ${GAME_SRC} ${GAME_HEADERS})
IF(CMAKE_BUILD_TYPE MATCHES RELEASE)
ADD_CUSTOM_COMMAND(TARGET ${APP_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} lib${APP_NAME}.so)
ENDIF()
else()
if ( WIN32 )
add_executable(${APP_NAME} WIN32 ${GAME_SRC})
else()
add_executable(${APP_NAME} ${GAME_SRC})
endif ( WIN32 )
add_executable(${APP_NAME} ${GAME_SRC} ${GAME_HEADERS})
endif()
target_link_libraries(${APP_NAME} cocos2d)
@ -163,6 +164,8 @@ if ( WIN32 )
COMMAND ${CMAKE_COMMAND} -E copy ${COCOS2D_ROOT}/external/win32-specific/gles/prebuilt/glew32.dll ${APP_BIN_DIR}/${CMAKE_BUILD_TYPE}
COMMAND ${CMAKE_COMMAND} -E copy ${COCOS2D_ROOT}/external/win32-specific/zlib/prebuilt/zlib1.dll ${APP_BIN_DIR}/${CMAKE_BUILD_TYPE}
)
elseif( ANDROID )
else()
pre_build(${APP_NAME}
COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources

View File

@ -10,9 +10,9 @@
android:icon="@mipmap/ic_launcher">
<!-- Tell Cocos2dxActivity the name of our .so -->
<meta-data android:name="android.app.lib_name"
android:value="cocos2dcpp" />
<meta-data android:name="android.app.lib_name"
android:value="MyGame" />
<activity
android:name="org.cocos2dx.cpp.AppActivity"
android:screenOrientation="landscape"

View File

@ -6,9 +6,9 @@ $(call import-add-path,$(LOCAL_PATH)/../../../cocos2d)
$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d/external)
$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d/cocos)
LOCAL_MODULE := cocos2dcpp_shared
LOCAL_MODULE := MyGame_shared
LOCAL_MODULE_FILENAME := libcocos2dcpp
LOCAL_MODULE_FILENAME := libMyGame
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../../Classes/AppDelegate.cpp \

View File

@ -13,7 +13,7 @@
<!-- Tell Cocos2dxActivity the name of our .so -->
<meta-data android:name="android.app.lib_name"
android:value="cocos2dcpp" />
android:value="MyGame" />
<activity android:name="org.cocos2dx.cpp.AppActivity"
android:label="@string/app_name"

View File

@ -6,9 +6,9 @@ $(call import-add-path,$(LOCAL_PATH)/../../cocos2d)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/external)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/cocos)
LOCAL_MODULE := cocos2dcpp_shared
LOCAL_MODULE := MyGame_shared
LOCAL_MODULE_FILENAME := libcocos2dcpp
LOCAL_MODULE_FILENAME := libMyGame
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \

View File

@ -49,6 +49,7 @@ endif(USE_BULLET)
# libcocos2d
set(BUILD_CPP_EMPTY_TEST OFF CACHE BOOL "turn off build cpp-empty-test")
set(BUILD_CPP_TESTS OFF CACHE BOOL "turn off build cpp-tests")
set(BUILD_LUA_TESTS OFF CACHE BOOL "turn off build lua-tests")
set(BUILD_JS_LIBS OFF CACHE BOOL "turn off build js releated targets")

View File

@ -1,7 +1,31 @@
set(APP_NAME cpp-empty-test)
#/****************************************************************************
# Copyright (c) 2015 Chukong Technologies Inc.
# http://www.cocos2d-x.org
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# ****************************************************************************/
set(APP_NAME cpp_empty_test)
if(ANDROID)
set(PLATFORM_SRC proj.android/jni/hellocpp/main.cpp)
set(PLATFORM_SRC proj.android/jni/main.cpp)
set(RES_PREFIX "/Resources")
elseif(WINDOWS)
set(PLATFORM_SRC proj.win32/main.cpp)
@ -28,19 +52,27 @@ else()
endif()
include_directories(Classes)
set(SAMPLE_SRC
${PLATFORM_SRC}
Classes/AppDelegate.cpp
Classes/HelloWorldScene.cpp
)
# add the executable
add_executable(${APP_NAME}
${SAMPLE_SRC}
)
if(ANDROID)
add_library(${APP_NAME} SHARED ${SAMPLE_SRC})
IF(CMAKE_BUILD_TYPE MATCHES RELEASE)
ADD_CUSTOM_COMMAND(TARGET ${APP_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} lib${APP_NAME}.so)
ENDIF()
else()
# add the executable
add_executable(${APP_NAME} ${SAMPLE_SRC})
endif()
target_link_libraries(${APP_NAME} cocos2d)
if(MSVC)
#get our resources

View File

@ -1,4 +1,4 @@
set(APP_NAME cpp-tests)
set(APP_NAME cpp_tests)
# Use same method as in cocos library
cocos_find_package(CURL CURL REQUIRED)
@ -16,6 +16,11 @@ elseif(MACOSX)
elseif(LINUX)
set(PLATFORM_SRC proj.linux/main.cpp)
set(RES_PREFIX "/Resources")
elseif(ANDROID)
set(PLATFORM_SRC
Classes/JNITest/JNITest.cpp
proj.android/jni/main.cpp)
set(RES_PREFIX "/Resources")
else()
message( FATAL_ERROR "Unsupported platform, CMake will exit" )
endif()
@ -245,21 +250,26 @@ else()
)
endif()
include_directories(
Classes
${CMAKE_SOURCE_DIR}/cocos/editor-support
)
# add the executable
add_executable(${APP_NAME}
${TESTS_SRC}
${EXTENDED_TESTS_SRC}
)
if(ANDROID)
list(APPEND TESTS_SRC
Classes/UITest/CocoStudioGUITest/UIWebViewTest/UIWebViewTest.cpp
Classes/UITest/CocoStudioGUITest/UIVideoPlayerTest/UIVideoPlayerTest.cpp
)
add_library(${APP_NAME} SHARED ${TESTS_SRC} ${EXTENDED_TESTS_SRC})
IF(CMAKE_BUILD_TYPE MATCHES RELEASE)
ADD_CUSTOM_COMMAND(TARGET ${APP_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} lib${APP_NAME}.so)
ENDIF()
else()
# add the executable
add_executable(${APP_NAME} ${TESTS_SRC} ${EXTENDED_TESTS_SRC})
endif()
target_link_libraries(${APP_NAME}
cocos2d
)
target_link_libraries(${APP_NAME} cocos2d)
cocos_use_pkg(${APP_NAME} CURL)
@ -268,12 +278,13 @@ if(MACOSX OR APPLE)
MACOSX_BUNDLE 1
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
ELSEIF(ANDROID)
set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin/${APP_NAME}")
set_target_properties(${APP_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}")
else()
set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin/${APP_NAME}")
set_target_properties(${APP_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}")
pre_build(${APP_NAME}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}${RES_PREFIX}
)

View File

@ -22,7 +22,7 @@
# THE SOFTWARE.
# ****************************************************************************/
set(APP_NAME js-tests)
set(APP_NAME js_memory_gc_tests)
if(WIN32)

View File

@ -22,7 +22,7 @@
# THE SOFTWARE.
# ****************************************************************************/
set(APP_NAME js-tests)
set(APP_NAME js_tests)
if(WIN32)

View File

@ -1,4 +1,4 @@
set(APP_NAME lua-empty-test)
set(APP_NAME lua_empty_test)
set(SAMPLE_SRC Classes/AppDelegate.cpp)

View File

@ -1,4 +1,4 @@
set(APP_NAME lua-tests)
set(APP_NAME lua_tests)
set(SAMPLE_SRC
Classes/AppDelegate.cpp