mirror of
https://github.com/mpv-player/mpv
synced 2025-02-27 02:40:53 +00:00
ci/mingw: use ccache
Can significantly reduce build time, most of dependencies have fixed versions, so they can be cached fully. Others will be incrementally build. Cache is saved on every run and restored from the newest one. Size is limited to 500M (compressed) to keep cache save/restore fast. Clean cached build is little over 100M, so we have a headroom as things will grow. ccache will automatically evict least recently used entries. It is unlikely that clean build will exceed the limit anytime soon, but it is something to keep in mind, as we do not want to evict cache entries from current build, so the cache size need to be set correctly.
This commit is contained in:
parent
0e0b396af4
commit
95a2d5b044
16
.github/workflows/build.yml
vendored
16
.github/workflows/build.yml
vendored
@ -12,6 +12,10 @@ on:
|
||||
jobs:
|
||||
mingw:
|
||||
runs-on: ubuntu-22.04
|
||||
env:
|
||||
CCACHE_BASEDIR: ${{ github.workspace }}
|
||||
CCACHE_DIR: ${{ github.workspace }}/.ccache
|
||||
CCACHE_MAXSIZE: 500M
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@ -19,11 +23,21 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Get time
|
||||
id: get_time
|
||||
run: echo "timestamp=`date +%s%N`" >> $GITHUB_OUTPUT
|
||||
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ env.CCACHE_DIR }}
|
||||
key: ${{ matrix.target }}-${{ steps.get_time.outputs.timestamp }}
|
||||
restore-keys: ${{ matrix.target }}-
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y autoconf automake pkg-config g++-mingw-w64 gcc-multilib python3-pip ninja-build nasm wine wine32 wine64
|
||||
sudo apt-get install -y autoconf automake pkg-config g++-mingw-w64 gcc-multilib python3-pip ninja-build nasm wine wine32 wine64 ccache
|
||||
sudo python3 -m pip install meson
|
||||
|
||||
- name: Build libraries
|
||||
|
@ -29,8 +29,8 @@ cat >"$prefix_dir/crossfile" <<EOF
|
||||
buildtype = 'release'
|
||||
wrap_mode = 'nodownload'
|
||||
[binaries]
|
||||
c = '${CC}'
|
||||
cpp = '${CXX}'
|
||||
c = ['ccache', '${CC}']
|
||||
cpp = ['ccache', '${CXX}']
|
||||
ar = '${AR}'
|
||||
strip = '${TARGET}-strip'
|
||||
pkgconfig = 'pkg-config'
|
||||
@ -43,6 +43,9 @@ cpu = '${TARGET%%-*}'
|
||||
endian = 'little'
|
||||
EOF
|
||||
|
||||
export CC="ccache $CC"
|
||||
export CXX="ccache $CXX"
|
||||
|
||||
function builddir () {
|
||||
[ -d "$1/builddir" ] && rm -rf "$1/builddir"
|
||||
mkdir -p "$1/builddir"
|
||||
@ -82,7 +85,7 @@ if [ ! -e "$prefix_dir/lib/libz.dll.a" ]; then
|
||||
gettar "https://zlib.net/fossils/zlib-${ver}.tar.gz"
|
||||
pushd zlib-${ver}
|
||||
make -fwin32/Makefile.gcc clean
|
||||
make -fwin32/Makefile.gcc PREFIX=$TARGET- SHARED_MODE=1 \
|
||||
make -fwin32/Makefile.gcc PREFIX=$TARGET- CC="$CC" SHARED_MODE=1 \
|
||||
DESTDIR="$prefix_dir" install \
|
||||
BINARY_PATH=/bin INCLUDE_PATH=/include LIBRARY_PATH=/lib
|
||||
popd
|
||||
@ -94,7 +97,7 @@ if [ ! -e "$prefix_dir/lib/libavcodec.dll.a" ]; then
|
||||
builddir ffmpeg
|
||||
../configure --pkg-config=pkg-config --target-os=mingw32 \
|
||||
--enable-cross-compile --cross-prefix=$TARGET- --arch=${TARGET%%-*} \
|
||||
$commonflags \
|
||||
--cc="$CC" --cxx="$CXX" $commonflags \
|
||||
--disable-{doc,programs,muxers,encoders,devices}
|
||||
makeplusinstall
|
||||
popd
|
||||
@ -179,11 +182,11 @@ fi
|
||||
if [ ! -e "$prefix_dir/lib/libluajit-5.1.a" ]; then
|
||||
$gitclone https://github.com/LuaJIT/LuaJIT.git
|
||||
pushd LuaJIT
|
||||
hostcc=cc
|
||||
hostcc="ccache cc"
|
||||
flags=
|
||||
[[ "$TARGET" == "i686-"* ]] && { hostcc="$hostcc -m32"; flags=XCFLAGS=-DLUAJIT_NO_UNWIND; }
|
||||
make TARGET_SYS=Windows clean
|
||||
make TARGET_SYS=Windows HOST_CC="$hostcc" CROSS=$TARGET- \
|
||||
make TARGET_SYS=Windows HOST_CC="$hostcc" CROSS="ccache $TARGET-" \
|
||||
BUILDMODE=static $flags amalg
|
||||
make DESTDIR="$prefix_dir" INSTALL_DEP= FILE_T=luajit.exe install
|
||||
popd
|
||||
|
Loading…
Reference in New Issue
Block a user