1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-22 15:57:15 +00:00
borg/setup_checksums.py
Felix Schwarz 2ff06c58f0 ability to use a system-provided version of "xxhash"
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.
2019-06-04 21:59:26 +02:00

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)