Skip to content

Commit 45f4929

Browse files
IceBBBBBwanghui187
andauthored
v4 supports ohos (#20808)
Signed-off-by: 冰冰冰 <[email protected]> --------- Signed-off-by: 冰冰冰 <[email protected]> Signed-off-by: @wanghui187 <[email protected]> Co-authored-by: @wanghui187 <[email protected]>
1 parent 7a5282a commit 45f4929

File tree

304 files changed

+25518
-151
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

304 files changed

+25518
-151
lines changed

.appveyor.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ environment:
88
PYTHON_VERSION: "2.7.13"
99
PYTHON_ARCH: "32"
1010
matrix:
11-
- build_type: windows32_cmake_test
12-
- build_type: android_cpp_tests
13-
- build_type: android_lua_tests
11+
# - build_type: windows32_cmake_test
12+
# - build_type: android_cpp_tests
13+
# - build_type: android_lua_tests
1414
# - build_type: android_cocos_new_test
1515
# - build_type: android_cpp_empty_test
1616
# - build_type: android_gen_libs

.github/workflows/main.yml

+76-76
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@ on:
1212
workflow_dispatch:
1313

1414
jobs:
15-
ubuntu-18_04:
16-
runs-on: ubuntu-18.04
17-
steps:
18-
- uses: actions/checkout@v2
19-
with:
20-
submodules: recursive
21-
- run: python download-deps.py --r no
22-
- run: echo -e "y" | bash install-deps-linux.sh
23-
- run: cmake -B b -S .
24-
- run: cmake --build b
15+
# ubuntu-18_04:
16+
# runs-on: ubuntu-18.04
17+
# steps:
18+
# - uses: actions/checkout@v2
19+
# with:
20+
# submodules: recursive
21+
# - run: python download-deps.py --r no
22+
# - run: echo -e "y" | bash install-deps-linux.sh
23+
# - run: cmake -B b -S .
24+
# - run: cmake --build b
2525

26-
ubuntu-20_04:
27-
runs-on: ubuntu-20.04
28-
steps:
29-
- uses: actions/checkout@v2
30-
with:
31-
submodules: recursive
32-
- run: python download-deps.py --r no
33-
- run: echo -e "y" | bash install-deps-linux.sh
34-
- run: cmake -B b -S .
35-
- run: cmake --build b
26+
# ubuntu-20_04:
27+
# runs-on: ubuntu-20.04
28+
# steps:
29+
# - uses: actions/checkout@v2
30+
# with:
31+
# submodules: recursive
32+
# - run: python download-deps.py --r no
33+
# - run: echo -e "y" | bash install-deps-linux.sh
34+
# - run: cmake -B b -S .
35+
# - run: cmake --build b
3636

3737
windows-2019:
3838
runs-on: windows-2019
@@ -54,64 +54,64 @@ jobs:
5454
- run: cmake -B b -S . -G "Visual Studio 17 2022" -A Win32
5555
- run: cmake --build b
5656

57-
macos-10_15:
58-
runs-on: macos-10.15
59-
steps:
60-
- uses: actions/checkout@v2
61-
with:
62-
submodules: recursive
63-
- run: python download-deps.py --r no
64-
- run: cmake -B b -S . -GXcode
65-
- run: cmake --build b
57+
# macos-10_15:
58+
# runs-on: macos-10.15
59+
# steps:
60+
# - uses: actions/checkout@v2
61+
# with:
62+
# submodules: recursive
63+
# - run: python download-deps.py --r no
64+
# - run: cmake -B b -S . -GXcode
65+
# - run: cmake --build b
6666

67-
macos-11:
68-
runs-on: macos-11
69-
steps:
70-
- uses: actions/checkout@v2
71-
with:
72-
submodules: recursive
73-
- run: python download-deps.py --r no
74-
- run: cmake -B b -S . -GXcode
75-
- run: cmake --build b
67+
# macos-11:
68+
# runs-on: macos-11
69+
# steps:
70+
# - uses: actions/checkout@v2
71+
# with:
72+
# submodules: recursive
73+
# - run: python download-deps.py --r no
74+
# - run: cmake -B b -S . -GXcode
75+
# - run: cmake --build b
7676

77-
macos-10_15_ios:
78-
runs-on: macos-10.15
79-
steps:
80-
- uses: actions/checkout@v2
81-
with:
82-
submodules: recursive
83-
- run: python download-deps.py --r no
84-
- run: cmake -B b -S . -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator
85-
- run: cmake --build b --config Release --target cpp-tests -- -quiet
77+
# macos-10_15_ios:
78+
# runs-on: macos-10.15
79+
# steps:
80+
# - uses: actions/checkout@v2
81+
# with:
82+
# submodules: recursive
83+
# - run: python download-deps.py --r no
84+
# - run: cmake -B b -S . -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator
85+
# - run: cmake --build b --config Release --target cpp-tests -- -quiet
8686

87-
macos-11_ios:
88-
runs-on: macos-11
89-
steps:
90-
- uses: actions/checkout@v2
91-
with:
92-
submodules: recursive
93-
- run: python download-deps.py --r no
94-
- run: cmake -B b -S . -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator
95-
- run: cmake --build b --config Release --target cpp-tests -- -quiet -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)"
87+
# macos-11_ios:
88+
# runs-on: macos-11
89+
# steps:
90+
# - uses: actions/checkout@v2
91+
# with:
92+
# submodules: recursive
93+
# - run: python download-deps.py --r no
94+
# - run: cmake -B b -S . -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator
95+
# - run: cmake --build b --config Release --target cpp-tests -- -quiet -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)"
9696

