Commit 7ea240dc authored by Alastair Robertson's avatar Alastair Robertson

Update BCC and GTest on every build by default

parent 5f558b7e
...@@ -20,14 +20,24 @@ add_compile_options("-Wno-format-security") ...@@ -20,14 +20,24 @@ add_compile_options("-Wno-format-security")
enable_testing() enable_testing()
include(ExternalProject) if (OFFLINE_BUILDS)
ExternalProject_Add(bcc include(ExternalProject)
GIT_REPOSITORY https://github.com/iovisor/bcc ExternalProject_Add(bcc
STEP_TARGETS build update GIT_REPOSITORY https://github.com/iovisor/bcc
EXCLUDE_FROM_ALL 1 STEP_TARGETS build update
UPDATE_DISCONNECTED 1 EXCLUDE_FROM_ALL 1
BUILD_COMMAND ${CMAKE_COMMAND} --build . --target bcc-static UPDATE_DISCONNECTED 1
) BUILD_COMMAND ${CMAKE_COMMAND} --build . --target bcc-static
)
else()
include(ExternalProject)
ExternalProject_Add(bcc
GIT_REPOSITORY https://github.com/iovisor/bcc
STEP_TARGETS build update
EXCLUDE_FROM_ALL 1
BUILD_COMMAND ${CMAKE_COMMAND} --build . --target bcc-static
)
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
find_package(LibElf REQUIRED) find_package(LibElf REQUIRED)
......
...@@ -41,6 +41,8 @@ make ...@@ -41,6 +41,8 @@ make
By default bpftrace will be built as a static binary to ease deployments. If a dynamically linked executable would be preferred, the CMake option `-DDYNAMIC_LINKING:BOOL=ON` can be used. By default bpftrace will be built as a static binary to ease deployments. If a dynamically linked executable would be preferred, the CMake option `-DDYNAMIC_LINKING:BOOL=ON` can be used.
The latest versions of BCC and Google Test will be downloaded on each build. To speed up builds and only download their sources on the first run, use the CMake option `-DOFFLINE_BUILDS:BOOL=ON`.
## Using Docker ## Using Docker
Building BPFtrace inside a Docker container is the recommended method: Building BPFtrace inside a Docker container is the recommended method:
...@@ -53,10 +55,3 @@ There are some more fine-grained options if you find yourself building BPFtrace ...@@ -53,10 +55,3 @@ There are some more fine-grained options if you find yourself building BPFtrace
- `./build-release.sh` - builds BPFtrace in a release configuration - `./build-release.sh` - builds BPFtrace in a release configuration
`./build.sh` is equivalent to `./build-docker.sh && ./build-release.sh` `./build.sh` is equivalent to `./build-docker.sh && ./build-release.sh`
These build scripts pass on any command line arguments to `make` internally. This means specific targets can be built individually, e.g.:
- `./build.sh bpftrace` - build only the targets required for the bpftrace executable
- `./build.sh bcc-update` - update the copy of BCC used to build BPFtrace
- `./build.sh gtest-update` - update the copy of Google Test used to build the BPFtrace tests
The latest versions of BCC and Google Test will be downloaded on the first build. To update them later, the targets `bcc-update` and `gtest-update` can be built as shown above.
...@@ -43,13 +43,22 @@ target_link_libraries(bpftrace_test ${LIBELF_LIBRARIES}) ...@@ -43,13 +43,22 @@ target_link_libraries(bpftrace_test ${LIBELF_LIBRARIES})
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
include(ExternalProject) if (OFFLINE_BUILDS)
ExternalProject_Add(gtest include(ExternalProject)
GIT_REPOSITORY https://github.com/google/googletest.git ExternalProject_Add(gtest
STEP_TARGETS build update GIT_REPOSITORY https://github.com/google/googletest.git
EXCLUDE_FROM_ALL 1 STEP_TARGETS build update
UPDATE_DISCONNECTED 1 EXCLUDE_FROM_ALL 1
) UPDATE_DISCONNECTED 1
)
else()
include(ExternalProject)
ExternalProject_Add(gtest
GIT_REPOSITORY https://github.com/google/googletest.git
STEP_TARGETS build update
EXCLUDE_FROM_ALL 1
)
endif()
add_dependencies(bpftrace_test gtest-build) add_dependencies(bpftrace_test gtest-build)
ExternalProject_Get_Property(gtest source_dir binary_dir) ExternalProject_Get_Property(gtest source_dir binary_dir)
target_include_directories(bpftrace_test PUBLIC ${source_dir}/googletest/include) target_include_directories(bpftrace_test PUBLIC ${source_dir}/googletest/include)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment