mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-27 02:08:54 +00:00
2ff06c58f0
The build process can be controlled via environment variables similar to other bundled libraries in borgbackup. The main difference is probably that upstream does not provide a pkgconfig file for xxhash. Therefore borg will probably fail to detect the system-provided version by default (tested on Fedora, seems like Debian and Ubuntu do not ship a pkgconfig file either). I kept the pkgconfig lookup code anyway to keep the code as similar as possible to "setup_compress.py"/"setup_crypto.py". Setting BORG_LIBXXHASH_PREFIX=/usr helps borg to detect xxhash on my system (Fedora). You can force the use of the bundled version of xxhash by setting BORG_USE_BUNDLED_XXHASH=1.
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
# Support code for building a C extension with checksums code
|
|
|
|
import os
|
|
|
|
|
|
def multi_join(paths, *path_segments):
|
|
"""apply os.path.join on a list of paths"""
|
|
return [os.path.join(*(path_segments + (path,))) for path in paths]
|
|
|
|
|
|
# xxhash files, structure as seen in xxhash project repository:
|
|
|
|
# path relative (to this file) to the bundled library source code files
|
|
xxhash_bundled_path = 'src/borg/algorithms/xxh64'
|
|
|
|
xxhash_sources = [
|
|
'xxhash.c',
|
|
]
|
|
|
|
xxhash_includes = [
|
|
'',
|
|
]
|
|
|
|
|
|
def xxhash_ext_kwargs(pc, prefer_system, system_prefix):
|
|
if prefer_system:
|
|
if system_prefix:
|
|
print('Detected and preferring libxxhash [via BORG_LIBXXHASH_PREFIX]')
|
|
return dict(include_dirs=[os.path.join(system_prefix, 'include')],
|
|
library_dirs=[os.path.join(system_prefix, 'lib')],
|
|
libraries=['xxhash'])
|
|
|
|
if pc and pc.installed('libxxhash', '>= 1.7.0'):
|
|
print('Detected and preferring libxxhash [via pkg-config]')
|
|
return pc.parse('libxxhash')
|
|
|
|
print('Using bundled xxhash')
|
|
sources = multi_join(xxhash_sources, xxhash_bundled_path)
|
|
include_dirs = multi_join(xxhash_includes, xxhash_bundled_path)
|
|
define_macros = [('BORG_USE_BUNDLED_XXHASH', 'YES')]
|
|
return dict(sources=sources, include_dirs=include_dirs, define_macros=define_macros)
|
|
|