Skip to content

Commit

Permalink
3.14 version OHOS adaptation (#20832)
Browse files Browse the repository at this point in the history
* 3.14 version OHOS adaptation
Signed-off-by: @wanghui187 <[email protected]>
  • Loading branch information
wanghui187 authored Dec 25, 2024
1 parent e5e431e commit 18c2a1e
Show file tree
Hide file tree
Showing 347 changed files with 28,163 additions and 124 deletions.
37 changes: 37 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version: 1.0.{build}
skip_tags: true
skip_branch_with_pr: true
image:
- Visual Studio 2015
environment:
PYTHON: "C:\\Python27"
PYTHON_VERSION: "2.7.13"
PYTHON_ARCH: "32"
matrix:
# - build_type: windows32_cmake_test
# - build_type: windows32_sln_test
# - build_type: android_lua_tests
# - build_type: android_cocos_new_test
# - build_type: android_cpp_empty_test
# - build_type: android_gen_libs


platform:
- x86

configuration:
- Release


branches:
except:
- v1
- v2
- v4-develop
- v3-doc
- v3.11_backup
- v35-for-tizen

clone_depth: 1

test: off
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ endif()
project (Cocos2d-X)

# The version number
set(COCOS2D_X_VERSION 3.13)
set(COCOS2D_X_VERSION 3.14)

# define some variables

Expand Down Expand Up @@ -113,8 +113,13 @@ if(BUILD_LUA_LIBS)

# build lua tests
if(BUILD_LUA_TESTS)
if(OHOS)
add_subdirectory(external/lua/luajit)
endif()
add_subdirectory(tests/lua-tests/project)
if(!OHOS)
add_subdirectory(tests/lua-empty-test/project)
endif()
endif(BUILD_LUA_TESTS)

endif(BUILD_LUA_LIBS)
Expand Down
11 changes: 11 additions & 0 deletions cmake/Modules/BuildModules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ macro (BuildModules)
message(STATUS "Bullet include dirs: ${BULLET_INCLUDE_DIRS}")
endif(USE_BULLET)

if(OHOS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/ohos-specific/pvmp3dec)
set(PVMP3DEC_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/ohos-specific/pvmp3dec/include)
set(PVMP3DEC_LIBRARIES pvmp3dec)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/ohos-specific/tremolo)
set(TREMOLO_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/ohos-specific/tremolo)
set(TREMOLO_LIBRARIES tremolo)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/openssl)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/websockets)
endif(OHOS)

# Recast (not prebuilded, exists as source)
if(USE_RECAST)
if(USE_PREBUILT_LIBS OR USE_SOURCES_EXTERNAL)
Expand Down
3 changes: 3 additions & 0 deletions cmake/Modules/CocosBuildHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ endfunction()
#IOS = iOS
#MACOSX = MacOS X
#LINUX = Linux
#OHOS = OHOS

if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
if(WINRT)
Expand All @@ -139,6 +140,8 @@ elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(APPLE TRUE)
set(SYSTEM_STRING "Mac OSX")
endif()
elseif(OHOS)
set(SYSTEM_STRING "HarmonyOS Next")
endif()

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
Expand Down
18 changes: 18 additions & 0 deletions cmake/Modules/FindCURL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@ if(NOT CURL_FOUND)
# Windows older "Win32 - MSVC" prebuilts (libcurl.lib, e.g. libcurl-7.15.5-win32-msvc.zip):
libcurl
)
if(OHOS)
# Active set path
if(${CURL_INCLUDE_DIR} STREQUAL "CURL_INCLUDE_DIR-NOTFOUND")
message("[OHOS_LOG] CURL_INCLUDE_DIR NOTFOUND")
set(CURL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/curl/include/ohos)
endif()

if(${CURL_LIBRARY} STREQUAL "CURL_LIBRARY-NOTFOUND")
message("[OHOS_LOG] CURL_LIBRARY NOTFOUND")
set(CURL_LIBRARY
${CMAKE_CURRENT_SOURCE_DIR}/external/curl/prebuilt/ohos/libcurl.a
)
endif()

message("[OHOS_LOG] CURL_INCLUDE_DIR ${CURL_INCLUDE_DIR}")
message("[OHOS_LOG] CURL_LIBRARY ${CURL_LIBRARY}")
endif()

