mirror of
https://github.com/hanzoai/quickjs-emscripten.git
synced 2026-10-30 19:37:29 +00:00
* Add vendor script for quickjs-ng and update to v0.12.1 amalgam - Add scripts/vendor-quickjs-ng.sh to download release amalgam zip - Update vendor/quickjs-ng to v0.12.1 amalgamated build - Update Variant.mk to use quickjs-amalgam.o for quickjs-ng variants - Fix c/interface.c compatibility with quickjs-ng: - Remove cutils.h include (not in amalgam) - Add BOOL compatibility define (quickjs-ng uses C99 bool) - Add QTS_JS_IsBigInt macro (different signatures) Note: Some quickjs-ng tests are failing due to API differences in promise handling. This needs further investigation. * Fix quickjs-ng build and test failures - Add forward declaration for js_std_dump_error (needed for debug builds) - Add -DQJS_BUILD_LIBC to enable libc functions in quickjs-ng amalgam - Disable JS_DetectModule for quickjs-ng: it parses code as a module and returns true if parsing succeeds, but any valid JS expression is valid module syntax, so it incorrectly detects non-modules as modules - Regenerate variant Makefiles with the updated template All tests pass. * rebuild * Update vendor-quickjs-ng.sh to auto-fetch latest release When no version argument is provided, the script now queries the GitHub API to get the latest release tag and uses that version. * Simplify vendor:ng:pull to use vendor-quickjs-ng.sh Remove vendor:ng:subtree and vendor:ng:add scripts since we now vendor quickjs-ng from release amalgam instead of git subtree. * Link quickjs-ng docs to release tag instead of commit SHA Add CLibraryUsesTagVersion to indicate which libraries should link to their VERSION file as a release tag instead of using git subtree SHA. quickjs-ng now links to releases/tag/v0.12.1 instead of commit/SHA. * fix variant links for quickjs-ng --------- Co-authored-by: Hanzo Dev <[email protected]>
99 lines
3.1 KiB
Bash
Executable File
99 lines
3.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Vendor a specific version of quickjs-ng from the release amalgam
|
|
# Usage: ./scripts/vendor-quickjs-ng.sh [version]
|
|
# If no version is provided, fetches the latest release
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
VENDOR_DIR="$REPO_ROOT/vendor/quickjs-ng"
|
|
|
|
if [[ $# -lt 1 ]]; then
|
|
echo "No version specified, fetching latest release..."
|
|
VERSION=$(curl -fsSL https://api.github.com/repos/quickjs-ng/quickjs/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
|
|
if [[ -z "$VERSION" ]]; then
|
|
echo "Error: Failed to fetch latest release version"
|
|
exit 1
|
|
fi
|
|
echo "Latest version: ${VERSION}"
|
|
else
|
|
VERSION="$1"
|
|
fi
|
|
|
|
# Validate version format (should start with 'v')
|
|
if [[ ! "$VERSION" =~ ^v[0-9] ]]; then
|
|
echo "Error: Version should start with 'v' (e.g., v0.12.1)"
|
|
exit 1
|
|
fi
|
|
|
|
DOWNLOAD_URL="https://github.com/quickjs-ng/quickjs/releases/download/${VERSION}/quickjs-amalgam.zip"
|
|
TEMP_DIR=$(mktemp -d)
|
|
ZIP_FILE="$TEMP_DIR/quickjs-amalgam.zip"
|
|
|
|
echo "Vendoring quickjs-ng ${VERSION}"
|
|
echo "Download URL: ${DOWNLOAD_URL}"
|
|
|
|
# Download the amalgam zip
|
|
echo "Downloading..."
|
|
if ! curl -fSL -o "$ZIP_FILE" "$DOWNLOAD_URL"; then
|
|
echo "Error: Failed to download ${DOWNLOAD_URL}"
|
|
echo "Check that the version exists at https://github.com/quickjs-ng/quickjs/releases"
|
|
rm -rf "$TEMP_DIR"
|
|
exit 1
|
|
fi
|
|
|
|
# Remove existing vendor directory contents
|
|
echo "Removing existing vendor/quickjs-ng contents..."
|
|
if [[ -d "$VENDOR_DIR" ]]; then
|
|
git -C "$REPO_ROOT" rm -rf "$VENDOR_DIR" || rm -rf "$VENDOR_DIR"
|
|
fi
|
|
mkdir -p "$VENDOR_DIR"
|
|
|
|
# Extract the zip
|
|
echo "Extracting..."
|
|
unzip -q "$ZIP_FILE" -d "$TEMP_DIR/extracted"
|
|
|
|
# Move contents to vendor directory
|
|
# The zip might have a top-level directory or files directly
|
|
if [[ -d "$TEMP_DIR/extracted/quickjs-amalgam" ]]; then
|
|
mv "$TEMP_DIR/extracted/quickjs-amalgam"/* "$VENDOR_DIR/"
|
|
elif [[ -d "$TEMP_DIR/extracted/quickjs" ]]; then
|
|
mv "$TEMP_DIR/extracted/quickjs"/* "$VENDOR_DIR/"
|
|
else
|
|
# Files are directly in extracted directory
|
|
mv "$TEMP_DIR/extracted"/* "$VENDOR_DIR/"
|
|
fi
|
|
|
|
# Write VERSION file
|
|
echo "Writing VERSION file..."
|
|
echo "$VERSION" > "$VENDOR_DIR/VERSION"
|
|
|
|
# Download LICENSE file (not included in amalgam)
|
|
echo "Downloading LICENSE..."
|
|
LICENSE_URL="https://raw.githubusercontent.com/quickjs-ng/quickjs/${VERSION}/LICENSE"
|
|
if ! curl -fSL -o "$VENDOR_DIR/LICENSE" "$LICENSE_URL"; then
|
|
echo "Warning: Failed to download LICENSE file"
|
|
fi
|
|
|
|
# Clean up
|
|
rm -rf "$TEMP_DIR"
|
|
|
|
# Apply patches
|
|
PATCHES_DIR="$REPO_ROOT/vendor/quickjs-ng-patches"
|
|
if [[ -d "$PATCHES_DIR" ]] && ls "$PATCHES_DIR"/*.patch >/dev/null 2>&1; then
|
|
echo "Applying patches..."
|
|
for patch in "$PATCHES_DIR"/*.patch; do
|
|
echo " Applying $(basename "$patch")..."
|
|
patch -d "$VENDOR_DIR" -p1 < "$patch"
|
|
done
|
|
fi
|
|
|
|
# Stage the changes
|
|
echo "Staging changes..."
|
|
git -C "$REPO_ROOT" add "$VENDOR_DIR"
|
|
|
|
echo ""
|
|
echo "Successfully vendored quickjs-ng ${VERSION}"
|
|
echo "Files are staged. Review with 'git status' and commit when ready."
|