diff --git a/.dockerignore b/.dockerignore index 421841b60..0d7798beb 100644 --- a/.dockerignore +++ b/.dockerignore @@ -11,9 +11,12 @@ **/*.a **/*.so **/*.log +/build*/ +/src/vcpkg_installed # vcpkg artifacts external/vcpkg/buildtrees external/vcpkg/packages external/vcpkg/downloads external/vcpkg/installed +external/vcpkg/vcpkg diff --git a/.github/test-matrix.json b/.github/test-matrix.json index 10a86591e..1ba144f13 100644 --- a/.github/test-matrix.json +++ b/.github/test-matrix.json @@ -1,13 +1,13 @@ [ -{ "name": "almalinux-9", "arch": "amd64", "tag": "@sha256:27aba382812a4ad52f32589bc35dad62bc1bec966df6c3ca34e15eea83dfb6cd", "git_label": "ghcr.io/microsoft/kompli/almalinux-9-amd64:git-db3dcdd446c78630f9d77b6ae3a471bb8f0acfdb"}, -{ "name": "azurelinux-3", "arch": "amd64", "tag": "@sha256:5e972f22e641d609dbf490f2116ddb0eb6f232bb5e7d9ac48e0fb827d93d9566", "git_label": "ghcr.io/microsoft/kompli/azurelinux-3-amd64:git-db3dcdd446c78630f9d77b6ae3a471bb8f0acfdb"}, -{ "name": "debian-12", "arch": "amd64", "tag": "@sha256:eeb284231a1c4035cab7bdddc36af1e2e5fa5cbfb7d0e9888aed8ad4101d7eef", "git_label": "ghcr.io/microsoft/kompli/debian-12-amd64:git-db3dcdd446c78630f9d77b6ae3a471bb8f0acfdb"}, -{ "name": "oraclelinux-8", "arch": "amd64", "tag": "@sha256:fbd141a63c80f05c18cd78a69ceede010e67f06ef74faf915d5d4a12c040c496", "git_label": "ghcr.io/microsoft/kompli/oraclelinux-8-amd64:git-db3dcdd446c78630f9d77b6ae3a471bb8f0acfdb"}, -{ "name": "rhel-8", "arch": "amd64", "tag": "@sha256:4d527bf8eb9a71a745f7f8d965c50d3a1e9b26a5c49c778a139479e4d54626a2", "git_label": "ghcr.io/microsoft/kompli/rhel-8-amd64:git-db3dcdd446c78630f9d77b6ae3a471bb8f0acfdb"}, -{ "name": "rhel-9", "arch": "amd64", "tag": "@sha256:493edc77899a9e5c034561179a1b7ef1d813778bee5dc2c453356436dc33153b", "git_label": "ghcr.io/microsoft/kompli/rhel-9-amd64:git-db3dcdd446c78630f9d77b6ae3a471bb8f0acfdb"}, -{ "name": "rockylinux-9", "arch": "amd64", "tag": "@sha256:a0f2b6c70b6d47c9d3ee81ec3d7a9fc2e3122cf1ac893fee2087946ee9078b99", "git_label": "ghcr.io/microsoft/kompli/rockylinux-9-amd64:git-db3dcdd446c78630f9d77b6ae3a471bb8f0acfdb"}, -{ "name": "sles-15", "arch": "amd64", "tag": "@sha256:c264c47e8772060f5a5a9b26ee62ad646cc984d719e32576688d19af4953da21", "git_label": "ghcr.io/microsoft/kompli/sles-15-amd64:git-db3dcdd446c78630f9d77b6ae3a471bb8f0acfdb"}, -{ "name": "ubuntu-20.04", "arch": "amd64", "tag": "@sha256:326f92ee417a0810e3d282b83542683d3beb65b297836529979705e9331fc213", "git_label": "ghcr.io/microsoft/kompli/ubuntu-20.04-amd64:git-db3dcdd446c78630f9d77b6ae3a471bb8f0acfdb"}, -{ "name": "ubuntu-22.04", "arch": "amd64", "tag": "@sha256:93793e1d5981e4abf256988afabe289807ef6f710714b394b51e5baf6d9a77e5", "git_label": "ghcr.io/microsoft/kompli/ubuntu-22.04-amd64:git-db3dcdd446c78630f9d77b6ae3a471bb8f0acfdb"}, -{ "name": "ubuntu-24.04", "arch": "amd64", "tag": "@sha256:e34558434b4814ac851460033ee210fb93f2e57f40f9f15d169d728ed910e4e8", "git_label": "ghcr.io/microsoft/kompli/ubuntu-24.04-amd64:git-db3dcdd446c78630f9d77b6ae3a471bb8f0acfdb"} +{ "name": "almalinux-9", "arch": "amd64", "tag": "@sha256:f9aaafc6cdd213e8f46b6eceefb0ff69934257f0c6b131833ef1cebb96256591", "git_label": "ghcr.io/microsoft/kompli/almalinux-9-amd64:git-805a020d5adc3f989785111b86b2d5c5b880421e"}, +{ "name": "azurelinux-3", "arch": "amd64", "tag": "@sha256:ebe0dddc9dd6c4fbd182361b9e091cbd7019493f3f5bc4f48657c07585da437f", "git_label": "ghcr.io/microsoft/kompli/azurelinux-3-amd64:git-805a020d5adc3f989785111b86b2d5c5b880421e"}, +{ "name": "debian-12", "arch": "amd64", "tag": "@sha256:15a82dbf1bef6a64b4d2dd2bf17134171cbc6592f09459fa3026d7af06ea8d35", "git_label": "ghcr.io/microsoft/kompli/debian-12-amd64:git-805a020d5adc3f989785111b86b2d5c5b880421e"}, +{ "name": "oraclelinux-8", "arch": "amd64", "tag": "@sha256:c620433633301aad9070f9abca1afd7c228fae7adb85c2c2a8fa639435b1eb8f", "git_label": "ghcr.io/microsoft/kompli/oraclelinux-8-amd64:git-805a020d5adc3f989785111b86b2d5c5b880421e"}, +{ "name": "rhel-8", "arch": "amd64", "tag": "@sha256:f3f55330dfa9abf1e65d0d860a2d8ee34d9cb16de03bd3a8c17b10bfd1370bf8", "git_label": "ghcr.io/microsoft/kompli/rhel-8-amd64:git-805a020d5adc3f989785111b86b2d5c5b880421e"}, +{ "name": "rhel-9", "arch": "amd64", "tag": "@sha256:35469313bbd24b0278f67856f840f2b88f04229fee3a11597283f0b85f826776", "git_label": "ghcr.io/microsoft/kompli/rhel-9-amd64:git-805a020d5adc3f989785111b86b2d5c5b880421e"}, +{ "name": "rockylinux-9", "arch": "amd64", "tag": "@sha256:43716d4a8228cec119c5dfed68f7439f4a8438fd789812a2c7b05d1a2c925131", "git_label": "ghcr.io/microsoft/kompli/rockylinux-9-amd64:git-805a020d5adc3f989785111b86b2d5c5b880421e"}, +{ "name": "sles-15", "arch": "amd64", "tag": "@sha256:f751cb29f8bb7cf47e6e32f149d30215d48128d624d469f8a1db87e188d5f766", "git_label": "ghcr.io/microsoft/kompli/sles-15-amd64:git-805a020d5adc3f989785111b86b2d5c5b880421e"}, +{ "name": "ubuntu-20.04", "arch": "amd64", "tag": "@sha256:472472246488377d526d05218df5bc96ddbdf9080638155bf2cc421b6105937f", "git_label": "ghcr.io/microsoft/kompli/ubuntu-20.04-amd64:git-805a020d5adc3f989785111b86b2d5c5b880421e"}, +{ "name": "ubuntu-22.04", "arch": "amd64", "tag": "@sha256:ff9492087fda67081afee9fff170d3ab0636eec5cac54afc5c315382ce33d253", "git_label": "ghcr.io/microsoft/kompli/ubuntu-22.04-amd64:git-805a020d5adc3f989785111b86b2d5c5b880421e"}, +{ "name": "ubuntu-24.04", "arch": "amd64", "tag": "@sha256:6347babfa21715a5bad7146a0a25c52e14a651941176d6196e6a6543afee9ca5", "git_label": "ghcr.io/microsoft/kompli/ubuntu-24.04-amd64:git-805a020d5adc3f989785111b86b2d5c5b880421e"} ] diff --git a/.github/workflows/build-containers.yml b/.github/workflows/build-containers.yml index c11cfdd67..04f2ed1a5 100644 --- a/.github/workflows/build-containers.yml +++ b/.github/workflows/build-containers.yml @@ -4,6 +4,16 @@ on: pull_request: paths: - devops/docker/**/Dockerfile + - devops/scripts/install-container-cmake.sh + - devops/scripts/prepare-container-dependencies.sh + - devops/scripts/download-vcpkg-asset.sh + - devops/scripts/tests/test_container_dependencies.py + - devops/scripts/tests/test_container_cmake.py + - external/vcpkg + - src/vcpkg*.json + - src/CMakeLists.txt + - src/ports-overlay/** + - src/triplets/** - .github/workflows/build-containers.yml push: branches: @@ -11,6 +21,15 @@ on: - main paths: - devops/docker/**/Dockerfile + - devops/scripts/install-container-cmake.sh + - devops/scripts/prepare-container-dependencies.sh + - devops/scripts/download-vcpkg-asset.sh + - devops/scripts/tests/test_container_cmake.py + - external/vcpkg + - src/vcpkg*.json + - src/CMakeLists.txt + - src/ports-overlay/** + - src/triplets/** - .github/workflows/build-containers.yml workflow_dispatch: inputs: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ebb027596..043afad58 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,7 +73,6 @@ jobs: with: container: ${{ steps.container.outputs.id }} cmd: | - (cd external/vcpkg && sed -e "s/\"2\\.7\\.4\"/\"1\\.0\\.0\"/g" -i scripts/vcpkg-tools.json && ./bootstrap-vcpkg.sh) mkdir build && cd build if [ "${{ matrix.target.name }}" = "ubuntu-14.04" ]; then cmake ../src -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -Duse_prov_client=ON -Dhsm_type_symm_key=ON -DCOMPILE_WITH_STRICTNESS=ON -DBUILD_TESTS=ON -DBUILD_SAMPLES=ON -DBUILD_ADAPTERS=ON -Duse_default_uuid=ON -DVCPKG_OVERLAY_TRIPLETS=../src/triplets -DVCPKG_TARGET_TRIPLET=x64-linux-gcc5 -DVCPKG_OVERLAY_PORTS=../src/ports-overlay diff --git a/devops/README.md b/devops/README.md index 97c4a1ec6..e57b509f4 100644 --- a/devops/README.md +++ b/devops/README.md @@ -16,8 +16,69 @@ This folder contains the artifacts and scripts used by our engineering systems ( - `terraform` - terraform modules for provisioning Azure resources for E2E tests - `rpm` - RPM packaging scripts -## Updating Build contaienrs used for CI builds -The `docker/-` - Build containers are used by ci [ci.yml](.github/workflows/ci.yml) -Their version(digest's) are stored inside [test-matrix.json](.github/test-matrix.json) -The [build-containers.yml](.github/workflows/build-contains.yml) is ran whenever any Build Containers dockerfile is changed. -The [build-containers.yml](.github/workflows/build-contains.yml) produces new-test-matrix.json that can be copted to [test-matrix.json](.github/test-matrix.json) and commited. Then next [ci.yml](.github/workflows/ci.yml) will use updated containers to run builds & tests. +## Updating build containers used for CI builds +All build containers use a two-stage CMake source build: + +1. `ARG CMAKE_VERSION=v3.30.1` selects the bootstrap CMake tag. This version + supports the system OpenSSL 1.1 development libraries on Oracle Linux 8, + RHEL 8, and Ubuntu 20.04. +2. The bootstrap CMake installs the dependencies from + [`src/vcpkg.json`](../src/vcpkg.json), including OpenSSL 3.6 or newer. vcpkg + acquires Ninja first, then uses the bootstrap tools without downloading a + newer CMake binary. +3. The final CMake version is selected from the Linux amd64 entry in + [`external/vcpkg/scripts/vcpkg-tools.json`](../external/vcpkg/scripts/vcpkg-tools.json) + and built from source against the static OpenSSL libraries installed by + vcpkg. Static linking keeps the final tools usable after the temporary + dependency installation is removed. Headers, libraries, and pkg-config + metadata all come from that same OpenSSL prefix. +4. The manifest is installed again with the final CMake to refresh package ABIs + and populate the binary cache used by subsequent offline project builds. + +Both CMake builds verify the installed `cmake`, `ctest`, and `cpack` versions. +`--build-arg CMAKE_VERSION=v3.30.1` can override the bootstrap tag only; the +final version always follows vcpkg's tool metadata. Build images from the repository root +with Podman (or Docker with BuildKit enabled) and the vcpkg submodule initialized, +for example: + +```bash +git submodule update --init --recursive +docker build --layers -f devops/docker/ubuntu-24.04-amd64/Dockerfile . +``` + +The images install all dependencies from [`src/vcpkg.json`](../src/vcpkg.json), +including Lua, while network access is available. The bootstrapped vcpkg tree, +downloaded source archives and helper tools, binary packages, and registry cache +are retained under `/opt/kompli`. `KOMPLI_VCPKG_ROOT` selects that bootstrapped +tree for CMake; builds outside these images still use a build-local vcpkg tree. +Each build restores dependencies into its own `build/vcpkg_installed` directory. +The image also retains the registry lock and seeds it into fresh build trees, +preventing vcpkg from fetching registry HEAD when no installation exists yet. +The images block vcpkg origin downloads after dependency preparation, so a +missing asset fails explicitly instead of downloading during the project build. +During dependency preparation, the asset helper retrieves Lua archives from the +MacPorts mirror; vcpkg still verifies the SHA512 from the selected port. Other +assets use their upstream URLs. The helper is disabled for offline builds. + +Every image must pass a fresh Release configure and build with tests enabled, +telemetry disabled, and `RUN --network=none`. This checks the actual project +without network access before the image can be published. Optional telemetry +uses an external SDK outside the vcpkg manifest and is not covered by this +offline check. + +Changes to the manifest, registry configuration, vcpkg submodule, overlays, +triplets, CMake installation script, dependency preparation script, root CMake configuration, or Dockerfiles +trigger the [build-container workflow](../.github/workflows/build-containers.yml). +Rebuild images when these dependency inputs change; do not enable downloads in +the later project build to work around stale images. + +Run the container setup regression tests locally with: + +```bash +python3 -m unittest discover -s devops/scripts/tests +``` + +The images are used by [CI](../.github/workflows/ci.yml), with pinned digests in +[`test-matrix.json`](../.github/test-matrix.json). After rebuilding, copy the +workflow's `new-test-matrix.json` artifact into that file and commit it so later +builds use the new images. diff --git a/devops/docker/almalinux-9-amd64/Dockerfile b/devops/docker/almalinux-9-amd64/Dockerfile index a9160279c..ebf6251af 100644 --- a/devops/docker/almalinux-9-amd64/Dockerfile +++ b/devops/docker/almalinux-9-amd64/Dockerfile @@ -1,8 +1,6 @@ # TODO: Add mcr.io retagged images FROM almalinux:9@sha256:245f8aab832fe800aa42bdab5fad75ebbd8e0b4c9f24820a83c638b177857ae2 -ARG CMAKE_VERSION=v3.30.1 - RUN dnf install -y \ autoconf \ gcc \ @@ -26,11 +24,27 @@ ENV PATH="/opt/kompli-venv/bin:${PATH}" WORKDIR /git # CMake -RUN git clone https://github.com/Kitware/CMake --recursive -b ${CMAKE_VERSION} -RUN cd CMake && ./bootstrap && make -j$(nproc) && make install && hash -r && rm -rf /git/CMake +ARG CMAKE_VERSION=v3.30.1 +COPY devops/scripts/install-container-cmake.sh /usr/local/bin/install-container-cmake +RUN bash /usr/local/bin/install-container-cmake "$CMAKE_VERSION" /usr/local + +ENV KOMPLI_VCPKG_ROOT=/opt/kompli/vcpkg \ + VCPKG_DOWNLOADS=/opt/kompli/downloads \ + VCPKG_DEFAULT_BINARY_CACHE=/opt/kompli/binary-cache \ + X_VCPKG_REGISTRIES_CACHE=/opt/kompli/registries \ + VCPKG_DISABLE_METRICS=1 +COPY external/vcpkg /opt/kompli/vcpkg +COPY devops/scripts/download-vcpkg-asset.sh /usr/local/bin/download-vcpkg-asset.sh +COPY devops/scripts/prepare-container-dependencies.sh /usr/local/bin/prepare-container-dependencies +RUN --mount=type=bind,source=src,target=/src \ + bash /usr/local/bin/prepare-container-dependencies /src -# Run vcpkg to install build depends -COPY . /src -WORKDIR /src -RUN (cd external/vcpkg && ./bootstrap-vcpkg.sh) && (cd src && ../external/vcpkg/vcpkg install) && rm -rf /src +ENV X_VCPKG_ASSET_SOURCES="clear;x-block-origin" +RUN --network=none --mount=type=bind,source=src,target=/source/src \ + cp -a /source /tmp/kompli-offline && \ + cmake -S /tmp/kompli-offline/src -B /tmp/kompli-offline/build \ + -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_TELEMETRY=OFF && \ + cmake --build /tmp/kompli-offline/build --parallel "$(nproc)" && \ + rm -rf /tmp/kompli-offline +WORKDIR /kompli diff --git a/devops/docker/azurelinux-3-amd64/Dockerfile b/devops/docker/azurelinux-3-amd64/Dockerfile index 43c536eb3..4bc33c28e 100644 --- a/devops/docker/azurelinux-3-amd64/Dockerfile +++ b/devops/docker/azurelinux-3-amd64/Dockerfile @@ -9,6 +9,7 @@ RUN tdnf install -y \ file \ git \ jq \ + openssl-devel \ perl \ perl-IPC-Cmd \ python3 \ @@ -29,6 +30,29 @@ RUN tdnf upgrade -y && \ RUN python3 -m venv /opt/kompli-venv ENV PATH="/opt/kompli-venv/bin:${PATH}" -COPY . /src -WORKDIR /src -RUN (cd external/vcpkg && ./bootstrap-vcpkg.sh) && (cd src && ../external/vcpkg/vcpkg install) && rm -rf /src +WORKDIR /git + +# CMake +ARG CMAKE_VERSION=v3.30.1 +COPY devops/scripts/install-container-cmake.sh /usr/local/bin/install-container-cmake +RUN bash /usr/local/bin/install-container-cmake "$CMAKE_VERSION" /usr/local + +ENV KOMPLI_VCPKG_ROOT=/opt/kompli/vcpkg \ + VCPKG_DOWNLOADS=/opt/kompli/downloads \ + VCPKG_DEFAULT_BINARY_CACHE=/opt/kompli/binary-cache \ + X_VCPKG_REGISTRIES_CACHE=/opt/kompli/registries \ + VCPKG_DISABLE_METRICS=1 +COPY external/vcpkg /opt/kompli/vcpkg +COPY devops/scripts/download-vcpkg-asset.sh /usr/local/bin/download-vcpkg-asset.sh +COPY devops/scripts/prepare-container-dependencies.sh /usr/local/bin/prepare-container-dependencies +RUN --mount=type=bind,source=src,target=/src \ + bash /usr/local/bin/prepare-container-dependencies /src + +ENV X_VCPKG_ASSET_SOURCES="clear;x-block-origin" +RUN --network=none --mount=type=bind,source=src,target=/source/src \ + cp -a /source /tmp/kompli-offline && \ + cmake -S /tmp/kompli-offline/src -B /tmp/kompli-offline/build \ + -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_TELEMETRY=OFF && \ + cmake --build /tmp/kompli-offline/build --parallel "$(nproc)" && \ + rm -rf /tmp/kompli-offline +WORKDIR /kompli diff --git a/devops/docker/debian-12-amd64/Dockerfile b/devops/docker/debian-12-amd64/Dockerfile index 28d977a40..ef0d09924 100644 --- a/devops/docker/debian-12-amd64/Dockerfile +++ b/devops/docker/debian-12-amd64/Dockerfile @@ -1,6 +1,5 @@ FROM mcr.microsoft.com/mirror/docker/library/debian:bookworm@sha256:d74df7598108a173a621eda4d58a2adbf850b2d9a9d81bc2cca1a6c21174a880 -ARG CMAKE_VERSION=v3.30.1 ARG DEBIAN_FRONTEND=noninteractive RUN apt -y update && apt-get -y install software-properties-common @@ -29,9 +28,26 @@ ENV PATH="/opt/kompli-venv/bin:${PATH}" WORKDIR /git # CMake -RUN git clone https://github.com/Kitware/CMake --recursive -b ${CMAKE_VERSION} -RUN cd CMake && ./bootstrap && make -j$(nproc) && make install && hash -r && rm -rf /git/CMake +ARG CMAKE_VERSION=v3.30.1 +COPY devops/scripts/install-container-cmake.sh /usr/local/bin/install-container-cmake +RUN bash /usr/local/bin/install-container-cmake "$CMAKE_VERSION" /usr/local + +ENV KOMPLI_VCPKG_ROOT=/opt/kompli/vcpkg \ + VCPKG_DOWNLOADS=/opt/kompli/downloads \ + VCPKG_DEFAULT_BINARY_CACHE=/opt/kompli/binary-cache \ + X_VCPKG_REGISTRIES_CACHE=/opt/kompli/registries \ + VCPKG_DISABLE_METRICS=1 +COPY external/vcpkg /opt/kompli/vcpkg +COPY devops/scripts/download-vcpkg-asset.sh /usr/local/bin/download-vcpkg-asset.sh +COPY devops/scripts/prepare-container-dependencies.sh /usr/local/bin/prepare-container-dependencies +RUN --mount=type=bind,source=src,target=/src \ + bash /usr/local/bin/prepare-container-dependencies /src -COPY . /src -WORKDIR /src -RUN (cd external/vcpkg && ./bootstrap-vcpkg.sh) && (cd src && ../external/vcpkg/vcpkg install) && rm -rf /src +ENV X_VCPKG_ASSET_SOURCES="clear;x-block-origin" +RUN --network=none --mount=type=bind,source=src,target=/source/src \ + cp -a /source /tmp/kompli-offline && \ + cmake -S /tmp/kompli-offline/src -B /tmp/kompli-offline/build \ + -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_TELEMETRY=OFF && \ + cmake --build /tmp/kompli-offline/build --parallel "$(nproc)" && \ + rm -rf /tmp/kompli-offline +WORKDIR /kompli diff --git a/devops/docker/oraclelinux-8-amd64/Dockerfile b/devops/docker/oraclelinux-8-amd64/Dockerfile index ea4062120..ded5980c4 100644 --- a/devops/docker/oraclelinux-8-amd64/Dockerfile +++ b/devops/docker/oraclelinux-8-amd64/Dockerfile @@ -1,10 +1,9 @@ # TODO: Add mcr.io retagged images FROM oraclelinux:8@sha256:1f74281d8cc37c6e4adef0559f4c583022193dcfa8562d2e4a87161b6cd54df8 -ARG CMAKE_VERSION=v3.30.1 - RUN yum install -y \ autoconf \ + curl \ gcc \ gcc-c++ \ git \ @@ -15,7 +14,10 @@ RUN yum install -y \ perl \ perl-IPC-Cmd \ python38 \ - rpm-build + rpm-build \ + tar \ + unzip \ + zip RUN python3.8 -m venv /opt/kompli-venv ENV PATH="/opt/kompli-venv/bin:${PATH}" @@ -23,9 +25,26 @@ ENV PATH="/opt/kompli-venv/bin:${PATH}" WORKDIR /git # CMake -RUN git clone https://github.com/Kitware/CMake --recursive -b ${CMAKE_VERSION} -RUN cd CMake && ./bootstrap && make -j$(nproc) && make install && hash -r && rm -rf /git/CMake +ARG CMAKE_VERSION=v3.30.1 +COPY devops/scripts/install-container-cmake.sh /usr/local/bin/install-container-cmake +RUN bash /usr/local/bin/install-container-cmake "$CMAKE_VERSION" /usr/local + +ENV KOMPLI_VCPKG_ROOT=/opt/kompli/vcpkg \ + VCPKG_DOWNLOADS=/opt/kompli/downloads \ + VCPKG_DEFAULT_BINARY_CACHE=/opt/kompli/binary-cache \ + X_VCPKG_REGISTRIES_CACHE=/opt/kompli/registries \ + VCPKG_DISABLE_METRICS=1 +COPY external/vcpkg /opt/kompli/vcpkg +COPY devops/scripts/download-vcpkg-asset.sh /usr/local/bin/download-vcpkg-asset.sh +COPY devops/scripts/prepare-container-dependencies.sh /usr/local/bin/prepare-container-dependencies +RUN --mount=type=bind,source=src,target=/src \ + bash /usr/local/bin/prepare-container-dependencies /src -COPY . /src -WORKDIR /src -RUN (cd external/vcpkg && ./bootstrap-vcpkg.sh) && (cd src && ../external/vcpkg/vcpkg install) && rm -rf /src +ENV X_VCPKG_ASSET_SOURCES="clear;x-block-origin" +RUN --network=none --mount=type=bind,source=src,target=/source/src \ + cp -a /source /tmp/kompli-offline && \ + cmake -S /tmp/kompli-offline/src -B /tmp/kompli-offline/build \ + -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_TELEMETRY=OFF && \ + cmake --build /tmp/kompli-offline/build --parallel "$(nproc)" && \ + rm -rf /tmp/kompli-offline +WORKDIR /kompli diff --git a/devops/docker/rhel-8-amd64/Dockerfile b/devops/docker/rhel-8-amd64/Dockerfile index bb914dafb..e053b2b0d 100644 --- a/devops/docker/rhel-8-amd64/Dockerfile +++ b/devops/docker/rhel-8-amd64/Dockerfile @@ -1,8 +1,6 @@ # TODO: Add mcr.io retagged images FROM registry.access.redhat.com/ubi8/ubi@sha256:c322aa68f2d630b36b9faab64094357f62720be2f56f7099376ca2d6c4fe389b -ARG CMAKE_VERSION=v3.30.1 - RUN yum install -y --disableplugin=subscription-manager \ autoconf \ curl \ @@ -27,9 +25,26 @@ ENV PATH="/opt/kompli-venv/bin:${PATH}" WORKDIR /git # CMake -RUN git clone https://github.com/Kitware/CMake --recursive -b ${CMAKE_VERSION} -RUN cd CMake && ./bootstrap && make -j$(nproc) && make install && hash -r && rm -rf /git/CMake +ARG CMAKE_VERSION=v3.30.1 +COPY devops/scripts/install-container-cmake.sh /usr/local/bin/install-container-cmake +RUN bash /usr/local/bin/install-container-cmake "$CMAKE_VERSION" /usr/local + +ENV KOMPLI_VCPKG_ROOT=/opt/kompli/vcpkg \ + VCPKG_DOWNLOADS=/opt/kompli/downloads \ + VCPKG_DEFAULT_BINARY_CACHE=/opt/kompli/binary-cache \ + X_VCPKG_REGISTRIES_CACHE=/opt/kompli/registries \ + VCPKG_DISABLE_METRICS=1 +COPY external/vcpkg /opt/kompli/vcpkg +COPY devops/scripts/download-vcpkg-asset.sh /usr/local/bin/download-vcpkg-asset.sh +COPY devops/scripts/prepare-container-dependencies.sh /usr/local/bin/prepare-container-dependencies +RUN --mount=type=bind,source=src,target=/src \ + bash /usr/local/bin/prepare-container-dependencies /src -COPY . /src -WORKDIR /src -RUN (cd external/vcpkg && ./bootstrap-vcpkg.sh) && (cd src && ../external/vcpkg/vcpkg install) && rm -rf /src +ENV X_VCPKG_ASSET_SOURCES="clear;x-block-origin" +RUN --network=none --mount=type=bind,source=src,target=/source/src \ + cp -a /source /tmp/kompli-offline && \ + cmake -S /tmp/kompli-offline/src -B /tmp/kompli-offline/build \ + -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_TELEMETRY=OFF && \ + cmake --build /tmp/kompli-offline/build --parallel "$(nproc)" && \ + rm -rf /tmp/kompli-offline +WORKDIR /kompli diff --git a/devops/docker/rhel-9-amd64/Dockerfile b/devops/docker/rhel-9-amd64/Dockerfile index 40e3fe650..40d561d0f 100644 --- a/devops/docker/rhel-9-amd64/Dockerfile +++ b/devops/docker/rhel-9-amd64/Dockerfile @@ -1,8 +1,6 @@ # TODO: Add mcr.io retagged images FROM registry.access.redhat.com/ubi9/ubi@sha256:8f989cc9270da6abec0144c22846ed1e6e92e462dc7768ce0981c4ac1d574733 -ARG CMAKE_VERSION=v3.30.1 - RUN yum install -y --disableplugin=subscription-manager \ autoconf \ gcc \ @@ -26,10 +24,27 @@ ENV PATH="/opt/kompli-venv/bin:${PATH}" WORKDIR /git # CMake -RUN git clone https://github.com/Kitware/CMake --recursive -b ${CMAKE_VERSION} -RUN cd CMake && ./bootstrap && make -j$(nproc) && make install && hash -r && rm -rf /git/CMake +ARG CMAKE_VERSION=v3.30.1 +COPY devops/scripts/install-container-cmake.sh /usr/local/bin/install-container-cmake +RUN bash /usr/local/bin/install-container-cmake "$CMAKE_VERSION" /usr/local + +ENV KOMPLI_VCPKG_ROOT=/opt/kompli/vcpkg \ + VCPKG_DOWNLOADS=/opt/kompli/downloads \ + VCPKG_DEFAULT_BINARY_CACHE=/opt/kompli/binary-cache \ + X_VCPKG_REGISTRIES_CACHE=/opt/kompli/registries \ + VCPKG_DISABLE_METRICS=1 +COPY external/vcpkg /opt/kompli/vcpkg +COPY devops/scripts/download-vcpkg-asset.sh /usr/local/bin/download-vcpkg-asset.sh +COPY devops/scripts/prepare-container-dependencies.sh /usr/local/bin/prepare-container-dependencies +RUN --mount=type=bind,source=src,target=/src \ + bash /usr/local/bin/prepare-container-dependencies /src -COPY . /src -WORKDIR /src -RUN (cd external/vcpkg && ./bootstrap-vcpkg.sh) && (cd src && ../external/vcpkg/vcpkg install) && rm -rf /src +ENV X_VCPKG_ASSET_SOURCES="clear;x-block-origin" +RUN --network=none --mount=type=bind,source=src,target=/source/src \ + cp -a /source /tmp/kompli-offline && \ + cmake -S /tmp/kompli-offline/src -B /tmp/kompli-offline/build \ + -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_TELEMETRY=OFF && \ + cmake --build /tmp/kompli-offline/build --parallel "$(nproc)" && \ + rm -rf /tmp/kompli-offline +WORKDIR /kompli diff --git a/devops/docker/rockylinux-9-amd64/Dockerfile b/devops/docker/rockylinux-9-amd64/Dockerfile index 9ec9110c0..c87c7f9d0 100644 --- a/devops/docker/rockylinux-9-amd64/Dockerfile +++ b/devops/docker/rockylinux-9-amd64/Dockerfile @@ -1,8 +1,6 @@ # TODO: Add mcr.io retagged images FROM rockylinux:9@sha256:d7be1c094cc5845ee815d4632fe377514ee6ebcf8efaed6892889657e5ddaaa6 -ARG CMAKE_VERSION=v3.30.1 - RUN yum install -y \ autoconf \ gcc \ @@ -26,9 +24,26 @@ ENV PATH="/opt/kompli-venv/bin:${PATH}" WORKDIR /git # CMake -RUN git clone https://github.com/Kitware/CMake --recursive -b ${CMAKE_VERSION} -RUN cd CMake && ./bootstrap && make -j$(nproc) && make install && hash -r && rm -rf /git/CMake +ARG CMAKE_VERSION=v3.30.1 +COPY devops/scripts/install-container-cmake.sh /usr/local/bin/install-container-cmake +RUN bash /usr/local/bin/install-container-cmake "$CMAKE_VERSION" /usr/local + +ENV KOMPLI_VCPKG_ROOT=/opt/kompli/vcpkg \ + VCPKG_DOWNLOADS=/opt/kompli/downloads \ + VCPKG_DEFAULT_BINARY_CACHE=/opt/kompli/binary-cache \ + X_VCPKG_REGISTRIES_CACHE=/opt/kompli/registries \ + VCPKG_DISABLE_METRICS=1 +COPY external/vcpkg /opt/kompli/vcpkg +COPY devops/scripts/download-vcpkg-asset.sh /usr/local/bin/download-vcpkg-asset.sh +COPY devops/scripts/prepare-container-dependencies.sh /usr/local/bin/prepare-container-dependencies +RUN --mount=type=bind,source=src,target=/src \ + bash /usr/local/bin/prepare-container-dependencies /src -COPY . /src -WORKDIR /src -RUN (cd external/vcpkg && ./bootstrap-vcpkg.sh) && (cd src && ../external/vcpkg/vcpkg install) && rm -rf /src +ENV X_VCPKG_ASSET_SOURCES="clear;x-block-origin" +RUN --network=none --mount=type=bind,source=src,target=/source/src \ + cp -a /source /tmp/kompli-offline && \ + cmake -S /tmp/kompli-offline/src -B /tmp/kompli-offline/build \ + -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_TELEMETRY=OFF && \ + cmake --build /tmp/kompli-offline/build --parallel "$(nproc)" && \ + rm -rf /tmp/kompli-offline +WORKDIR /kompli diff --git a/devops/docker/sles-15-amd64/Dockerfile b/devops/docker/sles-15-amd64/Dockerfile index 3374f24a0..414bfe285 100644 --- a/devops/docker/sles-15-amd64/Dockerfile +++ b/devops/docker/sles-15-amd64/Dockerfile @@ -1,8 +1,6 @@ # TODO: Add mcr.io retagged images FROM registry.suse.com/bci/bci-base:15.7@sha256:a1bff75c7ab3d66c8423e3f2370838d5dbed077a4133e9f38a98d7525a630958 -ARG CMAKE_VERSION=v3.30.1 - RUN zypper install -y \ autoconf \ curl \ @@ -32,9 +30,26 @@ RUN printf '%s\n' \ WORKDIR /git # CMake -RUN git clone https://github.com/Kitware/CMake --recursive -b ${CMAKE_VERSION} -RUN cd CMake && ./bootstrap && make -j$(nproc) && make install && hash -r && rm -rf /git/CMake +ARG CMAKE_VERSION=v3.30.1 +COPY devops/scripts/install-container-cmake.sh /usr/local/bin/install-container-cmake +RUN bash /usr/local/bin/install-container-cmake "$CMAKE_VERSION" /usr/local + +ENV KOMPLI_VCPKG_ROOT=/opt/kompli/vcpkg \ + VCPKG_DOWNLOADS=/opt/kompli/downloads \ + VCPKG_DEFAULT_BINARY_CACHE=/opt/kompli/binary-cache \ + X_VCPKG_REGISTRIES_CACHE=/opt/kompli/registries \ + VCPKG_DISABLE_METRICS=1 +COPY external/vcpkg /opt/kompli/vcpkg +COPY devops/scripts/download-vcpkg-asset.sh /usr/local/bin/download-vcpkg-asset.sh +COPY devops/scripts/prepare-container-dependencies.sh /usr/local/bin/prepare-container-dependencies +RUN --mount=type=bind,source=src,target=/src \ + bash /usr/local/bin/prepare-container-dependencies /src -COPY . /src -WORKDIR /src -RUN (cd external/vcpkg && ./bootstrap-vcpkg.sh) && (cd src && ../external/vcpkg/vcpkg install) && rm -rf /src +ENV X_VCPKG_ASSET_SOURCES="clear;x-block-origin" +RUN --network=none --mount=type=bind,source=src,target=/source/src \ + cp -a /source /tmp/kompli-offline && \ + cmake -S /tmp/kompli-offline/src -B /tmp/kompli-offline/build \ + -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_TELEMETRY=OFF && \ + cmake --build /tmp/kompli-offline/build --parallel "$(nproc)" && \ + rm -rf /tmp/kompli-offline +WORKDIR /kompli diff --git a/devops/docker/ubuntu-20.04-amd64/Dockerfile b/devops/docker/ubuntu-20.04-amd64/Dockerfile index d5d737c34..9d00cb8ac 100644 --- a/devops/docker/ubuntu-20.04-amd64/Dockerfile +++ b/devops/docker/ubuntu-20.04-amd64/Dockerfile @@ -1,6 +1,5 @@ FROM mcr.microsoft.com/mirror/docker/library/ubuntu:20.04@sha256:8feb4d8ca5354def3d8fce243717141ce31e2c428701f6682bd2fafe15388214 -ARG CMAKE_VERSION=v3.30.1 ARG DEBIAN_FRONTEND=noninteractive RUN apt -y update && apt-get -y install software-properties-common @@ -37,9 +36,26 @@ RUN apt-get update && apt-get install -y dotnet-sdk-5.0 WORKDIR /git # CMake -RUN git clone https://github.com/Kitware/CMake --recursive -b ${CMAKE_VERSION} -RUN cd CMake && ./bootstrap && make -j$(nproc) && make install && hash -r && rm -rf /git/CMake +ARG CMAKE_VERSION=v3.30.1 +COPY devops/scripts/install-container-cmake.sh /usr/local/bin/install-container-cmake +RUN bash /usr/local/bin/install-container-cmake "$CMAKE_VERSION" /usr/local + +ENV KOMPLI_VCPKG_ROOT=/opt/kompli/vcpkg \ + VCPKG_DOWNLOADS=/opt/kompli/downloads \ + VCPKG_DEFAULT_BINARY_CACHE=/opt/kompli/binary-cache \ + X_VCPKG_REGISTRIES_CACHE=/opt/kompli/registries \ + VCPKG_DISABLE_METRICS=1 +COPY external/vcpkg /opt/kompli/vcpkg +COPY devops/scripts/download-vcpkg-asset.sh /usr/local/bin/download-vcpkg-asset.sh +COPY devops/scripts/prepare-container-dependencies.sh /usr/local/bin/prepare-container-dependencies +RUN --mount=type=bind,source=src,target=/src \ + bash /usr/local/bin/prepare-container-dependencies /src -COPY . /src -WORKDIR /src -RUN (cd external/vcpkg && ./bootstrap-vcpkg.sh) && (cd src && ../external/vcpkg/vcpkg install) && rm -rf /src +ENV X_VCPKG_ASSET_SOURCES="clear;x-block-origin" +RUN --network=none --mount=type=bind,source=src,target=/source/src \ + cp -a /source /tmp/kompli-offline && \ + cmake -S /tmp/kompli-offline/src -B /tmp/kompli-offline/build \ + -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_TELEMETRY=OFF && \ + cmake --build /tmp/kompli-offline/build --parallel "$(nproc)" && \ + rm -rf /tmp/kompli-offline +WORKDIR /kompli diff --git a/devops/docker/ubuntu-22.04-amd64/Dockerfile b/devops/docker/ubuntu-22.04-amd64/Dockerfile index 66ec2cfc3..060cf1906 100644 --- a/devops/docker/ubuntu-22.04-amd64/Dockerfile +++ b/devops/docker/ubuntu-22.04-amd64/Dockerfile @@ -1,6 +1,5 @@ FROM mcr.microsoft.com/mirror/docker/library/ubuntu:22.04@sha256:104ae83764a5119017b8e8d6218fa0832b09df65aae7d5a6de29a85d813da2fb -ARG CMAKE_VERSION=v3.30.1 ARG DEBIAN_FRONTEND=noninteractive RUN apt -y update && apt-get -y install software-properties-common @@ -35,9 +34,26 @@ ENV PATH="/opt/kompli-venv/bin:${PATH}" WORKDIR /git # CMake -RUN git clone https://github.com/Kitware/CMake --recursive -b ${CMAKE_VERSION} -RUN cd CMake && ./bootstrap && make -j$(nproc) && make install && hash -r && rm -rf /git/CMake +ARG CMAKE_VERSION=v3.30.1 +COPY devops/scripts/install-container-cmake.sh /usr/local/bin/install-container-cmake +RUN bash /usr/local/bin/install-container-cmake "$CMAKE_VERSION" /usr/local + +ENV KOMPLI_VCPKG_ROOT=/opt/kompli/vcpkg \ + VCPKG_DOWNLOADS=/opt/kompli/downloads \ + VCPKG_DEFAULT_BINARY_CACHE=/opt/kompli/binary-cache \ + X_VCPKG_REGISTRIES_CACHE=/opt/kompli/registries \ + VCPKG_DISABLE_METRICS=1 +COPY external/vcpkg /opt/kompli/vcpkg +COPY devops/scripts/download-vcpkg-asset.sh /usr/local/bin/download-vcpkg-asset.sh +COPY devops/scripts/prepare-container-dependencies.sh /usr/local/bin/prepare-container-dependencies +RUN --mount=type=bind,source=src,target=/src \ + bash /usr/local/bin/prepare-container-dependencies /src -COPY . /src -WORKDIR /src -RUN (cd external/vcpkg && ./bootstrap-vcpkg.sh) && (cd src && ../external/vcpkg/vcpkg install) && rm -rf /src +ENV X_VCPKG_ASSET_SOURCES="clear;x-block-origin" +RUN --network=none --mount=type=bind,source=src,target=/source/src \ + cp -a /source /tmp/kompli-offline && \ + cmake -S /tmp/kompli-offline/src -B /tmp/kompli-offline/build \ + -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_TELEMETRY=OFF && \ + cmake --build /tmp/kompli-offline/build --parallel "$(nproc)" && \ + rm -rf /tmp/kompli-offline +WORKDIR /kompli diff --git a/devops/docker/ubuntu-24.04-amd64/Dockerfile b/devops/docker/ubuntu-24.04-amd64/Dockerfile index 58a49f887..f4a148850 100644 --- a/devops/docker/ubuntu-24.04-amd64/Dockerfile +++ b/devops/docker/ubuntu-24.04-amd64/Dockerfile @@ -1,6 +1,5 @@ FROM mcr.microsoft.com/mirror/docker/library/ubuntu:24.04@sha256:c35e29c9450151419d9448b0fd75374fec4fff364a27f176fb458d472dfc9e54 -ARG CMAKE_VERSION=v3.30.1 ARG DEBIAN_FRONTEND=noninteractive RUN apt -y update && apt-get -y install software-properties-common @@ -36,9 +35,26 @@ ENV PATH="/opt/kompli-venv/bin:${PATH}" WORKDIR /git # CMake -RUN git clone https://github.com/Kitware/CMake --recursive -b ${CMAKE_VERSION} -RUN cd CMake && ./bootstrap && make -j$(nproc) && make install && hash -r && rm -rf /git/CMake +ARG CMAKE_VERSION=v3.30.1 +COPY devops/scripts/install-container-cmake.sh /usr/local/bin/install-container-cmake +RUN bash /usr/local/bin/install-container-cmake "$CMAKE_VERSION" /usr/local + +ENV KOMPLI_VCPKG_ROOT=/opt/kompli/vcpkg \ + VCPKG_DOWNLOADS=/opt/kompli/downloads \ + VCPKG_DEFAULT_BINARY_CACHE=/opt/kompli/binary-cache \ + X_VCPKG_REGISTRIES_CACHE=/opt/kompli/registries \ + VCPKG_DISABLE_METRICS=1 +COPY external/vcpkg /opt/kompli/vcpkg +COPY devops/scripts/download-vcpkg-asset.sh /usr/local/bin/download-vcpkg-asset.sh +COPY devops/scripts/prepare-container-dependencies.sh /usr/local/bin/prepare-container-dependencies +RUN --mount=type=bind,source=src,target=/src \ + bash /usr/local/bin/prepare-container-dependencies /src -COPY . /src -WORKDIR /src -RUN (cd external/vcpkg && ./bootstrap-vcpkg.sh) && (cd src && ../external/vcpkg/vcpkg install) && rm -rf /src +ENV X_VCPKG_ASSET_SOURCES="clear;x-block-origin" +RUN --network=none --mount=type=bind,source=src,target=/source/src \ + cp -a /source /tmp/kompli-offline && \ + cmake -S /tmp/kompli-offline/src -B /tmp/kompli-offline/build \ + -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_TELEMETRY=OFF && \ + cmake --build /tmp/kompli-offline/build --parallel "$(nproc)" && \ + rm -rf /tmp/kompli-offline +WORKDIR /kompli diff --git a/devops/scripts/download-vcpkg-asset.sh b/devops/scripts/download-vcpkg-asset.sh new file mode 100644 index 000000000..e016bd427 --- /dev/null +++ b/devops/scripts/download-vcpkg-asset.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +set -euo pipefail + +url="$1" +destination="$2" + +# vcpkg checks the downloaded file against the port's SHA512 before using it. +if [[ "$url" =~ ^https://www\.lua\.org/ftp/(lua-[0-9.]+\.tar\.gz)$ ]]; then + curl --fail --location --retry 3 --connect-timeout 15 --max-time 120 \ + "https://distfiles.macports.org/lua/${BASH_REMATCH[1]}" \ + --output "$destination" +else + # A cache miss lets vcpkg use the original URL. + exit 1 +fi diff --git a/devops/scripts/install-container-cmake.sh b/devops/scripts/install-container-cmake.sh new file mode 100644 index 000000000..d7c0c6632 --- /dev/null +++ b/devops/scripts/install-container-cmake.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +set -euo pipefail + +version="${1#v}" +prefix="$2" +openssl_root="${3:-}" +jobs="$(nproc)" + +build_root="$(mktemp -d)" +trap 'rm -rf -- "$build_root"' EXIT + +git clone --depth 1 --recursive --branch "v$version" \ + https://github.com/Kitware/CMake "$build_root/source" +cd "$build_root/source" + +cmake_options=() +if [[ -n "$openssl_root" ]]; then + cmake_options+=("-DOPENSSL_ROOT_DIR=$openssl_root" -DOPENSSL_USE_STATIC_LIBS=TRUE) + export PKG_CONFIG_PATH="$openssl_root/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}" +fi +./bootstrap --prefix="$prefix" --parallel="$jobs" -- "${cmake_options[@]}" + +if [[ -n "$openssl_root" ]]; then + for entry in \ + "OPENSSL_INCLUDE_DIR:PATH=$openssl_root/include" \ + "OPENSSL_SSL_LIBRARY:FILEPATH=$openssl_root/lib/libssl.a" \ + "OPENSSL_CRYPTO_LIBRARY:FILEPATH=$openssl_root/lib/libcrypto.a"; do + if ! grep -Fx "$entry" CMakeCache.txt; then + echo "CMake did not select the static vcpkg OpenSSL installation: $entry" >&2 + exit 1 + fi + done +fi + +make -j"$jobs" +make install +for executable in cmake ctest cpack; do + actual_version="$("$prefix/bin/$executable" --version)" + if ! printf '%s\n' "$actual_version" | grep -Fx "$executable version $version"; then + echo "$executable does not match the requested CMake version ($version)" >&2 + exit 1 + fi +done diff --git a/devops/scripts/prepare-container-dependencies.sh b/devops/scripts/prepare-container-dependencies.sh new file mode 100644 index 000000000..b29c85aa2 --- /dev/null +++ b/devops/scripts/prepare-container-dependencies.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +set -euo pipefail + +manifest_root="$1" +install_root="$(mktemp -d)" +trap 'rm -rf -- "$install_root"' EXIT + +mkdir -p "$VCPKG_DOWNLOADS" "$VCPKG_DEFAULT_BINARY_CACHE" "$X_VCPKG_REGISTRIES_CACHE" +bash "$KOMPLI_VCPKG_ROOT/bootstrap-vcpkg.sh" -disableMetrics + +final_version="$(jq -er ' + [.tools[] | select(.name == "cmake" and .os == "linux" and .arch == "amd64")] + | if length == 1 then .[0].version else error("Expected one Linux amd64 CMake tool") end +' "$KOMPLI_VCPKG_ROOT/scripts/vcpkg-tools.json")" + +if ninja="$("$KOMPLI_VCPKG_ROOT/vcpkg" fetch ninja --x-stderr-status)"; then + if [[ ! -x "$ninja" ]]; then + echo "vcpkg did not return an executable Ninja tool: $ninja" >&2 + exit 1 + fi +else + status="$?" + printf '%s\n' "$ninja" >&2 + exit "$status" +fi +export PATH="$(dirname "$ninja"):$PATH" + +install_arguments=( + "--x-asset-sources=x-script,bash /usr/local/bin/download-vcpkg-asset.sh {url} {dst}" + --triplet=x64-linux + --x-manifest-root="$manifest_root" + --x-install-root="$install_root" +) +VCPKG_FORCE_SYSTEM_BINARIES=1 "$KOMPLI_VCPKG_ROOT/vcpkg" install "${install_arguments[@]}" + +bash "$(dirname "${BASH_SOURCE[0]}")/install-container-cmake" \ + "v$final_version" /usr/local "$install_root/x64-linux" + +# Refresh package ABIs and binary caches with the final CMake toolchain. +"$KOMPLI_VCPKG_ROOT/vcpkg" install "${install_arguments[@]}" +cp "$install_root/vcpkg/vcpkg-lock.json" "$KOMPLI_VCPKG_ROOT/vcpkg-lock.json" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 65a5ea43c..c297f7cd8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,6 +8,22 @@ endif() set(VCPKG_SOURCE_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../external/vcpkg") set(VCPKG_ROOT_DIR "${CMAKE_CURRENT_BINARY_DIR}/vcpkg_root") +if(DEFINED ENV{KOMPLI_VCPKG_ROOT}) + set(VCPKG_ROOT_DIR "$ENV{KOMPLI_VCPKG_ROOT}") + if(NOT EXISTS "${VCPKG_ROOT_DIR}/vcpkg" OR NOT EXISTS "${VCPKG_ROOT_DIR}/scripts/buildsystems/vcpkg.cmake") + message(FATAL_ERROR "KOMPLI_VCPKG_ROOT must point to a bootstrapped vcpkg tree; rebuild the build container") + endif() + if(NOT EXISTS "${VCPKG_ROOT_DIR}/vcpkg-lock.json") + message(FATAL_ERROR "Missing cached vcpkg registry lock; rebuild the build container") + endif() + if(NOT EXISTS "${CMAKE_BINARY_DIR}/vcpkg_installed/vcpkg/vcpkg-lock.json") + configure_file( + "${VCPKG_ROOT_DIR}/vcpkg-lock.json" + "${CMAKE_BINARY_DIR}/vcpkg_installed/vcpkg/vcpkg-lock.json" + COPYONLY + ) + endif() +endif() set(VCPKG_TOOLCHAIN_FILE_PATH "${VCPKG_ROOT_DIR}/scripts/buildsystems/vcpkg.cmake") set(VCPKG_EXECUTABLE_PATH "${VCPKG_ROOT_DIR}/vcpkg") @@ -104,7 +120,7 @@ endif() if (RUN_VCPKG_INSTALL) message(STATUS "Running vcpkg install (first run or manifest changed).") execute_process( - COMMAND ${VCPKG_EXECUTABLE_PATH} install + COMMAND ${VCPKG_EXECUTABLE_PATH} install "--x-install-root=${CMAKE_BINARY_DIR}/vcpkg_installed" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" RESULT_VARIABLE VCPKG_INSTALL_RESULT ) @@ -116,7 +132,7 @@ else() message(STATUS "Skipping initial vcpkg install (dependencies already up to date).") endif() -cmake_minimum_required(VERSION 3.21) +cmake_minimum_required(VERSION 4.4.2) project(kompli) set (CMAKE_C_STANDARD 11) diff --git a/src/common/telemetry/CMakeLists.txt b/src/common/telemetry/CMakeLists.txt index 1d82eb726..061bef3fc 100644 --- a/src/common/telemetry/CMakeLists.txt +++ b/src/common/telemetry/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. -cmake_minimum_required(VERSION 3.21) +cmake_minimum_required(VERSION 4.4.2) project(telemetry) if(BUILD_EXTERNAL) diff --git a/src/common/telemetry/bin/tests/CMakeLists.txt b/src/common/telemetry/bin/tests/CMakeLists.txt index a127d5625..d520af15e 100644 --- a/src/common/telemetry/bin/tests/CMakeLists.txt +++ b/src/common/telemetry/bin/tests/CMakeLists.txt @@ -3,7 +3,7 @@ project(telemetryexetests) -cmake_minimum_required(VERSION 3.2.0) +cmake_minimum_required(VERSION 4.4.2) add_compile_options("-Wall;-Wextra;-Wunused;-Werror;-Wformat;-Wformat-security;-Wno-unused-result;-Wno-unused-parameter") include(GoogleTest) diff --git a/src/common/telemetry/lib/CMakeLists.txt b/src/common/telemetry/lib/CMakeLists.txt index 8cfa25db9..dac99440c 100644 --- a/src/common/telemetry/lib/CMakeLists.txt +++ b/src/common/telemetry/lib/CMakeLists.txt @@ -33,9 +33,13 @@ ExternalProject_Add( ${ONEDS_CPP_SDK_VERSION} GIT_SUBMODULES "" # This disables submodule checkout + PATCH_COMMAND + ${CMAKE_COMMAND} -DSDK_SOURCE_DIR= + -P ${CMAKE_CURRENT_SOURCE_DIR}/Patch1dsSdk.cmake CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} # use the same toolchain -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DBUILD_FUNC_TESTS=OFF diff --git a/src/common/telemetry/lib/Patch1dsSdk.cmake b/src/common/telemetry/lib/Patch1dsSdk.cmake new file mode 100644 index 000000000..03b6e393e --- /dev/null +++ b/src/common/telemetry/lib/Patch1dsSdk.cmake @@ -0,0 +1,14 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +set(header "${SDK_SOURCE_DIR}/lib/include/public/ICdsFactory.hpp") +file(READ "${header}" content) + +# Older SDK releases rely on transitive includes for uint8_t. +if(NOT content MATCHES "#include[ \t]*[<\"]cstdint[>\"]") + if(NOT content MATCHES "#include ") + message(FATAL_ERROR "Cannot patch ${header}: expected include not found") + endif() + string(REPLACE "#include " "#include \n#include " content "${content}") + file(WRITE "${header}" "${content}") +endif() diff --git a/src/tests/fuzzer/CMakeLists.txt b/src/tests/fuzzer/CMakeLists.txt index f99f126cf..070147cc1 100644 --- a/src/tests/fuzzer/CMakeLists.txt +++ b/src/tests/fuzzer/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. -cmake_minimum_required(VERSION 3.21) +cmake_minimum_required(VERSION 4.4.2) # Set the project name and version project(kompli-fuzzer)