# See the License for the specific language governing permissions and
# limitations under the License
-MACRO(ADD_OSQUERY_LIBRARY IS_CORE TARGET)
+MACRO(ADD_OSQUERY_LIBRARY CROSS_PLATFORM TARGET)
ADD_LIBRARY(${TARGET} OBJECT ${ARGN})
- IF(${IS_CORE})
+ IF(${CROSS_PLATFORM})
LIST(APPEND ${TARGET_OSQUERY_LIB}_SRCS $<TARGET_OBJECTS:${TARGET}>)
SET(${TARGET_OSQUERY_LIB}_SRCS ${${TARGET_OSQUERY_LIB}_SRCS} PARENT_SCOPE)
ELSE()
- LIST(APPEND ${TARGET_OSQUERY_LIB_ADDITIONAL}_SRCS $<TARGET_OBJECTS:${TARGET}>)
- SET(${TARGET_OSQUERY_LIB_ADDITIONAL}_SRCS ${${TARGET_OSQUERY_LIB_ADDITIONAL}_SRCS} PARENT_SCOPE)
+ LIST(APPEND ${TARGET_OSQUERY_LIB_ONLY_GBS}_SRCS $<TARGET_OBJECTS:${TARGET}>)
+ SET(${TARGET_OSQUERY_LIB_ONLY_GBS}_SRCS
+ ${${TARGET_OSQUERY_LIB_ONLY_GBS}_SRCS} PARENT_SCOPE)
ENDIF()
-ENDMACRO(ADD_OSQUERY_LIBRARY TARGET)
+ENDMACRO(ADD_OSQUERY_LIBRARY)
-MACRO(ADD_OSQUERY_TEST IS_CORE)
- LIST(APPEND ${TARGET_OSQUERY_TEST}_SRCS ${ARGN})
- SET(${TARGET_OSQUERY_TEST}_SRCS ${${TARGET_OSQUERY_TEST}_SRCS} PARENT_SCOPE)
+MACRO(ADD_OSQUERY_TEST CROSS_PLATFORM)
+ IF(${CROSS_PLATFORM})
+ LIST(APPEND ${TARGET_OSQUERY_LIB}_TESTS ${ARGN})
+ SET(${TARGET_OSQUERY_LIB}_TESTS ${${TARGET_OSQUERY_LIB}_TESTS} PARENT_SCOPE)
+ ELSE()
+ LIST(APPEND ${TARGET_OSQUERY_LIB_ONLY_GBS}_TESTS ${ARGN})
+ SET(${TARGET_OSQUERY_LIB_ONLY_GBS}_TESTS
+ ${${TARGET_OSQUERY_LIB_ONLY_GBS}_TESTS} PARENT_SCOPE)
+ ENDIF()
ENDMACRO(ADD_OSQUERY_TEST)
+MACRO(ADD_OSQUERY_LINK CROSS_PLATFORM)
+ IF(${CROSS_PLATFORM})
+ LIST(APPEND ${TARGET_OSQUERY_LIB}_DEPS ${ARGN})
+ SET(${TARGET_OSQUERY_LIB}_DEPS ${${TARGET_OSQUERY_LIB}_DEPS} PARENT_SCOPE)
+ ELSE()
+ LIST(APPEND ${TARGET_OSQUERY_LIB_ONLY_GBS}_DEPS ${ARGN})
+ SET(${TARGET_OSQUERY_LIB_ONLY_GBS}_DEPS
+ ${${TARGET_OSQUERY_LIB_ONLY_GBS}_DEPS} PARENT_SCOPE)
+ ENDIF()
+ENDMACRO(ADD_OSQUERY_LINK)
+
MACRO(TARGET_OSQUERY_LINK_WHOLE TARGET LIBRARY)
TARGET_LINK_LIBRARIES(${TARGET} "-Wl,-whole-archive")
TARGET_LINK_LIBRARIES(${TARGET} ${LIBRARY})
SET(TARGET_OSQUERY_DAEMON osqueryd)
SET(${TARGET_OSQUERY_LIB}_SRCS "")
-SET(${TARGET_OSQUERY_LIB_ADDITIONAL}_SRCS "")
-SET(${TARGET_OSQUERY_TEST}_SRCS "")
-
-SET(${TARGET_OSQUERY_LIB}_DEP glog
- gflags
- pthread
- libthrift.a
- # rocksdb deps
- librocksdb.a
- snappy
- z
- bz2
- dl
- lz4
- zstd
- boost_regex
- boost_system
- boost_thread
- boost_filesystem
- crypto # openssl
- # shell deps
- readline
- # build-in tables deps
- systemd
- udev
- ip4tc)
+SET(${TARGET_OSQUERY_LIB}_DEPS "")
+SET(${TARGET_OSQUERY_LIB}_TESTS "")
+
+SET(${TARGET_OSQUERY_LIB_ONLY_GBS}_SRCS "")
+SET(${TARGET_OSQUERY_LIB_ONLY_GBS}_DEPS "")
+SET(${TARGET_OSQUERY_LIB_ONLY_GBS}_TESTS "")
+
+ADD_OSQUERY_LINK(TRUE glog
+ gflags
+ pthread
+ libthrift.a
+ # rocksdb deps
+ librocksdb.a
+ snappy
+ z
+ bz2
+ dl
+ lz4
+ zstd
+ boost_regex
+ boost_system
+ boost_thread
+ boost_filesystem
+ crypto # openssl
+ # shell deps
+ readline
+ # build-in tables deps
+ systemd)
SET(OSQUERY_CODEGEN_PATH "${CMAKE_SOURCE_DIR}/tools/codegen")
SET(OSQUERY_TABLES_PATH "${CMAKE_SOURCE_DIR}")
# static_lib should include every object file in the archive in the link
# ref: TARGET_OSQUERY_LINK_WHOLE
ADD_LIBRARY(osquery_generated_tables OBJECT "${AMALGAMATION_FILE_GEN}")
-ADD_LIBRARY(${TARGET_OSQUERY_LIB}
- STATIC main/lib.cpp
- $<TARGET_OBJECTS:osquery_generated_tables>
- $<TARGET_OBJECTS:osquery_sqlite>
- ${${TARGET_OSQUERY_LIB}_SRCS}
- ${${TARGET_OSQUERY_LIB_ADDITIONAL}_SRCS})
-TARGET_LINK_LIBRARIES(${TARGET_OSQUERY_LIB} ${${TARGET_OSQUERY_LIB}_DEP})
+IF(DEFINED GBS_BUILD)
+ ADD_LIBRARY(${TARGET_OSQUERY_LIB}
+ STATIC main/lib.cpp
+ $<TARGET_OBJECTS:osquery_generated_tables>
+ $<TARGET_OBJECTS:osquery_sqlite>
+ ${${TARGET_OSQUERY_LIB}_SRCS}
+ ${${TARGET_OSQUERY_LIB_ONLY_GBS}_SRCS})
+ TARGET_LINK_LIBRARIES(${TARGET_OSQUERY_LIB} ${${TARGET_OSQUERY_LIB}_DEPS})
+ELSE()
+ ADD_LIBRARY(${TARGET_OSQUERY_LIB}
+ STATIC main/lib.cpp
+ $<TARGET_OBJECTS:osquery_generated_tables>
+ $<TARGET_OBJECTS:osquery_sqlite>
+ ${${TARGET_OSQUERY_LIB}_SRCS})
+ TARGET_LINK_LIBRARIES(${TARGET_OSQUERY_LIB} ${${TARGET_OSQUERY_LIB}_DEPS}
+ ${${TARGET_OSQUERY_LIB_ONLY_GBS}_DEPS})
+ENDIF()
SET_TARGET_PROPERTIES(${TARGET_OSQUERY_LIB} PROPERTIES OUTPUT_NAME ${TARGET_OSQUERY_LIB})
#INSTALL(TARGETS ${TARGET_OSQUERY_LIB}
WORLD_EXECUTE)
## osquery-test generation ##########################################################
-ADD_EXECUTABLE(${TARGET_OSQUERY_TEST} ${${TARGET_OSQUERY_TEST}_SRCS} main/tests.cpp)
+
+IF(DEFINED GBS_BUILD)
+ ADD_EXECUTABLE(${TARGET_OSQUERY_TEST} main/tests.cpp
+ ${${TARGET_OSQUERY_LIB}_TESTS}
+ ${${TARGET_OSQUERY_LIB_ONLY_GBS}_TESTS})
+ELSE()
+ ADD_EXECUTABLE(${TARGET_OSQUERY_TEST} main/tests.cpp
+ ${${TARGET_OSQUERY_LIB}_TESTS})
+ENDIF()
TARGET_OSQUERY_LINK_WHOLE(${TARGET_OSQUERY_TEST} ${TARGET_OSQUERY_LIB})
TARGET_LINK_LIBRARIES(${TARGET_OSQUERY_TEST} gtest)
SET_TARGET_PROPERTIES(${TARGET_OSQUERY_TEST}
ADD_OSQUERY_LIBRARY(TRUE osquery_config config.cpp)
-ADD_OSQUERY_LIBRARY(FALSE osquery_config_plugins update.cpp
- plugins/filesystem.cpp
- parsers/query_packs.cpp)
+ADD_OSQUERY_LIBRARY(TRUE osquery_config_plugins update.cpp
+ plugins/filesystem.cpp
+ parsers/query_packs.cpp)
FILE(GLOB OSQUERY_CONFIG_TESTS "tests/*.cpp")
ADD_OSQUERY_TEST(TRUE ${OSQUERY_CONFIG_TESTS})
-ADD_OSQUERY_LIBRARY(FALSE osquery_devtools printer.cpp)
+ADD_OSQUERY_LIBRARY(TRUE osquery_devtools printer.cpp)
FILE(GLOB OSQUERY_DEVTOOLS_TESTS "tests/*.cpp")
-ADD_OSQUERY_TEST(FALSE ${OSQUERY_DEVTOOLS_TESTS})
+ADD_OSQUERY_TEST(TRUE ${OSQUERY_DEVTOOLS_TESTS})
ADD_OSQUERY_LIBRARY(TRUE osquery_distributed distributed.cpp)
FILE(GLOB OSQUERY_DISTRIBUTED_TESTS "tests/*.cpp")
-ADD_OSQUERY_TEST(FALSE ${OSQUERY_DISTRIBUTED_TESTS})
+ADD_OSQUERY_TEST(TRUE ${OSQUERY_DISTRIBUTED_TESTS})
+# Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# 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
+
+ADD_OSQUERY_LINK(TRUE udev ip4tc)
+
ADD_OSQUERY_LIBRARY(TRUE osquery_events events.cpp)
-ADD_OSQUERY_LIBRARY(FALSE osquery_events_linux linux/inotify.cpp
- linux/udev.cpp)
+ADD_OSQUERY_LIBRARY(TRUE osquery_events_linux linux/inotify.cpp
+ linux/udev.cpp)
FILE(GLOB OSQUERY_EVENTS_TESTS "tests/*.cpp")
ADD_OSQUERY_TEST(TRUE ${OSQUERY_EVENTS_TESTS})
FILE(GLOB OSQUERY_LINUX_EVENTS_TESTS "linux/tests/*.cpp")
-ADD_OSQUERY_TEST(FALSE ${OSQUERY_LINUX_EVENTS_TESTS})
+ADD_OSQUERY_TEST(TRUE ${OSQUERY_LINUX_EVENTS_TESTS})
ADD_OSQUERY_LIBRARY(TRUE osquery_logger logger.cpp)
-ADD_OSQUERY_LIBRARY(FALSE osquery_logger_plugins plugins/filesystem.cpp
- plugins/syslog.cpp)
+ADD_OSQUERY_LIBRARY(TRUE osquery_logger_plugins plugins/filesystem.cpp
+ plugins/syslog.cpp)
FILE(GLOB OSQUERY_LOGGER_TESTS "tests/*.cpp")
-ADD_OSQUERY_TEST(FALSE ${OSQUERY_LOGGER_TESTS})
+ADD_OSQUERY_TEST(TRUE ${OSQUERY_LOGGER_TESTS})
file(GLOB OSQUERY_LOGGER_PLUGIN_TESTS "plugins/tests/*.cpp")
-ADD_OSQUERY_TEST(FALSE ${OSQUERY_LOGGER_PLUGIN_TESTS})
+ADD_OSQUERY_TEST(TRUE ${OSQUERY_LOGGER_PLUGIN_TESTS})
ADD_OSQUERY_LIBRARY(TRUE osquery_sql sql.cpp)
-ADD_OSQUERY_LIBRARY(FALSE osquery_sql_internal sqlite_util.cpp
- virtual_table.cpp)
+ADD_OSQUERY_LIBRARY(TRUE osquery_sql_internal sqlite_util.cpp
+ virtual_table.cpp)
FILE(GLOB OSQUERY_SQL_TESTS "tests/*.cpp")
-ADD_OSQUERY_TEST(FALSE ${OSQUERY_SQL_TESTS})
+ADD_OSQUERY_TEST(TRUE ${OSQUERY_SQL_TESTS})
ADD_OSQUERY_LIBRARY(TRUE osquery_tables ${OSQUERY_CROSS_TABLES})
FILE(GLOB OSQUERY_CROSS_TABLES_TESTS "[!uo]*/tests/*.cpp")
-ADD_OSQUERY_TEST(FALSE ${OSQUERY_CROSS_TABLES_TESTS})
+ADD_OSQUERY_TEST(TRUE ${OSQUERY_CROSS_TABLES_TESTS})
%build
%{!?build_type:%define build_type "RELEASE"}
%cmake . -DCMAKE_BUILD_TYPE=%{build_type} \
- -DOSQUERY_BUILD_VERSION=%{version}
+ -DOSQUERY_BUILD_VERSION=%{version} \
+ -DGBS_BUILD="TRUE"
+
make %{?jobs:-j%jobs}