Skip to content

Commit b671a6f

Browse files
committed
chore(falco): apply code formatting
Signed-off-by: Poiana <[email protected]>
1 parent 11bac9d commit b671a6f

File tree

169 files changed

+8745
-9603
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+8745
-9603
lines changed

CMakeLists.txt

+133-75
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
#
33
# Copyright (C) 2023 The Falco Authors.
44
#
5-
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
6-
# the License. You may obtain a copy of the License at
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6+
# in compliance with the License. You may obtain a copy of the License at
77
#
88
# http://www.apache.org/licenses/LICENSE-2.0
99
#
10-
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
11-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
12-
# specific language governing permissions and limitations under the License.
10+
# Unless required by applicable law or agreed to in writing, software distributed under the License
11+
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12+
# or implied. See the License for the specific language governing permissions and limitations under
13+
# the License.
1314
#
1415
cmake_minimum_required(VERSION 3.5.1)
1516

@@ -18,62 +19,82 @@ project(falco)
1819
option(USE_BUNDLED_DEPS "Bundle hard to find dependencies into the Falco binary" ON)
1920
option(USE_DYNAMIC_LIBELF "Dynamically link libelf" ON)
2021
option(BUILD_WARNINGS_AS_ERRORS "Enable building with -Wextra -Werror flags" OFF)
21-
option(MINIMAL_BUILD "Build a minimal version of Falco, containing only the engine and basic input/output (EXPERIMENTAL)" OFF)
22+
option(
23+
MINIMAL_BUILD
24+
"Build a minimal version of Falco, containing only the engine and basic input/output (EXPERIMENTAL)"
25+
OFF
26+
)
2227
option(MUSL_OPTIMIZED_BUILD "Enable if you want a musl optimized build" OFF)
2328
option(BUILD_FALCO_UNIT_TESTS "Build falco unit tests" OFF)
2429
option(USE_ASAN "Build with AddressSanitizer" OFF)
2530
option(USE_UBSAN "Build with UndefinedBehaviorSanitizer" OFF)
2631
option(UBSAN_HALT_ON_ERROR "Halt on error when building with UBSan" ON)
2732

2833
if(WIN32)
29-
if(POLICY CMP0091)
30-
# Needed for CMAKE_MSVC_RUNTIME_LIBRARY
31-
# https://cmake.org/cmake/help/latest/policy/CMP0091.html
32-
cmake_policy(SET CMP0091 NEW)
33-
endif()
34+
if(POLICY CMP0091)
35+
# Needed for CMAKE_MSVC_RUNTIME_LIBRARY
36+
# https://cmake.org/cmake/help/latest/policy/CMP0091.html
37+
cmake_policy(SET CMP0091 NEW)
38+
endif()
3439
set(CPACK_GENERATOR "NSIS") # this needs NSIS installed, and available
35-
elseif (APPLE)
40+
elseif(APPLE)
3641
set(CPACK_GENERATOR "DragNDrop")
3742
elseif(EMSCRIPTEN)
38-
set(USE_BUNDLED_DEPS ON CACHE BOOL "" FORCE)
39-
set(BUILD_DRIVER OFF CACHE BOOL "" FORCE)
40-
set(ENABLE_DKMS OFF CACHE BOOL "" FORCE)
41-
set(BUILD_BPF OFF CACHE BOOL "" FORCE)
42-
set(CPACK_GENERATOR TGZ CACHE BOOL "" FORCE)
43+
set(USE_BUNDLED_DEPS
44+
ON
45+
CACHE BOOL "" FORCE
46+
)
47+
set(BUILD_DRIVER
48+
OFF
49+
CACHE BOOL "" FORCE
50+
)
51+
set(ENABLE_DKMS
52+
OFF
53+
CACHE BOOL "" FORCE
54+
)
55+
set(BUILD_BPF
56+
OFF
57+
CACHE BOOL "" FORCE
58+
)
59+
set(CPACK_GENERATOR
60+
TGZ
61+
CACHE BOOL "" FORCE
62+
)
4363
endif()
4464

4565
# gVisor is currently only supported on Linux x86_64
46-
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT MINIMAL_BUILD)
47-
option(BUILD_FALCO_GVISOR "Build gVisor support for Falco" ON)
48-
if (BUILD_FALCO_GVISOR)
49-
add_definitions(-DHAS_GVISOR)
50-
endif()
66+
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64"
67+
AND CMAKE_SYSTEM_NAME MATCHES "Linux"
68+
AND NOT MINIMAL_BUILD
69+
)
70+
option(BUILD_FALCO_GVISOR "Build gVisor support for Falco" ON)
71+
if(BUILD_FALCO_GVISOR)
72+
add_definitions(-DHAS_GVISOR)
73+
endif()
5174
endif()
5275

