fix: build lib (#2217)

This commit is contained in:
yetone
2025-06-13 12:14:34 +08:00
committed by GitHub
parent 8a64d454ef
commit 1ce6ca86d6

View File

@@ -14,12 +14,15 @@ TARGET_DIR="${SCRIPT_DIR}/build"
case "$(uname -s)" in
Linux*)
PLATFORM="linux"
LIB_EXT="so"
;;
Darwin*)
PLATFORM="darwin"
LIB_EXT="dylib"
;;
CYGWIN* | MINGW* | MSYS*)
PLATFORM="windows"
LIB_EXT="dll"
;;
*)
echo "Unsupported platform"
@@ -62,20 +65,30 @@ test_gh_auth() {
fi
}
fetch_remote_tags() {
git ls-remote --tags origin | cut -f2 | sed 's|refs/tags/||' | while read tag; do
if ! git rev-parse "$tag" >/dev/null 2>&1; then
git fetch origin "refs/tags/$tag:refs/tags/$tag"
fi
done
}
if [ ! -d "$TARGET_DIR" ]; then
mkdir -p "$TARGET_DIR"
fi
fetch_remote_tags
latest_tag="$(git describe --tags --abbrev=0 || true)" # will be empty in clone repos
built_tag="$(cat build/.tag 2>/dev/null || true)"
save_tag() {
echo "$latest_tag" >build/.tag
echo "$latest_tag" > build/.tag
}
if [[ "$latest_tag" = "$built_tag" && -n "$latest_tag" ]]; then
echo "Local build is up to date. No download needed."
echo "Local build is up to date $latest_tag. No download needed."
elif [[ "$latest_tag" != "$built_tag" && -n "$latest_tag" ]]; then
echo "Local build is out of date $built_tag. Downloading latest $latest_tag."
if test_command "gh" && test_gh_auth; then
gh release download "$latest_tag" --repo "github.com/$REPO_OWNER/$REPO_NAME" --pattern "*$ARTIFACT_NAME_PATTERN*" --clobber --output - | tar -zxv -C "$TARGET_DIR"
save_tag
@@ -91,8 +104,9 @@ elif [[ "$latest_tag" != "$built_tag" && -n "$latest_tag" ]]; then
save_tag
fi
else
echo "No latest tag found. Building from source."
cargo build --release --features=$LUA_VERSION
for f in target/release/lib*.so; do
for f in target/release/lib*.$LIB_EXT; do
cp "$f" "build/$(echo $f | sed 's#.*/lib##')"
done
fi