From 7e1e7c2e420a2ada062e13d1ca6f732da5462df8 Mon Sep 17 00:00:00 2001 From: Leonardo Grasso Date: Wed, 22 Jun 2022 15:30:53 +0200 Subject: [PATCH] chore(cmake/modules): duplicate git history (part 1) Signed-off-by: Leonardo Grasso --- .../CMakeLists.txt | 0 ...{falcosecurity-libs.cmake => driver.cmake} | 0 .../CMakeLists.txt.tmp | 27 ++++++ cmake/modules/falcosecurity-libs.cmake.tmp | 86 +++++++++++++++++++ 4 files changed, 113 insertions(+) rename cmake/modules/{falcosecurity-libs-repo => driver-repo}/CMakeLists.txt (100%) rename cmake/modules/{falcosecurity-libs.cmake => driver.cmake} (100%) create mode 100644 cmake/modules/falcosecurity-libs-repo/CMakeLists.txt.tmp create mode 100644 cmake/modules/falcosecurity-libs.cmake.tmp diff --git a/cmake/modules/falcosecurity-libs-repo/CMakeLists.txt b/cmake/modules/driver-repo/CMakeLists.txt similarity index 100% rename from cmake/modules/falcosecurity-libs-repo/CMakeLists.txt rename to cmake/modules/driver-repo/CMakeLists.txt diff --git a/cmake/modules/falcosecurity-libs.cmake b/cmake/modules/driver.cmake similarity index 100% rename from cmake/modules/falcosecurity-libs.cmake rename to cmake/modules/driver.cmake diff --git a/cmake/modules/falcosecurity-libs-repo/CMakeLists.txt.tmp b/cmake/modules/falcosecurity-libs-repo/CMakeLists.txt.tmp new file mode 100644 index 00000000..0b82aa90 --- /dev/null +++ b/cmake/modules/falcosecurity-libs-repo/CMakeLists.txt.tmp @@ -0,0 +1,27 @@ +# +# Copyright (C) 2020 The Falco Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. +# +cmake_minimum_required(VERSION 3.5.1) + +project(falcosecurity-libs-repo NONE) + +include(ExternalProject) +message(STATUS "Driver version: ${FALCOSECURITY_LIBS_VERSION}") + +ExternalProject_Add( + falcosecurity-libs + URL "https://github.com/falcosecurity/libs/archive/${FALCOSECURITY_LIBS_VERSION}.tar.gz" + URL_HASH "${FALCOSECURITY_LIBS_CHECKSUM}" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "") diff --git a/cmake/modules/falcosecurity-libs.cmake.tmp b/cmake/modules/falcosecurity-libs.cmake.tmp new file mode 100644 index 00000000..c198e0bf --- /dev/null +++ b/cmake/modules/falcosecurity-libs.cmake.tmp @@ -0,0 +1,86 @@ +# +# Copyright (C) 2021 The Falco Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. +# + +set(FALCOSECURITY_LIBS_CMAKE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/falcosecurity-libs-repo") +set(FALCOSECURITY_LIBS_CMAKE_WORKING_DIR "${CMAKE_BINARY_DIR}/falcosecurity-libs-repo") + +file(MAKE_DIRECTORY ${FALCOSECURITY_LIBS_CMAKE_WORKING_DIR}) + +if(FALCOSECURITY_LIBS_SOURCE_DIR) + set(FALCOSECURITY_LIBS_VERSION "local") + message(STATUS "Using local falcosecurity/libs in '${FALCOSECURITY_LIBS_SOURCE_DIR}'") +else() + # The falcosecurity/libs git reference (branch name, commit hash, or tag) To update falcosecurity/libs version for the next release, change the + # default below In case you want to test against another falcosecurity/libs version just pass the variable - ie., `cmake + # -DFALCOSECURITY_LIBS_VERSION=dev ..` + if(NOT FALCOSECURITY_LIBS_VERSION) + set(FALCOSECURITY_LIBS_VERSION "075da069af359954122ed7b8a9fc98bc7bcf3116") + set(FALCOSECURITY_LIBS_CHECKSUM "SHA256=4cfad3ff77afd3709cac92f244f38c998020156071138fb9edae2fb987954a84") + endif() + + # cd /path/to/build && cmake /path/to/source + execute_process(COMMAND "${CMAKE_COMMAND}" -DFALCOSECURITY_LIBS_VERSION=${FALCOSECURITY_LIBS_VERSION} -DFALCOSECURITY_LIBS_CHECKSUM=${FALCOSECURITY_LIBS_CHECKSUM} + ${FALCOSECURITY_LIBS_CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${FALCOSECURITY_LIBS_CMAKE_WORKING_DIR}) + + # todo(leodido, fntlnz) > use the following one when CMake version will be >= 3.13 + + # execute_process(COMMAND "${CMAKE_COMMAND}" -B ${FALCOSECURITY_LIBS_CMAKE_WORKING_DIR} WORKING_DIRECTORY + # "${FALCOSECURITY_LIBS_CMAKE_SOURCE_DIR}") + execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${FALCOSECURITY_LIBS_CMAKE_WORKING_DIR}") + set(FALCOSECURITY_LIBS_SOURCE_DIR "${FALCOSECURITY_LIBS_CMAKE_WORKING_DIR}/falcosecurity-libs-prefix/src/falcosecurity-libs") +endif() + +set(LIBS_PACKAGE_NAME "falcosecurity") + +add_definitions(-D_GNU_SOURCE) +add_definitions(-DHAS_CAPTURE) + +if(MUSL_OPTIMIZED_BUILD) + add_definitions(-DMUSL_OPTIMIZED) +endif() + +set(DRIVER_VERSION "${FALCOSECURITY_LIBS_VERSION}") +set(DRIVER_NAME "falco") +set(DRIVER_PACKAGE_NAME "falco") +set(DRIVER_COMPONENT_NAME "falco-driver") +set(SCAP_BPF_PROBE_ENV_VAR_NAME "FALCO_BPF_PROBE") +set(SCAP_HOST_ROOT_ENV_VAR_NAME "HOST_ROOT") + +if(NOT LIBSCAP_DIR) + set(LIBSCAP_DIR "${FALCOSECURITY_LIBS_SOURCE_DIR}") +endif() + +set(LIBSINSP_DIR "${FALCOSECURITY_LIBS_SOURCE_DIR}") + +# explicitly disable the tests/examples of this dependency +set(CREATE_TEST_TARGETS OFF CACHE BOOL "") +set(BUILD_LIBSCAP_EXAMPLES OFF CACHE BOOL "") + +set(USE_BUNDLED_TBB ON CACHE BOOL "") +set(USE_BUNDLED_B64 ON CACHE BOOL "") +set(USE_BUNDLED_JSONCPP ON CACHE BOOL "") + +list(APPEND CMAKE_MODULE_PATH "${FALCOSECURITY_LIBS_SOURCE_DIR}/cmake/modules") + +include(CheckSymbolExists) +check_symbol_exists(strlcpy "string.h" HAVE_STRLCPY) + +if(HAVE_STRLCPY) + message(STATUS "Existing strlcpy found, will *not* use local definition by setting -DHAVE_STRLCPY.") + add_definitions(-DHAVE_STRLCPY) +else() + message(STATUS "No strlcpy found, will use local definition") +endif() + +include(libscap) +include(libsinsp)