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.12 version OHOS adaptation #20825

Merged
merged 5 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ include(BuildModules)
BuildModules()

# build cpp-empty-test
if(!OHOS)
if(BUILD_CPP_EMPTY_TEST)
add_subdirectory(tests/cpp-empty-test)
endif(BUILD_CPP_EMPTY_TEST)
endif()

# build cpp-tests
if(BUILD_CPP_TESTS)
Expand All @@ -114,12 +116,15 @@ if(BUILD_LUA_LIBS)
# build lua tests
if(BUILD_LUA_TESTS)
add_subdirectory(tests/lua-tests/project)
if(!OHOS)
add_subdirectory(tests/lua-empty-test/project)
endif()
endif(BUILD_LUA_TESTS)

endif(BUILD_LUA_LIBS)

## JS
if(!OHOS)
if(BUILD_JS_LIBS)
add_subdirectory(cocos/scripting/js-bindings)

Expand All @@ -129,3 +134,4 @@ if(BUILD_JS_LIBS)
endif(BUILD_JS_TESTS)

endif(BUILD_JS_LIBS)
endif()
27 changes: 19 additions & 8 deletions cmake/Modules/BuildModules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,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(external/Box2D)
set(Box2D_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/box2d/include)
set(Box2D_LIBRARIES box2d)
Expand All @@ -64,7 +64,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(external/bullet)
set(BULLET_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/bullet)
set(BULLET_LIBRARIES bullet)
Expand All @@ -75,9 +75,20 @@ 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)
if(USE_PREBUILT_LIBS OR USE_SOURCES_EXTERNAL OR OHOS)
add_subdirectory(external/recast)
set(RECAST_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/recast)
set(RECAST_LIBRARIES recast)
Expand All @@ -89,7 +100,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(external/tinyxml2)
set(TinyXML2_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/tinyxml2)
set(TinyXML2_LIBRARIES tinyxml2)
Expand All @@ -107,7 +118,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(external/unzip)
Expand All @@ -131,7 +142,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(external/flatbuffers)
set(FLATBUFFERS_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external)
message(STATUS "Flatbuffers include dirs: ${FLATBUFFERS_INCLUDE_DIRS}")
Expand All @@ -140,7 +151,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(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 "HarmonyOS Next")
endif()

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
Expand Down
13 changes: 13 additions & 0 deletions cmake/Modules/FindCURL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ 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")
set(CURL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/curl/include/ohos)
endif()

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

mark_as_advanced(CURL_LIBRARY)

if(CURL_INCLUDE_DIR)
Expand Down
13 changes: 13 additions & 0 deletions cmake/Modules/FindChipmunk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ 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")
set(CHIPMUNK_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/chipmunk/include)
endif()

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

IF(CHIPMUNK_LIBRARY)
# include the math library for Unix
IF(UNIX AND NOT APPLE)
Expand Down
17 changes: 17 additions & 0 deletions cmake/Modules/FindFreetype.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,23 @@ 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")
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")
set(FREETYPE_INCLUDE_DIR_freetype2 ${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/include/ohos/freetype2)
endif()

if(${FREETYPE_LIBRARY} STREQUAL "FREETYPE_LIBRARY-NOTFOUND")
set(FREETYPE_LIBRARY
${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/prebuilt/ohos/libfreetype.a
)
endif()
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
12 changes: 12 additions & 0 deletions cmake/Modules/FindJPEG.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ 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")
set(JPEG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/include/ohos)
endif()
if(${JPEG_LIBRARY} STREQUAL "JPEG_LIBRARY-NOTFOUND")
set(JPEG_LIBRARY
${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/prebuilt/ohos/libjpeg.a
)
endif()
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
13 changes: 13 additions & 0 deletions cmake/Modules/FindPNG.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ 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")
set(PNG_PNG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/png/include/ohos)
endif()

if(${PNG_LIBRARY} STREQUAL "PNG_LIBRARY-NOTFOUND")
set(PNG_LIBRARY
${CMAKE_CURRENT_SOURCE_DIR}/external/png/prebuilt/ohos/libpng.a
)
endif()
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
13 changes: 13 additions & 0 deletions cmake/Modules/FindTIFF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ find_library(TIFF_LIBRARY
/opt
)

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

if(${TIFF_LIBRARY} STREQUAL "TIFF_LIBRARY-NOTFOUND")
set(TIFF_LIBRARY
${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/prebuilt/ohos/libtiff.a
)
endif()
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
13 changes: 13 additions & 0 deletions cmake/Modules/FindWEBSOCKETS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ find_library(WEBSOCKETS_LIBRARY NAMES websockets libwebsockets
/opt
)

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

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

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

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

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

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

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

Expand Down
19 changes: 18 additions & 1 deletion cmake/Modules/SetCompilerOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,23 @@ macro (SetCompilerOptions)
set(PLATFORM_FOLDER android)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsigned-char -latomic")
elseif(OHOS)
add_compile_options(-DUSE_FILE32API
-Wno-absolute-value
-Wno-extra
-Wno-implicit-int-float-conversion
-Wno-overloaded-virtual
-Wno-unused-function
-Wno-unused-private-field
-Wno-unused-parameter
-Wno-reorder-ctor
-Wno-unsequenced
-Wno-extra
-Wno-c++11-narrowing
-Wno-expansion-to-defined
-Wno-unused-command-line-argument
)
set(PLATFORM_FOLDER ohos)
else()
message( FATAL_ERROR "Unsupported platform, CMake will exit" )
return()
Expand All @@ -97,7 +114,7 @@ macro (SetCompilerOptions)
endif()
endif()

if (MINGW AND NOT USE_PREBUILT_LIBS)
if (MINGW AND NOT USE_PREBUILT_LIBS AND NOT OHOS)
add_definitions(-DMINIZIP_FROM_SYSTEM)
endif()

Expand Down
Loading