Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use absolute include paths #1509

Merged
merged 11 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
19 changes: 9 additions & 10 deletions cmake/modules/libscap.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
if(NOT HAVE_LIBSCAP)
set(HAVE_LIBSCAP On)

# This should be renamed in `LIBS_DIR` not `LIBSCAP_DIR`
if(NOT LIBSCAP_DIR)
get_filename_component(LIBSCAP_DIR ${CMAKE_CURRENT_LIST_DIR}/../.. ABSOLUTE)
if(NOT LIBS_DIR)
get_filename_component(LIBS_DIR ${CMAKE_CURRENT_LIST_DIR}/../.. ABSOLUTE)
endif()

option(USE_BUNDLED_DEPS "Enable bundled dependencies instead of using the system ones" ON)
Expand Down Expand Up @@ -54,8 +53,8 @@ else()
get_filename_component(DRIVER_CONFIG_DIR ${PROJECT_SOURCE_DIR}/driver ABSOLUTE)
endif()

get_filename_component(LIBSCAP_INCLUDE_DIR ${LIBSCAP_DIR}/userspace/libscap ABSOLUTE)
set(LIBSCAP_INCLUDE_DIRS ${LIBSCAP_INCLUDE_DIR} ${PROJECT_BINARY_DIR}/libscap ${DRIVER_CONFIG_DIR})
get_filename_component(LIBSCAP_INCLUDE_DIR ${LIBS_DIR}/userspace/libscap ABSOLUTE)
set(LIBSCAP_INCLUDE_DIRS ${LIBSCAP_INCLUDE_DIR} ${PROJECT_BINARY_DIR} ${DRIVER_CONFIG_DIR})

function(set_scap_target_properties target)
set_target_properties(${target} PROPERTIES
Expand All @@ -64,14 +63,14 @@ function(set_scap_target_properties target)
)
endfunction()

add_subdirectory(${LIBSCAP_DIR}/userspace/libscap ${PROJECT_BINARY_DIR}/libscap)
add_subdirectory(${LIBS_DIR}/userspace/libscap ${PROJECT_BINARY_DIR}/libscap)

set(LIBSCAP_INSTALL_LIBS)

# All of the targets in userspace/libscap
get_directory_property(libscap_subdirs DIRECTORY ${LIBSCAP_DIR}/userspace/libscap SUBDIRECTORIES)
get_directory_property(libscap_subdirs DIRECTORY ${LIBS_DIR}/userspace/libscap SUBDIRECTORIES)
set(libscap_subdir_targets)
foreach(libscap_subdir ${LIBSCAP_DIR}/userspace/libscap ${libscap_subdirs})
foreach(libscap_subdir ${LIBS_DIR}/userspace/libscap ${libscap_subdirs})
get_directory_property(subdir_targets DIRECTORY ${libscap_subdir} BUILDSYSTEM_TARGETS)
list(APPEND libscap_subdir_targets ${subdir_targets})
endforeach()
Expand Down Expand Up @@ -119,7 +118,7 @@ endforeach()

string(REPLACE ";" " " LIBSCAP_LINK_LIBRARIES_FLAGS "${libscap_link_flags}")
string(REPLACE ";" " " LIBSCAP_LINK_LIBDIRS_FLAGS "${libscap_link_libdirs}")
configure_file(${LIBSCAP_DIR}/userspace/libscap/libscap.pc.in ${PROJECT_BINARY_DIR}/libscap/libscap.pc @ONLY)
configure_file(${LIBS_DIR}/userspace/libscap/libscap.pc.in ${PROJECT_BINARY_DIR}/libscap/libscap.pc @ONLY)

