Improve shared library for android, remove mojoal,sdl2, still use OpenAL.framework on apple platform, alsoft on other platforms.

This commit is contained in:
halx99 2020-08-17 18:45:14 +08:00
parent bda3a720b4
commit d084d9f61a
22 changed files with 38 additions and 51 deletions

View File

@ -35,31 +35,6 @@ set(COCOS_CORE_LIB cocos2d)
project(cocos2d_libs)
option(CC_USE_MOJOAL "Use mojoAL for all platforms" OFF)
option(CC_USE_ALSOFT "Use openal-soft on apple platform" OFF)
# checking MojoAL first
if(CC_USE_MOJOAL)
add_definitions(-DCC_USE_MOJOAL=1)
else() # choose openal-soft or apple openal framework
if(NOT APPLE)
set(CC_USE_ALSOFT ON CACHE BOOL "Use openal-soft on apple platform" FORCE)
else()
set(CC_USE_ALSOFT ${CC_USE_ALSOFT} CACHE BOOL "Use openal-soft on apple platform" FORCE)
endif()
if(CC_USE_ALSOFT)
add_definitions(-DCC_USE_ALSOFT=1)
endif()
endif()
# store al choice to cache
set(CC_USE_MOJOAL ${CC_USE_MOJOAL} CACHE BOOL "Use mojoAL platform" FORCE)
set(CC_USE_ALSOFT ${CC_USE_ALSOFT} CACHE BOOL "Use OpenAL-soft platform" FORCE)
# print al backend
message(STATUS "CC_USE_MOJOAL:${CC_USE_MOJOAL}")
message(STATUS "CC_USE_ALSOFT:${CC_USE_ALSOFT}")
include(2d/CMakeLists.txt)
include(3d/CMakeLists.txt)
include(platform/CMakeLists.txt)

View File

@ -127,6 +127,8 @@ else()
add_library(${APP_NAME} SHARED ${all_code_files})
add_subdirectory(${COCOS2DX_ROOT_PATH}/cocos/platform/android ${ENGINE_BINARY_PATH}/cocos/platform)
target_link_libraries(${APP_NAME} -Wl,--whole-archive cpp_android_spec -Wl,--no-whole-archive)
config_android_shared_libs("org.cocos2dx.${APP_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/proj.android/app/src")
endif()
target_link_libraries(${APP_NAME} cocos2d)

View File

