diff --git a/.github/scripts/conan/regenerate_lockfile.sh b/.github/scripts/conan/regenerate_lockfile.sh new file mode 100755 index 000000000..2024c80d6 --- /dev/null +++ b/.github/scripts/conan/regenerate_lockfile.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +set -ex + +TEMP_DIR=$(mktemp -d) +trap "rm -rf $TEMP_DIR" EXIT + +echo "Using temporary CONAN_HOME: $TEMP_DIR" + +# We use a temporary Conan home to avoid polluting the user's existing Conan +# configuration and to not use local cache (which leads to non-reproducible lockfiles). +export CONAN_HOME="$TEMP_DIR" + +# Ensure that the xrplf remote is the first to be consulted, so any recipes we +# patched are used. We also add it there to not created huge diff when the +# official Conan Center Index is updated. +conan remote add --force --index 0 xrplf https://conan.ripplex.io + +# Delete any existing lockfile. +rm -f conan.lock + +# Create a new lockfile that is compatible with macOS. +# It should also work on Linux. +conan lock create . \ + --profile:all=.github/scripts/conan/apple-clang-17.profile diff --git a/.github/workflows/upload-conan-deps.yml b/.github/workflows/upload-conan-deps.yml index 178e80d6c..dd31d3bc5 100644 --- a/.github/workflows/upload-conan-deps.yml +++ b/.github/workflows/upload-conan-deps.yml @@ -22,6 +22,7 @@ on: - .github/actions/conan/action.yml - ".github/scripts/conan/**" + - "!.github/scripts/conan/regenerate_lockfile.sh" - conanfile.py - conan.lock @@ -32,6 +33,7 @@ on: - .github/actions/conan/action.yml - ".github/scripts/conan/**" + - "!.github/scripts/conan/regenerate_lockfile.sh" - conanfile.py - conan.lock diff --git a/docs/build-clio.md b/docs/build-clio.md index 51c6822b5..791bc49d3 100644 --- a/docs/build-clio.md +++ b/docs/build-clio.md @@ -97,30 +97,14 @@ Now you should be able to download the prebuilt dependencies (including `xrpl` p #### Conan lockfile -To achieve reproducible dependencies, we use [Conan lockfile](https://docs.conan.io/2/tutorial/versioning/lockfiles.html). +To achieve reproducible dependencies, we use a [Conan lockfile](https://docs.conan.io/2/tutorial/versioning/lockfiles.html). The `conan.lock` file in the repository contains a "snapshot" of the current dependencies. It is implicitly used when running `conan` commands, you don't need to specify it. You have to update this file every time you add a new dependency or change a revision or version of an existing dependency. -> [!NOTE] -> Conan uses local cache by default when creating a lockfile. -> -> To ensure, that lockfile creation works the same way on all developer machines, you should clear the local cache before creating a new lockfile. - -To create a new lockfile, run the following commands in the repository root: - -```bash -conan remove '*' --confirm -rm conan.lock -# This ensure that xrplf remote is the first to be consulted -conan remote add --force --index 0 xrplf https://conan.ripplex.io -conan lock create . -``` - -> [!NOTE] -> If some dependencies are exclusive for some OS, you may need to run the last command for them adding `--profile:all `. +To update a lockfile, run from the repository root: `./.github/scripts/conan/regenerate_lockfile.sh` ## Building Clio