install(TARGETS ${LIBSCAP_INSTALL_LIBS}
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
Expand All @@ -134,7 +133,7 @@ install(DIRECTORY "${LIBSCAP_INCLUDE_DIR}" DESTINATION "${CMAKE_INSTALL_INCLUDED
install(DIRECTORY "${DRIVER_CONFIG_DIR}/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBS_PACKAGE_NAME}/driver"
COMPONENT "scap"
FILES_MATCHING PATTERN "*.h")
install(DIRECTORY "${LIBSCAP_DIR}/userspace/plugin" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBS_PACKAGE_NAME}/userspace"
install(DIRECTORY "${LIBS_DIR}/userspace/plugin" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBS_PACKAGE_NAME}/userspace"
COMPONENT "scap"
FILES_MATCHING PATTERN "*.h")
install(FILES ${PROJECT_BINARY_DIR}/libscap/scap_config.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${LIBS_PACKAGE_NAME}/userspace/libscap)
Expand Down
17 changes: 7 additions & 10 deletions cmake/modules/libsinsp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
if(NOT HAVE_LIBSINSP)
set(HAVE_LIBSINSP On)

if(NOT LIBSINSP_DIR)
get_filename_component(LIBSINSP_DIR ${CMAKE_CURRENT_LIST_DIR}/../.. ABSOLUTE)
if(NOT LIBS_DIR)
get_filename_component(LIBS_DIR ${CMAKE_CURRENT_LIST_DIR}/../.. ABSOLUTE)
endif()

option(USE_BUNDLED_DEPS "Enable bundled dependencies instead of using the system ones" ON)
Expand All @@ -40,10 +40,7 @@ include(jsoncpp)
include(valijson)
include(re2)

set(LIBSINSP_INCLUDE_DIRS ${LIBSINSP_DIR}/userspace/libsinsp ${LIBSCAP_INCLUDE_DIRS} ${DRIVER_CONFIG_DIR})
if(WITH_CHISEL)
list(APPEND LIBSINSP_INCLUDE_DIRS ${LIBSINSP_DIR}/userspace/chisel)
endif()
set(LIBSINSP_INCLUDE_DIRS ${LIBS_DIR} ${LIBS_DIR}/userspace ${LIBSCAP_INCLUDE_DIRS} ${DRIVER_CONFIG_DIR})

if (NOT EMSCRIPTEN)
get_filename_component(TBB_ABSOLUTE_INCLUDE_DIR ${TBB_INCLUDE_DIR} ABSOLUTE)
Expand Down Expand Up @@ -76,25 +73,25 @@ function(set_sinsp_target_properties target)
)
endfunction()

add_subdirectory(${LIBSINSP_DIR}/userspace/libsinsp ${CMAKE_BINARY_DIR}/libsinsp)
add_subdirectory(${LIBS_DIR}/userspace/libsinsp ${CMAKE_BINARY_DIR}/libsinsp)
install(TARGETS sinsp
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
COMPONENT "sinsp")
install(DIRECTORY "${LIBSINSP_DIR}/userspace/libsinsp" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBS_PACKAGE_NAME}/userspace"
install(DIRECTORY "${LIBS_DIR}/userspace/libsinsp" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBS_PACKAGE_NAME}/userspace"
COMPONENT "sinsp"
FILES_MATCHING PATTERN "*.h"
PATTERN "*third_party*" EXCLUDE
PATTERN "*examples*" EXCLUDE
PATTERN "*doxygen*" EXCLUDE
PATTERN "*scripts*" EXCLUDE
PATTERN "*test*" EXCLUDE)
install(DIRECTORY "${LIBSINSP_DIR}/userspace/async" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBS_PACKAGE_NAME}/userspace"
install(DIRECTORY "${LIBS_DIR}/userspace/async" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBS_PACKAGE_NAME}/userspace"
COMPONENT "sinsp"
FILES_MATCHING PATTERN "*.h")
if(WITH_CHISEL)
install(DIRECTORY "${LIBSINSP_DIR}/userspace/chisel" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBS_PACKAGE_NAME}/userspace"
install(DIRECTORY "${LIBS_DIR}/userspace/chisel" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBS_PACKAGE_NAME}/userspace"
COMPONENT "sinsp"
FILES_MATCHING PATTERN "*.h")
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/uthash.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

option(USE_BUNDLED_UTHASH "Enable downloading of the bundled uthash library" ${USE_BUNDLED_DEPS})
set(UTHASH_DOWNLOAD_URL "https://raw.githubusercontent.com/troydhanson/uthash/v1.9.8/src/uthash.h")
set(UTHASH_DOWNLOAD_DIR "${LIBSCAP_DIR}/userspace/libscap")
set(UTHASH_DOWNLOAD_DIR "${LIBS_DIR}/userspace/libscap")

if(UTHASH_INCLUDE)
# we already have uthash
Expand Down
2 changes: 1 addition & 1 deletion driver/modern_bpf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ list(APPEND MODERN_PROBE_INCLUDE "-I${CMAKE_CURRENT_SOURCE_DIR}")

# Note here we use the libs root directory since we want to avoid conflicts between the `bpf` folder inside
# `driver` and the `libbpf` includes.
set(PPM_INCLUDE ${LIBSCAP_DIR})
set(PPM_INCLUDE ${LIBS_DIR})

## Set CLANG FLAGS
set(CLANG_FLAGS "")
Expand Down
2 changes: 1 addition & 1 deletion driver/modern_bpf/helpers/base/stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#pragma once