mark_as_advanced(CURL_LIBRARY)

if(CURL_INCLUDE_DIR)
Expand Down
18 changes: 18 additions & 0 deletions cmake/Modules/FindChipmunk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,24 @@ FIND_LIBRARY(CHIPMUNK_LIBRARY

set(CHIPMUNK_INCLUDE_DIRS "${CHIPMUNK_INCLUDE_DIR}")

if(OHOS)
# Active set path
if(${CHIPMUNK_INCLUDE_DIR} STREQUAL "CHIPMUNK_INCLUDE_DIR-NOTFOUND")
# message("[OHOS_LOG] CHIPMUNK_INCLUDE_DIR NOTFOUND")
set(CHIPMUNK_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/chipmunk/include)
endif()

if(${CHIPMUNK_LIBRARY} STREQUAL "CHIPMUNK_LIBRARY-NOTFOUND")
# message("[OHOS_LOG] CHIPMUNK_LIBRARY NOTFOUND")
set(CHIPMUNK_LIBRARY
${CMAKE_CURRENT_SOURCE_DIR}/external/chipmunk/prebuilt/ohos/libchipmunk.a
)
endif()

# message("[OHOS_LOG] CHIPMUNK_INCLUDE_DIR ${CHIPMUNK_INCLUDE_DIR}")
# message("[OHOS_LOG] CHIPMUNK_LIBRARY ${CHIPMUNK_LIBRARY}")
endif()

IF(CHIPMUNK_LIBRARY)
# include the math library for Unix
IF(UNIX AND NOT APPLE)
Expand Down
24 changes: 24 additions & 0 deletions cmake/Modules/FindFreetype.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,30 @@ find_library(FREETYPE_LIBRARY
[HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]
)

if(OHOS)
# Active set path
if(${FREETYPE_INCLUDE_DIR_ft2build} STREQUAL "FREETYPE_INCLUDE_DIR_ft2build-NOTFOUND")
# message("[OHOS_LOG] FREETYPE_INCLUDE_DIR_ft2build NOTFOUND")
set(FREETYPE_INCLUDE_DIR_ft2build ${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/include/ohos)
endif()

if(${FREETYPE_INCLUDE_DIR_freetype2} STREQUAL "FREETYPE_INCLUDE_DIR_freetype2-NOTFOUND")
# message("[OHOS_LOG] FREETYPE_INCLUDE_DIR_freetype2 NOTFOUND")
set(FREETYPE_INCLUDE_DIR_freetype2 ${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/include/ohos/freetype2)
endif()

if(${FREETYPE_LIBRARY} STREQUAL "FREETYPE_LIBRARY-NOTFOUND")
# message("[OHOS_LOG] FREETYPE_LIBRARY NOTFOUND")
set(FREETYPE_LIBRARY
${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/prebuilt/ohos/libfreetype.a
)
endif()

# message("[OHOS_LOG] FREETYPE_INCLUDE_DIR_ft2build ${FREETYPE_INCLUDE_DIR_ft2build}")
# message("[OHOS_LOG] FREETYPE_INCLUDE_DIR_freetype2 ${FREETYPE_INCLUDE_DIR_freetype2}")
# message("[OHOS_LOG] FREETYPE_LIBRARY ${FREETYPE_LIBRARY}")
endif()

# set the user variables
if(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2)
set(FREETYPE_INCLUDE_DIRS "${FREETYPE_INCLUDE_DIR_ft2build};${FREETYPE_INCLUDE_DIR_freetype2}")
Expand Down
17 changes: 17 additions & 0 deletions cmake/Modules/FindJPEG.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,23 @@ find_path(JPEG_INCLUDE_DIR jpeglib.h)
set(JPEG_NAMES ${JPEG_NAMES} jpeg)
find_library(JPEG_LIBRARY NAMES ${JPEG_NAMES} )

if(OHOS)
# Active set path
if(${JPEG_INCLUDE_DIR} STREQUAL "JPEG_INCLUDE_DIR-NOTFOUND")
# message("[OHOS_LOG] JPEG_INCLUDE_DIR NOTFOUND")
set(JPEG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/include/ohos)
endif()
if(${JPEG_LIBRARY} STREQUAL "JPEG_LIBRARY-NOTFOUND")
# message("[OHOS_LOG] JPEG_LIBRARY NOTFOUND")
set(JPEG_LIBRARY
${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/prebuilt/ohos/libjpeg.a
)
endif()

# message("[OHOS_LOG] JPEG_INCLUDE_DIR ${JPEG_INCLUDE_DIR}")
# message("[OHOS_LOG] JPEG_LIBRARY ${JPEG_LIBRARY}")
endif()

# handle the QUIETLY and REQUIRED arguments and set JPEG_FOUND to TRUE if
# all listed variables are TRUE
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
Expand Down
18 changes: 18 additions & 0 deletions cmake/Modules/FindPNG.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,24 @@ if(ZLIB_FOUND)
# find_package_handle_standard_args() below.
unset(PNG_FOUND)

if(OHOS)
# Active set path
if(${PNG_PNG_INCLUDE_DIR} STREQUAL "PNG_PNG_INCLUDE_DIR-NOTFOUND")
# message("[OHOS_LOG] PNG_PNG_INCLUDE_DIR NOTFOUND")
set(PNG_PNG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/png/include/ohos)
endif()

if(${PNG_LIBRARY} STREQUAL "PNG_LIBRARY-NOTFOUND")
# message("[OHOS_LOG] PNG_LIBRARY NOTFOUND")
set(PNG_LIBRARY
${CMAKE_CURRENT_SOURCE_DIR}/external/png/prebuilt/ohos/libpng.a
)
endif()

# message("[OHOS_LOG] PNG_PNG_INCLUDE_DIR ${PNG_PNG_INCLUDE_DIR}")
# message("[OHOS_LOG] PNG_LIBRARY ${PNG_LIBRARY}")
endif()

if (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR)
# png.h includes zlib.h. Sigh.
set(PNG_INCLUDE_DIRS ${PNG_PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
Expand Down
18 changes: 18 additions & 0 deletions cmake/Modules/FindTIFF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,24 @@ find_library(TIFF_LIBRARY
/opt
)

if(OHOS)
# Active set path
if(${TIFF_INCLUDE_DIR} STREQUAL "TIFF_INCLUDE_DIR-NOTFOUND")
# message("[OHOS_LOG] TIFF_INCLUDE_DIR NOTFOUND")
set(TIFF_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/include/ohos)
endif()

if(${TIFF_LIBRARY} STREQUAL "TIFF_LIBRARY-NOTFOUND")
# message("[OHOS_LOG] TIFF_LIBRARY NOTFOUND")
set(TIFF_LIBRARY
${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/prebuilt/ohos/libtiff.a
)
endif()

# message("[OHOS_LOG] TIFF_INCLUDE_DIR ${TIFF_INCLUDE_DIR}")
# message("[OHOS_LOG] TIFF_LIBRARY ${TIFF_LIBRARY}")
endif()

if(TIFF_INCLUDE_DIR AND EXISTS "${TIFF_INCLUDE_DIR}/tiffvers.h")
file(STRINGS "${TIFF_INCLUDE_DIR}/tiffvers.h" tiff_version_str
REGEX "^#define[\t ]+TIFFLIB_VERSION_STR[\t ]+\"LIBTIFF, Version .*")
Expand Down
18 changes: 18 additions & 0 deletions cmake/Modules/FindWEBSOCKETS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ find_library(WEBSOCKETS_LIBRARY NAMES websockets libwebsockets
/opt
)

if(OHOS)
# Active set path
if(${WEBSOCKETS_INCLUDE_DIR} STREQUAL "WEBSOCKETS_INCLUDE_DIR-NOTFOUND")
# message("[OHOS_LOG] WEBSOCKETS_INCLUDE_DIR NOTFOUND")
set(WEBSOCKETS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/websockets/include/ohos)
endif()

if(${WEBSOCKETS_LIBRARY} STREQUAL "WEBSOCKETS_LIBRARY-NOTFOUND")
# message("[OHOS_LOG] WEBSOCKETS_LIBRARY NOTFOUND")
set(WEBSOCKETS_LIBRARY
${CMAKE_CURRENT_SOURCE_DIR}/external/websockets/prebuilt/ohos/libwebsockets.a
)
endif()

# message("[OHOS_LOG] WEBSOCKETS_INCLUDE_DIR ${WEBSOCKETS_INCLUDE_DIR}")
# message("[OHOS_LOG] WEBSOCKETS_LIBRARY ${WEBSOCKETS_LIBRARY}")
endif()

set(WEBSOCKETS_INCLUDE_DIRS ${WEBSOCKETS_INCLUDE_DIR})
set(WEBSOCKETS_LIBRARIES ${WEBSOCKETS_LIBRARY})

Expand Down
18 changes: 18 additions & 0 deletions cmake/Modules/FindWebP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@ FIND_LIBRARY(WEBP_LIBRARY
/opt
)

if(OHOS)
# Active set path
if(${WEBP_INCLUDE_DIR} STREQUAL "WEBP_INCLUDE_DIR-NOTFOUND")
# message("[Nnnnut] WEBP_INCLUDE_DIR NOTFOUND")
set(WEBP_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/webp/include/ohos)
endif()

if(${WEBP_LIBRARY} STREQUAL "WEBP_LIBRARY-NOTFOUND")
# message("[Nnnnut] WEBP_LIBRARY NOTFOUND")
set(WEBP_LIBRARY
${CMAKE_CURRENT_SOURCE_DIR}/external/webp/prebuilt/ohos/libwebp.a
)
endif()

# message("[Nnnnut] WEBP_INCLUDE_DIR ${WEBP_INCLUDE_DIR}")
# message("[Nnnnut] WEBP_LIBRARY ${WEBP_LIBRARY}")
endif()

set(WEBP_INCLUDE_DIRS "${WEBP_INCLUDE_DIR}")
set(WEBP_LIBRARIES "${WEBP_LIBRARY}")

Expand Down
57 changes: 34 additions & 23 deletions cmake/Modules/SelectModule.cmake
Original file line number Diff line number Diff line change
@@ -1,28 +1,39 @@
macro (SelectModule)
set(USE_WEBP_DEFAULT ON)
if(WINRT OR WP8)
set(USE_WEBP_DEFAULT OFF)
endif()
if (OHOS)
set(USE_WEBP_DEFAULT ON)
set(USE_PREBUILT_LIBS_DEFAULT ON)
set(BUILD_CPP_EMPTY_TEST_DEFAULT OFF)
set(BUILD_CPP_TESTS_DEFAULT ON)
set(BUILD_LUA_LIBS_DEFAULT ON)
set(BUILD_LUA_TESTS_DEFAULT ON)
set(BUILD_JS_LIBS_DEFAULT OFF)
set(BUILD_JS_TESTS_DEFAULT OFF)
else()
set(USE_WEBP_DEFAULT ON)
if(WINRT OR WP8)
set(USE_WEBP_DEFAULT OFF)
endif()

set(USE_PREBUILT_LIBS_DEFAULT ON)
if(MINGW)
set(USE_PREBUILT_LIBS_DEFAULT OFF)
endif()
set(USE_PREBUILT_LIBS_DEFAULT ON)
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)
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)
set(BUILD_JS_LIBS_DEFAULT OFF)
set(BUILD_JS_TESTS_DEFAULT OFF)
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)
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)
set(BUILD_JS_LIBS_DEFAULT OFF)
set(BUILD_JS_TESTS_DEFAULT OFF)
endif()
endif()

option(USE_CHIPMUNK "Use chipmunk for physics library" ON)
Expand All @@ -46,7 +57,7 @@ macro (SelectModule)
option(USE_PREBUILT_LIBS "Use prebuilt libraries in external directory" ${USE_PREBUILT_LIBS_DEFAULT})
option(USE_SOURCES_EXTERNAL "Use sources in external directory (automatically ON when USE_PREBUILT_LIBS is ON)" OFF)

if(USE_PREBUILT_LIBS AND MINGW)
if(USE_PREBUILT_LIBS AND MINGW AND NOT OHOS)
message(FATAL_ERROR "Prebuilt windows libs can't be used with mingw, please use packages.")
return()
endif()
Expand Down
Loading

0 comments on commit 18c2a1e

Please sign in to comment.