diff --git a/.github/actions/setup-llcppg/action.yml b/.github/actions/setup-llcppg/action.yml index 870aad4a..3d4a31b6 100644 --- a/.github/actions/setup-llcppg/action.yml +++ b/.github/actions/setup-llcppg/action.yml @@ -1,5 +1,5 @@ name: "Setup llcppg" -description: "Install dependencies, set up Go, set up LLGo, install llcppg" +description: "Install dependencies, set up Go, download LLGo release, install llcppg" inputs: go: description: "Go version to install" @@ -8,18 +8,12 @@ inputs: description: "LLVM version to install (e.g. 18)" default: "19" llgo: - description: "LLGo git ref or tag" - default: "e4218f90d7926d31c1ffae3965a4e36228d38fd2" + description: "LLGo version to download (e.g. v0.12.0)" + default: "v0.12.0" runs: using: "composite" steps: - uses: actions/checkout@v4 - - name: Checkout LLGo - uses: actions/checkout@v4 - with: - repository: 'goplus/llgo' - path: '.llgo' - ref: ${{inputs.llgo}} - name: Set up Go uses: actions/setup-go@v4 with: @@ -41,15 +35,21 @@ runs: echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-${{inputs.llvm}} main" | sudo tee /etc/apt/sources.list.d/llvm.list wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - sudo apt-get update - sudo apt-get install -y llvm-${{inputs.llvm}}-dev clang-${{inputs.llvm}} libclang-${{inputs.llvm}}-dev lld-${{inputs.llvm}} libunwind-${{inputs.llvm}}-dev libc++-${{inputs.llvm}}-dev pkg-config libgc-dev libssl-dev zlib1g-dev libffi-dev libuv1-dev + sudo apt-get install -y clang-${{inputs.llvm}} pkg-config libgc-dev libssl-dev zlib1g-dev libffi-dev libuv1-dev echo "/usr/lib/llvm-${{inputs.llvm}}/bin" >> $GITHUB_PATH - - name: Install LLGo + - name: Download LLGo release shell: bash - working-directory: .llgo run: | - go install -v ./cmd/llgo/... + bash .github/actions/setup-llcppg/download-llgo.sh ${{inputs.llgo}} .llgo + echo "$GITHUB_WORKSPACE/.llgo/bin" >> $GITHUB_PATH export LLGO_ROOT=$GITHUB_WORKSPACE/.llgo echo "LLGO_ROOT=$LLGO_ROOT" >> $GITHUB_ENV + - name: Verify LLGo installation + shell: bash + run: | + echo "LLGO_ROOT: $LLGO_ROOT" + llgo version + clang --version - name: Build shell: bash run: go build -v ./... diff --git a/.github/actions/setup-llcppg/download-llgo.sh b/.github/actions/setup-llcppg/download-llgo.sh new file mode 100755 index 00000000..3c05febc --- /dev/null +++ b/.github/actions/setup-llcppg/download-llgo.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +# Script to download and extract LLGo release +# Usage: ./download-llgo.sh +# Example: ./download-llgo.sh v0.12.0 ./llgo + +set -e + +VERSION=$1 +INSTALL_DIR=$2 + +if [ -z "$VERSION" ] || [ -z "$INSTALL_DIR" ]; then + echo "Usage: $0 " + echo "Example: $0 v0.12.0 ./llgo" + exit 1 +fi + +# Detect OS and architecture +OS=$(uname -s | tr '[:upper:]' '[:lower:]') +ARCH=$(uname -m) + +# Map architecture names +case $ARCH in + x86_64) + ARCH="amd64" + ;; + aarch64|arm64) + ARCH="arm64" + ;; + *) + echo "Unsupported architecture: $ARCH" + exit 1 + ;; +esac + +# Construct download URL +# Format: llgo{version}.{os}-{arch}.tar.gz +# Example: llgo0.12.0.darwin-arm64.tar.gz or llgo0.12.0.linux-amd64.tar.gz +# Remove 'v' prefix from version if present +VERSION_NUMBER="${VERSION#v}" +FILENAME="llgo${VERSION_NUMBER}.${OS}-${ARCH}.tar.gz" +URL="https://github.com/goplus/llgo/releases/download/${VERSION}/${FILENAME}" + +echo "Downloading LLGo ${VERSION} for ${OS}-${ARCH}..." +echo "URL: $URL" + +# Create install directory +mkdir -p "$INSTALL_DIR" + +# Download and extract +curl -L -o "/tmp/${FILENAME}" "$URL" +tar -xzf "/tmp/${FILENAME}" -C "$INSTALL_DIR" +rm "/tmp/${FILENAME}" + +echo "LLGo ${VERSION} has been installed to ${INSTALL_DIR}" +echo "Binary location: ${INSTALL_DIR}/bin/llgo" + +# Verify installation +if [ -f "${INSTALL_DIR}/bin/llgo" ]; then + echo "Installation verified successfully" + ls -lh "${INSTALL_DIR}/bin/llgo" +else + echo "Error: llgo binary not found at ${INSTALL_DIR}/bin/llgo" + exit 1 +fi