-
Notifications
You must be signed in to change notification settings - Fork 13
Improve libgit2 build reliability #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3fb831e
9ec0c95
28aeb09
1c6bda2
7960a6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,45 @@ | |
|
|
||
| set -e | ||
|
|
||
| cd "External/libgit2" | ||
| # Resolve the repository root so the script behaves identically whether CI runs | ||
| # it from the root or Xcode runs it from $SRCROOT. | ||
| script_dir=$(cd "$(dirname "$0")" && pwd) | ||
| script_path="$script_dir/$(basename "$0")" | ||
| root=$(cd "$script_dir/.." && pwd) | ||
| cd "$root" | ||
|
|
||
| submodule="$root/External/libgit2" | ||
| archive="$root/External/libgit2.a" | ||
| stamp="$root/External/libgit2.a.stamp" | ||
|
|
||
| # A key identifying the archive we would produce. It covers the submodule | ||
| # revision, so switching revisions invalidates the archive even when the new | ||
| # revision only deletes or renames sources; the submodule working tree, so | ||
| # local edits and deletions invalidate it; the host architecture, since the | ||
| # archive is built for the host only; and this script, so changing the cmake | ||
| # flags invalidates it. If any part of the key cannot be computed we rebuild | ||
| # rather than trust an archive we cannot account for. | ||
| build_key() { | ||
| git -C "$submodule" rev-parse HEAD || return 1 | ||
| git -C "$submodule" status --porcelain --untracked-files=all \ | ||
| -- . ':(exclude)build' || return 1 | ||
|
Comment on lines
+25
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As it's a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be an alternative: copy&past from google |
||
| uname -m || return 1 | ||
| git hash-object "$script_path" || return 1 | ||
| } | ||
|
|
||
| key=$(build_key) || key='' | ||
|
|
||
| if [ -n "$key" ] && [ -f "$archive" ] && [ -f "$stamp" ] && | ||
| [ "$key" = "$(cat "$stamp")" ]; then | ||
| echo "libgit2 is up to date." | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Drop the stamp before building: if the build fails or is interrupted, the | ||
| # archive left behind must not look up to date on the next run. | ||
| rm -f "$stamp" | ||
|
|
||
| cd "$submodule" | ||
|
|
||
| if [ -d "build" ]; then | ||
| rm -rf "build" | ||
|
|
@@ -12,7 +50,7 @@ mkdir build | |
| cd build | ||
|
|
||
| # OpenSSL is keg-only, so add its pkgconfig location manually | ||
| if [[ $(uname -m) == 'arm64' ]]; then | ||
| if [ "$(uname -m)" = 'arm64' ]; then | ||
| echo "Running on a Apple Silicon M1" | ||
| export ARCH_PREFIX=/opt/homebrew | ||
| else | ||
|
|
@@ -34,9 +72,13 @@ cmake -DBUILD_SHARED_LIBS:BOOL=OFF \ | |
| .. | ||
| cmake --build . | ||
|
|
||
| product="libgit2.a" | ||
| install_path="../../${product}" | ||
| rm -rf $install_path | ||
| cp -v "${product}" "${install_path}" | ||
| rm -f "$archive" | ||
| cp -v "libgit2.a" "$archive" | ||
|
|
||
| if [ -n "$key" ]; then | ||
| printf '%s\n' "$key" > "$stamp" | ||
| else | ||
| echo "Could not record a libgit2 build stamp; libgit2 will be rebuilt next time." >&2 | ||
| fi | ||
|
|
||
| echo "libgit2 has been updated." | ||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed there was a bug !