5376
# Modern BPF is not supported on not Linux systems and in MINIMAL_BUILD
5477
if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT MINIMAL_BUILD)
55-
option(BUILD_FALCO_MODERN_BPF "Build modern BPF support for Falco" ON)
56-
if(BUILD_FALCO_MODERN_BPF)
57-
add_definitions(-DHAS_MODERN_BPF)
58-
endif()
78+
option(BUILD_FALCO_MODERN_BPF "Build modern BPF support for Falco" ON)
79+
if(BUILD_FALCO_MODERN_BPF)
80+
add_definitions(-DHAS_MODERN_BPF)
81+
endif()
5982
endif()
6083

6184
# We shouldn't need to set this, see https://gitlab.kitware.com/cmake/cmake/-/issues/16419
6285
option(EP_UPDATE_DISCONNECTED "ExternalProject update disconnected" OFF)
63-
if (${EP_UPDATE_DISCONNECTED})
64-
set_property(
65-
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
66-
PROPERTY EP_UPDATE_DISCONNECTED TRUE)
86+
if(${EP_UPDATE_DISCONNECTED})
87+
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY EP_UPDATE_DISCONNECTED TRUE)
6788
endif()
6889

69-
# Elapsed time
70-
# set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_COMMAND} -E time") # TODO(fntlnz, leodido): add a flag to enable this
90+
# Elapsed time set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_COMMAND} -E time") #
91+
# TODO(fntlnz, leodido): add a flag to enable this
7192

7293
# Make flag for parallel processing
7394
include(ProcessorCount)
74-
processorcount(PROCESSOR_COUNT)
95+
ProcessorCount(PROCESSOR_COUNT)
7596
if(NOT PROCESSOR_COUNT EQUAL 0)
76-
set(PROCESSOUR_COUNT_MAKE_FLAG -j${PROCESSOR_COUNT})
97+
set(PROCESSOUR_COUNT_MAKE_FLAG -j${PROCESSOR_COUNT})
7798
endif()
7899

79100
# Custom CMake modules
@@ -83,14 +104,14 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
83104
include(GNUInstallDirs)
84105

85106
if(NOT DEFINED FALCO_ETC_DIR)
86-
set(FALCO_ETC_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/falco")
107+
set(FALCO_ETC_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/falco")
87108
endif()
88109

89110
# This will be used to print the architecture for which Falco is compiled.
90-
if (EMSCRIPTEN)
91-
set(FALCO_TARGET_ARCH "wasm")
111+
if(EMSCRIPTEN)
112+
set(FALCO_TARGET_ARCH "wasm")
92113
else()
93-
set(FALCO_TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR})
114+
set(FALCO_TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR})
94115
endif()
95116

96117
include(CompilerFlags)
@@ -100,19 +121,20 @@ set(DRIVER_NAME "falco")
100121
set(DRIVER_DEVICE_NAME "falco")
101122
set(DRIVERS_REPO "https://download.falco.org/driver")
102123

103-
# If no path is provided, try to search the BPF probe in: `home/.falco/falco-bpf.o`
104-
# This is the same fallback that we had in the libraries: `SCAP_PROBE_BPF_FILEPATH`.
124+
# If no path is provided, try to search the BPF probe in: `home/.falco/falco-bpf.o` This is the same
125+
# fallback that we had in the libraries: `SCAP_PROBE_BPF_FILEPATH`.
105126
set(FALCO_PROBE_BPF_FILEPATH ".${DRIVER_NAME}/${DRIVER_NAME}-bpf.o")
106127
add_definitions(-DFALCO_PROBE_BPF_FILEPATH="${FALCO_PROBE_BPF_FILEPATH}")
107128

108129
if(NOT DEFINED FALCO_COMPONENT_NAME)
109-
set(FALCO_COMPONENT_NAME "${CMAKE_PROJECT_NAME}")
130+
set(FALCO_COMPONENT_NAME "${CMAKE_PROJECT_NAME}")
110131
endif()
111132

112133
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
113-
set(CMAKE_INSTALL_PREFIX
114-
/usr
115-
CACHE PATH "Default install path" FORCE)
134+
set(CMAKE_INSTALL_PREFIX
135+
/usr
136+
CACHE PATH "Default install path" FORCE
137+
)
116138
endif()
117139

118140
set(CMD_MAKE make)
@@ -131,61 +153,93 @@ include(njson)
131153
# yaml-cpp
132154
include(yaml-cpp)
133155

