Skip to content

Commit c9e98d7

Browse files
committed
ci: enhance GitHub workflow with LLVM configuration and macOS support
- Update workflow name to "Go tests" for clarity - Configure specific LLVM version 20 with proper env variables for Linux - Add proper LLVM configuration for macOS with dynamic library paths - Improve generator step with better error handling and documentation - Set minimum macOS deployment target to 13.0 to avoid version warnings - Rearrange build and test steps for better workflow organization
1 parent 06c11aa commit c9e98d7

2 files changed

Lines changed: 46 additions & 10 deletions

File tree

.github/workflows/go.yml

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Go
1+
name: Go tests
22

33
on:
44
push:
@@ -40,16 +40,43 @@ jobs:
4040
run: |
4141
if [ "${{ matrix.os }}" = "linux" ]; then
4242
sudo apt-get update
43-
sudo apt-get install -y libclang-dev llvm-dev
43+
sudo apt-get install -y libclang-20-dev llvm-20-dev
44+
echo "CGO_LDFLAGS=-L/usr/lib/llvm-20/lib" >> $GITHUB_ENV
45+
echo "CGO_CFLAGS=-I/usr/lib/llvm-20/include" >> $GITHUB_ENV
46+
# Also try the generic path
47+
echo "LD_LIBRARY_PATH=/usr/lib/llvm-20/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
4448
elif [ "${{ matrix.os }}" = "darwin" ]; then
4549
brew install llvm
50+
LLVM_PREFIX=$(brew --prefix llvm)
51+
echo "CGO_LDFLAGS=-L${LLVM_PREFIX}/lib" >> $GITHUB_ENV
52+
echo "CGO_CFLAGS=-I${LLVM_PREFIX}/include" >> $GITHUB_ENV
53+
echo "PATH=${LLVM_PREFIX}/bin:$PATH" >> $GITHUB_ENV
54+
# macOS needs explicit library path
55+
echo "DYLD_LIBRARY_PATH=${LLVM_PREFIX}/lib:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV
4656
fi
4757
4858
- name: Download FFmpeg libraries
4959
run: go run ./cmd/download-lib/
5060

51-
- name: Run generator
52-
run: go run ./internal/generator
61+
- name: Build
62+
run: go build -v .
63+
64+
# Note: macOS may show linker warnings about version mismatches if the static
65+
# libraries were built on a newer macOS version than the runner.
66+
# These warnings are harmless - the libraries have MACOSX_DEPLOYMENT_TARGET=13.0
67+
- name: Test
68+
run: go test -v .
69+
70+
# The generator creates Go bindings from FFmpeg headers using libclang.
71+
# It's only needed during development when FFmpeg is updated.
72+
# Failures here are acceptable in CI as the generated files are committed.
73+
- name: Run generator (optional - for development only)
74+
run: |
75+
echo "::notice::Generator requires libclang. Failures are expected if libclang setup differs from development environment."
76+
echo "Running generator with environment:"
77+
echo "CGO_LDFLAGS=$CGO_LDFLAGS"
78+
echo "CGO_CFLAGS=$CGO_CFLAGS"
79+
go run ./internal/generator 2>&1 | grep -v "cgo-gcc-prolog\|deprecated" || true
5380
continue-on-error: true
5481

5582
- name: Check for generated code differences
@@ -64,9 +91,3 @@ jobs:
6491
echo "::notice title=Generated Code Match on ${{ matrix.os }}/${{ matrix.arch }}::Generated bindings match committed version."
6592
fi
6693
continue-on-error: true
67-
68-
- name: Build
69-
run: go build -v .
70-
71-
- name: Test
72-
run: go test -v .

internal/builder/library.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,5 +207,20 @@ func buildEnv(installDir string) []string {
207207
env = append(env, "PATH="+binPath)
208208
}
209209

210+
// Set minimum macOS deployment target to avoid version mismatch warnings
211+
// This ensures libraries work on macOS 13.0 and later (supports Intel and Apple Silicon)
212+
if runtime.GOOS == "darwin" {
213+
hasDeploymentTarget := false
214+
for _, e := range env {
215+
if strings.HasPrefix(e, "MACOSX_DEPLOYMENT_TARGET=") {
216+
hasDeploymentTarget = true
217+
break
218+
}
219+
}
220+
if !hasDeploymentTarget {
221+
env = append(env, "MACOSX_DEPLOYMENT_TARGET=13.0")
222+
}
223+
}
224+
210225
return env
211226
}

0 commit comments

Comments
 (0)