Fix builder script for Linux.

dev
Apex Liu 2020-11-03 00:57:26 +08:00
parent f26c71d52d
commit c2cf5b1842
4 changed files with 19 additions and 9 deletions

2
.gitignore vendored
View File

@ -15,7 +15,7 @@
# for CMake # for CMake
CMakeFiles CMakeFiles
cmake_install.cmake cmake_install.cmake
cmake-build-* cmake-build*
# cmake-build-debug # cmake-build-debug
client/tp_assist_macos/build client/tp_assist_macos/build
**/xcode_build **/xcode_build

View File

@ -91,9 +91,11 @@ class BuilderLinux(BuilderBase):
utils.makedirs(out_path) utils.makedirs(out_path)
build_path = os.path.join(env.root_path, 'cmake-build-linux') # build_path = os.path.join(env.root_path, 'cmake-build-linux')
if not os.path.exists(build_path): # if not os.path.exists(build_path):
utils.makedirs(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() # old_p = os.getcwd()
# os.chdir(build_path) # os.chdir(build_path)

View File

@ -8,12 +8,20 @@
#ifdef EX_OS_WIN32 #ifdef EX_OS_WIN32
# include <process.h> # include <process.h>
typedef HANDLE EX_THREAD_HANDLE; typedef HANDLE EX_THREAD_HANDLE;
# define EX_THREAD_NULL NULL
#else #else
# include <pthread.h> # include <pthread.h>
# include <sys/time.h> # include <sys/time.h>
typedef pthread_t EX_THREAD_HANDLE; 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 #endif
class ExThreadBase class ExThreadBase

View File

@ -18,7 +18,7 @@ void *ExThreadBase::_thread_func(void *pParam)
_this->m_is_running = true; _this->m_is_running = true;
_this->_thread_loop(); _this->_thread_loop();
_this->m_is_running = false; _this->m_is_running = false;
_this->m_handle = nullptr; _this->m_handle = EX_THREAD_NULL;
_this->_on_stopped(); _this->_on_stopped();
EXLOGV("[thread] - `%s` exit.\n", _this->m_thread_name.c_str()); 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) : ExThreadBase::ExThreadBase(const char *thread_name) :
m_handle(0), m_handle(EX_THREAD_NULL),
m_is_running(false), m_is_running(false),
m_need_stop(false) { m_need_stop(false) {
m_thread_name = thread_name; m_thread_name = thread_name;
@ -50,7 +50,7 @@ bool ExThreadBase::start() {
} }
m_handle = h; m_handle = h;
#else #else
pthread_t tid = nullptr; pthread_t tid = EX_THREAD_NULL;
int ret = pthread_create(&tid, nullptr, _thread_func, (void *) this); int ret = pthread_create(&tid, nullptr, _thread_func, (void *) this);
if (ret != 0) { if (ret != 0) {
return false; return false;
@ -63,7 +63,7 @@ bool ExThreadBase::start() {
} }
bool ExThreadBase::stop() { 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()); EXLOGW("[thread] `%s` already stopped before stop() call.\n", m_thread_name.c_str());
return true; return true;
} }
@ -81,7 +81,7 @@ bool ExThreadBase::stop() {
} }
} }
#else #else
if(m_handle != 0) { if(m_handle != EX_THREAD_NULL) {
if (pthread_join(m_handle, nullptr) != 0) { if (pthread_join(m_handle, nullptr) != 0) {
return false; return false;
} }