-
Notifications
You must be signed in to change notification settings - Fork 1
165 lines (146 loc) · 5.31 KB
/
build-libwebp.yml
File metadata and controls
165 lines (146 loc) · 5.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Build libwebp
on:
push:
paths:
- '.github/workflows/build-libwebp.yml'
workflow_dispatch:
inputs:
libwebp_version:
description: 'libwebp version tag (e.g. v1.6.0)'
required: false
default: 'v1.6.0'
env:
LIBWEBP_VERSION: ${{ inputs.libwebp_version || 'v1.6.0' }}
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: linux
artifact: libwebp.so
- os: windows-latest
target: windows
artifact: libwebp.dll
- os: macos-latest
target: macos
artifact: libwebp.dylib
name: ${{ matrix.target }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Clone libwebp
run: git clone --depth 1 --branch ${{ env.LIBWEBP_VERSION }} https://chromium.googlesource.com/webm/libwebp
- name: Patch out decoder
shell: bash
run: |
cd libwebp
sed -i.bak 's/\$<TARGET_OBJECTS:webpdecode>//' CMakeLists.txt
sed -i.bak 's/add_library(sharpyuv /add_library(sharpyuv STATIC /' CMakeLists.txt
- name: Create export lists
shell: bash
run: |
cat > libwebp-exports.txt <<'EOF'
{ global: WebPEncodeLosslessBGRA; WebPFree; local: *; };
EOF
cat > libwebp-exports-macos.txt <<'EOF'
_WebPEncodeLosslessBGRA
_WebPFree
EOF
cat > libwebp-exports.def <<'EOF'
EXPORTS
WebPEncodeLosslessBGRA
WebPFree
EOF
- name: Build (Unix)
if: runner.os != 'Windows'
run: |
cd libwebp
mkdir build && cd build
if [ "${{ matrix.target }}" = "macos" ]; then
EXTRA_FLAGS="-DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_SHARED_LINKER_FLAGS=-Wl,-exported_symbols_list,${{ github.workspace }}/libwebp-exports-macos.txt,-dead_strip"
else
EXTRA_FLAGS="-DCMAKE_SHARED_LINKER_FLAGS=-Wl,--version-script=${{ github.workspace }}/libwebp-exports.txt,--gc-sections"
fi
cmake .. \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
-DCMAKE_C_FLAGS="-ffunction-sections -fdata-sections -fvisibility=hidden -fno-asynchronous-unwind-tables" \
-DBUILD_SHARED_LIBS=ON \
-DWEBP_BUILD_ANIM_UTILS=OFF \
-DWEBP_BUILD_CWEBP=OFF \
-DWEBP_BUILD_DWEBP=OFF \
-DWEBP_BUILD_GIF2WEBP=OFF \
-DWEBP_BUILD_IMG2WEBP=OFF \
-DWEBP_BUILD_VWEBP=OFF \
-DWEBP_BUILD_WEBPINFO=OFF \
-DWEBP_BUILD_WEBPMUX=OFF \
-DWEBP_BUILD_EXTRAS=OFF \
$EXTRA_FLAGS
cmake --build . --target webp --config MinSizeRel
if [ "${{ matrix.target }}" = "macos" ]; then
strip -x libwebp.* 2>/dev/null || true
else
strip -s libwebp.* 2>/dev/null || true
fi
- name: Build (Windows)
if: runner.os == 'Windows'
run: |
cd libwebp
mkdir build && cd build
cmake .. `
-DCMAKE_BUILD_TYPE=MinSizeRel `
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON `
-DCMAKE_C_FLAGS="/Gw /DWEBP_EXTERN=extern" `
-DBUILD_SHARED_LIBS=ON `
-DCMAKE_SHARED_LINKER_FLAGS="/DEF:${{ github.workspace }}/libwebp-exports.def /OPT:REF,ICF" `
-DWEBP_BUILD_ANIM_UTILS=OFF `
-DWEBP_BUILD_CWEBP=OFF `
-DWEBP_BUILD_DWEBP=OFF `
-DWEBP_BUILD_GIF2WEBP=OFF `
-DWEBP_BUILD_IMG2WEBP=OFF `
-DWEBP_BUILD_VWEBP=OFF `
-DWEBP_BUILD_WEBPINFO=OFF `
-DWEBP_BUILD_WEBPMUX=OFF `
-DWEBP_BUILD_EXTRAS=OFF
cmake --build . --target webp --config MinSizeRel
- name: Copy artifact
shell: bash
run: |
mkdir -p output
if [ "${{ matrix.target }}" = "windows" ]; then
cp libwebp/build/MinSizeRel/${{ matrix.artifact }} output/
else
cp libwebp/build/${{ matrix.artifact }} output/
fi
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: libwebp-${{ matrix.target }}
path: output/${{ matrix.artifact }}
commit:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
- name: Place natives
run: |
mkdir -p webp/src/main/resources/natives/{linux,windows,macos}
cp artifacts/libwebp-linux/libwebp.so webp/src/main/resources/natives/linux/
cp artifacts/libwebp-windows/libwebp.dll webp/src/main/resources/natives/windows/
cp artifacts/libwebp-macos/libwebp.dylib webp/src/main/resources/natives/macos/
- name: Commit
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add webp/src/main/resources/natives/
git diff --cached --quiet && echo "No changes" && exit 0
git commit -m "Update bundled libwebp ${{ env.LIBWEBP_VERSION }}"
git push