diff --git a/CMakeLists.txt b/CMakeLists.txt index 1df3a616..7c509b18 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,9 @@ option(BUILD_FALCO_UNIT_TESTS "Build falco unit tests" OFF) if(EMSCRIPTEN) set(USE_BUNDLED_DEPS ON CACHE BOOL "" FORCE) set(BUILD_DRIVER OFF CACHE BOOL "" FORCE) + set(ENABLE_DKMS OFF CACHE BOOL "" FORCE) + set(BUILD_BPF OFF CACHE BOOL "" FORCE) + set(CPACK_GENERATOR TGZ CACHE BOOL "" FORCE) endif() # gVisor is currently only supported on Linux x86_64 @@ -223,11 +226,13 @@ add_subdirectory(scripts) add_subdirectory(userspace/engine) add_subdirectory(userspace/falco) -if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT MUSL_OPTIMIZED_BUILD) - include(plugins) -endif() +if(CMAKE_SYSTEM_NAME MATCHES "Linux") + if(NOT MUSL_OPTIMIZED_BUILD) + include(plugins) + endif() -include(falcoctl) + include(falcoctl) +endif() # Packages configuration include(CPackConfig) diff --git a/cmake/modules/CPackConfig.cmake b/cmake/modules/CPackConfig.cmake index 101ea66d..defdcfc9 100644 --- a/cmake/modules/CPackConfig.cmake +++ b/cmake/modules/CPackConfig.cmake @@ -22,14 +22,21 @@ set(CPACK_PACKAGE_VERSION_MINOR "${FALCO_VERSION_MINOR}") set(CPACK_PACKAGE_VERSION_PATCH "${FALCO_VERSION_PATCH}") set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_SYSTEM_PROCESSOR}") set(CPACK_PROJECT_CONFIG_FILE "${PROJECT_SOURCE_DIR}/cmake/cpack/CMakeCPackOptions.cmake") -set(CPACK_STRIP_FILES "ON") set(CPACK_PACKAGE_RELOCATABLE "OFF") +if (NOT EMSCRIPTEN) + set(CPACK_STRIP_FILES "ON") +endif() # Built packages will include only the following components set(CPACK_INSTALL_CMAKE_PROJECTS - "${CMAKE_CURRENT_BINARY_DIR};${FALCO_COMPONENT_NAME};${FALCO_COMPONENT_NAME};/" - "${CMAKE_CURRENT_BINARY_DIR};${DRIVER_COMPONENT_NAME};${DRIVER_COMPONENT_NAME};/" + "${CMAKE_CURRENT_BINARY_DIR};${FALCO_COMPONENT_NAME};${FALCO_COMPONENT_NAME};/" ) + +if(CMAKE_SYSTEM_NAME MATCHES "Linux") + list(APPEND CPACK_INSTALL_CMAKE_PROJECTS + "${CMAKE_CURRENT_BINARY_DIR};${DRIVER_COMPONENT_NAME};${DRIVER_COMPONENT_NAME};/") +endif() + if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT MUSL_OPTIMIZED_BUILD) # static builds do not have plugins list(APPEND CPACK_INSTALL_CMAKE_PROJECTS "${CMAKE_CURRENT_BINARY_DIR};${PLUGINS_COMPONENT_NAME};${PLUGINS_COMPONENT_NAME};/" @@ -37,7 +44,11 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT MUSL_OPTIMIZED_BUILD) # static buil endif() if(NOT CPACK_GENERATOR) + if (CMAKE_SYSTEM_NAME MATCHES "Linux") set(CPACK_GENERATOR DEB RPM TGZ) + else() + set(CPACK_GENERATOR TGZ) + endif() endif() message(STATUS "Using package generators: ${CPACK_GENERATOR}") diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index b64c6627..e669ed4d 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -15,40 +15,39 @@ # limitations under the License. # -# Systemd -file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/scripts/systemd) -configure_file("${PROJECT_SOURCE_DIR}/scripts/systemd/falco-kmod-inject.service" - "${PROJECT_BINARY_DIR}/scripts/systemd" COPYONLY) -configure_file("${PROJECT_SOURCE_DIR}/scripts/systemd/falco-kmod.service" - "${PROJECT_BINARY_DIR}/scripts/systemd" COPYONLY) -configure_file("${PROJECT_SOURCE_DIR}/scripts/systemd/falco-bpf.service" - "${PROJECT_BINARY_DIR}/scripts/systemd" COPYONLY) -configure_file("${PROJECT_SOURCE_DIR}/scripts/systemd/falco-modern-bpf.service" - "${PROJECT_BINARY_DIR}/scripts/systemd" COPYONLY) -configure_file("${PROJECT_SOURCE_DIR}/scripts/systemd/falco-custom.service" - "${PROJECT_BINARY_DIR}/scripts/systemd" COPYONLY) -configure_file("${PROJECT_SOURCE_DIR}/scripts/systemd/falcoctl-artifact-follow.service" - "${PROJECT_BINARY_DIR}/scripts/systemd" COPYONLY) - -# Debian -configure_file(debian/postinst.in debian/postinst COPYONLY) -configure_file(debian/postrm.in debian/postrm COPYONLY) -configure_file(debian/prerm.in debian/prerm COPYONLY) - -# Rpm -configure_file(rpm/postinstall.in rpm/postinstall COPYONLY) -configure_file(rpm/postuninstall.in rpm/postuninstall COPYONLY) -configure_file(rpm/preuninstall.in rpm/preuninstall COPYONLY) - -configure_file(falco-driver-loader falco-driver-loader @ONLY) - -# Install Falcoctl config file -if(NOT DEFINED FALCOCTL_ETC_DIR) - set(FALCOCTL_ETC_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/falcoctl") -endif() -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/falcoctl/falcoctl.yaml DESTINATION "${FALCOCTL_ETC_DIR}" COMPONENT "${FALCO_COMPONENT_NAME}") - if(CMAKE_SYSTEM_NAME MATCHES "Linux") + # Systemd + file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/scripts/systemd) + configure_file("${PROJECT_SOURCE_DIR}/scripts/systemd/falco-kmod-inject.service" + "${PROJECT_BINARY_DIR}/scripts/systemd" COPYONLY) + configure_file("${PROJECT_SOURCE_DIR}/scripts/systemd/falco-kmod.service" + "${PROJECT_BINARY_DIR}/scripts/systemd" COPYONLY) + configure_file("${PROJECT_SOURCE_DIR}/scripts/systemd/falco-bpf.service" + "${PROJECT_BINARY_DIR}/scripts/systemd" COPYONLY) + configure_file("${PROJECT_SOURCE_DIR}/scripts/systemd/falco-modern-bpf.service" + "${PROJECT_BINARY_DIR}/scripts/systemd" COPYONLY) + configure_file("${PROJECT_SOURCE_DIR}/scripts/systemd/falco-custom.service" + "${PROJECT_BINARY_DIR}/scripts/systemd" COPYONLY) + configure_file("${PROJECT_SOURCE_DIR}/scripts/systemd/falcoctl-artifact-follow.service" + "${PROJECT_BINARY_DIR}/scripts/systemd" COPYONLY) + + # Debian + configure_file(debian/postinst.in debian/postinst COPYONLY) + configure_file(debian/postrm.in debian/postrm COPYONLY) + configure_file(debian/prerm.in debian/prerm COPYONLY) + + # Rpm + configure_file(rpm/postinstall.in rpm/postinstall COPYONLY) + configure_file(rpm/postuninstall.in rpm/postuninstall COPYONLY) + configure_file(rpm/preuninstall.in rpm/preuninstall COPYONLY) + + configure_file(falco-driver-loader falco-driver-loader @ONLY) + # Install Falcoctl config file + if(NOT DEFINED FALCOCTL_ETC_DIR) + set(FALCOCTL_ETC_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/falcoctl") + endif() + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/falcoctl/falcoctl.yaml DESTINATION "${FALCOCTL_ETC_DIR}" COMPONENT "${FALCO_COMPONENT_NAME}") + install(PROGRAMS ${PROJECT_BINARY_DIR}/scripts/falco-driver-loader DESTINATION ${FALCO_BIN_DIR} COMPONENT "${FALCO_COMPONENT_NAME}") endif() diff --git a/userspace/falco/CMakeLists.txt b/userspace/falco/CMakeLists.txt index 6e0d6a5a..a84168de 100644 --- a/userspace/falco/CMakeLists.txt +++ b/userspace/falco/CMakeLists.txt @@ -210,4 +210,12 @@ if(MUSL_OPTIMIZED_BUILD AND CMAKE_BUILD_TYPE STREQUAL "release") ) endif() -install(TARGETS falco RUNTIME DESTINATION ${FALCO_BIN_DIR} COMPONENT "${FALCO_COMPONENT_NAME}") +if (NOT EMSCRIPTEN) + install(TARGETS falco RUNTIME DESTINATION ${FALCO_BIN_DIR} COMPONENT "${FALCO_COMPONENT_NAME}") +else() + install(FILES + "$/falco.js" + "$/falco.wasm" + DESTINATION / + COMPONENT "${FALCO_COMPONENT_NAME}") +endif()