Start work on porting Go rsync implementation to C

This commit is contained in:
Kovid Goyal
2023-07-14 15:45:04 +05:30
parent 85df15bfc3
commit fabb6bd8cc
7 changed files with 280 additions and 484 deletions

View File

@@ -299,24 +299,6 @@ def set_arches(flags: List[str], arches: Iterable[str] = ('x86_64', 'arm64')) ->
flags.extend(('-arch', arch))
def detect_librsync(cc: List[str], cflags: List[str], ldflags: List[str]) -> str:
if not test_compile(
cc, *cflags, libraries=('rsync',), ldflags=ldflags, show_stderr=True,
src='#include <librsync.h>\nint main(void) { rs_strerror(0); return 0; }'):
raise SystemExit('The librsync library is required')
# check for rs_sig_args() which was added to librsync in Apr 2020 version 2.3.0
if test_compile(cc, *cflags, libraries=('rsync',), ldflags=ldflags, src='''
#include <librsync.h>
int main(void) {
rs_magic_number magic_number = 0;
size_t block_len = 0, strong_len = 0;
rs_sig_args(1024, &magic_number, &block_len, &strong_len);
return 0;
}'''):
return '-DKITTY_HAS_RS_SIG_ARGS'
return ''
def is_gcc(cc: Iterable[str]) -> bool:
@lru_cache()
@@ -434,10 +416,6 @@ def init_env(
cflags.insert(0, f'-I{os.environ["DEVELOP_ROOT"]}/include')
ldpaths.insert(0, f'-L{os.environ["DEVELOP_ROOT"]}/lib')
rs_cflag = detect_librsync(cc, cflags, ldflags + ldpaths)
if rs_cflag:
cflags.append(rs_cflag)
if build_universal_binary:
set_arches(cflags)
set_arches(ldflags)
@@ -830,7 +808,7 @@ def compile_kittens(args: Options) -> None:
return kitten, sources, headers, f'kittens/{kitten}/{output}', includes, libraries
for kitten, sources, all_headers, dest, includes, libraries in (
files('transfer', 'rsync', libraries=('rsync',)),
files('transfer', 'rsync', libraries=('xxhash',)),
):
final_env = kenv.copy()
final_env.cflags.extend(f'-I{x}' for x in includes)