97-
windows-2019-android:
98-
runs-on: windows-2019
99-
steps:
100-
- uses: actions/checkout@v2
101-
with:
102-
submodules: recursive
103-
- run: python download-deps.py --r no
104-
- run: ./gradlew assembleRelease -PPROP_BUILD_TYPE=cmake --info
105-
shell: bash
106-
working-directory: tests/cpp-tests/proj.android
97+
# windows-2019-android:
98+
# runs-on: windows-2019
99+
# steps:
100+
# - uses: actions/checkout@v2
101+
# with:
102+
# submodules: recursive
103+
# - run: python download-deps.py --r no
104+
# - run: ./gradlew assembleRelease -PPROP_BUILD_TYPE=cmake --info
105+
# shell: bash
106+
# working-directory: tests/cpp-tests/proj.android
107107

108-
ubuntu-20_04-android:
109-
runs-on: ubuntu-20.04
110-
steps:
111-
- uses: actions/checkout@v2
112-
with:
113-
submodules: recursive
114-
- run: python download-deps.py --r no
115-
- run: ./gradlew assembleRelease -PPROP_BUILD_TYPE=cmake --info
116-
shell: bash
117-
working-directory: tests/cpp-tests/proj.android
108+
# ubuntu-20_04-android:
109+
# runs-on: ubuntu-20.04
110+
# steps:
111+
# - uses: actions/checkout@v2
112+
# with:
113+
# submodules: recursive
114+
# - run: python download-deps.py --r no
115+
# - run: ./gradlew assembleRelease -PPROP_BUILD_TYPE=cmake --info
116+
# shell: bash
117+
# working-directory: tests/cpp-tests/proj.android

.gitmodules

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[submodule "tools/cocos2d-console"]
22
path = tools/cocos2d-console
3-
url = git://github.com/cocos2d/cocos2d-console.git
3+
url = https://github.com/cocos2d/cocos2d-console.git
44
[submodule "tools/bindings-generator"]
55
path = tools/bindings-generator
6-
url = git://github.com/cocos2d/bindings-generator.git
6+
url = https://github.com/cocos2d/bindings-generator.git
77
[submodule "tests/cpp-tests/Resources/ccs-res"]
88
path = tests/cpp-tests/Resources/ccs-res
9-
url = git://github.com/dumganhar/ccs-res.git
9+
url = https://github.com/dumganhar/ccs-res.git

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ matrix:
2929
language: android
3030
sudo: required
3131
dist: xenial
32-
# android_lua cmake
32+
android_lua cmake
3333
- os: linux
3434
env: BUILD_TARGET=android_lua_cmake
3535
language: android

cmake/Modules/CocosConfigDefine.cmake

