Skip to content

Commit

Permalink
oh compile on 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
oahcy committed Sep 6, 2022
1 parent 56f6eb4 commit 0a58f4b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 30 deletions.
20 changes: 6 additions & 14 deletions native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2116,15 +2116,18 @@ cocos_source_files(

######## auto
if(NOT OPENHARMONY)# TODO:May be removed later
cocos_source_files(
NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_network_auto.cpp
cocos/bindings/auto/jsb_network_auto.h
)
endif()# TODO:May be removed later
cocos_source_files(
NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_cocos_auto.cpp
cocos/bindings/auto/jsb_cocos_auto.h
NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_extension_auto.cpp
cocos/bindings/auto/jsb_extension_auto.h
NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_gfx_auto.cpp
cocos/bindings/auto/jsb_gfx_auto.h
NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_network_auto.cpp
cocos/bindings/auto/jsb_network_auto.h
NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_pipeline_auto.cpp
cocos/bindings/auto/jsb_pipeline_auto.h
NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_scene_auto.cpp
Expand All @@ -2138,18 +2141,7 @@ cocos_source_files(
NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_2d_auto.cpp
cocos/bindings/auto/jsb_2d_auto.h
)
elseif(OPENHARMONY)# TODO:May be removed later
cocos_source_files(
NO_WERROR cocos/bindings/auto/jsb_gfx_auto.cpp
cocos/bindings/auto/jsb_gfx_auto.h
NO_WERROR cocos/bindings/auto/jsb_pipeline_auto.cpp
cocos/bindings/auto/jsb_pipeline_auto.h
NO_WERROR cocos/bindings/auto/jsb_scene_auto.cpp
cocos/bindings/auto/jsb_scene_auto.h
NO_WERROR cocos/bindings/auto/jsb_cocos_auto.cpp
cocos/bindings/auto/jsb_cocos_auto.h
)
endif()


if(USE_AUDIO)
cocos_source_files(
Expand Down
13 changes: 11 additions & 2 deletions native/cocos/bindings/jswrapper/napi/ScriptEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,21 @@ bool ScriptEngine::_needCallConstructor() {
return _isneedCallConstructor;
}

bool callFunction(Object *targetObj, const char *funcName, uint32_t argc, Value *args, Value *rval = nullptr) {
bool ScriptEngine::callFunction(Object *targetObj, const char *funcName, uint32_t argc, Value *args, Value *rval) {
return true;
}

void ScriptEngine::handlePromiseExceptions() {
//TODO not impl
return;
}
}; // namespace se

void ScriptEngine::mainLoopUpdate() {
// empty implementation
}

void ScriptEngine::throwException(const std::string &errorMessage) {
napi_status status;
NODE_API_CALL_RETURN_VOID(getEnv(), napi_throw_error(getEnv(), nullptr, errorMessage.c_str()));
}
}; // namespace se
4 changes: 3 additions & 1 deletion native/cocos/engine/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ int32_t Engine::init() {

void Engine::destroy() {
cc::DeferredReleasePool::clear();
#if (CC_PLATFORM != CC_PLATFORM_OPENHARMONY) // TODO(qgh):May be removed later
cc::network::HttpClient::destroyInstance();
#endif
_scheduler->removeAllFunctionsToBePerformedInCocosThread();
_scheduler->unscheduleAll();
CCObject::deferredDestroy();
Expand Down Expand Up @@ -217,7 +219,7 @@ int Engine::restart() {
}

void Engine::close() { // NOLINT

#if CC_USE_AUDIO
cc::AudioEngine::stopAll();
#endif
Expand Down
17 changes: 5 additions & 12 deletions native/cocos/platform/openharmony/FileUtils-OpenHarmony.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <stdio.h>
#include <dirent.h>
#include <unistd.h>
#include "base/memory/Memory.h"

#include "cocos/base/Log.h"

Expand All @@ -47,6 +48,10 @@ namespace cc {

NativeResourceManager* FileUtilsOpenHarmony::_nativeResourceManager = nullptr;

FileUtils *createFileUtils() {
return ccnew FileUtilsOpenHarmony();
}

bool FileUtilsOpenHarmony::initResourceManager(napi_env env, napi_value param) {
_nativeResourceManager = OH_ResourceManager_InitNativeResourceManager(env, param);
return true;
Expand Down Expand Up @@ -124,18 +129,6 @@ FileUtils::Status FileUtilsOpenHarmony::getContents(const std::string &filename,
return FileUtils::Status::OK;
}

FileUtils *FileUtils::getInstance() {
if (FileUtils::sharedFileUtils == nullptr) {
FileUtils::sharedFileUtils = new FileUtilsOpenHarmony();
if (!FileUtils::sharedFileUtils->init()) {
delete FileUtils::sharedFileUtils;
FileUtils::sharedFileUtils = nullptr;
CC_LOG_DEBUG("ERROR: Could not init CCFileUtilsAndroid");
}
}
return FileUtils::sharedFileUtils;
}

FileUtilsOpenHarmony::~FileUtilsOpenHarmony() {
if(_nativeResourceManager)
OH_ResourceManager_ReleaseNativeResourceManager(_nativeResourceManager);
Expand Down
2 changes: 1 addition & 1 deletion templates/cmake/openharmony.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ endmacro()
macro(cc_openharmony_after_target target_name)

target_link_libraries(${target_name}
cocos2d
${ENGINE_NAME}
)
target_include_directories(${target_name} PRIVATE
${CC_PROJECT_DIR}/../common/Classes
Expand Down

0 comments on commit 0a58f4b

Please sign in to comment.