Skip to content

Commit e507a36

Browse files
authored
Merge pull request #138 from zen010101/feat/fpc-direct-build
GitHub Actions CI and build_fpc.sh - cross-platform build script
2 parents 80b0a48 + bf09aa2 commit e507a36

10 files changed

Lines changed: 1336 additions & 525 deletions

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Ensure shell scripts always use LF line endings
2+
*.sh text eol=lf
3+
4+
# Ensure workflow files use LF line endings
5+
*.yml text eol=lf
6+
*.yaml text eol=lf

.github/workflows/build.yml

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
name: Build pasls
2+
3+
on:
4+
push:
5+
branches: [trunk, main]
6+
tags: ['v*']
7+
pull_request:
8+
branches: [trunk, main]
9+
workflow_dispatch:
10+
11+
env:
12+
# Lazarus release to use for CodeTools source
13+
LAZARUS_VERSION: "lazarus_4_0"
14+
15+
jobs:
16+
# Native builds for all platforms
17+
build:
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
include:
22+
# Linux x86_64
23+
- os: ubuntu-latest
24+
target: x86_64-linux
25+
# Linux ARM64
26+
- os: ubuntu-24.04-arm
27+
target: aarch64-linux
28+
# macOS Intel
29+
- os: macos-15-intel
30+
target: x86_64-darwin
31+
# macOS Apple Silicon
32+
- os: macos-latest
33+
target: aarch64-darwin
34+
# Windows 64-bit
35+
- os: windows-latest
36+
target: x86_64-win64
37+
# Windows 32-bit (built on 64-bit Windows)
38+
- os: windows-latest
39+
target: i386-win32
40+
41+
runs-on: ${{ matrix.os }}
42+
43+
steps:
44+
- name: Checkout repository
45+
uses: actions/checkout@v4
46+
47+
# Install FPC on Linux
48+
- name: Install FPC (Linux)
49+
if: runner.os == 'Linux'
50+
run: |
51+
sudo apt-get update
52+
sudo apt-get install -y fpc
53+
54+
# Install FPC on macOS
55+
- name: Install FPC (macOS)
56+
if: runner.os == 'macOS'
57+
run: |
58+
brew update
59+
brew install fpc
60+
61+
# Install FPC OOTB on Windows (portable, no installation needed)
62+
- name: Install FPC (Windows)
63+
if: runner.os == 'Windows'
64+
shell: bash
65+
run: |
66+
# Download FPC OOTB for the target platform
67+
FPC_VERSION="322"
68+
FPC_BASE_URL="https://github.com/fredvs/freepascal-ootb/releases/download/3.2.2"
69+
70+
if [[ "${{ matrix.target }}" == "i386-win32" ]]; then
71+
FPC_PACKAGE="fpc-ootb-${FPC_VERSION}-i386-win32.zip"
72+
else
73+
FPC_PACKAGE="fpc-ootb-${FPC_VERSION}-x86_64-win64.zip"
74+
fi
75+
76+
echo "Downloading FPC OOTB: $FPC_PACKAGE"
77+
curl -L -o fpc-ootb.zip "${FPC_BASE_URL}/${FPC_PACKAGE}"
78+
79+
# Extract to C:\fpc-ootb
80+
mkdir -p /c/fpc-ootb
81+
unzip -o fpc-ootb.zip -d /c/fpc-ootb
82+
83+
# FPC OOTB uses fpc-ootb-32.exe or fpc-ootb-64.exe
84+
if [[ "${{ matrix.target }}" == "i386-win32" ]]; then
85+
FPC_EXE=$(find /c/fpc-ootb -name "fpc-ootb-32.exe" -type f | head -1)
86+
else
87+
FPC_EXE=$(find /c/fpc-ootb -name "fpc-ootb-64.exe" -type f | head -1)
88+
fi
89+
FPC_DIR=$(dirname "$FPC_EXE")
90+
echo "FPC OOTB directory: $FPC_DIR"
91+
echo "FPC executable: $FPC_EXE"
92+
93+
# List contents for debugging
94+
ls -la "$FPC_DIR"
95+
96+
# Set FPC environment variable (detected by build_fpc.sh)
97+
# Convert to Windows path for FPC
98+
FPC_WIN_PATH=$(cygpath -w "$FPC_EXE")
99+
echo "FPC=$FPC_WIN_PATH" >> $GITHUB_ENV
100+
101+
# Also add directory to PATH
102+
echo "$FPC_DIR" >> $GITHUB_PATH
103+
104+
# Verify
105+
"$FPC_EXE" -iV
106+
107+
# Download Lazarus source for CodeTools
108+
- name: Download Lazarus source
109+
run: |
110+
git clone --depth 1 --branch ${{ env.LAZARUS_VERSION }} \
111+
https://gitlab.com/freepascal.org/lazarus/lazarus.git \
112+
"${{ runner.temp }}/lazarus"
113+
shell: bash
114+
115+
- name: Build pasls
116+
run: |
117+
export LAZARUSDIR="${{ runner.temp }}/lazarus"
118+
cd src
119+
chmod +x build_fpc.sh
120+
./build_fpc.sh ${{ matrix.target }}
121+
shell: bash
122+
123+
- name: Build tests
124+
run: |
125+
export LAZARUSDIR="${{ runner.temp }}/lazarus"
126+
cd src
127+
./build_fpc.sh ${{ matrix.target }} --tests
128+
shell: bash
129+
130+
- name: Run tests (Unix)
131+
if: runner.os != 'Windows'
132+
run: |
133+
chmod +x build/${{ matrix.target }}/testlsp
134+
build/${{ matrix.target }}/testlsp
135+
shell: bash
136+
137+
- name: Run tests (Windows)
138+
if: runner.os == 'Windows'
139+
run: |
140+
build/${{ matrix.target }}/testlsp.exe
141+
shell: bash
142+
143+
- name: Upload artifacts
144+
uses: actions/upload-artifact@v4
145+
with:
146+
name: pasls-${{ matrix.target }}
147+
path: dist/${{ matrix.target }}/pasls*
148+
if-no-files-found: error
149+
150+
# Combine all artifacts into a single download
151+
package:
152+
needs: [build]
153+
if: always()
154+
runs-on: ubuntu-latest
155+
steps:
156+
- name: Download all artifacts
157+
uses: actions/download-artifact@v4
158+
with:
159+
path: dist
160+
161+
- name: Display structure
162+
run: ls -R dist
163+
164+
- name: Upload combined package
165+
uses: actions/upload-artifact@v4
166+
with:
167+
name: pasls-all-platforms
168+
path: dist/
169+
170+
# Create GitHub Release when a tag is pushed
171+
release:
172+
needs: [build]
173+
if: startsWith(github.ref, 'refs/tags/')
174+
runs-on: ubuntu-latest
175+
permissions:
176+
contents: write
177+
178+
steps:
179+
- name: Download all artifacts
180+
uses: actions/download-artifact@v4
181+
with:
182+
path: dist
183+
184+
- name: Create archives and checksums
185+
run: |
186+
cd dist
187+
for dir in pasls-*/; do
188+
target="${dir%/}"
189+
target="${target#pasls-}"
190+
if [[ "$target" == *"win"* ]]; then
191+
zip -r "pasls-${target}.zip" "pasls-${target}/"
192+
else
193+
tar -czvf "pasls-${target}.tar.gz" "pasls-${target}/"
194+
fi
195+
done
196+
# Generate SHA256 checksums
197+
sha256sum *.tar.gz *.zip > checksums.sha256
198+
echo "=== checksums.sha256 ==="
199+
cat checksums.sha256
200+
ls -la
201+
202+
- name: Create Release
203+
uses: softprops/action-gh-release@v1
204+
with:
205+
files: |
206+
dist/*.tar.gz
207+
dist/*.zip
208+
dist/checksums.sha256
209+
generate_release_notes: true

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Lazarus session files
2+
*.lps
3+
4+
# Lazarus backup / temp
5+
*.bak
6+
*.~*
7+
*.ppu
8+
*.o
9+
*.or
10+
*.rst
11+
12+
# Lazarus build output
13+
/lib/
14+
*.exe
15+
*.dll
16+
*.so
17+
*.dylib
18+
19+
# Lazarus config
20+
*.compiled
21+
22+
# AI files
23+
.serena
24+
.claude
25+
26+
# Program database files
27+
*.db
28+
*.ini
29+
30+
# Build output
31+
build/
32+
dist/
33+
src/standard/lib/
34+
35+
# Lazarus user config
36+
packagefiles.xml

0 commit comments

Comments
 (0)