+10
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ endif()
1010
#IOS = iOS
1111
#MACOSX = MacOS X
1212
#LINUX = Linux
13+
#OHOS = OHOS
1314
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
1415
set(WINDOWS TRUE)
1516
set(PLATFORM_FOLDER win32)
1617
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android")
1718
set(PLATFORM_FOLDER android)
19+
elseif(CMAKE_SYSTEM_NAME MATCHES "OHOS")
20+
set(PLATFORM_FOLDER ohos)
1821
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
1922
if(ANDROID)
2023
set(PLATFORM_FOLDER android)
@@ -60,7 +63,11 @@ define_property(TARGET
6063
# check c++ standard
6164
set(CMAKE_C_STANDARD 99)
6265
set(CMAKE_C_STANDARD_REQUIRED ON)
66+
if(OHOS)
67+
set(CMAKE_CXX_STANDARD 14)
68+
else()
6369
set(CMAKE_CXX_STANDARD 11)
70+
endif()
6471
set(CMAKE_CXX_STANDARD_REQUIRED ON)
6572
set(CMAKE_CXX_EXTENSIONS OFF)
6673

@@ -92,6 +99,9 @@ endif()
9299
elseif(ANDROID)
93100
target_compile_definitions(${target} PUBLIC ANDROID)
94101
target_compile_definitions(${target} PUBLIC USE_FILE32API)
102+
elseif(OHOS)
103+
target_compile_definitions(${target} PUBLIC OHOS)
104+
target_compile_definitions(${target} PUBLIC USE_FILE32API)
95105
elseif(WINDOWS)
96106
target_compile_definitions(${target}
97107
PUBLIC WIN32

cmake/Modules/CocosConfigDepend.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ macro(cocos2dx_depend)
2121
set(THREADS_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
2222
elseif(ANDROID)
2323
list(APPEND PLATFORM_SPECIFIC_LIBS GLESv2 EGL log android OpenSLES)
24+
elseif(OHOS)
25+
list(APPEND PLATFORM_SPECIFIC_LIBS native_drawing EGL GLESv3 hilog_ndk.z ace_ndk.z ace_napi.z uv rawfile.z OpenSLES)
2426
elseif(APPLE)
2527

2628
include_directories(/System/Library/Frameworks)

cocos/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ use_cocos2dx_compile_define(cocos2d)
118118
use_cocos2dx_compile_options(cocos2d)
119119

120120
# use all platform related system libs
121+
if (OHOS)
122+
123+
target_link_libraries(cocos2d ${Drawing-lib} ${libace-lib} ${GLES-lib} ${libnapi-lib} ${libuv-lib} ${rawfile-lib} ${EGL-lib} ${hilog-lib} libohaudio.so libavplayer.so libnative_window.so libnative_buffer.so)
124+
endif()
121125
use_cocos2dx_libs_depend(cocos2d)
122126

123127
target_include_directories(cocos2d

cocos/audio/AudioEngine.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
#include "audio/win32/AudioEngine-win32.h"
4040
#elif CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
4141
#include "audio/linux/AudioEngine-linux.h"
42+
#elif CC_TARGET_PLATFORM == CC_PLATFORM_OHOS
43+
#include "audio/ohos/AudioEngine-inl.h"
4244
#endif
4345

4446
#define TIME_DELAY_PRECISION 0.0001

cocos/audio/CMakeLists.txt

+72
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,78 @@ elseif(ANDROID)
105105
audio/android/tinysndfile.cpp
106106
)
107107

108+
elseif(OHOS)
109+
set(COCOS_AUDIO_PLATFORM_HEADER
110+
audio/ohos/PcmAudioService.h
111+
audio/ohos/AudioBufferProvider.h
112+
audio/ohos/IAudioPlayer.h
113+
audio/ohos/AudioResampler.h
114+
audio/ohos/AudioDecoder.h
115+
audio/ohos/AudioResamplerPublic.h
116+
audio/ohos/AudioMixer.h
117+
audio/ohos/tinysndfile.h
118+
audio/ohos/mp3reader.h
119+
audio/ohos/AudioMixerOps.h
120+
audio/ohos/cutils/bitops.h
121+
audio/ohos/cutils/log.h
122+
audio/ohos/audio.h
123+
audio/ohos/AudioPlayerProvider.h
124+
audio/ohos/utils/Utils.h
125+
audio/ohos/utils/Errors.h
126+
audio/ohos/utils/Compat.h
127+
audio/ohos/AudioDecoderOgg.h
128+
audio/ohos/Track.h
129+
audio/ohos/OpenSLHelper.h
130+
audio/ohos/PcmAudioPlayer.h
131+
audio/ohos/AssetFd.h
132+
audio/ohos/PcmBufferProvider.h
133+
audio/ohos/CCThreadPool.h
134+
audio/ohos/audio_utils/include/audio_utils/minifloat.h
135+
audio/ohos/audio_utils/include/audio_utils/primitives.h
136+
audio/ohos/audio_utils/AudioDef.h
137+
audio/ohos/audio_utils/RefCounted.h
138+
audio/ohos/ICallerThreadUtils.h
139+
audio/ohos/AudioDecoderWav.h
140+
audio/ohos/AudioDecoderProvider.h
141+
audio/ohos/UrlAudioPlayer.h
142+
audio/ohos/AudioDecoderSLES.h
143+
audio/ohos/AudioDecoderMp3.h
144+
audio/ohos/PcmData.h
145+
audio/ohos/AudioMixerController.h
146+
audio/ohos/AudioResamplerCubic.h
147+
audio/ohos/AudioEngine-inl.h
148+
audio/ohos/IVolumeProvider.h
149+
audio/ohos/Macros.h
150+
)
151+
152+
set(COCOS_AUDIO_PLATFORM_SRC
153+
audio/ohos/AudioEngine-inl.cpp
154+
audio/ohos/CCThreadPool.cpp
155+
audio/ohos/AssetFd.cpp
156+
audio/ohos/AudioDecoder.cpp
157+
audio/ohos/AudioDecoderProvider.cpp
158+
audio/ohos/AudioDecoderSLES.cpp
159+
audio/ohos/AudioDecoderOgg.cpp
160+
audio/ohos/AudioDecoderMp3.cpp
161+
audio/ohos/AudioDecoderWav.cpp
162+
audio/ohos/AudioPlayerProvider.cpp
163+
audio/ohos/AudioResampler.cpp
164+
audio/ohos/AudioResamplerCubic.cpp
165+
audio/ohos/PcmBufferProvider.cpp
166+
audio/ohos/PcmAudioPlayer.cpp
167+
audio/ohos/PcmData.cpp
168+
audio/ohos/PcmAudioService.cpp
169+
audio/ohos/UrlAudioPlayer.cpp
170+
audio/ohos/AudioMixerController.cpp
171+
audio/ohos/AudioMixer.cpp
172+
audio/ohos/mp3reader.cpp
173+
audio/ohos/tinysndfile.cpp
174+
audio/ohos/Track.cpp
175+
audio/ohos/audio_utils/RefCounted.cpp
176+
audio/ohos/audio_utils/minifloat.cpp
177+
audio/ohos/audio_utils/primitives.cpp
178+
audio/ohos/utils/Utils.cpp
179+
)
108180
elseif(LINUX)
109181
set(COCOS_AUDIO_PLATFORM_HEADER
110182
audio/linux/AudioEngine-linux.h

cocos/audio/ohos/AssetFd.cpp

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/****************************************************************************
2+
Copyright (c) 2016 Chukong Technologies Inc.
3+
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
4+
5+
http://www.cocos2d-x.org
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in
15+
all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
THE SOFTWARE.
24+
****************************************************************************/
25+
26+
#define LOG_TAG "AssetFd"
27+
28+
#include "cutils/log.h"
29+
#include "AssetFd.h"
30+
31+
namespace cocos2d {
32+
33+
AssetFd::AssetFd(int assetFd)
34+
: _assetFd(assetFd) {
35+
}
36+
37+
AssetFd::~AssetFd() {
38+
ALOGV("~AssetFd: %d", _assetFd);
39+
if (_assetFd > 0) {
40+
::close(_assetFd);
41+
_assetFd = 0;
42+
}
43+
};
44+
45+
} // namespace CocosDenshion

0 commit comments

Comments
 (0)