134-
if(NOT WIN32 AND NOT APPLE AND NOT MINIMAL_BUILD AND NOT EMSCRIPTEN)
135-
# OpenSSL
136-
include(openssl)
156+
if(NOT WIN32
157+
AND NOT APPLE
158+
AND NOT MINIMAL_BUILD
159+
AND NOT EMSCRIPTEN
160+
)
161+
# OpenSSL
162+
include(openssl)
137163

138-
# libcurl
139-
include(curl)
164+
# libcurl
165+
include(curl)
140166

141-
# todo(jasondellaluce,rohith-raju): support webserver for non-linux builds too
142-
# cpp-httlib
143-
include(cpp-httplib)
167+
# todo(jasondellaluce,rohith-raju): support webserver for non-linux builds too cpp-httlib
168+
include(cpp-httplib)
144169
endif()
145170

146171
include(cxxopts)
147172

148173
# One TBB
149-
if (NOT EMSCRIPTEN)
150-
include(tbb)
174+
if(NOT EMSCRIPTEN)
175+
include(tbb)
151176
endif()
152177

153178
include(zlib)
154179
include(valijson)
155-
if (NOT MINIMAL_BUILD)
156-
if (NOT WIN32 AND NOT APPLE AND NOT EMSCRIPTEN)
157-
include(cares)
158-
include(protobuf)
159-
# gRPC
160-
include(grpc)
161-
endif()
180+
if(NOT MINIMAL_BUILD)
181+
if(NOT WIN32
182+
AND NOT APPLE
183+
AND NOT EMSCRIPTEN
184+
)
185+
include(cares)
186+
include(protobuf)
187+
# gRPC
188+
include(grpc)
189+
endif()
162190
endif()
163191

164192
# Installation
165193
if(WIN32)
166-
set(FALCO_INSTALL_CONF_FILE "%PROGRAMFILES%/${PACKAGE_NAME}-${FALCO_VERSION}/etc/falco/falco.yaml")
167-
install(FILES falco.yaml DESTINATION etc/falco/ COMPONENT "${FALCO_COMPONENT_NAME}")
168-
install(DIRECTORY DESTINATION etc/falco/config.d COMPONENT "${FALCO_COMPONENT_NAME}")
194+
set(FALCO_INSTALL_CONF_FILE
195+
"%PROGRAMFILES%/${PACKAGE_NAME}-${FALCO_VERSION}/etc/falco/falco.yaml"
196+
)
197+
install(
198+
FILES falco.yaml
199+
DESTINATION etc/falco/
200+
COMPONENT "${FALCO_COMPONENT_NAME}"
201+
)
202+
install(
203+
DIRECTORY
204+
DESTINATION etc/falco/config.d
205+
COMPONENT "${FALCO_COMPONENT_NAME}"
206+
)
169207
elseif(APPLE)
170208
set(FALCO_INSTALL_CONF_FILE "/etc/falco/falco.yaml")
171-
install(FILES falco.yaml DESTINATION etc/falco/ COMPONENT "${FALCO_COMPONENT_NAME}")
172-
install(DIRECTORY DESTINATION etc/falco/config.d COMPONENT "${FALCO_COMPONENT_NAME}")
209+
install(
210+
FILES falco.yaml
211+
DESTINATION etc/falco/
212+
COMPONENT "${FALCO_COMPONENT_NAME}"
213+
)
214+
install(
215+
DIRECTORY
216+
DESTINATION etc/falco/config.d
217+
COMPONENT "${FALCO_COMPONENT_NAME}"
218+
)
173219
else()
174220
set(FALCO_INSTALL_CONF_FILE "/etc/falco/falco.yaml")
175-
install(FILES falco.yaml DESTINATION "${FALCO_ETC_DIR}" COMPONENT "${FALCO_COMPONENT_NAME}")
176-
install(DIRECTORY DESTINATION "${FALCO_ETC_DIR}/config.d" COMPONENT "${FALCO_COMPONENT_NAME}")
221+
install(
222+
FILES falco.yaml
223+
DESTINATION "${FALCO_ETC_DIR}"
224+
COMPONENT "${FALCO_COMPONENT_NAME}"
225+
)
226+
install(
227+
DIRECTORY
228+
DESTINATION "${FALCO_ETC_DIR}/config.d"
229+
COMPONENT "${FALCO_COMPONENT_NAME}"
230+
)
177231
endif()
178232

179233
if(NOT MINIMAL_BUILD)
180-
# Coverage
181-
include(Coverage)
234+
# Coverage
235+
include(Coverage)
182236
endif()
183237

184238
# Rules
185239
include(rules)
186240

