From c2cf5b1842a60759ba22cd6310161bd251be1554 Mon Sep 17 00:00:00 2001 From: Apex Liu Date: Tue, 3 Nov 2020 00:57:26 +0800 Subject: [PATCH] Fix builder script for Linux. --- .gitignore | 2 +- build/builder/build-server.py | 8 +++++--- common/libex/include/ex/ex_thread.h | 8 ++++++++ common/libex/src/ex_thread.cpp | 10 +++++----- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index c80f15f..da101a7 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,7 @@ # for CMake CMakeFiles cmake_install.cmake -cmake-build-* +cmake-build* # cmake-build-debug client/tp_assist_macos/build **/xcode_build diff --git a/build/builder/build-server.py b/build/builder/build-server.py index 803bc7c..f1573a4 100644 --- a/build/builder/build-server.py +++ b/build/builder/build-server.py @@ -91,9 +91,11 @@ class BuilderLinux(BuilderBase): utils.makedirs(out_path) - build_path = os.path.join(env.root_path, 'cmake-build-linux') - if not os.path.exists(build_path): - utils.makedirs(build_path) + # build_path = os.path.join(env.root_path, 'cmake-build-linux') + # if not os.path.exists(build_path): + # utils.makedirs(build_path) + + utils.cmake(os.path.join(env.root_path, 'cmake-build-linux'), ctx.target_path, False) # old_p = os.getcwd() # os.chdir(build_path) diff --git a/common/libex/include/ex/ex_thread.h b/common/libex/include/ex/ex_thread.h index 9be0af5..522606d 100644 --- a/common/libex/include/ex/ex_thread.h +++ b/common/libex/include/ex/ex_thread.h @@ -8,12 +8,20 @@ #ifdef EX_OS_WIN32 # include typedef HANDLE EX_THREAD_HANDLE; +# define EX_THREAD_NULL NULL #else # include # include typedef pthread_t EX_THREAD_HANDLE; + +# if defined(EX_OS_LINUX) +# define EX_THREAD_NULL 0 +# elif defined(EX_OS_MACOS) +# define EX_THREAD_NULL nullptr +# endif + #endif class ExThreadBase diff --git a/common/libex/src/ex_thread.cpp b/common/libex/src/ex_thread.cpp index b261211..f854a74 100644 --- a/common/libex/src/ex_thread.cpp +++ b/common/libex/src/ex_thread.cpp @@ -18,7 +18,7 @@ void *ExThreadBase::_thread_func(void *pParam) _this->m_is_running = true; _this->_thread_loop(); _this->m_is_running = false; - _this->m_handle = nullptr; + _this->m_handle = EX_THREAD_NULL; _this->_on_stopped(); EXLOGV("[thread] - `%s` exit.\n", _this->m_thread_name.c_str()); @@ -26,7 +26,7 @@ void *ExThreadBase::_thread_func(void *pParam) } ExThreadBase::ExThreadBase(const char *thread_name) : - m_handle(0), + m_handle(EX_THREAD_NULL), m_is_running(false), m_need_stop(false) { m_thread_name = thread_name; @@ -50,7 +50,7 @@ bool ExThreadBase::start() { } m_handle = h; #else - pthread_t tid = nullptr; + pthread_t tid = EX_THREAD_NULL; int ret = pthread_create(&tid, nullptr, _thread_func, (void *) this); if (ret != 0) { return false; @@ -63,7 +63,7 @@ bool ExThreadBase::start() { } bool ExThreadBase::stop() { - if (m_handle == 0) { + if (m_handle == EX_THREAD_NULL) { EXLOGW("[thread] `%s` already stopped before stop() call.\n", m_thread_name.c_str()); return true; } @@ -81,7 +81,7 @@ bool ExThreadBase::stop() { } } #else - if(m_handle != 0) { + if(m_handle != EX_THREAD_NULL) { if (pthread_join(m_handle, nullptr) != 0) { return false; }