use snprintf
instead of sprintf
#71
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'which tag to upload to' | |
default: '' | |
jobs: | |
build: | |
runs-on: windows-latest | |
defaults: | |
run: | |
shell: msys2 {0} | |
strategy: | |
matrix: | |
target_cpu: | |
- x86-64 | |
- ivybridge | |
- haswell | |
- skylake | |
- alderlake | |
- raptorlake | |
- bdver4 | |
- znver1 | |
- znver2 | |
- znver3 | |
- znver4 | |
toolchain: | |
- clang | |
#- ucrt | |
steps: | |
- name: Parse matrix | |
run: | | |
if ("${{matrix.toolchain}}" -eq "clang") { | |
echo "MSYSTEM=CLANG64" >> $env:GITHUB_ENV | |
} else { | |
echo "MSYSTEM=UCRT64" >> $env:GITHUB_ENV | |
} | |
shell: pwsh | |
- name: Checkout x265 | |
uses: actions/checkout@v4 | |
with: | |
path: x265 | |
fetch-depth: 0 | |
- name: Cache FFmpeg | |
id: cache-ff | |
uses: actions/cache@v4 | |
with: | |
path: ffmpeg | |
key: ${{matrix.target_cpu}}-${{matrix.toolchain}}-ff | |
- name: Checkout FFmpeg | |
uses: actions/checkout@v4 | |
with: | |
path: ffmpeg | |
repository: FFmpeg/FFmpeg | |
ref: n4.4 | |
if: steps.cache-ff.outputs.cache-hit != 'true' | |
- name: Cache mimalloc | |
id: cache-mi | |
uses: actions/cache@v4 | |
with: | |
path: mimalloc | |
key: ${{matrix.target_cpu}}-${{matrix.toolchain}}-mi-v2 | |
- name: Checkout mimalloc | |
uses: actions/checkout@v4 | |
with: | |
path: mimalloc | |
repository: AmusementClub/mimalloc2 | |
ref: v2.0.2-AC | |
if: steps.cache-mi.outputs.cache-hit != 'true' | |
- name: Setup MSYS2 | |
uses: msys2/setup-msys2@v2 | |
with: | |
msystem: ${{env.MSYSTEM}} | |
update: true | |
install: >- | |
p7zip | |
base-devel | |
mingw-w64-${{matrix.toolchain}}-x86_64-nasm | |
mingw-w64-${{matrix.toolchain}}-x86_64-toolchain | |
mingw-w64-${{matrix.toolchain}}-x86_64-cmake | |
mingw-w64-${{matrix.toolchain}}-x86_64-ninja | |
- name: Compile FFmpeg | |
run: | | |
./configure --enable-gpl --enable-version3 --disable-runtime-cpudetect --disable-all --disable-autodetect --enable-avformat --enable-avcodec --enable-avformat --disable-everything --disable-network --enable-demuxer=mpegts,mov,matroska,h264,hevc --enable-decoder=h264,hevc,ffv1,ffvhuff,huffyuv --enable-protocol=file,pipe --cc=cc --cxx=c++ --cpu=${{matrix.target_cpu}} | |
make -j`nproc` | |
working-directory: ffmpeg | |
if: steps.cache-ff.outputs.cache-hit != 'true' | |
- name: Get rid of .dll.a | |
run: find /*64/ /usr/ -type f -name "*.dll.a" -print -delete | |
- name: Install FFmpeg | |
run: make install | |
working-directory: ffmpeg | |
- name: Compile mimalloc | |
run: | | |
mkdir build | |
cd build | |
# our fork only supports static linking. | |
cmake -GNinja .. -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_POLICY_DEFAULT_CMP0069=NEW -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DMI_BUILD_SHARED=OFF -DMI_BUILD_STATIC=ON -DMI_BUILD_OBJECT=OFF -DMI_BUILD_TESTS=OFF | |
ninja | |
working-directory: mimalloc | |
if: steps.cache-mi.outputs.cache-hit != 'true' | |
- name: Install mimalloc | |
run: ninja install | |
working-directory: mimalloc/build | |
- name: Setup build dir | |
run: mkdir -p build/8b build/10b build/12b | |
- name: Download profdata | |
run: iwr https://github.com/${{github.repository}}/raw/profdata/x265.profdata -OutFile x265.profdata | |
shell: pwsh | |
- name: Compile x265 8bit | |
run: | | |
cmake -GNinja ../../x265/source -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DTARGET_CPU=${{matrix.target_cpu}} -DUSE_MIMALLOC=ON -DUSE_LTO=ON -DCMAKE_ASM_NASM_FLAGS=-w-macro-params-legacy | |
ninja | |
cp libx265.a ../10b/libx265_8b.a | |
working-directory: build/8b | |
- name: Compile x265 12bit | |
run: | | |
cmake -GNinja ../../x265/source -DHIGH_BIT_DEPTH=ON -DMAIN12=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DTARGET_CPU=${{matrix.target_cpu}} -DUSE_MIMALLOC=ON -DUSE_LTO=ON -DCMAKE_ASM_NASM_FLAGS=-w-macro-params-legacy | |
ninja | |
cp libx265.a ../10b/libx265_12b.a | |
working-directory: build/12b | |
- name: Compile x265 10bit (with PGO) | |
working-directory: build | |
run: | | |
cp -a 10b 10bprof | |
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig | |
cmake_flags="-GNinja ../../x265/source -DEXTRA_LIB=x265_8b.a;x265_12b.a -DEXTRA_LINK_FLAGS=-L. -DLINKED_8BIT=ON -DLINKED_12BIT=ON -DENABLE_HDR10_PLUS=ON -DENABLE_AVISYNTH=OFF -DENABLE_VPYSYNTH=OFF -DHIGH_BIT_DEPTH=ON -DENABLE_SHARED=OFF -DENABLE_LAVF=ON -DENABLE_STATIC_LAVF=ON -DTARGET_CPU=${{matrix.target_cpu}} -DUSE_MIMALLOC=ON -DUSE_LTO=ON -DCMAKE_EXE_LINKER_FLAGS=-LD:/a/_temp/msys/msys64/usr/local/lib -DCMAKE_ASM_NASM_FLAGS=-w-macro-params-legacy" | |
pushd 10b | |
cmake $cmake_flags "-DCMAKE_CXX_FLAGS=-I../../FFmpeg -fprofile-instr-use=${{github.workspace}}/x265.profdata" | |
ninja | |
strip -s x265.exe | |
popd | |
pushd 10bprof | |
cmake $cmake_flags "-DCMAKE_CXX_FLAGS=-I../../FFmpeg -fprofile-instr-generate -fprofile-update=atomic" | |
ninja | |
strip -s x265.exe | |
mv x265.exe x265-profiling.exe | |
popd | |
- name: Package | |
run: | | |
mkdir dist | |
cp ${{env.DLL_DEPS}} build/10b*/x265*.exe dist | |
- name: Upload | |
uses: actions/upload-artifact@v4 | |
with: | |
name: x265-win64-${{matrix.target_cpu}}-${{matrix.toolchain}}-full | |
path: dist/* | |
- name: Compress artifact for release | |
if: github.event_name == 'workflow_dispatch' && github.event.inputs.tag != '' | |
run: | | |
cd dist | |
# do not release profiling binary | |
7za a -t7z -mx=7 ../x265-win64-${{matrix.target_cpu}}-${{matrix.toolchain}}.${{ github.event.inputs.tag }}.7z x265.exe | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
if: github.event_name == 'workflow_dispatch' && github.event.inputs.tag != '' | |
with: | |
tag_name: ${{ github.event.inputs.tag }} | |
files: x265-win64-${{matrix.target_cpu}}-${{matrix.toolchain}}.${{ github.event.inputs.tag }}.7z | |
fail_on_unmatched_files: true | |
generate_release_notes: false | |
prerelease: true |