Skip to content

Commit

Permalink
CMake+GitLab CI: Add and use RPMBUILD_EXTRA_ARGS.
Browse files Browse the repository at this point in the history
Add an RPMBUILD_EXTRA_ARGS variable to CMakeLists.txt and use it in
GitLab CI to define __cmake_builddir. This should let ccache work with
our RPM builds.
  • Loading branch information
geraldcombs committed Oct 21, 2022
1 parent d7c993d commit 139e468
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
17 changes: 5 additions & 12 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ variables:
tags:
- docker
after_script:
- for builddir in build/packaging/rpm/BUILD/wireshark-*/build build/packaging/rpm/BUILD/wireshark-* build obj-*; do [ ! -d "$builddir/run" ] || break; done
- for builddir in build/packaging/rpm/BUILD/wireshark-*/build build/packaging/rpm/BUILD/wireshark* build obj-*; do [ ! -d "$builddir/run" ] || break; done
- if [[ "$CI_JOB_NAME" == "build:rpm-opensuse-"* ]]; then export LD_LIBRARY_PATH=$builddir/run; fi
- if [ -f $builddir/run/tshark ]; then $builddir/run/tshark --version; fi
needs: []
Expand Down Expand Up @@ -141,15 +141,8 @@ variables:
paths:
- ccache/
before_script:
- BUILD_DIR=$(ls wireshark-*.tar.*)
- BUILD_DIR=${BUILD_DIR%%.tar.*}
- mkdir -p ccache
- ccache --show-stats
# Not yet supported by openSUSE
- ccache --set-config absolute_paths_in_stderr=true || true
- ccache --set-config hash_dir=false
- ccache --set-config base_dir="$CI_PROJECT_DIR/build/packaging/rpm/BUILD/$BUILD_DIR"
- cat "$CCACHE_DIR/ccache.conf"
- git config --global user.email "[email protected]"
- git config --global user.name "Your Name"
- mkdir build
Expand All @@ -159,7 +152,7 @@ variables:
after_script:
# The cache should be large enough to be useful but it shouldn't take
# too long to restore+save each run.
- ccache --max-size $( du --summarize --block-size=1M $CI_PROJECT_DIR/build/packaging/rpm/BUILD/wireshark-* | awk '{printf ("%dM", $1 * 1.5)}' )
- ccache --max-size $( du --summarize --block-size=1M $CI_PROJECT_DIR/build/packaging/rpm/BUILD/wireshark | awk '{printf ("%dM", $1 * 1.5)}' )
artifacts:
paths:
- build/packaging/rpm/RPMS
Expand Down Expand Up @@ -260,7 +253,7 @@ Fedora RPM Package:
# https://gitlab.com/gitlab-com/support-forum/issues/2790
- export FORCE_CMAKE_NINJA_NON_VERBOSE=1
- printf "\e[0Ksection_start:%s:cmake_section[collapsed=true]\r\e[0KRunning CMake" "$( date +%s)"
- cmake3 -GNinja -DENABLE_CCACHE=ON ..
- cmake3 -G Ninja -DENABLE_CCACHE=ON -DRPMBUILD_EXTRA_ARGS="--define;__cmake_builddir $CI_PROJECT_DIR/build/packaging/rpm/BUILD/wireshark" ..
- printf "\e[0Ksection_end:%s:cmake_section\r\e[0K" "$( date +%s)"
- ninja wireshark_rpm

Expand All @@ -277,7 +270,7 @@ openSUSE 15.3 RPM Package:
image: registry.gitlab.com/wireshark/wireshark-containers/opensuse-15.3-dev
script:
- printf "\e[0Ksection_start:%s:cmake_section[collapsed=true]\r\e[0KRunning CMake" "$( date +%s)"
- cmake -GNinja -DENABLE_CCACHE=ON -DUSE_qt6=OFF ..
- cmake -G Ninja -DENABLE_CCACHE=ON -DRPMBUILD_EXTRA_ARGS="--define;__cmake_builddir $CI_PROJECT_DIR/build/packaging/rpm/BUILD/wireshark" -DUSE_qt6=OFF ..
- printf "\e[0Ksection_end:%s:cmake_section\r\e[0K" "$( date +%s)"
- ninja wireshark_rpm

Expand All @@ -294,7 +287,7 @@ Rocky Linux 9 RPM Package:
image: registry.gitlab.com/wireshark/wireshark-containers/rockylinux-9-dev
script:
- printf "\e[0Ksection_start:%s:cmake_section[collapsed=true]\r\e[0KRunning CMake" "$( date +%s)"
- cmake -GNinja -DENABLE_CCACHE=ON -DUSE_qt6=OFF ..
- cmake -G Ninja -DENABLE_CCACHE=ON -DRPMBUILD_EXTRA_ARGS="--define;__cmake_builddir $CI_PROJECT_DIR/build/packaging/rpm/BUILD/wireshark" -DUSE_qt6=OFF ..
- printf "\e[0Ksection_end:%s:cmake_section\r\e[0K" "$( date +%s)"
- ninja wireshark_rpm

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3547,7 +3547,7 @@ if(RPMBUILD_EXECUTABLE)
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/packaging/rpm/${_rpm_dir}")
endforeach()

set(_rpmbuild_with_args)
set(_rpmbuild_with_args ${RPMBUILD_EXTRA_ARGS})
#
# This is ugly.
#
Expand Down

0 comments on commit 139e468

Please sign in to comment.