From 72ec8be7cb82192bf016b4f2219c1db470638d6e Mon Sep 17 00:00:00 2001 From: PP Date: Thu, 5 Nov 2020 09:46:21 +0800 Subject: [PATCH] update gen-simulator workflow (#2971) --- .../cocos/renderer/gfx-vulkan/VKContext.cpp | 9 +- native/gulpfile.js | 93 ++++++++++++------- native/package.json | 7 +- .../runtime-src/proj.win32/SimulatorWin.cpp | 44 +++++---- .../runtime-src/proj.win32/SimulatorWin.h | 2 +- .../lib/ProjectConfig/ProjectConfig.h | 2 +- .../win32/PlayerEditBoxServiceWin.cpp | 8 +- .../platform/win32/PlayerEditBoxServiceWin.h | 4 +- .../win32/PlayerFileDialogServiceWin.cpp | 26 +++--- .../platform/win32/PlayerMenuServiceWin.cpp | 34 +++---- .../lib/platform/win32/PlayerMenuServiceWin.h | 2 +- .../win32/PlayerMessageBoxServiceWin.cpp | 8 +- .../platform/win32/PlayerTaskServiceWin.cpp | 20 ++-- .../lib/platform/win32/PlayerTaskServiceWin.h | 2 +- .../lib/platform/win32/PlayerWin.cpp | 2 +- .../lib/platform/win32/PlayerWin.h | 2 +- .../google/protobuf/extension_set.cc | 5 + .../libsimulator/lib/runtime/ConfigParser.cpp | 6 +- .../libsimulator/lib/runtime/FileServer.cpp | 4 +- .../libsimulator/lib/runtime/Runtime.cpp | 4 +- .../libsimulator/lib/runtime/VisibleRect.cpp | 2 +- 21 files changed, 165 insertions(+), 121 deletions(-) diff --git a/native/cocos/renderer/gfx-vulkan/VKContext.cpp b/native/cocos/renderer/gfx-vulkan/VKContext.cpp index dd0a4e9382..314d15a7f4 100644 --- a/native/cocos/renderer/gfx-vulkan/VKContext.cpp +++ b/native/cocos/renderer/gfx-vulkan/VKContext.cpp @@ -63,6 +63,11 @@ VKAPI_ATTR VkBool32 VKAPI_CALL debugReportCallback(VkDebugReportFlagsEXT flags, return VK_FALSE; } + // We already handled this + if (strstr(message, "setupLoaderTermPhysDevs") || strstr(message, "setupLoaderTrampPhysDevs")) { + return VK_FALSE; + } + if (flags & VK_DEBUG_REPORT_ERROR_BIT_EXT) { CC_LOG_ERROR("VError: %s: %s", layerPrefix, message); CCASSERT(ALLOW_VALIDATION_ERRORS, "Validation Error"); @@ -295,9 +300,9 @@ bool CCVKContext::initialize(const ContextInfo &info) { // Querying valid physical devices on the machine uint physicalDeviceCount{0}; - VK_CHECK(vkEnumeratePhysicalDevices(_gpuContext->vkInstance, &physicalDeviceCount, nullptr)); + res = vkEnumeratePhysicalDevices(_gpuContext->vkInstance, &physicalDeviceCount, nullptr); - if (physicalDeviceCount < 1) { + if (res || physicalDeviceCount < 1) { return false; } diff --git a/native/gulpfile.js b/native/gulpfile.js index 8fcb98da04..549b7d7f01 100644 --- a/native/gulpfile.js +++ b/native/gulpfile.js @@ -33,6 +33,11 @@ var ExecSync = require('child_process').execSync; var spawn = require('child_process').spawn; var Path = require('path'); var fs = require('fs-extra'); +const which = require('which'); + +function absolutePath (relativePath) { + return Path.join(__dirname, relativePath); +} var program = require('commander'); program @@ -143,40 +148,66 @@ gulp.task('gen-cocos2d-x', function(cb) { cb(); }); -gulp.task('gen-simulator', function(cb) { - var cocosConsoleRoot = './tools/cocos2d-console/bin'; - var cocosConsoleBin = Path.join(cocosConsoleRoot, process.platform === 'win32' ? 'cocos.bat' : 'cocos'); - var args; - if (process.platform === 'darwin') { - args = ['gen-simulator', '-m', 'debug', '-p', 'mac']; - } else { - args = ['gen-simulator', '-c', '-m', 'debug', '-p', 'win32', '--vs', '2017', '--ol', 'en']; - } - try { - var child = spawn(cocosConsoleBin, args); - child.stdout.on('data', function(data) { - console.log(data.toString()); - }); - child.stderr.on('data', function(data) { - console.error(data.toString()); - }); - child.on('close', (code) => { - if (code !== 0) { - cb('Generate simulator failed'); - return; +gulp.task('gen-simulator', async function () { + // get the cmake path + let cmakeBin = await new Promise((resolve, reject) => { + which('cmake', (err, resolvedPath) => { + if (err) { + console.log('failed to resolve path for cmake, maybe you need to install cmake in the global environment\n'); + return reject(err); } - if (process.platform === 'darwin') { - //reset project file to hide code sign information. - execSync('git checkout -- ./tools/simulator/frameworks/runtime-src/proj.ios_mac/simulator.xcodeproj'); - } - cb(); + resolve(resolvedPath); }); - child.on('error', function() { - cb('Generate simulator failed'); + }); + let simulatorProject = absolutePath('./simulator'); + await fs.ensureDir(simulatorProject); + + console.log('=====================================\n'); + console.log('make project\n'); + console.log('=====================================\n'); + await new Promise((resolve, reject) => { + let cmakeProcess = spawn(cmakeBin, ['-G', process.platform === 'win32'? 'Visual Studio 15 2017': 'Xcode', absolutePath('./tools/simulator/frameworks/runtime-src/')], { + cwd: simulatorProject, }); - } catch (err) { - cb(err); - } + cmakeProcess.on('close', () => { + console.log('cmake finished!'); + resolve(); + }); + cmakeProcess.on('error', err => { + console.error(err); + }); + cmakeProcess.stderr.on('data', err => { + console.error(err.toString ? err.toString() : err); + }); + cmakeProcess.stdout.on('data', data => { + console.log(data.toString ? data.toString() : data); + }); + }); + + + console.log('=====================================\n'); + console.log('build project\n'); + console.log('=====================================\n'); + await new Promise((resolve, reject) => { + let buildProcess = spawn(cmakeBin, ['--build', simulatorProject], { + cwd: simulatorProject, + }); + buildProcess.on('close', () => { + console.log('cmake finished!'); + resolve(); + }); + buildProcess.on('error', err => { + console.error(err); + }); + buildProcess.stderr.on('data', err => { + console.error(err.toString ? err.toString() : err); + }); + buildProcess.stdout.on('data', data => { + console.log(data.toString ? data.toString() : data); + }); + }); + + console.log('done!'); }); gulp.task('sign-simulator', function () { diff --git a/native/package.json b/native/package.json index bd6de0208b..7e37d72d4d 100644 --- a/native/package.json +++ b/native/package.json @@ -4,6 +4,7 @@ "description": "Native implementation of creator 3d.", "main": "gulpfile.js", "devDependencies": { + "gulp": "^4.0.2", "@types/fs-extra": "^9.0.1", "async": "^2.6.1", "chalk": "^2.4.1", @@ -11,7 +12,11 @@ "ftp": "0.3.10", "tmp": "^0.2.1", "tree-kill": "^1.2.0", - "yargs": "^15.3.1" + "yargs": "^15.3.1", + "commander": "^6.2.0", + "gulp-sequence": "^1.0.0", + "gulp-zip": "^5.0.2", + "which": "^2.0.2" }, "repository": { "type": "git", diff --git a/native/tools/simulator/frameworks/runtime-src/proj.win32/SimulatorWin.cpp b/native/tools/simulator/frameworks/runtime-src/proj.win32/SimulatorWin.cpp index 2b104b2501..2d9a03daa4 100755 --- a/native/tools/simulator/frameworks/runtime-src/proj.win32/SimulatorWin.cpp +++ b/native/tools/simulator/frameworks/runtime-src/proj.win32/SimulatorWin.cpp @@ -53,18 +53,17 @@ #include "runtime/ConfigParser.h" #include "runtime/Runtime.h" -#include "platform/CCApplication.h" +#include "platform/Application.h" #include "platform/win32/PlayerWin.h" #include "platform/win32/PlayerMenuServiceWin.h" -#include "platform/CCStdC.h" -#include "scripting/js-bindings/jswrapper/SeApi.h" - +#include "platform/StdC.h" +#include "cocos/bindings/jswrapper/SeApi.h" #include "resource.h" namespace { - std::weak_ptr gView; + std::weak_ptr gView; /** @brief This function changes the PVRFrame show/hide setting in register. @param bEnable If true show the PVRFrame window, otherwise hide. @@ -123,12 +122,12 @@ namespace } //exported function -std::shared_ptr cc_get_application_view() { +std::shared_ptr cc_get_application_view() { return gView.lock(); } -USING_NS_CC; +using namespace cc; static WNDPROC g_oldWindowProc = NULL; INT_PTR CALLBACK AboutDialogCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) @@ -244,7 +243,7 @@ void SimulatorWin::quit() void SimulatorWin::relaunch() { - _project.setWindowOffset(Vec2(getPositionX(), getPositionY())); + _project.setWindowOffset(cc::Vec2(getPositionX(), getPositionY())); openProjectWithProjectConfig(_project); } @@ -264,7 +263,7 @@ void SimulatorWin::openNewPlayerWithProjectConfig(const ProjectConfig &config) commandLine.append(" "); commandLine.append(config.makeCommandLine()); - CCLOG("SimulatorWin::openNewPlayerWithProjectConfig(): %s", commandLine.c_str()); + CC_LOG_DEBUG("SimulatorWin::openNewPlayerWithProjectConfig(): %s", commandLine.c_str()); // http://msdn.microsoft.com/en-us/library/windows/desktop/ms682499(v=vs.85).aspx SECURITY_ATTRIBUTES sa = {0}; @@ -293,7 +292,7 @@ void SimulatorWin::openNewPlayerWithProjectConfig(const ProjectConfig &config) if (!success) { - CCLOG("PlayerTaskWin::run() - create process failed, for execute %s", commandLine.c_str()); + CC_LOG_DEBUG("PlayerTaskWin::run() - create process failed, for execute %s", commandLine.c_str()); } } @@ -327,7 +326,7 @@ int SimulatorWin::run() parseCocosProjectConfig(_project); // load project config from command line args - vector args; + std::vector args; for (int i = 0; i < __argc; ++i) { wstring ws(__wargv[i]); @@ -377,7 +376,7 @@ int SimulatorWin::run() _writeDebugLogFile = fopen(debugLogFilePath.c_str(), "w"); if (!_writeDebugLogFile) { - CCLOG("Cannot create debug log file %s", debugLogFilePath.c_str()); + CC_LOG_DEBUG("Cannot create debug log file %s", debugLogFilePath.c_str()); } } @@ -413,10 +412,10 @@ int SimulatorWin::run() { screenScale = 2.0f; } - CCLOG("SCREEN DPI = %d, SCREEN SCALE = %0.2f", dpi, screenScale); + CC_LOG_DEBUG("SCREEN DPI = %d, SCREEN SCALE = %0.2f", dpi, screenScale); // check scale - Size frameSize = _project.getFrameSize(); + cc::Size frameSize = _project.getFrameSize(); float frameScale = _project.getFrameScale(); if (_project.isRetinaDisplay()) { @@ -438,7 +437,7 @@ int SimulatorWin::run() float frameBorderCY = GetSystemMetrics(SM_CYSIZEFRAME); workareaWidth -= frameBorderCX * 2; workareaHeight -= (frameBorderCY * 2 + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYMENU)); - CCLOG("WORKAREA WIDTH %0.2f, HEIGHT %0.2f", workareaWidth, workareaHeight); + CC_LOG_DEBUG("WORKAREA WIDTH %0.2f, HEIGHT %0.2f", workareaWidth, workareaHeight); while (true && frameScale > 0.25f) { if (frameSize.width * frameScale > workareaWidth || frameSize.height * frameScale > workareaHeight) @@ -454,7 +453,7 @@ int SimulatorWin::run() if (frameScale < 0.25f) frameScale = 0.25f; } _project.setFrameScale(frameScale); - CCLOG("FRAME SCALE = %0.2f", frameScale); + CC_LOG_DEBUG("FRAME SCALE = %0.2f", frameScale); // create opengl view const Rect frameRect = Rect(0, 0, frameSize.width, frameSize.height); @@ -466,7 +465,7 @@ int SimulatorWin::run() auto frameWidth = (int) (_project.getFrameScale() * frameSize.width); auto frameHeight = (int) (_project.getFrameScale() * frameSize.height); - _view = std::make_shared(title.str(), frameWidth, frameWidth); + _view = std::make_shared(title.str(), frameWidth, frameWidth); // create opengl view, and init app _app.reset(new Game(frameWidth, frameHeight)); @@ -510,7 +509,6 @@ int SimulatorWin::run() DrawMenuBar(_hwnd); // prepare - FileUtils::getInstance()->setPopupNotify(false); _project.dump(); g_oldWindowProc = (WNDPROC)SetWindowLong(_hwnd, GWL_WNDPROC, (LONG)SimulatorWin::windowProc); @@ -722,8 +720,8 @@ void SimulatorWin::setupUI() std::swap(size.width, size.height); } - project.setFrameSize(cocos2d::Size(size.width, size.height)); - project.setWindowOffset(cocos2d::Vec2(_instance->getPositionX(), _instance->getPositionY())); + project.setFrameSize(cc::Size(size.width, size.height)); + project.setWindowOffset(cc::Vec2(_instance->getPositionX(), _instance->getPositionY())); _instance->openProjectWithProjectConfig(project); } else if (data == "DIRECTION_PORTRAIT_MENU") @@ -763,7 +761,7 @@ void SimulatorWin::updateWindowTitle() std::stringstream title; title << "Cocos " << tr("Simulator") << " (" << _project.getFrameScale() * 100 << "%)"; std::u16string u16title; - cocos2d::StringUtils::UTF8ToUTF16(title.str(), u16title); + cc::StringUtils::UTF8ToUTF16(title.str(), u16title); SetWindowText(_hwnd, (LPCTSTR)u16title.c_str()); } @@ -782,7 +780,7 @@ void SimulatorWin::parseCocosProjectConfig(ProjectConfig &config) // get project directory ProjectConfig tmpConfig; // load project config from command line args - vector args; + std::vector args; for (int i = 0; i < __argc; ++i) { wstring ws(__wargv[i]); @@ -969,7 +967,7 @@ LRESULT CALLBACK SimulatorWin::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L buf << ",\"name\":" << "\"menuClicked\"" << "}"; event.setDataString(buf.str()); event.args[0].ptrVal = (void*)menuItem; - cocos2d::EventDispatcher::dispatchCustomEvent(event); + cc::EventDispatcher::dispatchCustomEvent(event); } if (menuId == ID_HELP_ABOUT) diff --git a/native/tools/simulator/frameworks/runtime-src/proj.win32/SimulatorWin.h b/native/tools/simulator/frameworks/runtime-src/proj.win32/SimulatorWin.h index 7464871018..ac218b2751 100755 --- a/native/tools/simulator/frameworks/runtime-src/proj.win32/SimulatorWin.h +++ b/native/tools/simulator/frameworks/runtime-src/proj.win32/SimulatorWin.h @@ -61,7 +61,7 @@ protected: FILE *_writeDebugLogFile; std::shared_ptr _app; - std::shared_ptr _view; + std::shared_ptr _view; bool _quit = false; diff --git a/native/tools/simulator/libsimulator/lib/ProjectConfig/ProjectConfig.h b/native/tools/simulator/libsimulator/lib/ProjectConfig/ProjectConfig.h index 4811a22af5..69a028e396 100755 --- a/native/tools/simulator/libsimulator/lib/ProjectConfig/ProjectConfig.h +++ b/native/tools/simulator/libsimulator/lib/ProjectConfig/ProjectConfig.h @@ -86,7 +86,7 @@ public: string getNormalizedPackagePath() const; void setPackagePath(const string &packagePath); void addPackagePath(const string &packagePath); - vector getPackagePathArray() const; + std::vector getPackagePathArray() const; cc::Size getFrameSize() const; void setFrameSize(const cc::Size &frameSize); diff --git a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerEditBoxServiceWin.cpp b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerEditBoxServiceWin.cpp index 9c4b89b891..9c7870bd8b 100755 --- a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerEditBoxServiceWin.cpp +++ b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerEditBoxServiceWin.cpp @@ -50,14 +50,14 @@ PlayerEditBoxServiceWin::~PlayerEditBoxServiceWin() DestroyWindow(_hwndMulti); } -void PlayerEditBoxServiceWin::showSingleLineEditBox(const cocos2d::Rect &rect) +void PlayerEditBoxServiceWin::showSingleLineEditBox(const cc::Rect &rect) { MoveWindow(_hwndSingle, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height, TRUE); ShowWindow(_hwndSingle, SW_SHOW); SetFocus(_hwndSingle); } -void PlayerEditBoxServiceWin::showMultiLineEditBox(const cocos2d::Rect &rect) +void PlayerEditBoxServiceWin::showMultiLineEditBox(const cc::Rect &rect) { MoveWindow(_hwndMulti, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height, TRUE); ShowWindow(_hwndMulti, SW_SHOW); @@ -77,7 +77,7 @@ void PlayerEditBoxServiceWin::setFont(const std::string &name, int size) removeFont(); std::u16string u16name; - cocos2d::StringUtils::UTF8ToUTF16(name, u16name); + cc::StringUtils::UTF8ToUTF16(name, u16name); HDC hdc = GetDC(_hwnd); size = -MulDiv(size, GetDeviceCaps(hdc, LOGPIXELSY), 72); @@ -89,7 +89,7 @@ void PlayerEditBoxServiceWin::setFont(const std::string &name, int size) if (!_hfont) { DWORD err = GetLastError(); - CCLOG("PlayerEditBoxServiceWin::setFont() - create HFONT for font \"%s\" failed, error code = 0x%08x", + CC_LOG_DEBUG("PlayerEditBoxServiceWin::setFont() - create HFONT for font \"%s\" failed, error code = 0x%08x", name.c_str(), err); } else diff --git a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerEditBoxServiceWin.h b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerEditBoxServiceWin.h index 06d89a6f25..ea291a88e0 100755 --- a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerEditBoxServiceWin.h +++ b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerEditBoxServiceWin.h @@ -41,8 +41,8 @@ public: PlayerEditBoxServiceWin(HWND hwnd); virtual ~PlayerEditBoxServiceWin(); - virtual void showSingleLineEditBox(const cocos2d::Rect &rect); - virtual void showMultiLineEditBox(const cocos2d::Rect &rect); + virtual void showSingleLineEditBox(const cc::Rect &rect); + virtual void showMultiLineEditBox(const cc::Rect &rect); virtual void hide(); virtual void setText(const std::string &text); diff --git a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerFileDialogServiceWin.cpp b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerFileDialogServiceWin.cpp index 6af48d08ac..b93fd35c20 100755 --- a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerFileDialogServiceWin.cpp +++ b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerFileDialogServiceWin.cpp @@ -65,13 +65,13 @@ std::string PlayerFileDialogServiceWin::saveFile(const std::string &title, const std::string &path) const { std::u16string u16title; - cocos2d::StringUtils::UTF8ToUTF16(title, u16title); + cc::StringUtils::UTF8ToUTF16(title, u16title); WCHAR buff[MAX_PATH + 1] = {0}; if (path.length() > 0) { std::u16string u16filename; - cocos2d::StringUtils::UTF8ToUTF16(path, u16filename); + cc::StringUtils::UTF8ToUTF16(path, u16filename); wcscpy_s(buff, (WCHAR*)u16filename.c_str()); } @@ -91,12 +91,12 @@ std::string PlayerFileDialogServiceWin::saveFile(const std::string &title, DWORD err = CommDlgExtendedError(); if (err) { - CCLOG("PlayerFileDialogServiceWin::saveFile() - failed, title (%s), error code = %u", title.c_str(), err); + CC_LOG_DEBUG("PlayerFileDialogServiceWin::saveFile() - failed, title (%s), error code = %u", title.c_str(), err); } return result; } - cocos2d::StringUtils::UTF16ToUTF8((char16_t*)buff, result); + cc::StringUtils::UTF16ToUTF8((char16_t*)buff, result); return result; } @@ -115,13 +115,13 @@ std::string PlayerFileDialogServiceWin::openDirectory(const std::string &title, const std::string &directory) const { std::u16string u16title; - cocos2d::StringUtils::UTF8ToUTF16(title, u16title); + cc::StringUtils::UTF8ToUTF16(title, u16title); WCHAR basedir[MAX_PATH + 1]; if (directory.length()) { std::u16string u16directory; - cocos2d::StringUtils::UTF8ToUTF16(directory, u16directory); + cc::StringUtils::UTF8ToUTF16(directory, u16directory); wcscpy_s(basedir, (WCHAR*)u16directory.c_str()); } else @@ -143,7 +143,7 @@ std::string PlayerFileDialogServiceWin::openDirectory(const std::string &title, { SHGetPathFromIDList(pid, (LPSTR)buff); std::string result; - cocos2d::StringUtils::UTF16ToUTF8((char16_t*)buff, result); + cc::StringUtils::UTF16ToUTF8((char16_t*)buff, result); return result; } else @@ -176,7 +176,7 @@ LPTSTR PlayerFileDialogServiceWin::parseExtensions(const std::string &extensions std::u16string split2((char16_t*)L"|"); std::u16string split3((char16_t*)L","); std::string extensionsArg(extensions); - cocos2d::StringUtils::UTF8ToUTF16(extensions, u16extensions); + cc::StringUtils::UTF8ToUTF16(extensions, u16extensions); vector pairs = splitString(u16extensions, split1); size_t buffsize = extensions.length() * 6; @@ -218,13 +218,13 @@ std::vector PlayerFileDialogServiceWin::openMultipleInternal(const bool isMulti) const { std::u16string u16title; - cocos2d::StringUtils::UTF8ToUTF16(title, u16title); + cc::StringUtils::UTF8ToUTF16(title, u16title); WCHAR basedir[MAX_PATH + 1]; if (directory.length()) { std::u16string u16directory; - cocos2d::StringUtils::UTF8ToUTF16(directory, u16directory); + cc::StringUtils::UTF8ToUTF16(directory, u16directory); wcscpy_s(basedir, (WCHAR*)u16directory.c_str()); } else @@ -257,7 +257,7 @@ std::vector PlayerFileDialogServiceWin::openMultipleInternal(const DWORD err = CommDlgExtendedError(); if (err) { - CCLOG("PlayerFileDialogServiceWin::openMultipleInternal() - failed, title (%s), error code = %u", title.c_str(), err); + CC_LOG_DEBUG("PlayerFileDialogServiceWin::openMultipleInternal() - failed, title (%s), error code = %u", title.c_str(), err); } delete[] buff; return result; @@ -271,7 +271,7 @@ std::vector PlayerFileDialogServiceWin::openMultipleInternal(const { std::string filename; std::u16string u16filename((char16_t*)(buff + offset)); - cocos2d::StringUtils::UTF16ToUTF8(u16filename, filename); + cc::StringUtils::UTF16ToUTF8(u16filename, filename); if (offset == 0) { @@ -291,7 +291,7 @@ std::vector PlayerFileDialogServiceWin::openMultipleInternal(const else { std::string path; - cocos2d::StringUtils::UTF16ToUTF8((char16_t*)buff, path); + cc::StringUtils::UTF16ToUTF8((char16_t*)buff, path); result.push_back(path); } delete[] buff; diff --git a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerMenuServiceWin.cpp b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerMenuServiceWin.cpp index 7a706c3ee5..6808e9a5ff 100755 --- a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerMenuServiceWin.cpp +++ b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerMenuServiceWin.cpp @@ -50,12 +50,12 @@ PlayerMenuItemWin::~PlayerMenuItemWin() CC_SAFE_RELEASE(_parent); if (_hmenu) { - CCLOG("PlayerMenuItemWin::~PlayerMenuItemWin() - %s (HMENU)", _menuId.c_str()); + CC_LOG_DEBUG("PlayerMenuItemWin::~PlayerMenuItemWin() - %s (HMENU)", _menuId.c_str()); DestroyMenu(_hmenu); } else { - CCLOG("PlayerMenuItemWin::~PlayerMenuItemWin() - %s", _menuId.c_str()); + CC_LOG_DEBUG("PlayerMenuItemWin::~PlayerMenuItemWin() - %s", _menuId.c_str()); } } @@ -63,7 +63,7 @@ void PlayerMenuItemWin::setTitle(const std::string &title) { if (title.length() == 0) { - CCLOG("MenuServiceWin::setTitle() - can not set menu title to empty, menu id (%s)", _menuId.c_str()); + CC_LOG_DEBUG("MenuServiceWin::setTitle() - can not set menu title to empty, menu id (%s)", _menuId.c_str()); return; } @@ -72,7 +72,7 @@ void PlayerMenuItemWin::setTitle(const std::string &title) menuitem.fMask = MIIM_FTYPE | MIIM_STRING; menuitem.fType = (title.compare("-") == 0) ? MFT_SEPARATOR : MFT_STRING; std::u16string u16title; - cocos2d::StringUtils::UTF8ToUTF16(title, u16title); + cc::StringUtils::UTF8ToUTF16(title, u16title); menuitem.dwTypeData = (LPTSTR)u16title.c_str(); if (SetMenuItemInfo(_parent->_hmenu, _commandId, MF_BYCOMMAND, &menuitem)) { @@ -81,7 +81,7 @@ void PlayerMenuItemWin::setTitle(const std::string &title) else { DWORD err = GetLastError(); - CCLOG("MenuServiceWin::setTitle() - set menu title failed, menu id (%s). error code = %u", _menuId.c_str(), err); + CC_LOG_DEBUG("MenuServiceWin::setTitle() - set menu title failed, menu id (%s). error code = %u", _menuId.c_str(), err); } } @@ -98,7 +98,7 @@ void PlayerMenuItemWin::setEnabled(bool enabled) else { DWORD err = GetLastError(); - CCLOG("MenuServiceWin::setEnabled() - set menu enabled failed, menu id (%s). error code = %u", _menuId.c_str(), err); + CC_LOG_DEBUG("MenuServiceWin::setEnabled() - set menu enabled failed, menu id (%s). error code = %u", _menuId.c_str(), err); } } @@ -115,7 +115,7 @@ void PlayerMenuItemWin::setChecked(bool checked) else { DWORD err = GetLastError(); - CCLOG("MenuServiceWin::setChecked() - set menu checked failed, menu id (%s). error code = %u", _menuId.c_str(), err); + CC_LOG_DEBUG("MenuServiceWin::setChecked() - set menu checked failed, menu id (%s). error code = %u", _menuId.c_str(), err); } } @@ -161,14 +161,14 @@ PlayerMenuItem *PlayerMenuServiceWin::addItem(const std::string &menuId, { if (menuId.length() == 0 || title.length() == 0) { - CCLOG("MenuServiceWin::addItem() - menuId and title must is non-empty"); + CC_LOG_DEBUG("MenuServiceWin::addItem() - menuId and title must is non-empty"); return nullptr; } // check menu id is exists if (_items.find(menuId) != _items.end()) { - CCLOG("MenuServiceWin::addItem() - menu id (%s) is exists", menuId.c_str()); + CC_LOG_DEBUG("MenuServiceWin::addItem() - menu id (%s) is exists", menuId.c_str()); return false; } @@ -196,7 +196,7 @@ PlayerMenuItem *PlayerMenuServiceWin::addItem(const std::string &menuId, if (!SetMenuItemInfo(parent->_parent->_hmenu, parent->_commandId, MF_BYCOMMAND, &menuitem)) { DWORD err = GetLastError(); - CCLOG("MenuServiceWin::addItem() - set menu handle failed, menu id (%s). error code = %u", parent->_menuId.c_str(), err); + CC_LOG_DEBUG("MenuServiceWin::addItem() - set menu handle failed, menu id (%s). error code = %u", parent->_menuId.c_str(), err); return nullptr; } } @@ -216,7 +216,7 @@ PlayerMenuItem *PlayerMenuServiceWin::addItem(const std::string &menuId, menuitem.fState = (item->_isEnabled) ? MFS_ENABLED : MFS_DISABLED; menuitem.fState |= (item->_isChecked) ? MFS_CHECKED : MFS_UNCHECKED; std::u16string u16title; - cocos2d::StringUtils::UTF8ToUTF16(item->_title, u16title); + cc::StringUtils::UTF8ToUTF16(item->_title, u16title); menuitem.dwTypeData = (LPTSTR)u16title.c_str(); menuitem.wID = _newCommandId; @@ -234,7 +234,7 @@ PlayerMenuItem *PlayerMenuServiceWin::addItem(const std::string &menuId, if (!InsertMenuItem(parent->_hmenu, order, TRUE, &menuitem)) { DWORD err = GetLastError(); - CCLOG("MenuServiceWin::addItem() - insert new menu item failed, menu id (%s). error code = %u", item->_menuId.c_str(), err); + CC_LOG_DEBUG("MenuServiceWin::addItem() - insert new menu item failed, menu id (%s). error code = %u", item->_menuId.c_str(), err); item->release(); return nullptr; } @@ -259,7 +259,7 @@ PlayerMenuItem *PlayerMenuServiceWin::getItem(const std::string &menuId) auto it = _items.find(menuId); if (it == _items.end()) { - CCLOG("MenuServiceWin::getItem() - Invalid menu id (%s)", menuId.c_str()); + CC_LOG_DEBUG("MenuServiceWin::getItem() - Invalid menu id (%s)", menuId.c_str()); return nullptr; } @@ -300,7 +300,7 @@ bool PlayerMenuServiceWin::removeItemInternal(const std::string &menuId, bool is auto it = _items.find(menuId); if (it == _items.end()) { - CCLOG("MenuServiceWin::removeItem() - Invalid menu id (%s)", menuId.c_str()); + CC_LOG_DEBUG("MenuServiceWin::removeItem() - Invalid menu id (%s)", menuId.c_str()); return false; } @@ -310,7 +310,7 @@ bool PlayerMenuServiceWin::removeItemInternal(const std::string &menuId, bool is if (!DeleteMenu(item->_parent->_hmenu, item->_commandId, MF_BYCOMMAND)) { DWORD err = GetLastError(); - CCLOG("MenuServiceWin::removeItem() - remove menu item failed, menu id (%s). error code = %u", item->_menuId.c_str(), err); + CC_LOG_DEBUG("MenuServiceWin::removeItem() - remove menu item failed, menu id (%s). error code = %u", item->_menuId.c_str(), err); return false; } @@ -321,7 +321,7 @@ bool PlayerMenuServiceWin::removeItemInternal(const std::string &menuId, bool is { if ((*it)->_commandId == item->_commandId) { - CCLOG("MenuServiceWin::removeItem() - remove menu item (%s)", item->_menuId.c_str()); + CC_LOG_DEBUG("MenuServiceWin::removeItem() - remove menu item (%s)", item->_menuId.c_str()); children->erase(it); removed = true; break; @@ -330,7 +330,7 @@ bool PlayerMenuServiceWin::removeItemInternal(const std::string &menuId, bool is if (!removed) { - CCLOG("MenuServiceWin::removeItem() - remove menu item (%s) failed, not found command id from parent->children", item->_menuId.c_str()); + CC_LOG_DEBUG("MenuServiceWin::removeItem() - remove menu item (%s) failed, not found command id from parent->children", item->_menuId.c_str()); } // remove menu id mapping diff --git a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerMenuServiceWin.h b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerMenuServiceWin.h index 4e43bcba9e..3928da7ac3 100755 --- a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerMenuServiceWin.h +++ b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerMenuServiceWin.h @@ -55,7 +55,7 @@ protected: UINT _commandId; HMENU _hmenu; bool _menubarEnabled; - cocos2d::Vector _children; + cc::Vector _children; friend class PlayerMenuServiceWin; }; diff --git a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerMessageBoxServiceWin.cpp b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerMessageBoxServiceWin.cpp index d7b8828dfe..dec95ff6af 100755 --- a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerMessageBoxServiceWin.cpp +++ b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerMessageBoxServiceWin.cpp @@ -38,11 +38,11 @@ int PlayerMessageBoxServiceWin::showMessageBox(const std::string &title, int buttonsType /* = BUTTONS_OK */) { std::u16string u16title; - cocos2d::StringUtils::UTF8ToUTF16(title, u16title); + cc::StringUtils::UTF8ToUTF16(title, u16title); std::u16string u16message; - cocos2d::StringUtils::UTF8ToUTF16(message, u16message); + cc::StringUtils::UTF8ToUTF16(message, u16message); - CCLOG("PlayerMessageBoxServiceWin::showMessageBox() - title = %s, message = %s", title.c_str(), message.c_str()); + CC_LOG_DEBUG("PlayerMessageBoxServiceWin::showMessageBox() - title = %s, message = %s", title.c_str(), message.c_str()); UINT mbtype = MB_APPLMODAL; switch (buttonsType) @@ -84,7 +84,7 @@ int PlayerMessageBoxServiceWin::showMessageBox(const std::string &title, result = BUTTON_OK; } - CCLOG("PlayerMessageBoxServiceWin::showMessageBox() - result = %d", result); + CC_LOG_DEBUG("PlayerMessageBoxServiceWin::showMessageBox() - result = %d", result); return result; } diff --git a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerTaskServiceWin.cpp b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerTaskServiceWin.cpp index 8dfe15bc90..b7e0fd865f 100755 --- a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerTaskServiceWin.cpp +++ b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerTaskServiceWin.cpp @@ -64,7 +64,7 @@ bool PlayerTaskWin::run() { if (!isIdle()) { - CCLOG("PlayerTaskWin::run() - task is not idle"); + CC_LOG_DEBUG("PlayerTaskWin::run() - task is not idle"); return false; } @@ -89,7 +89,7 @@ bool PlayerTaskWin::run() // Create a pipe for the child process's STDOUT. if (!CreatePipe(&_childStdOutRead, &_childStdOutWrite, &sa, 0) || !SetHandleInformation(_childStdOutRead, HANDLE_FLAG_INHERIT, 0)) { - CCLOG("PlayerTaskWin::run() - create stdout handle failed, for execute %s", _executePath.c_str()); + CC_LOG_DEBUG("PlayerTaskWin::run() - create stdout handle failed, for execute %s", _executePath.c_str()); cleanup(); return false; } @@ -97,7 +97,7 @@ bool PlayerTaskWin::run() // Create a pipe for the child process's STDIN. if (!CreatePipe(&_childStdInRead, &_childStdInWrite, &sa, 0) || !SetHandleInformation(_childStdInWrite, HANDLE_FLAG_INHERIT, 0)) { - CCLOG("PlayerTaskWin::run() - create stdout handle failed, for execute %s", _executePath.c_str()); + CC_LOG_DEBUG("PlayerTaskWin::run() - create stdout handle failed, for execute %s", _executePath.c_str()); cleanup(); return false; } @@ -130,7 +130,7 @@ bool PlayerTaskWin::run() if (!success) { - CCLOG("PlayerTaskWin::run() - create process failed, for execute %s", _executePath.c_str()); + CC_LOG_DEBUG("PlayerTaskWin::run() - create process failed, for execute %s", _executePath.c_str()); cleanup(); return false; } @@ -139,7 +139,7 @@ bool PlayerTaskWin::run() _outputBuffWide = new WCHAR[BUFF_SIZE]; _state = STATE_RUNNING; - // cocos2d::Director::getInstance()->getScheduler()->scheduleUpdate(this, 0, false); + // cc::Director::getInstance()->getScheduler()->scheduleUpdate(this, 0, false); return true; } @@ -152,7 +152,7 @@ void PlayerTaskWin::runInTerminal() buf << _commandLineArguments; std::u16string u16command; - cocos2d::StringUtils::UTF8ToUTF16(buf.str(), u16command); + cc::StringUtils::UTF8ToUTF16(buf.str(), u16command); ShellExecute(NULL, NULL, (LPCSTR)L"CMD.EXE", (LPCSTR)u16command.c_str(), NULL, SW_SHOWNORMAL); } @@ -207,7 +207,7 @@ void PlayerTaskWin::update(float dt) _resultCode = (int)GetLastError(); } - // cocos2d::Director::getInstance()->getScheduler()->unscheduleAllForTarget(this); + // cc::Director::getInstance()->getScheduler()->unscheduleAllForTarget(this); cleanup(); } @@ -234,9 +234,9 @@ void PlayerTaskWin::cleanup() _state = STATE_COMPLETED; - CCLOG("CMD: %s", _output.c_str()); + CC_LOG_DEBUG("CMD: %s", _output.c_str()); - // cocos2d::Director::getInstance()->getEventDispatcher()->dispatchCustomEvent(_name); + // cc::Director::getInstance()->getEventDispatcher()->dispatchCustomEvent(_name); } std::u16string PlayerTaskWin::makeCommandLine() const @@ -248,7 +248,7 @@ std::u16string PlayerTaskWin::makeCommandLine() const buf << _commandLineArguments; std::u16string u16command; - cocos2d::StringUtils::UTF8ToUTF16(buf.str(), u16command); + cc::StringUtils::UTF8ToUTF16(buf.str(), u16command); return u16command; } diff --git a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerTaskServiceWin.h b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerTaskServiceWin.h index 5958ca0fd3..1402018965 100755 --- a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerTaskServiceWin.h +++ b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerTaskServiceWin.h @@ -82,7 +82,7 @@ public: protected: HWND _hwnd; - cocos2d::Map _tasks; + cc::Map _tasks; }; PLAYER_NS_END diff --git a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.cpp b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.cpp index cde7c13d06..8d7122ab09 100755 --- a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.cpp +++ b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.cpp @@ -26,7 +26,7 @@ #include "PlayerWin.h" -USING_NS_CC; +using namespace std; PLAYER_NS_BEGIN PlayerWin::PlayerWin() diff --git a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.h b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.h index e4abe72030..42bc9624a8 100755 --- a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.h +++ b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.h @@ -38,7 +38,7 @@ PLAYER_NS_BEGIN -class CC_LIBSIM_DLL PlayerWin : public PlayerProtocol, public cocos2d::Ref +class CC_LIBSIM_DLL PlayerWin : public PlayerProtocol, public cc::Ref { public: static PlayerWin *createWithHwnd(HWND hWnd); diff --git a/native/tools/simulator/libsimulator/lib/protobuf-lite/google/protobuf/extension_set.cc b/native/tools/simulator/libsimulator/lib/protobuf-lite/google/protobuf/extension_set.cc index 2cbba8f546..d9b51c0446 100755 --- a/native/tools/simulator/libsimulator/lib/protobuf-lite/google/protobuf/extension_set.cc +++ b/native/tools/simulator/libsimulator/lib/protobuf-lite/google/protobuf/extension_set.cc @@ -43,6 +43,11 @@ #include #include + +#ifdef OPTIONAL +#undef OPTIONAL +#endif // OPTIONAL + namespace google { namespace protobuf { namespace internal { diff --git a/native/tools/simulator/libsimulator/lib/runtime/ConfigParser.cpp b/native/tools/simulator/libsimulator/lib/runtime/ConfigParser.cpp index c2df486c09..3befbaed42 100755 --- a/native/tools/simulator/libsimulator/lib/runtime/ConfigParser.cpp +++ b/native/tools/simulator/libsimulator/lib/runtime/ConfigParser.cpp @@ -53,9 +53,9 @@ void ConfigParser::readConfig(const string &filepath) #if (CC_PLATFORM == CC_PLATFORM_MAC_IOS || CC_PLATFORM == CC_PLATFORM_ANDROID) // add writable path to search path temporarily for reading config file - vector searchPathArray = cocos2d::FileUtils::getInstance()->getSearchPaths(); + vector searchPathArray = cc::FileUtils::getInstance()->getSearchPaths(); searchPathArray.insert(searchPathArray.begin(), FileServer::getShareInstance()->getWritePath()); - cocos2d::FileUtils::getInstance()->setSearchPaths(searchPathArray); + cc::FileUtils::getInstance()->setSearchPaths(searchPathArray); #endif // read config file @@ -68,7 +68,7 @@ void ConfigParser::readConfig(const string &filepath) #if (CC_PLATFORM == CC_PLATFORM_MAC_IOS || CC_PLATFORM == CC_PLATFORM_ANDROID) // revert search path searchPathArray.erase(searchPathArray.begin()); - cocos2d::FileUtils::getInstance()->setSearchPaths(searchPathArray); + cc::FileUtils::getInstance()->setSearchPaths(searchPathArray); #endif if(fileContent.empty()) diff --git a/native/tools/simulator/libsimulator/lib/runtime/FileServer.cpp b/native/tools/simulator/libsimulator/lib/runtime/FileServer.cpp index dce78da249..c6f6161c58 100755 --- a/native/tools/simulator/libsimulator/lib/runtime/FileServer.cpp +++ b/native/tools/simulator/libsimulator/lib/runtime/FileServer.cpp @@ -79,7 +79,7 @@ void FileServer::readResFileFinfo() //save file info to disk every five second CC_LOG_DEBUG("FileServer::readResFileFinfo()"); -// cocos2d::Director::getInstance()->getScheduler()->schedule([&](float){ +// cc::Director::getInstance()->getScheduler()->schedule([&](float){ // rapidjson::StringBuffer buffer; // rapidjson::Writer< rapidjson::StringBuffer > writer(buffer); // _filecfgjson.Accept(writer); @@ -417,7 +417,7 @@ void FileServer::loopWriteFile() _fileNameMutex.lock(); _strFileName = filename; _fileNameMutex.unlock(); - //cocos2d::log("WriteFile:: fullfilename = %s",filename.c_str()); + //cc::log("WriteFile:: fullfilename = %s",filename.c_str()); createDir(fullfilename.substr(0, fullfilename.find_last_of("/")).c_str()); FILE *fp= nullptr; diff --git a/native/tools/simulator/libsimulator/lib/runtime/Runtime.cpp b/native/tools/simulator/libsimulator/lib/runtime/Runtime.cpp index 61db1a6781..3181198ecb 100755 --- a/native/tools/simulator/libsimulator/lib/runtime/Runtime.cpp +++ b/native/tools/simulator/libsimulator/lib/runtime/Runtime.cpp @@ -325,7 +325,7 @@ void RuntimeEngine::trackEvent(const std::string &eventName) char cidBuf[64] = {0}; auto guid = player::DeviceEx::getInstance()->getUserGUID(); snprintf(cidBuf, sizeof(cidBuf), "%x", XXH32(guid.c_str(), (int)guid.length(), 0)); - auto request = cocos2d::extra::HTTPRequest::createWithUrl(NULL, + auto request = cc::extra::HTTPRequest::createWithUrl(NULL, "http://www.google-analytics.com/collect", kCCHTTPRequestMethodPOST); request->addPOSTValue("v", "1"); @@ -334,7 +334,7 @@ void RuntimeEngine::trackEvent(const std::string &eventName) request->addPOSTValue("t", "event"); request->addPOSTValue("an", "simulator"); - request->addPOSTValue("av", cocos2d::cocos2dVersion()); + request->addPOSTValue("av", cc::cocos2dVersion()); request->addPOSTValue("ec", platform); request->addPOSTValue("ea", eventName.c_str()); diff --git a/native/tools/simulator/libsimulator/lib/runtime/VisibleRect.cpp b/native/tools/simulator/libsimulator/lib/runtime/VisibleRect.cpp index 1c266f38f0..a1653f8ede 100755 --- a/native/tools/simulator/libsimulator/lib/runtime/VisibleRect.cpp +++ b/native/tools/simulator/libsimulator/lib/runtime/VisibleRect.cpp @@ -31,7 +31,7 @@ void VisibleRect::lazyInit() { // no lazy init // Useful if we change the resolution in runtime -// s_visibleRect = cocos2d::Director::getInstance()->getOpenGLView()->getVisibleRect(); +// s_visibleRect = cc::Director::getInstance()->getOpenGLView()->getVisibleRect(); CC_LOG_DEBUG("lazyInit"); }