Skip to content

Commit 4c82276

Browse files
authored
chore: add PAIMON_THIRDPARTY_MIRROR_URL env (#19)
1 parent c11112f commit 4c82276

File tree

2 files changed

+76
-3
lines changed

2 files changed

+76
-3
lines changed

cmake_modules/ThirdpartyToolchain.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ foreach(_VERSION_ENTRY ${TOOLCHAIN_VERSIONS_TXT})
6161
set(${_VARIABLE_NAME} ${_VARIABLE_VALUE})
6262
endforeach()
6363

64-
set(THIRDPARTY_MIRROR_URL "")
64+
if(DEFINED ENV{PAIMON_THIRDPARTY_MIRROR_URL})
65+
set(THIRDPARTY_MIRROR_URL "$ENV{PAIMON_THIRDPARTY_MIRROR_URL}")
66+
else()
67+
set(THIRDPARTY_MIRROR_URL "")
68+
endif()
6569

6670
if(DEFINED ENV{PAIMON_ARROW_URL})
6771
set(ARROW_SOURCE_URL "$ENV{PAIMON_ARROW_URL}")

docs/source/building.rst

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,6 @@ at runtime (for example when executing unit tests).
140140

141141
* ``-DPAIMON_USE_ASAN=ON``: Enable Address Sanitizer to check for memory leaks,
142142
buffer overflows or other kinds of memory management issues.
143-
* ``-DPAIMON_USE_TSAN=ON``: Enable Thread Sanitizer to check for races in
144-
multi-threaded code.
145143
* ``-DPAIMON_USE_UBSAN=ON``: Enable Undefined Behavior Sanitizer to check for
146144
situations which trigger C++ undefined behavior.
147145

@@ -159,3 +157,74 @@ LLVM and Clang Tools
159157
We currently use LLVM for library builds and for developer tools such as code
160158
formatting with clang-format. LLVM can be installed via most modern package
161159
managers (apt, yum, etc.).
160+
161+
Environment variables
162+
~~~~~~~~~~~~~~~~~~~~~
163+
164+
The build system and helper scripts accept several environment variables that
165+
can alter fetch and build behaviour without changing CMake flags. These are
166+
especially useful when you want to use a local or corporate mirror for
167+
third-party archives, or to override a specific dependency's download URL.
168+
169+
Common environment variables
170+
----------------------------
171+
172+
* ``PAIMON_THIRDPARTY_MIRROR_URL``
173+
174+
When set, this string is used as a prefix for the default third-party
175+
download URLs. For example, if a dependency would normally be downloaded
176+
from
177+
178+
``https://github.com/fmtlib/fmt/archive/refs/tags/${PAIMON_FMT_BUILD_VERSION}.tar.gz``
179+
180+
and ``PAIMON_THIRDPARTY_MIRROR_URL`` is set to
181+
182+
``https://mirror.example.com/paimon/thirdparty/``, the build system will
183+
attempt to download from
184+
185+
``https://mirror.example.com/paimon/thirdparty/https://github.com/fmtlib/fmt/archive/refs/tags/${PAIMON_FMT_BUILD_VERSION}.tar.gz``
186+
187+
(the exact concatenation semantics follow the third-party fetch helpers
188+
defined in ``cmake_modules/ThirdpartyToolchain.cmake``). If you set a
189+
mirror URL, prefer including a trailing slash to avoid accidental URL
190+
concatenation issues.
191+
192+
* Per-dependency override variables (examples)
193+
194+
Many dependencies support overriding their download URL via a dedicated
195+
environment variable. Examples implemented in the CMake helper include:
196+
197+
- ``PAIMON_FMT_URL`` to override the fmt archive URL
198+
- ``PAIMON_RAPIDJSON_URL`` to override RapidJSON download URL
199+
- ``PAIMON_ZLIB_URL``, ``PAIMON_ZSTD_URL``, ``PAIMON_LZ4_URL`` etc.
200+
201+
If one of these per-dependency environment variables is defined, it will
202+
take precedence over the mirror prefix. Use these variables to precisely
203+
control where a given dependency is fetched from.
204+
205+
Usage examples
206+
--------------
207+
208+
Use a mirror for all third-party downloads:
209+
210+
.. code-block:: shell
211+
212+
export PAIMON_THIRDPARTY_MIRROR_URL="https://mirror.example.com/paimon/thirdparty/"
213+
mkdir build
214+
cd build
215+
cmake -DPAIMON_BUILD_TESTS=ON ..
216+
217+
Override only a single dependency (fmt):
218+
219+
.. code-block:: shell
220+
221+
export PAIMON_FMT_URL="https://internal.example.com/archives/fmt-8.1.1.tar.gz"
222+
mkdir build
223+
cd build
224+
cmake ..
225+
226+
.. note::
227+
228+
The exact fetch behaviour (how the mirror prefix is concatenated, or whether the helper expects a full URL vs. a prefix)
229+
is implemented in ``cmake_modules/ThirdpartyToolchain.cmake``. Consult that file when you need a custom setup.
230+
Unset an environment variable to revert to the default upstream download locations: ``unset PAIMON_THIRDPARTY_MIRROR_URL``

0 commit comments

Comments
 (0)