Move the build tree out of the source tree (fixed ../build)

The build directory is now a fixed 'build' next to the tree
(qt6-after/build), not in-tree build4 / build4_<timestamp>_<pid> dirs.

- CMakeLists: the $ORIGIN RTI RUNPATH entry is now 4 levels up from a
  bin/ or lib/ artifact (the build tree is one level shallower)
- new_docker_build_release2.sh: BUILD_DIR is the fixed ../build; the DEB
  tar drops the ./build4* exclude (the build dir is outside the tree)
- new_docker_build.sh: Docker mounts the tree's parent so ../build lands
  next to the tree on the host; in-container paths (cmake source,
  SRCROOT, deb_stage, rpms, staging tar) updated accordingly
- rpmbuild/make_rpm_ubuntu26*.py: stale build4/ references now say build/
- README: build4 -> ../build in every snippet and doc line

Verified: fresh full-scope configure + ninja all in qt6-after/build is
green; ctest 20/22 (same 2 pre-existing out-of-scope failures as the
previous baseline); RUNPATH carries the 4-level $ORIGIN entry and
ddscore_unit_test runs with no LD_LIBRARY_PATH / RTI_LICENSE.
This commit is contained in:
berrux-dev committed 2026-11-16 22:20:12 +01:00
1 parent 874efd4733
commit dc2c3e358b
6 files changed
+56 -46

No files matched your search