187-
# Clang format
188-
# add_custom_target(format COMMAND clang-format --style=file -i $<TARGET_PROPERTY:falco,SOURCES> COMMENT "Formatting ..." VERBATIM)
241+
# Clang format add_custom_target(format COMMAND clang-format --style=file -i
242+
# $<TARGET_PROPERTY:falco,SOURCES> COMMENT "Formatting ..." VERBATIM)
189243

190244
# Static analysis
191245
include(static-analysis)
@@ -199,13 +253,17 @@ add_subdirectory(scripts)
199253
add_subdirectory(userspace/engine)
200254
add_subdirectory(userspace/falco)
201255

202-
if(NOT WIN32 AND NOT APPLE AND NOT EMSCRIPTEN AND NOT MUSL_OPTIMIZED_BUILD)
203-
include(falcoctl)
256+
if(NOT WIN32
257+
AND NOT APPLE
258+
AND NOT EMSCRIPTEN
259+
AND NOT MUSL_OPTIMIZED_BUILD
260+
)
261+
include(falcoctl)
204262
endif()
205263

206264
# Packages configuration
207265
include(CPackConfig)
208266

209267
if(BUILD_FALCO_UNIT_TESTS)
210-
add_subdirectory(unit_tests)
268+
add_subdirectory(unit_tests)
211269
endif()

cmake/cpack/CMakeCPackOptions.cmake

+41-12
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,53 @@
22
#
33
# Copyright (C) 2023 The Falco Authors.
44
#
5-
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
6-
# the License. You may obtain a copy of the License at
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6+
# in compliance with the License. You may obtain a copy of the License at
77
#
88
# http://www.apache.org/licenses/LICENSE-2.0
99
#
10-
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
11-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
12-
# specific language governing permissions and limitations under the License.
10+
# Unless required by applicable law or agreed to in writing, software distributed under the License
11+
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12+
# or implied. See the License for the specific language governing permissions and limitations under
13+
# the License.
1314
#
1415

1516
if(CPACK_GENERATOR MATCHES "DEB" OR CPACK_GENERATOR MATCHES "RPM")
16-
list(APPEND CPACK_INSTALL_COMMANDS "mkdir -p _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/usr/lib/systemd/system")
17-
list(APPEND CPACK_INSTALL_COMMANDS "cp scripts/systemd/falco-kmod-inject.service _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/usr/lib/systemd/system")
18-
list(APPEND CPACK_INSTALL_COMMANDS "cp scripts/systemd/falco-kmod.service _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/usr/lib/systemd/system")
19-
list(APPEND CPACK_INSTALL_COMMANDS "cp scripts/systemd/falco-bpf.service _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/usr/lib/systemd/system")
20-
list(APPEND CPACK_INSTALL_COMMANDS "cp scripts/systemd/falco-modern-bpf.service _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/usr/lib/systemd/system")
21-
list(APPEND CPACK_INSTALL_COMMANDS "cp scripts/systemd/falco-custom.service _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/usr/lib/systemd/system")
22-
list(APPEND CPACK_INSTALL_COMMANDS "cp scripts/systemd/falcoctl-artifact-follow.service _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/usr/lib/systemd/system")
17+
list(
18+
APPEND
19+
CPACK_INSTALL_COMMANDS
20+
"mkdir -p _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/usr/lib/systemd/system"
21+
)
22+
list(
23+
APPEND
24+
CPACK_INSTALL_COMMANDS
25+
"cp scripts/systemd/falco-kmod-inject.service _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/usr/lib/systemd/system"
26+
)
27+
list(
28+
APPEND
29+
CPACK_INSTALL_COMMANDS
30+
"cp scripts/systemd/falco-kmod.service _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/usr/lib/systemd/system"
31+
)
32+
list(
33+
APPEND
34+
CPACK_INSTALL_COMMANDS
35+
"cp scripts/systemd/falco-bpf.service _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/usr/lib/systemd/system"
36+
)
37+
list(
38+
APPEND
39+
CPACK_INSTALL_COMMANDS
40+
"cp scripts/systemd/falco-modern-bpf.service _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/usr/lib/systemd/system"
41+
)
42+
list(
43+
APPEND
44+
CPACK_INSTALL_COMMANDS
45+
"cp scripts/systemd/falco-custom.service _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/usr/lib/systemd/system"
46+
)
47+
list(
48+
APPEND
49+
CPACK_INSTALL_COMMANDS
50+
"cp scripts/systemd/falcoctl-artifact-follow.service _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/usr/lib/systemd/system"
51+
)
2352
endif()
2453

2554
if(CPACK_GENERATOR MATCHES "TGZ")

0 commit comments

Comments
 (0)