Intergrated syncthing (#1442)

This commit is contained in:
superboo07 authored and GitHub committed 2026-11-01 12:58:09 -05:00
1 parent 5b7e401b11
commit 8c09b2c6a8
34 files changed
+2492 -7

No files matched your search

+22 -1
View File
@@ -45,7 +45,7 @@ if ! command -v docker >/dev/null 2>&1; then
echo "Docker is required to cross-compile the glibc ARM64 preload libraries." >&2
exit 1
fi
for tool in curl tar zstd shasum unzip python3; do
for tool in curl tar zstd shasum unzip python3 go; do
if ! command -v "${tool}" >/dev/null 2>&1; then
echo "${tool} is required to build the CI-equivalent APK." >&2
exit 1
@@ -337,6 +337,27 @@ else
(cd "${proot_out}" && shasum -a 256 libproot.so libproot-loader.so > .proot-outputs)
fi
syncthing_src="${repo_root}/tools/syncthing/syncthing-android/syncthing/src/github.com/syncthing/syncthing"
git -C "${repo_root}" submodule update --init --recursive tools/syncthing/syncthing-android
syncthing_inputs=$(printf '%s\n' "$(cd "${repo_root}" && shasum -a 256 tools/syncthing/build.sh \
tools/syncthing/syncthing-android/gradle/libs.versions.toml)" \
"$(git -C "${syncthing_src}" rev-parse HEAD)" \
"$(git -C "${syncthing_src}" diff --binary HEAD | shasum -a 256)" \
"$(cd "${syncthing_src}" && git ls-files -z --others --exclude-standard | xargs -0 shasum -a 256)" \
"${ndk_version}" | shasum -a 256 | cut -d' ' -f1)
if [[ -f "${proot_out}/libsyncthingnative.so" \
&& "$(cat "${proot_out}/.syncthing-inputs" 2>/dev/null)" = "${syncthing_inputs}" ]]; then
echo "syncthing: sources unchanged, keeping ${proot_out}/libsyncthingnative.so"
else
syncthing_stage="${staging_dir}/syncthing"
if ! restore_step syncthing "${syncthing_inputs}" "${syncthing_stage}"; then
"${repo_root}/tools/syncthing/build.sh" "${syncthing_stage}"
save_step syncthing "${syncthing_inputs}" "${syncthing_stage}"
fi
install -m755 "${syncthing_stage}/libsyncthingnative.so" "${proot_out}/"
echo "${syncthing_inputs}" > "${proot_out}/.syncthing-inputs"
fi
bundle_dir="${staging_dir}/pulseaudio-bundle"
mkdir -p "${bundle_dir}"
zstd -dc "${bundle_asset}" | tar -xf - -C "${bundle_dir}"
+48
View File
@@ -0,0 +1,48 @@
#!/usr/bin/env bash
set -euo pipefail
OUTDIR=$(mkdir -p "$1" && cd "$1" && pwd)
: "${NDK:?set NDK to the Android NDK root}"
API=26
HERE=$(cd "$(dirname "$0")" && pwd)
FORK="$HERE/syncthing-android"
SRC="$FORK/syncthing/src/github.com/syncthing/syncthing"
if [[ ! -f "$SRC/build.go" ]]; then
echo "Syncthing source missing; run: git submodule update --init --recursive tools/syncthing/syncthing-android" >&2
exit 1
fi
command -v go >/dev/null || { echo "Go is required to build Syncthing" >&2; exit 1; }
toml="$FORK/gradle/libs.versions.toml"
GO_VERSION=$(sed -n 's/^go_version *= *"\(.*\)"/\1/p' "$toml")
APP_VERSION=$(sed -n 's/^version-name *= *"\(.*\)"/\1/p' "$toml")
[[ -n "$GO_VERSION" && -n "$APP_VERSION" ]] || { echo "Cannot read go_version/version-name from $toml" >&2; exit 1; }
ST_VERSION="v$(echo "$APP_VERSION" | cut -d. -f1-3)"
case "$(uname -s):$(uname -m)" in
Darwin:*) NDK_HOST=darwin-x86_64 ;;
Linux:x86_64) NDK_HOST=linux-x86_64 ;;
Linux:aarch64|Linux:arm64) NDK_HOST=linux-aarch64 ;;
*) echo "Unsupported build host: $(uname -s) $(uname -m)" >&2; exit 1 ;;
esac
TOOLCHAIN="$NDK/toolchains/llvm/prebuilt/$NDK_HOST/bin"
if [[ ! -d "$TOOLCHAIN" && -d "$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin" ]]; then
TOOLCHAIN="$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin"
fi
CC="$TOOLCHAIN/aarch64-linux-android${API}-clang"
[[ -x "$CC" ]] || { echo "Android NDK toolchain not found at $TOOLCHAIN" >&2; exit 1; }
EPOCH=$(git -C "$SRC" show -s --format=%ct HEAD)
cache=${DROIDDECK_BUILD_CACHE:-"${HOME}/.cache/droiddeck-build"}
WORK=$(mktemp -d)
trap 'rm -rf "$WORK"' EXIT
# build.go writes its output into the source tree, so build from a copy.
cp -a "$SRC" "$WORK/syncthing"
rm -f "$WORK/syncthing/.git"
# -checklinkname=0: the fork's anet dependency links against internal net symbols.
(
cd "$WORK/syncthing"
export GOTOOLCHAIN="go${GO_VERSION}" GOPATH="$cache/go" GOMODCACHE="$cache/go/pkg/mod" GOFLAGS=-buildvcs=false
export CGO_ENABLED=1 EXTRA_LDFLAGS=-checklinkname=0 BUILD_HOST=droiddeck BUILD_USER=reproducible-build SOURCE_DATE_EPOCH="$EPOCH"
go version
go run build.go -goos android -goarch arm64 -cc "$CC" -version "$ST_VERSION" -no-upgrade build
)
install -m755 "$WORK/syncthing/syncthing" "$OUTDIR/libsyncthingnative.so"
echo "Syncthing ${ST_VERSION} (fork ${APP_VERSION}, Go ${GO_VERSION}) built into $OUTDIR/libsyncthingnative.so"