Skip to content

Commit

Permalink
Move all yaml related code into test (#750)
Browse files Browse the repository at this point in the history
Signed-off-by: Alan Jowett <[email protected]>
  • Loading branch information
Alan-Jowett authored Oct 20, 2024
1 parent 17bc9e1 commit 4832643
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 18 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt install libboost-dev libboost-filesystem-dev libboost-program-options-dev libyaml-cpp-dev valgrind
sudo apt install libboost-dev libboost-filesystem-dev libboost-program-options-dev
- name: Install test dependencies
if: ${{matrix.target == 'tests'}}
run: |
sudo apt install libyaml-cpp-dev valgrind
- uses: actions/checkout@v4
with:
Expand Down
41 changes: 24 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ endif ()

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR
"${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
find_package(yaml-cpp REQUIRED)
if (VERIFIER_ENABLE_TESTS)
find_package(yaml-cpp REQUIRED)
endif()
find_package(Boost REQUIRED)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand All @@ -57,22 +59,24 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(Boost_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/packages/boost/lib/native/include)
set(Boost_LIBRARY_DIRS ${CMAKE_BINARY_DIR}/packages/boost_filesystem-vc143/lib/native)

# MSVC's "std:c++20" option is the current standard that supports all the C++17
# features we use. However, cmake can't deal with that here, so we set it below.

set(EXTERNAL_INSTALL_LOCATION ${CMAKE_BINARY_DIR}/packages/yaml-cpp)
include(ExternalProject)
ExternalProject_Add(yaml-cpp
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
GIT_TAG "yaml-cpp-0.7.0"
GIT_SHALLOW true
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION}
-DYAML_MSVC_SHARED_RT=ON
-DYAML_CPP_BUILD_TESTS=OFF
-DYAML_CPP_BUILD_TOOLS=OFF
)
set(YAML_CPP_LIBRARIES ${EXTERNAL_INSTALL_LOCATION}/lib/yaml-cpp$<$<CONFIG:DEBUG>:d>.lib)
set(YAML_CPP_INCLUDE_DIR ${EXTERNAL_INSTALL_LOCATION}/include/)
if (VERIFIER_ENABLE_TESTS)
# MSVC's "std:c++20" option is the current standard that supports all the C++17
# features we use. However, cmake can't deal with that here, so we set it below.

set(EXTERNAL_INSTALL_LOCATION ${CMAKE_BINARY_DIR}/packages/yaml-cpp)
include(ExternalProject)
ExternalProject_Add(yaml-cpp
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
GIT_TAG "yaml-cpp-0.7.0"
GIT_SHALLOW true
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION}
-DYAML_MSVC_SHARED_RT=ON
-DYAML_CPP_BUILD_TESTS=OFF
-DYAML_CPP_BUILD_TOOLS=OFF
)
set(YAML_CPP_LIBRARIES ${EXTERNAL_INSTALL_LOCATION}/lib/yaml-cpp$<$<CONFIG:DEBUG>:d>.lib)
set(YAML_CPP_INCLUDE_DIR ${EXTERNAL_INSTALL_LOCATION}/include/)
endif()
endif ()

include_directories(./external)
Expand Down Expand Up @@ -104,6 +108,7 @@ file(GLOB ALL_TEST
"./src/test/test_wto.cpp"
"./src/test/test_yaml.cpp"
)
set(LIB_SRC ${LIB_SRC} "./src/test/ebpf_yaml.cpp")
endif()

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR
Expand Down Expand Up @@ -131,6 +136,8 @@ endif()
target_include_directories(ebpfverifier PRIVATE ${GSL_INCLUDE_DIRS})

if(VERIFIER_ENABLE_TESTS)
target_include_directories(run_yaml PRIVATE src/test)

set_target_properties(check
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/..")
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 4832643

Please sign in to comment.