From 6e97dce120fde581a5f6520855151374fb90c6d6 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sun, 9 May 2021 15:15:38 +0800 Subject: [PATCH] TD-4088 --- src/os/CMakeLists.txt | 4 +++- src/os/src/darwin/CMakeLists.txt | 2 +- src/os/src/detail/CMakeLists.txt | 6 +++--- src/os/src/linux/CMakeLists.txt | 7 +++++++ src/os/src/{detail/osEnv.c => linux/linuxEnv.c} | 3 +-- src/os/src/windows/CMakeLists.txt | 4 ++-- 6 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 src/os/src/linux/CMakeLists.txt rename src/os/src/{detail/osEnv.c => linux/linuxEnv.c} (98%) diff --git a/src/os/CMakeLists.txt b/src/os/CMakeLists.txt index efe2a1ed77..4472c683c7 100644 --- a/src/os/CMakeLists.txt +++ b/src/os/CMakeLists.txt @@ -1,7 +1,9 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(TDengine) -IF (TD_DARWIN) +IF (TD_LINUX) + ADD_SUBDIRECTORY(src/linux) +ELSEIF (TD_DARWIN) ADD_SUBDIRECTORY(src/darwin) ELSEIF (TD_WINDOWS) ADD_SUBDIRECTORY(src/windows) diff --git a/src/os/src/darwin/CMakeLists.txt b/src/os/src/darwin/CMakeLists.txt index f46dfac6a1..259e1a7a0b 100644 --- a/src/os/src/darwin/CMakeLists.txt +++ b/src/os/src/darwin/CMakeLists.txt @@ -2,4 +2,4 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(TDengine) AUX_SOURCE_DIRECTORY(. SRC) -ADD_LIBRARY(osd ${SRC}) +ADD_LIBRARY(osdarwin ${SRC}) diff --git a/src/os/src/detail/CMakeLists.txt b/src/os/src/detail/CMakeLists.txt index a3db8bd8b8..5c49df24c1 100644 --- a/src/os/src/detail/CMakeLists.txt +++ b/src/os/src/detail/CMakeLists.txt @@ -10,12 +10,12 @@ SET_SOURCE_FILES_PROPERTIES(osCoredump.c PROPERTIES COMPILE_FLAGS -w) ADD_LIBRARY(os ${SRC}) IF (TD_LINUX) - TARGET_LINK_LIBRARIES(os m rt z) + TARGET_LINK_LIBRARIES(os oslinux) IF (TD_ARM_32 OR TD_LINUX_32) TARGET_LINK_LIBRARIES(os atomic) ENDIF () ELSEIF (TD_DARWIN) - TARGET_LINK_LIBRARIES(os osd) + TARGET_LINK_LIBRARIES(os osdarwin) ELSEIF (TD_WINDOWS) - TARGET_LINK_LIBRARIES(os osw) + TARGET_LINK_LIBRARIES(os oswindows) ENDIF () diff --git a/src/os/src/linux/CMakeLists.txt b/src/os/src/linux/CMakeLists.txt new file mode 100644 index 0000000000..08b696ba1a --- /dev/null +++ b/src/os/src/linux/CMakeLists.txt @@ -0,0 +1,7 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +PROJECT(TDengine) + +AUX_SOURCE_DIRECTORY(. SRC) +ADD_LIBRARY(oslinux ${SRC}) + +TARGET_LINK_LIBRARIES(oslinux m rt z) \ No newline at end of file diff --git a/src/os/src/detail/osEnv.c b/src/os/src/linux/linuxEnv.c similarity index 98% rename from src/os/src/detail/osEnv.c rename to src/os/src/linux/linuxEnv.c index e3eadbc94b..417513314c 100644 --- a/src/os/src/detail/osEnv.c +++ b/src/os/src/linux/linuxEnv.c @@ -40,9 +40,8 @@ void osInit() { strcpy(tsOsName, "Linux"); } -char cmdline[1024]; - char* taosGetCmdlineByPID(int pid) { + static char cmdline[1024]; sprintf(cmdline, "/proc/%d/cmdline", pid); FILE* f = fopen(cmdline, "r"); if (f) { diff --git a/src/os/src/windows/CMakeLists.txt b/src/os/src/windows/CMakeLists.txt index 1ac2700f1d..e5472e1abd 100644 --- a/src/os/src/windows/CMakeLists.txt +++ b/src/os/src/windows/CMakeLists.txt @@ -2,6 +2,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(TDengine) AUX_SOURCE_DIRECTORY(. SRC) -ADD_LIBRARY(osw ${SRC}) +ADD_LIBRARY(oswindows ${SRC}) -TARGET_LINK_LIBRARIES(osw winmm IPHLPAPI ws2_32 MsvcLibXw) +TARGET_LINK_LIBRARIES(oswindows winmm IPHLPAPI ws2_32 MsvcLibXw) \ No newline at end of file -- GitLab