Skip to content

Commit

Permalink
fix: PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ncvicchi committed Dec 12, 2024
1 parent f201f8d commit b9c6000
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 42 deletions.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.22)

set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake")

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++")
endif()

Expand Down
2 changes: 1 addition & 1 deletion src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ add_subdirectory(dbsync)
add_subdirectory(error_messages)
add_subdirectory(filesystem_wrapper)
add_subdirectory(hashHelper)
add_subdirectory(mem_op)
add_subdirectory(logger)
add_subdirectory(mem_op)
add_subdirectory(networkHelper)
add_subdirectory(pal)
add_subdirectory(privsep_op)
Expand Down
11 changes: 6 additions & 5 deletions src/common/binaries_op/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
add_library(binaries_op STATIC src/binaries_op.c)

get_filename_component(COMMON_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/../ ABSOLUTE)
target_include_directories(binaries_op PUBLIC include)
include_directories(${COMMON_FOLDER}/pal/include)
include_directories(${COMMON_FOLDER}/error_messages/include)
include_directories(${COMMON_FOLDER}/utils/include)
include_directories(${COMMON_FOLDER}/file_op/include)
target_include_directories(binaries_op PUBLIC
include
${COMMON_FOLDER}/error_messages/include
${COMMON_FOLDER}/file_op/include
${COMMON_FOLDER}/pal/include
${COMMON_FOLDER}/utils/include)

target_link_libraries(binaries_op
utils
Expand Down
5 changes: 3 additions & 2 deletions src/common/file_op/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ find_package(ZLIB REQUIRED)
add_library(file_op STATIC src/file_op.c)

get_filename_component(COMMON_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/../ ABSOLUTE)
target_include_directories(file_op PUBLIC include)
include_directories(${COMMON_FOLDER}/pal/include)
target_include_directories(file_op PUBLIC
include
${COMMON_FOLDER}/pal/include)

target_link_libraries(file_op utils time_op version_op ZLIB::ZLIB Logger)
7 changes: 4 additions & 3 deletions src/common/mem_op/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
add_library(mem_op STATIC src/mem_op.c)

get_filename_component(COMMON_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/../ ABSOLUTE)
target_include_directories(mem_op PUBLIC include)
include_directories(${COMMON_FOLDER}/pal/include)
include_directories(${COMMON_FOLDER}/error_messages/include)
target_include_directories(mem_op PUBLIC
include
${COMMON_FOLDER}/error_messages/include
${COMMON_FOLDER}/pal/include)

target_link_libraries(mem_op utils Logger time_op)
3 changes: 1 addition & 2 deletions src/common/pal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ else()
message(FATAL_ERROR "Unsupported OS")
endif()

include_directories(include/${OS_NAME})

file(GLOB_RECURSE SOURCE_FILES src/${OS_NAME}/*.c)

message(STATUS "Source files: ${SOURCE_FILES}")
Expand All @@ -22,6 +20,7 @@ if(NOT SOURCE_FILES)
endif()

add_library(pal STATIC ${SOURCE_FILES})
target_include_directories(pal PUBLIC include/${OS_NAME})

if(BUILD_TESTS)
enable_testing()
Expand Down
4 changes: 2 additions & 2 deletions src/common/pal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Since we are currently using GNU C for Linux. AppleClang for MacOS and MSVC for
pal
├── README.md
├── CMakeLists.txt
├── include
├── include
│ ├── Linux
│ │ ├── pal_file.h
│ │ ├── pal_thread.h
Expand Down Expand Up @@ -46,7 +46,7 @@ pal
### Usage

A commom public file named "pal.h" should be included in every file that will be platform dependant. No more includes should be necessary.
Thos definitions, prototypes, etc, provided by the PAL should be used in Wazuh agent's code, avoiding whenever possible the usage of pre-processor in higher level code.
Those definitions, prototypes, etc, provided by the PAL should be used in Wazuh agent's code, avoiding whenever possible the usage of pre-processor in higher level code.
If situations not considered in the PAL are found during development, it should be prioritized to extend the PAL than taking shortcuts as ad-hoc solutions, except if this option is no available for implementation reasons.

#### NOTE: Due to time available for this proposal, an emulation of POSIX functions and structures were implemented. It will be left for later to implement a fully abstracted layer to improve code quality.
5 changes: 3 additions & 2 deletions src/common/privsep_op/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ add_library(privsep_op STATIC src/privsep_op.c)

get_filename_component(COMMON_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/../ ABSOLUTE)
target_include_directories(privsep_op PUBLIC include)
include_directories(${COMMON_FOLDER}/pal/include)
include_directories(${COMMON_FOLDER}/error_messages/include)
target_include_directories(privsep_op PUBLIC
${COMMON_FOLDER}/error_messages/include
${COMMON_FOLDER}/pal/include)

target_link_libraries(privsep_op utils time_op Logger)
5 changes: 3 additions & 2 deletions src/common/pthreads_op/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ add_library(pthreads_op STATIC src/pthreads_op.c)

get_filename_component(COMMON_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/../ ABSOLUTE)
target_include_directories(pthreads_op PUBLIC include)
include_directories(${COMMON_FOLDER}/pal/include)
include_directories(${COMMON_FOLDER}/error_messages/include)
target_include_directories(pthreads_op PUBLIC
${COMMON_FOLDER}/error_messages/include
${COMMON_FOLDER}/pal/include)

target_link_libraries(pthreads_op utils time_op Logger)
7 changes: 4 additions & 3 deletions src/common/randombytes/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
add_library(randombytes STATIC src/randombytes.c)

get_filename_component(COMMON_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/../ ABSOLUTE)
target_include_directories(randombytes PUBLIC include)
include_directories(${COMMON_FOLDER}/pal/include)
include_directories(${COMMON_FOLDER}/error_messages/include)
target_include_directories(randombytes PUBLIC
include
${COMMON_FOLDER}/error_messages/include
${COMMON_FOLDER}/pal/include)

target_link_libraries(randombytes
utils
Expand Down
7 changes: 4 additions & 3 deletions src/common/regex_op/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
add_library(regex_op STATIC src/regex_op.c)

get_filename_component(COMMON_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/../ ABSOLUTE)
target_include_directories(regex_op PUBLIC include)
include_directories(${COMMON_FOLDER}/pal/include)
include_directories(${COMMON_FOLDER}/error_messages/include)
target_include_directories(regex_op PUBLIC
include
${COMMON_FOLDER}/error_messages/include
${COMMON_FOLDER}/pal/include)

target_link_libraries(regex_op utils Logger time_op)
11 changes: 6 additions & 5 deletions src/common/time_op/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
add_library(time_op STATIC src/time_op.c)

get_filename_component(COMMON_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/../ ABSOLUTE)
target_include_directories(time_op PUBLIC include)
include_directories(${COMMON_FOLDER}/pal/include)
include_directories(${COMMON_FOLDER}/regex_op/include)
include_directories(${COMMON_FOLDER}/error_messages/include)
include_directories(${COMMON_FOLDER}/utils/include)
target_include_directories(time_op PUBLIC
include
${COMMON_FOLDER}/error_messages/include
${COMMON_FOLDER}/pal/include
${COMMON_FOLDER}/regex_op/include
${COMMON_FOLDER}/utils/include)

target_link_libraries(time_op utils Logger)
15 changes: 7 additions & 8 deletions src/common/version_op/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
add_library(version_op STATIC src/version_op.c)

get_filename_component(COMMON_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/../ ABSOLUTE)
target_include_directories(version_op PUBLIC include)
include_directories(${COMMON_FOLDER}/pal/include)
include_directories(${COMMON_FOLDER}/error_messages/include)
include_directories(${COMMON_FOLDER}/utils/include)
include_directories(${COMMON_FOLDER}/file_op/include)
include_directories(${COMMON_FOLDER}/regex_op/include)
include_directories(${COMMON_FOLDER}/binaries_op/include)
include_directories(${COMMON_FOLDER}/pal/include)
target_include_directories(version_op PUBLIC
include
${COMMON_FOLDER}/binaries_op/include
${COMMON_FOLDER}/file_op/include
${COMMON_FOLDER}/pal/include
${COMMON_FOLDER}/regex_op/include
${COMMON_FOLDER}/utils/include)

target_link_libraries(version_op
utils
Expand Down
6 changes: 3 additions & 3 deletions src/modules/inventory/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ add_library(Inventory
src/inventory.cpp
src/inventoryImp.cpp
src/inventoryNormalizer.cpp)

if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(Inventory PRIVATE /WX-)
endif()
Expand All @@ -30,13 +30,13 @@ target_include_directories(Inventory PUBLIC
${COMMON_FOLDER}/dbsync/include
${COMMON_FOLDER}/error_messages/include
${COMMON_FOLDER}/hashHelper/include
${COMMON_FOLDER}/pal/include
${COMMON_FOLDER}/privsep_op/include
${COMMON_FOLDER}/pthreads_op/include
${COMMON_FOLDER}/stringHelper/include
${COMMON_FOLDER}/time_op/include
${COMMON_FOLDER}/timeHelper/include
${COMMON_FOLDER}/utils
${COMMON_FOLDER}/pal/include)
${COMMON_FOLDER}/utils)

target_link_libraries(Inventory
PUBLIC
Expand Down

0 comments on commit b9c6000

Please sign in to comment.