Misc Changes
This commit is contained in:
@@ -18,6 +18,7 @@ LOCAL_PROPERTIES_PATH="$PROJECT_DIR/local.properties"
|
||||
HOST_GIT_BINARY="$PROJECT_DIR/build/host-git/libgit.so"
|
||||
GIT_SRC_DIR="$TMP_DIR/git-src"
|
||||
HOST_GIT_DIR="$PROJECT_DIR/build/host-git"
|
||||
HOST_GIT_STAMP="$HOST_GIT_DIR/.source-fingerprint"
|
||||
ANDROID_JNI_DIR="$PROJECT_DIR/app/src/main/jniLibs"
|
||||
ANDROID_ASSET_MANPAGE_DIR="$PROJECT_DIR/app/src/main/assets/manpages"
|
||||
ANDROID_API=24
|
||||
@@ -309,10 +310,46 @@ bundle_git_manpages() {
|
||||
done < <(find "$GIT_SRC_DIR/Documentation" -maxdepth 1 -type f \( -name 'git*.txt' -o -name 'git*.adoc' -o -name 'gitignore.txt' -o -name 'gitignore.adoc' \))
|
||||
}
|
||||
|
||||
git_source_fingerprint() {
|
||||
ensure_git_source
|
||||
|
||||
local head
|
||||
local tracked_changes
|
||||
head="$(git -C "$GIT_SRC_DIR" rev-parse HEAD)"
|
||||
tracked_changes="$(git -C "$GIT_SRC_DIR" diff --binary HEAD -- | git hash-object --stdin)"
|
||||
printf '%s:%s\n' "$head" "$tracked_changes"
|
||||
}
|
||||
|
||||
target_is_current() {
|
||||
local output="$1"
|
||||
local stamp="$2"
|
||||
local fingerprint="$3"
|
||||
|
||||
[ -x "$output" ] \
|
||||
&& [ -f "$stamp" ] \
|
||||
&& [ "$(cat "$stamp" 2>/dev/null || true)" = "$fingerprint" ]
|
||||
}
|
||||
|
||||
mark_target_current() {
|
||||
local stamp="$1"
|
||||
local fingerprint="$2"
|
||||
|
||||
mkdir -p "$(dirname "$stamp")"
|
||||
printf '%s\n' "$fingerprint" > "$stamp"
|
||||
}
|
||||
|
||||
build_host_git() {
|
||||
ensure_git_source
|
||||
bundle_git_manpages
|
||||
|
||||
local fingerprint
|
||||
fingerprint="$(git_source_fingerprint):host"
|
||||
if target_is_current "$HOST_GIT_BINARY" "$HOST_GIT_STAMP" "$fingerprint"; then
|
||||
log "Host Git binary is current; skipping rebuild"
|
||||
"$HOST_GIT_BINARY" --version
|
||||
return
|
||||
fi
|
||||
|
||||
log "Building Git for development host"
|
||||
cd "$GIT_SRC_DIR"
|
||||
make clean >/dev/null 2>&1 || true
|
||||
@@ -322,6 +359,7 @@ build_host_git() {
|
||||
mkdir -p "$HOST_GIT_DIR"
|
||||
cp git "$HOST_GIT_BINARY"
|
||||
chmod 755 "$HOST_GIT_BINARY"
|
||||
mark_target_current "$HOST_GIT_STAMP" "$fingerprint"
|
||||
|
||||
log "Host test Git binary: $HOST_GIT_BINARY"
|
||||
"$HOST_GIT_BINARY" --version
|
||||
@@ -332,9 +370,18 @@ build_android_git_for_abi() {
|
||||
local abi="$1"
|
||||
local cc="$2"
|
||||
local output_dir="$ANDROID_JNI_DIR/$abi"
|
||||
local output_binary="$output_dir/libgit.so"
|
||||
local stamp="$output_dir/.source-fingerprint"
|
||||
local fingerprint="$3:android:$abi:$cc:$ANDROID_API"
|
||||
|
||||
require_path "$ANDROID_TOOLBIN/$cc"
|
||||
|
||||
if target_is_current "$output_binary" "$stamp" "$fingerprint"; then
|
||||
log "Android $abi Git binary is current; skipping rebuild"
|
||||
ls -lh "$output_binary"
|
||||
return
|
||||
fi
|
||||
|
||||
log "Building Git for Android $abi"
|
||||
cd "$GIT_SRC_DIR"
|
||||
make clean >/dev/null 2>&1 || true
|
||||
@@ -357,9 +404,10 @@ build_android_git_for_abi() {
|
||||
readelf -h git | sed -n '1,12p'
|
||||
|
||||
mkdir -p "$output_dir"
|
||||
llvm-strip -s git -o "$output_dir/libgit.so"
|
||||
chmod 755 "$output_dir/libgit.so"
|
||||
ls -lh "$output_dir/libgit.so"
|
||||
llvm-strip -s git -o "$output_binary"
|
||||
chmod 755 "$output_binary"
|
||||
mark_target_current "$stamp" "$fingerprint"
|
||||
ls -lh "$output_binary"
|
||||
cd "$PROJECT_DIR"
|
||||
}
|
||||
|
||||
@@ -369,10 +417,13 @@ build_android_git() {
|
||||
require_path "$ANDROID_NDK_DIR"
|
||||
export PATH="$ANDROID_TOOLBIN:$PATH"
|
||||
|
||||
build_android_git_for_abi "arm64-v8a" "aarch64-linux-android${ANDROID_API}-clang"
|
||||
build_android_git_for_abi "armeabi-v7a" "armv7a-linux-androideabi${ANDROID_API}-clang"
|
||||
build_android_git_for_abi "x86" "i686-linux-android${ANDROID_API}-clang"
|
||||
build_android_git_for_abi "x86_64" "x86_64-linux-android${ANDROID_API}-clang"
|
||||
local fingerprint
|
||||
fingerprint="$(git_source_fingerprint)"
|
||||
|
||||
build_android_git_for_abi "arm64-v8a" "aarch64-linux-android${ANDROID_API}-clang" "$fingerprint"
|
||||
build_android_git_for_abi "armeabi-v7a" "armv7a-linux-androideabi${ANDROID_API}-clang" "$fingerprint"
|
||||
build_android_git_for_abi "x86" "i686-linux-android${ANDROID_API}-clang" "$fingerprint"
|
||||
build_android_git_for_abi "x86_64" "x86_64-linux-android${ANDROID_API}-clang" "$fingerprint"
|
||||
}
|
||||
|
||||
build_all_git_targets() {
|
||||
|
||||
Reference in New Issue
Block a user