#include <helpers/base/common.h>
#include <shared_definitions/struct_definitions.h>
#include <driver/modern_bpf/shared_definitions/struct_definitions.h>
#include <driver/ppm_events_public.h>

/////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion driver/modern_bpf/maps/maps.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#pragma once

#include <helpers/base/common.h>
#include <shared_definitions/struct_definitions.h>
#include <driver/modern_bpf/shared_definitions/struct_definitions.h>
#include <driver/ppm_events_public.h>
#include <driver/driver_config.h>

Expand Down
2 changes: 1 addition & 1 deletion test/drivers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ set(DRIVERS_TEST_SOURCES
set(DRIVERS_TEST_INCLUDE
PRIVATE
"${GTEST_INCLUDE}"
"${LIBSCAP_DIR}/driver/"
"${LIBS_DIR}/driver/"
"${LIBSCAP_INCLUDE_DIRS}"
)

Expand Down
2 changes: 1 addition & 1 deletion test/drivers/event_class/event_class.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "strl.h"
#include <libscap/strl.h>
#include "event_class.h"
#include <time.h>

Expand Down
6 changes: 3 additions & 3 deletions test/drivers/event_class/event_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
#include "network_utils.h"
#include <arpa/inet.h>
#include <sys/un.h>
#include <scap.h>
#include <libscap/scap.h>

#define CURRENT_PID -1
#define CURRENT_EVENT_TYPE -1

extern "C"
{
#include <ppm_events_public.h>
#include <feature_gates.h>
#include <driver/ppm_events_public.h>
#include <driver/feature_gates.h>
}

struct param
Expand Down
2 changes: 1 addition & 1 deletion test/drivers/flags/capabilities.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "flags_definitions.h"
#include <ppm_events_public.h>
#include <driver/ppm_events_public.h>

#ifdef __NR_capget

Expand Down
8 changes: 4 additions & 4 deletions test/drivers/start_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include <iostream>
#include <string>
#include <scap.h>
#include <scap_engines.h>
#include <scap_vtable.h>
#include <libscap/scap.h>
#include <libscap/scap_engines.h>
#include <libscap/scap_vtable.h>
#include <getopt.h>
#include <gtest/gtest.h>
#include "./event_class/event_class.h"
#include "strl.h"
#include <libscap/strl.h>

/* We support only these arguments */
#define HELP_OPTION "help"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "strl.h"
#include <libscap/strl.h>
#include "../../event_class/event_class.h"
#include <sys/mount.h>

Expand Down
6 changes: 3 additions & 3 deletions test/libscap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ set(LIBSCAP_TESTS_INCLUDE
PRIVATE
"${GTEST_INCLUDE}"
"${CMAKE_CURRENT_SOURCE_DIR}" # for test helpers <helpers/...>
"${LIBSCAP_INCLUDE_DIRS}" # this is for libscap includes
"${CMAKE_SOURCE_DIR}/userspace/common" # used to include `strl.h`
"${CMAKE_SOURCE_DIR}/driver" # for the event_stats.h file
"${LIBS_DIR}"
"${LIBS_DIR}/userspace"
"${PROJECT_BINARY_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}" # used to include `libscap_test_var.h`
)

Expand Down
2 changes: 1 addition & 1 deletion test/libscap/helpers/engines.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <gtest/gtest.h>
#include <syscall.h>
#include <scap.h>
#include <libscap/scap.h>
#include <errno.h>
#include <fcntl.h>

Expand Down
2 changes: 1 addition & 1 deletion test/libscap/helpers/engines.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <scap.h>
#include <libscap/scap.h>

void check_event_is_not_overwritten(scap_t* h);

Expand Down
6 changes: 3 additions & 3 deletions test/libscap/test_suites/engines/bpf/bpf.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <scap.h>
#include <scap_engines.h>
#include <scap_engine_util.h>
#include <libscap/scap.h>
#include <libscap/scap_engines.h>
#include <libscap/scap_engine_util.h>
#include <gtest/gtest.h>
#include <unordered_set>
#include <helpers/engines.h>
Expand Down
4 changes: 2 additions & 2 deletions test/libscap/test_suites/engines/gvisor/gvisor_parsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ limitations under the License.

*/

#include <scap.h>
#include <libscap/scap.h>
#include <gtest/gtest.h>
#include <google/protobuf/any.pb.h>

#include <pkg/sentry/seccheck/points/syscall.pb.h>
#include <pkg/sentry/seccheck/points/sentry.pb.h>
#include <pkg/sentry/seccheck/points/container.pb.h>
#include <engine/gvisor/gvisor.h>
#include <libscap/engine/gvisor/gvisor.h>

#ifdef __x86_64__
#include "../../driver/syscall_compat_x86_64.h"
Expand Down
4 changes: 2 additions & 2 deletions test/libscap/test_suites/engines/kmod/kmod.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <scap.h>
#include <scap_engines.h>
#include <libscap/scap.h>
#include <libscap/scap_engines.h>
#include <gtest/gtest.h>
#include <unordered_set>
#include <helpers/engines.h>
Expand Down
6 changes: 3 additions & 3 deletions test/libscap/test_suites/engines/modern_bpf/modern_bpf.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <scap.h>
#include <scap_engines.h>
#include <scap_engine_util.h>
#include <libscap/scap.h>
#include <libscap/scap_engines.h>
#include <libscap/scap_engine_util.h>
#include <gtest/gtest.h>
#include <unordered_set>
#include <syscall.h>
Expand Down
2 changes: 1 addition & 1 deletion test/libscap/test_suites/userspace/common_strl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
*/

#include <gtest/gtest.h>
#include "strl.h"
#include <libscap/strl.h>

static const char* s_10_chars = "0123456789";
static const char* s_20_chars = "abcdefghijklmnopqrst";
Expand Down
4 changes: 2 additions & 2 deletions test/libscap/test_suites/userspace/event_table.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "scap.h"
#include <libscap/scap.h>
#include <gtest/gtest.h>
#include <event_stats.h>
#include <driver/event_stats.h>

TEST(event_table, scap_get_syscall_category_from_event)
{
Expand Down
4 changes: 2 additions & 2 deletions test/libscap/test_suites/userspace/linux/scap_cgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ limitations under the License.
*/

#include <gtest/gtest.h>
#include <linux/scap_cgroup.h>
#include <linux/scap_cgroup.c>
#include <libscap/linux/scap_cgroup.h>
#include <libscap/linux/scap_cgroup.c>

TEST(cgroups, path_relative)
{
Expand Down
2 changes: 1 addition & 1 deletion test/libscap/test_suites/userspace/ppm_sc_names_table.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "scap.h"
#include <libscap/scap.h>
#include <gtest/gtest.h>

TEST(ppm_sc_names, scap_get_ppm_sc_name)
Expand Down
2 changes: 1 addition & 1 deletion test/libscap/test_suites/userspace/scap_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

*/

#include <scap.h>
#include <libscap/scap.h>
#include <gtest/gtest.h>

// fills the buffer with ASCII data to catch bugs
Expand Down
2 changes: 1 addition & 1 deletion test/libscap/test_suites/userspace/scap_ppm_sc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

*/

#include <scap.h>
#include <libscap/scap.h>
#include <gtest/gtest.h>
#include <sys/syscall.h>

Expand Down
2 changes: 1 addition & 1 deletion test/libscap/test_suites/userspace/syscall_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

*/

#include <scap.h>
#include <libscap/scap.h>
#include <gtest/gtest.h>

extern const struct syscall_evt_pair g_syscall_table[SYSCALL_TABLE_SIZE];
Expand Down
10 changes: 5 additions & 5 deletions userspace/chisel/chisel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ limitations under the License.

*/

#include "filterchecks.h"
#include <libsinsp/filterchecks.h>

#include "chisel.h"
#include "chisel_api.h"
#include "chisel_table.h"
#include "chisel_capture_interrupt_exception.h"
#include <chisel/chisel.h>
#include <chisel/chisel_api.h>
#include <chisel/chisel_table.h>
#include <chisel/chisel_capture_interrupt_exception.h>

#define HAS_LUA_CHISELS

Expand Down
4 changes: 2 additions & 2 deletions userspace/chisel/chisel.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ limitations under the License.

#pragma once

#include <sinsp.h>
#include "chisel_viewinfo.h"
#include <libsinsp/sinsp.h>
#include <chisel/chisel_viewinfo.h>

class sinsp_filter_check;

Expand Down
14 changes: 7 additions & 7 deletions userspace/chisel/chisel_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ limitations under the License.

*/

#include "strl.h"
#include "sinsp.h"
#include "sinsp_int.h"
#include "chisel.h"
#include "chisel_api.h"
#include "filter.h"
#include "filterchecks.h"
#include <libscap/strl.h>
#include <libsinsp/sinsp.h>
#include <libsinsp/sinsp_int.h>
#include <chisel/chisel.h>
#include <chisel/chisel_api.h>
#include <libsinsp/filter.h>
#include <libsinsp/filterchecks.h>
#ifdef HAS_ANALYZER
#include "analyzer.h"
#endif
Expand Down
Loading