@ -31,6 +31,10 @@ import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
public class AppActivity extends Cocos2dxActivity {
static {
// DNT remove, some android simulator require explicit load shared libraries, otherwise will crash
SharedLoader.load();
}
@Override
protected void onCreate(Bundle savedInstanceState) {

View File

@ -7,7 +7,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.android.tools.build:gradle:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip

View File

@ -119,6 +119,8 @@ else()
target_link_libraries(${APP_NAME} -Wl,--whole-archive cpp_android_spec -Wl,--no-whole-archive)
add_subdirectory(${COCOS2DX_ROOT_PATH}/cocos/scripting/lua-bindings/proj.android ${ENGINE_BINARY_PATH}/cocos/lua-android)
target_link_libraries(${APP_NAME} -Wl,--whole-archive lua_android_spec -Wl,--no-whole-archive)
config_android_shared_libs("org.cocos2dx.${APP_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/proj.android/app/src")
endif()
target_link_libraries(${APP_NAME} luacocos2d)

View File

@ -30,6 +30,11 @@ import android.os.Bundle;
import org.cocos2dx.lib.Cocos2dxActivity;
public class AppActivity extends Cocos2dxActivity{
static {
// DNT remove, some android simulator require explicit load shared libraries, otherwise will crash
SharedLoader.load();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.setEnableVirtualButton(false);

View File

@ -7,7 +7,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.android.tools.build:gradle:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip

View File

@ -388,8 +388,8 @@ else()
add_library(${APP_NAME} SHARED ${all_code_files})
add_subdirectory(${COCOS2DX_ROOT_PATH}/cocos/platform/android ${ENGINE_BINARY_PATH}/cocos/platform)
target_link_libraries(${APP_NAME} -Wl,--whole-archive cpp_android_spec -Wl,--no-whole-archive)
configure_file(${OPENAL_SO_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/proj.android/app/src/main/jniLibs/${ANDROID_ABI}/${OPENAL_SO_NAME} COPYONLY)
configure_file(${MPG123_SO_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/proj.android/app/src/main/jniLibs/${ANDROID_ABI}/${MPG123_SO_NAME} COPYONLY)
config_android_shared_libs("org.cocos2dx.${APP_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/proj.android/app/src")
endif()
target_link_libraries(${APP_NAME} cocos2d)

View File

@ -30,9 +30,10 @@ import org.cocos2dx.lib.Cocos2dxActivity;
public class AppActivity extends Cocos2dxActivity {
static {
System.loadLibrary("mpg123");
System.loadLibrary("openal");
// DNT remove, some android simulator require explicit load shared libraries, otherwise will crash
SharedLoader.load();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.setEnableVirtualButton(false);
@ -46,6 +47,5 @@ public class AppActivity extends Cocos2dxActivity {
return;
}
// DO OTHER INITIALIZATION BELOW
}
}

View File

@ -7,7 +7,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.android.tools.build:gradle:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

View File

@ -31,7 +31,7 @@ PROP_TARGET_SDK_VERSION=28
# Available architextures (armeabi-v7a | arm64-v8a | x86)
# To build for multiple architexture, use the `:` between them
# Example - PROP_APP_ABI=armeabi-v7a:arm64-v8a:x86
PROP_APP_ABI=armeabi-v7a
PROP_APP_ABI=arm64-v8a
# uncomment it and fill in sign information for release mode
#RELEASE_STORE_FILE=file path of keystore

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip

View File

@ -114,8 +114,7 @@ else()
add_subdirectory(${COCOS2DX_ROOT_PATH}/cocos/platform/android ${ENGINE_BINARY_PATH}/cocos/platform)
target_link_libraries(${APP_NAME} -Wl,--whole-archive cpp_android_spec -Wl,--no-whole-archive)
configure_file(${OPENAL_SO_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/proj.android/app/src/main/jniLibs/${ANDROID_ABI}/${OPENAL_SO_NAME} COPYONLY)
configure_file(${MPG123_SO_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/proj.android/app/src/main/jniLibs/${ANDROID_ABI}/${MPG123_SO_NAME} COPYONLY)
config_android_shared_libs("org.cocos2dx.${APP_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/proj.android/app/src")
endif()
target_link_libraries(${APP_NAME} cocos2d)

View File

@ -30,9 +30,9 @@ import org.cocos2dx.lib.Cocos2dxActivity;
public class AppActivity extends Cocos2dxActivity {
static {
System.loadLibrary("mpg123");
System.loadLibrary("openal");
SharedLoader.load();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.setEnableVirtualButton(false);

View File

@ -7,7 +7,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.android.tools.build:gradle:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip

View File

@ -111,8 +111,7 @@ else()
target_link_libraries(${APP_NAME} -Wl,--whole-archive lua_android_spec -Wl,--no-whole-archive)
endif()
configure_file(${OPENAL_SO_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/proj.android/app/src/main/jniLibs/${ANDROID_ABI}/${OPENAL_SO_NAME} COPYONLY)
configure_file(${MPG123_SO_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/proj.android/app/src/main/jniLibs/${ANDROID_ABI}/${MPG123_SO_NAME} COPYONLY)
config_android_shared_libs("org.cocos2dx.${APP_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/proj.android/app/src")
endif()
target_link_libraries(${APP_NAME} luacocos2d)
target_include_directories(${APP_NAME} PRIVATE Classes)

View File

@ -31,9 +31,10 @@ import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
public class AppActivity extends Cocos2dxActivity{
static {
System.loadLibrary("mpg123");
System.loadLibrary("openal");
// DNT remove, some android simulator require explicit load shared libraries, otherwise will crash
SharedLoader.load();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.setEnableVirtualButton(false);

View File

@ -7,7 +7,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.android.tools.build:gradle:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip