Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.13 version OHOS adaptation #20831

Merged
merged 4 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ if (CMAKE_FIND_ROOT_PATH AND USE_PREBUILT_LIBS)
set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${COCOS_EXTERNAL_DIR})
endif ()

if(OHOS)
set(CMAKE_FIND_ROOT_PATH ${COCOS_EXTERNAL_DIR})
endif()

include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/cocos
Expand Down Expand Up @@ -113,8 +117,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
27 changes: 19 additions & 8 deletions cmake/Modules/BuildModules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ macro (BuildModules)
endif()
endif(LINUX OR MACOSX OR WINDOWS)

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)

# Freetype required on all platforms
cocos_find_package(Freetype FREETYPE REQUIRED)

Expand All @@ -42,14 +53,14 @@ macro (BuildModules)

# Chipmunk
if(USE_CHIPMUNK)
if(USE_PREBUILT_LIBS)
if(USE_PREBUILT_LIBS OR OHOS)
cocos_find_package(Chipmunk CHIPMUNK REQUIRED)
endif()
endif(USE_CHIPMUNK)

# Box2d (not prebuilded, exists as source)
if(USE_BOX2D)
if(USE_PREBUILT_LIBS OR USE_SOURCES_EXTERNAL)
if(USE_PREBUILT_LIBS OR USE_SOURCES_EXTERNAL OR OHOS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/Box2D)
set(Box2D_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/box2d/include)
set(Box2D_LIBRARIES box2d)
Expand All @@ -65,7 +76,7 @@ macro (BuildModules)

# Bullet (not prebuilded, exists as source)
if(USE_BULLET)
if(USE_PREBUILT_LIBS OR USE_SOURCES_EXTERNAL)
if(USE_PREBUILT_LIBS OR USE_SOURCES_EXTERNAL OR OHOS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/bullet)
set(BULLET_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/bullet)
set(BULLET_LIBRARIES bullet)
Expand All @@ -78,7 +89,7 @@ macro (BuildModules)

# Recast (not prebuilded, exists as source)
if(USE_RECAST)
if(USE_PREBUILT_LIBS OR USE_SOURCES_EXTERNAL)
if(USE_PREBUILT_LIBS OR USE_SOURCES_EXTERNAL OR OHOS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/recast)
set(RECAST_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/recast)
set(RECAST_LIBRARIES recast)
Expand All @@ -90,7 +101,7 @@ macro (BuildModules)
endif(USE_RECAST)

# Tinyxml2 (not prebuilded, exists as source)
if(USE_PREBUILT_LIBS OR USE_SOURCES_EXTERNAL)
if(USE_PREBUILT_LIBS OR USE_SOURCES_EXTERNAL OR OHOS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/tinyxml2)
set(TinyXML2_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/tinyxml2)
set(TinyXML2_LIBRARIES tinyxml2)
Expand All @@ -108,7 +119,7 @@ macro (BuildModules)
# dists have packages from zlib, thats very old for us.
# moreover our embedded version modified to quick provide
# functionality needed by cocos.
if(USE_PREBUILT_LIBS OR NOT MINGW)
if(USE_PREBUILT_LIBS OR NOT MINGW OR OHOS)
#TODO: hack! should be in external/unzip/CMakeLists.txt
include_directories(${ZLIB_INCLUDE_DIRS})
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/unzip)
Expand All @@ -132,7 +143,7 @@ macro (BuildModules)
cocos_find_package(CURL CURL REQUIRED)

# flatbuffers
if(USE_PREBUILT_LIBS OR USE_SOURCES_EXTERNAL)
if(USE_PREBUILT_LIBS OR USE_SOURCES_EXTERNAL OR OHOS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/flatbuffers)
set(FLATBUFFERS_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external)
message(STATUS "Flatbuffers include dirs: ${FLATBUFFERS_INCLUDE_DIRS}")
Expand All @@ -141,7 +152,7 @@ macro (BuildModules)
endif()

# xxhash
if(USE_PREBUILT_LIBS OR USE_SOURCES_EXTERNAL)
if(USE_PREBUILT_LIBS OR USE_SOURCES_EXTERNAL OR OHOS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/xxhash)
set(XXHASH_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/xxhash)
set(XXHASH_LIBRARIES xxhash)
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 "OHOS")
minggo marked this conversation as resolved.
Show resolved Hide resolved
endif()

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
Expand Down
17 changes: 17 additions & 0 deletions cmake/Modules/FindCURL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ if(NOT CURL_FOUND)
# Windows older "Win32 - MSVC" prebuilts (libcurl.lib, e.g. libcurl-7.15.5-win32-msvc.zip):
libcurl
)
if(OHOS)
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)
# 主动set路径
minggo marked this conversation as resolved.
Show resolved Hide resolved
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
23 changes: 23 additions & 0 deletions cmake/Modules/FindFreetype.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,29 @@ find_library(FREETYPE_LIBRARY
[HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]
)

if(OHOS)
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
16 changes: 16 additions & 0 deletions cmake/Modules/FindJPEG.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ find_path(JPEG_INCLUDE_DIR jpeglib.h)
set(JPEG_NAMES ${JPEG_NAMES} jpeg)
find_library(JPEG_LIBRARY NAMES ${JPEG_NAMES} )

if(OHOS)
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
17 changes: 17 additions & 0 deletions cmake/Modules/FindPNG.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,23 @@ if(ZLIB_FOUND)
# find_package_handle_standard_args() below.
unset(PNG_FOUND)

if(OHOS)
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
17 changes: 17 additions & 0 deletions cmake/Modules/FindTIFF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@ find_library(TIFF_LIBRARY
/opt
)

if(OHOS)
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
17 changes: 17 additions & 0 deletions cmake/Modules/FindWEBSOCKETS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ find_library(WEBSOCKETS_LIBRARY NAMES websockets libwebsockets
/opt
)

if(OHOS)
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
17 changes: 17 additions & 0 deletions cmake/Modules/FindWebP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ FIND_LIBRARY(WEBP_LIBRARY
/opt
)

if(OHOS)
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
10 changes: 10 additions & 0 deletions cmake/Modules/SelectModule.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ macro (SelectModule)
set(BUILD_JS_TESTS_DEFAULT OFF)
endif()

# OHOS single test switch
if(OHOS)
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)
endif()

option(USE_CHIPMUNK "Use chipmunk for physics library" ON)
option(USE_BOX2D "Use box2d for physics library" OFF)
option(USE_BULLET "Use bullet for physics3d library" ON)
Expand Down
Loading