@@ -49,12 +49,14 @@ SET(CMAKE_BUILD_RPATH "${CMAKE_BINARY_DIR}/lib")
# The RTI Connext libraries live outside the tree (pipeline-root
# external/rti_connext_dds-7.7.0). The absolute path CMake bakes into the
# RUNPATH only resolves on the mount of the build host, so also add a
# $ORIGIN-relative entry (5 levels up from any bin/ or lib/ artifact is
# the pipeline root) so the binaries load under any mount point
# (e.g. /workspace) without LD_LIBRARY_PATH.
# $ORIGIN-relative entry (4 levels up from any bin/ or lib/ artifact is
# the pipeline root: the build tree is <qt6-migration-legatus>/qt6-after/
# build, so bin/ -> build -> qt6-after -> qt-migration-legatus -> root)
# so the binaries load under any mount point (e.g. /workspace) without
# LD_LIBRARY_PATH.
SET(CMAKE_BUILD_RPATH
"${CMAKE_BUILD_RPATH};"
"$ORIGIN/../../../../../external/rti_connext_dds-7.7.0/resource/app/lib/x64Linux4gcc8.5.0")
"$ORIGIN/../../../../external/rti_connext_dds-7.7.0/resource/app/lib/x64Linux4gcc8.5.0")
SET(CMAKE_INSTALL_RPATH "${CMAKE_BINARY_DIR}/lib")
SET(CMAKE_BUILD_RPATH_USE_ORIGIN ON)
+22 -18
View File
@@ -21,7 +21,8 @@ Entries at the tree root:
- `Dockerfile` — recipe of the prebuilt build image (Ubuntu 26.04 + Qt 6.10.2 + deps)
- `rpmbuild/make_rpm_ubuntu26.py` — in-tree DEB package producer (self-contained)
- `jenkins-ci-rme/` — in-tree copy of the Jenkins CI flow (see its own `README.md`)
- `build4/` — build tree, created by the driver (git-ignored scratch area)
- `../build/` — build tree, created by the driver **next to the tree**
(`qt6-after/build`), never inside it (git-ignored scratch area)
Toolchain inside the image: **Ubuntu 26.04, GCC 15.2.0, Qt 6.10.2**
(`/opt/Qt/6.10.2/gcc_64`), C++17, Release build. No license file is
@@ -32,9 +33,11 @@ required.
1. **Docker** available on the host.
2. The tree must be reachable inside the container at
`/workspace/qt-migration-legatus/qt6-after/qt6-migrated-legatus`, i.e.
mount the pipeline root on `/workspace` — this is how
`new_docker_build.sh` invokes Docker, so running the driver as-is
satisfies this.
mount the tree's parent directory on `/workspace` — this is how
`new_docker_build.sh` invokes Docker (it mounts
`${MIGRATE_PIPELINE_ROOT}/..`), so running the driver as-is satisfies
this. The build tree then lives at `/workspace/build` in the container,
which is `../build` next to the tree on the host.
The driver resolves the pipeline root from its own location (override
with the exported `MIGRATE_PIPELINE_ROOT` or the `.envrc` in this
@@ -68,11 +71,12 @@ To remove it later:
What the driver does inside the container:
1. `rm -rf build4 && mkdir build4 && cd build4` (fresh build tree)
1. `rm -rf ../build && mkdir -p ../build && cd ../build` (fresh build tree,
next to the source tree)
2. Configure with CMake:
```bash
cmake .. \
cmake /workspace/qt6-migrated-legatus \
-DBUILD_TESTING=ON \
-DRELEASE_BUILD=ON \
-DCMAKE_CXX_STANDARD=17 \
@@ -89,24 +93,24 @@ What the driver does inside the container:
Output to inspect after the run:
- `build4/release_build.log` — full make output (the build must end with
- `../build/release_build.log` — full make output (the build must end with
**0 warnings**)
- `build4/bin/` — executables (apps + test binaries)
- `build4/lib/` — shared libraries
- `../build/bin/` — executables (apps + test binaries)
- `../build/lib/` — shared libraries
To rebuild incrementally without a fresh tree, run `make` directly in an
interactive container against the existing `build4/`:
interactive container against the existing `../build/`:
```bash
docker run --rm -it -v /path/to/pipeline-root:/workspace legatus-qt6:1.0 \
bash -c 'cd /workspace/qt-migration-legatus/qt6-after/qt6-migrated-legatus/build4 \
bash -c 'cd /workspace/qt-migration-legatus/qt6-after/build \
&& make -j8'
```
## Run an executable directly
To run a built executable interactively — e.g. the GUI apps under
`build4/bin/` (`LogView`, `PrtCnv`) against your local display — start a
`../build/bin/` (`LogView`, `PrtCnv`) against your local display — start a
shell inside the container with X11 forwarding:
```bash
@@ -116,14 +120,14 @@ docker run --rm -it \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /path/to/pipeline-root:/workspace \
legatus-qt6:1.0 \
bash -c 'cd /workspace/qt-migration-legatus/qt6-after/qt6-migrated-legatus/build4 && exec bash'
bash -c 'cd /workspace/qt-migration-legatus/qt6-after/build && exec bash'
```
## Step 3 — Run the tests
### 3.1 ctest (automatic)
`new_docker_build.sh` already runs `ctest --test-dir build4
`new_docker_build.sh` already runs `ctest --test-dir ../build
--output-on-failure` after the compile. Expected baseline (7 tests, all
passed):
@@ -141,7 +145,7 @@ passed):
```bash
docker run --rm -v /path/to/pipeline-root:/workspace legatus-qt6:1.0 \
bash -c 'cd /workspace/qt-migration-legatus/qt6-after/qt6-migrated-legatus/build4 \
bash -c 'cd /workspace/qt-migration-legatus/qt6-after/build \
&& make -j8 coprtcnv_unit_test logview_unit_test prtcnv_unit_test'
```
@@ -152,7 +156,7 @@ GUI-free tests need the offscreen Qt platform in a headless container:
```bash
docker run --rm -it -v /path/to/pipeline-root:/workspace legatus-qt6:1.0 \
bash -c 'export QT_QPA_PLATFORM=offscreen
cd /workspace/qt-migration-legatus/qt6-after/qt6-migrated-legatus/build4
cd /workspace/qt-migration-legatus/qt6-after/build
./bin/coprtcnv_unit_test # CoPrtCnv: telegrams, fragmentation, helpers
./bin/logview_unit_test # LogView: IntegerCalculator
./bin/prtcnv_unit_test # PrtCnv: PrtCnvMember fragmented-telegram handling
@@ -292,8 +296,8 @@ Environment overrides: `DOCKER_IMAGE`, `RUN_JENKINS_BUILDER`,
- **"no Qt platform plugin could be initialized"** when running a test
binary by hand → `export QT_QPA_PLATFORM=offscreen`.
- **Stale build tree** → the driver always recreates `build4/`; for
manual builds delete `build4/` and rerun Step 2 if CMake behaves oddly.
- **Stale build tree** → the driver always recreates `../build/`; for
manual builds delete `../build/` and rerun Step 2 if CMake behaves oddly.
- **DEBs not on the host** → the output dir must be a path that exists
*on the host* (it is bind-mounted into the container as
`/workspace/packages-out`); check the `package-output-dir` argument.
@@ -474,11 +474,12 @@ log_info "Using prebuilt Docker image: all build dependencies are baked in"
export QT_QPA_PLATFORM=offscreen
cd /workspace
cd /workspace/qt6-migrated-legatus
rm -rf build4
mkdir -p build4
cd build4
# The build tree is ../build: next to the source tree, outside it.
rm -rf ../build
mkdir -p ../build
cd ../build
COV_CMAKE_ARGS=()
if [[ "${RUN_COVERAGE}" == "ON" ]]; then
@@ -489,7 +490,7 @@ if [[ "${RUN_COVERAGE}" == "ON" ]]; then
"-DCMAKE_SHARED_LINKER_FLAGS=--coverage"
)
fi
cmake .. \
cmake /workspace/qt6-migrated-legatus \
-DBUILD_TESTING=ON \
-DRELEASE_BUILD="${RELEASE_BUILD}" \
-DCMAKE_CXX_STANDARD=17 \
@@ -515,7 +516,7 @@ fi
if [[ "${RUN_COVERAGE}" == "ON" ]]; then
log_info "=== Code coverage (lcov) ==="
COVOUT=/workspace/coverage-out
SRCROOT=/workspace
SRCROOT=/workspace/qt6-migrated-legatus
mkdir -p "${COVOUT}"
COV_IGNORE=(--ignore-errors mismatch,inconsistent,unused)
@@ -558,7 +559,7 @@ if [[ "${RUN_JENKINS_BUILDER}" == "ON" ]]; then
log_info "=== DEB Package Production (in-tree rpmbuild) ==="
OS_VERSION=$(cat /etc/os-release | grep "^VERSION_ID=" | cut -d'"' -f2)
STAGE_DIR=/workspace/deb_stage
STAGE_DIR=/workspace/qt6-migrated-legatus/deb_stage
STAGED_SOURCE_DIR="${STAGE_DIR}"
log_info "Staging workspace to ${STAGE_DIR}"
@@ -567,7 +568,7 @@ if [[ "${RUN_JENKINS_BUILDER}" == "ON" ]]; then
tar --exclude='./rpms' --exclude='./.git' --exclude='./build' \
--exclude='./deb_build_tmp' --exclude='./deb_stage' --exclude='./packages-out' \
--exclude='./legatus-qt6_1.0.tar.gz' \
-cf - -C /workspace . | tar -xf - -C "${STAGE_DIR}"
-cf - -C /workspace/qt6-migrated-legatus . | tar -xf - -C "${STAGE_DIR}"
if [[ ! -f "${STAGED_SOURCE_DIR}/CMakeLists.txt" || ! -f "${STAGED_SOURCE_DIR}/rpmbuild/make_rpm_ubuntu26.py" ]]; then
log_error "Staged source incomplete under ${STAGED_SOURCE_DIR} (CMakeLists.txt or rpmbuild/make_rpm_ubuntu26.py missing)"
@@ -586,7 +587,7 @@ if [[ "${RUN_JENKINS_BUILDER}" == "ON" ]]; then
if python3 make_rpm_ubuntu26.py -c LTS \
--project_name "${PROJECT}" \
--version "${LTS_VERSION}" \
--output_dir "/workspace/rpms/${PROJECT}/${OS_VERSION}/" \
--output_dir "/workspace/qt6-migrated-legatus/rpms/${PROJECT}/${OS_VERSION}/" \
--source_dir "${STAGED_SOURCE_DIR}" \
--cmake_build_flags "-DUSE_IPO=ON -DUSE_UNITY_BUILD=ON -DGUEZ_MODE=${GUEZ_MODE} -DBUILD_WLS=ON -DPostgreSQL_TYPE_INCLUDE_DIR=/usr/include/postgresql/ -DRELEASE_BUILD=ON" \
--build_number "${BUILD_NUMBER}" \
@@ -601,7 +602,7 @@ if [[ "${RUN_JENKINS_BUILDER}" == "ON" ]]; then
DEST_DIR=/workspace/packages-out
mkdir -p "${DEST_DIR}"
shopt -s nullglob
for deb in "/workspace/rpms/${PROJECT}/${OS_VERSION}/"*.deb; do
for deb in "/workspace/qt6-migrated-legatus/rpms/${PROJECT}/${OS_VERSION}/"*.deb; do
base="$(basename "${deb}")"
if [[ -e "${DEST_DIR}/${base}" ]] &&
[[ "$(stat -c '%d:%i' "${deb}")" == "$(stat -c '%d:%i' "${DEST_DIR}/${base}")" ]]; then
@@ -619,6 +620,10 @@ EOF
chmod +x "${CONTAINER_SCRIPT_HOST}"
# The workspace mount is the tree's parent (not the tree): the build tree
# ../build then lands next to the tree on the host (qt6-after/build), not
# inside it. NOTE: no # comment lines inside the backslash-continued docker
# run below - they break the continuation and drop the remaining arguments.
docker run --rm \
-e MIGRATE_PIPELINE_ROOT \
-e LANG \
@@ -639,7 +644,7 @@ docker run --rm \
-e QT_ARCH_DIR \
-e QT_BASE_DIR \
-e RELEASE_BUILD_TARGETS="${RELEASE_BUILD_TARGETS_STRING}" \
-v "${WORKSPACE_ROOT_HOST}:/workspace" \
-v "${WORKSPACE_ROOT_HOST}/..:/workspace" \
-v "${CONTAINER_SCRIPT_HOST}:/tmp/run-build-inside-container.sh:ro" \
-v "${PACKAGE_OUTPUT_DIR}:/workspace/packages-out" \
-v "${COVERAGE_OUTPUT_DIR}:/workspace/coverage-out" \
@@ -502,8 +502,8 @@ fi
# Configure CMake
log_info "Configuring CMake..."
# Use unique build directory to avoid Docker mount caching issues
BUILD_DIR="build4_$(date +%Y%m%d_%H%M%S)_$$"
# Fixed build dir next to the tree (../build), outside the source tree.
BUILD_DIR="../build"
log_info "Using build directory: ${BUILD_DIR}"
rm -rf "${BUILD_DIR}"
mkdir -p "${BUILD_DIR}"
@@ -587,16 +587,15 @@ if [[ "${RUN_JENKINS_BUILDER}" == "ON" ]]; then
log_info "Staging workspace to ${STAGE_DIR}"
rm -rf "${STAGE_DIR}"
mkdir -p "${STAGE_DIR}"
# Exclude build4* (the driver build dirs, e.g. build4_<timestamp>): the DEB
# pipeline builds its own tree in <staging>/build; nothing in the DEB step
# consumes the driver build output (the ctest DEB looks for a plain build4
# dir, which the driver never creates; it uses build4_<timestamp> instead).
# The driver build dir is ../build (next to the tree, outside it), so the
# tar of the tree above excludes it by construction; nothing in the DEB
# step consumes the driver build output (the DEB pipeline builds its own
# tree in <staging>/build).
# NOTE: no apostrophes allowed in comments here - this block lives inside
# the single-quoted docker bash -c string (see lines 477/653).
tar --exclude='./rpms' --exclude='./.git' --exclude='./build' \
--exclude='./deb_build_tmp' --exclude='./deb_stage' --exclude='./packages-out' \
--exclude='./legatus-qt6_1.0.tar.gz' \
--exclude=./build4\* \
-cf - -C "${WORKSPACE_DIR}" . | tar -xf - -C "${STAGE_DIR}"
if [[ ! -f "${STAGED_SOURCE_DIR}/CMakeLists.txt" || ! -f "${STAGED_SOURCE_DIR}/rpmbuild/make_rpm_ubuntu26_release2.py" ]]; then
@@ -128,9 +128,9 @@ def find_test_module_source(pkg_dir, test_name, release_dirs):
def find_test_executables(pkg_dir, release_dirs):
"""(executable, module) pairs for the test executables in build4/bin/."""
"""(executable, module) pairs for the test executables in build/bin/."""
test_executables = []
build_bin_dir = os.path.join(pkg_dir, "build4", "bin")
build_bin_dir = os.path.join(pkg_dir, "build", "bin")
if not os.path.exists(build_bin_dir):
warning(f"Build bin directory not found: {build_bin_dir}")
return test_executables
@@ -371,7 +371,7 @@ def ctest_runtime_install_lines(pkg_dir, release_dirs):
for exe_path, module_path in find_test_executables(pkg_dir, release_dirs):
lines.append(f"{os.path.relpath(exe_path, pkg_dir)} usr/lib/ctest/")
info(f" Including test executable: {os.path.basename(exe_path)} from {module_path}")
for ctest_file in ("build4/CTestTestfile.cmake", "build4/DartConfiguration.tcl", "build4/Testing/TAG"):
for ctest_file in ("build/CTestTestfile.cmake", "build/DartConfiguration.tcl", "build/Testing/TAG"):
if os.path.exists(os.path.join(pkg_dir, ctest_file)):
lines.append(f"{ctest_file} usr/lib/ctest/")
return lines
@@ -128,9 +128,9 @@ def find_test_module_source(pkg_dir, test_name, release_dirs):
def find_test_executables(pkg_dir, release_dirs):
"""(executable, module) pairs for the test executables in build4/bin/."""
"""(executable, module) pairs for the test executables in build/bin/."""
test_executables = []
build_bin_dir = os.path.join(pkg_dir, "build4", "bin")
build_bin_dir = os.path.join(pkg_dir, "build", "bin")
if not os.path.exists(build_bin_dir):
warning(f"Build bin directory not found: {build_bin_dir}")
return test_executables
@@ -373,7 +373,7 @@ def ctest_runtime_install_lines(pkg_dir, release_dirs):
for exe_path, module_path in find_test_executables(pkg_dir, release_dirs):
lines.append(f"{os.path.relpath(exe_path, pkg_dir)} usr/lib/ctest/")
info(f" Including test executable: {os.path.basename(exe_path)} from {module_path}")
for ctest_file in ("build4/CTestTestfile.cmake", "build4/DartConfiguration.tcl", "build4/Testing/TAG"):
for ctest_file in ("build/CTestTestfile.cmake", "build/DartConfiguration.tcl", "build/Testing/TAG"):
if os.path.exists(os.path.join(pkg_dir, ctest_file)):
lines.append(f"{ctest_file} usr/lib/ctest/")
return lines