From efb2989a94a8cd3259ffddcdeb7f282a84470180 Mon Sep 17 00:00:00 2001 From: seiya-git Date: Thu, 29 Jan 2026 13:44:51 +0300 Subject: [PATCH 1/4] Add Meson build files for project and source directory setup --- .gitignore | 5 +++ meson.build | 38 +++++++++++++++++++++ src/meson.build | 64 +++++++++++++++++++++++++++++++++++ subprojects/avisynthplus.wrap | 4 +++ subprojects/libass.wrap | 4 +++ 5 files changed, 115 insertions(+) create mode 100644 meson.build create mode 100644 src/meson.build create mode 100644 subprojects/avisynthplus.wrap create mode 100644 subprojects/libass.wrap diff --git a/.gitignore b/.gitignore index 521dfe8..746810a 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,11 @@ build/* */build/x64 Test +# Meson +/subprojects/* +!/subprojects/avisynthplus.wrap +!/subprojects/libass.wrap + # Build results [Dd]ebug/ [Dd]ebugPublic/ diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..e40cffb --- /dev/null +++ b/meson.build @@ -0,0 +1,38 @@ +project( + 'assrender', + ['c', 'cpp'], + default_options: [ + 'default_library=static', + 'buildtype=release', + 'b_vscrt=static_from_buildtype', + 'c_std=c11', + 'cpp_std=c++17', + 'warning_level=3', + ], +) + +# Mirror the MinGW-specific behavior from CMake +cc = meson.get_compiler('c') +is_mingw = host_machine.system() == 'windows' and cc.get_id() == 'gcc' + +if is_mingw + add_project_arguments( + '-Wpedantic', + language: 'c', + ) + + add_project_link_arguments( + '-static-libgcc', + '-Wl,--add-stdcall-alias', + language: 'c', + ) + + if get_option('buildtype') in ['release', 'minsize'] + add_project_link_arguments( + '-s', + language: 'c', + ) + endif +endif + +subdir('src') diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..0b2f3d0 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,64 @@ +cc = meson.get_compiler('c') + +cmake_mod = import('cmake') +win = import('windows') + +plugin_name = 'assrender' + +sources = files( + 'assrender.c', + 'render.c', + 'sub.c', + 'timecodes.c', +) + +if host_machine.system() == 'windows' + sources += win.compile_resources('ASSRender.rc') +endif + +inc_public = include_directories('include') + +libass_dep = dependency( + 'libass', + required: true, + version: '>=0.17.4', +) + +avisynth_dep = dependency( + 'avisynth', + required: false, + version: '>=3.7.3', +) + +if not avisynth_dep.found() + opt = cmake_mod.subproject_options() + opt.add_cmake_defines({'HEADERS_ONLY': true}) + + avisynth_sp = cmake_mod.subproject('avisynthplus', options: opt) + avisynth_dep = avisynth_sp.dependency('AviSynth-Headers') +endif + +deps = [avisynth_dep, libass_dep] +is_mingw = (host_machine.system() == 'windows' and cc.get_id() == 'gcc') +need_defs = host_machine.system() == 'windows' and (not is_mingw) and host_machine.cpu_family() == 'x86' + +if need_defs + assrender = shared_library( + plugin_name, + sources, + include_directories: [inc_public], + dependencies: deps, + vs_module_defs: files('assrender.def'), + install: true, + install_dir: join_paths(get_option('libdir'), 'avisynth'), + ) +else + assrender = shared_library( + plugin_name, + sources, + include_directories: [inc_public], + dependencies: deps, + install: true, + install_dir: join_paths(get_option('libdir'), 'avisynth'), + ) +endif diff --git a/subprojects/avisynthplus.wrap b/subprojects/avisynthplus.wrap new file mode 100644 index 0000000..96bfed9 --- /dev/null +++ b/subprojects/avisynthplus.wrap @@ -0,0 +1,4 @@ +[wrap-git] +directory=avisynthplus +url=https://github.com/AviSynth/AviSynthPlus.git +revision=v3.7.5 diff --git a/subprojects/libass.wrap b/subprojects/libass.wrap new file mode 100644 index 0000000..a154cdd --- /dev/null +++ b/subprojects/libass.wrap @@ -0,0 +1,4 @@ +[wrap-git] +directory=libass +url=https://github.com/libass/libass.git +revision=0.17.4 From a19d1f0465ce9c9f2de1b099882d10ca95cdabf5 Mon Sep 17 00:00:00 2001 From: seiya-git Date: Thu, 29 Jan 2026 15:22:05 +0300 Subject: [PATCH 2/4] Remove 'b_vscrt=static_from_buildtype' from default Meson options --- meson.build | 1 - 1 file changed, 1 deletion(-) diff --git a/meson.build b/meson.build index e40cffb..cf84c47 100644 --- a/meson.build +++ b/meson.build @@ -4,7 +4,6 @@ project( default_options: [ 'default_library=static', 'buildtype=release', - 'b_vscrt=static_from_buildtype', 'c_std=c11', 'cpp_std=c++17', 'warning_level=3', From 263b8d8c1bda21e7f52a0b877f670c4f007e25fa Mon Sep 17 00:00:00 2001 From: seiya-git Date: Thu, 29 Jan 2026 15:32:11 +0300 Subject: [PATCH 3/4] Remove AviSynthPlus and libass manual build; simplify Meson setup steps --- .github/workflows/github-ci.yml | 69 +-------------------------------- 1 file changed, 2 insertions(+), 67 deletions(-) diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index 53f18d8..bb407df 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -5,13 +5,6 @@ on: pull_request: workflow_dispatch: # -env: - ass_repo: https://github.com/libass/libass - ass_ver: 0.17.4 - avs_repo: https://github.com/AviSynth/AviSynthPlus - avs_ver: 3.7.5 - avs_date: 20250420 - jobs: build-linux: runs-on: ubuntu-latest @@ -21,33 +14,11 @@ jobs: - name: Install dependencies run: | sudo apt-get update && sudo apt-get install -y ninja-build nasm libfontconfig1-dev meson - - git clone ${{ env.avs_repo }}.git -b v${{ env.avs_ver }} --depth=1 avsplus - - cd ./avsplus - cmake -DCMAKE_INSTALL_PREFIX=/usr/local -S . -B avisynth-build - cmake --build avisynth-build --config Release -j 2 - sudo cmake --install avisynth-build --config Release - cd .. - - git clone ${{ env.ass_repo }}.git -b ${{ env.ass_ver }} --depth=1 libass - - cd ./libass meson wrap update-db - meson wrap install fribidi - meson wrap install freetype2 - meson wrap install expat - meson wrap install harfbuzz - meson wrap install libpng - meson wrap install zlib - - meson setup build -Ddefault_library=static -Dbuildtype=release -Dasm=enabled -Dc_std=c11 -Dcpp_std=c++17 - meson compile -C build - sudo meson install -C build - name: Build & Save binary run: | - cmake -B build -S . - cmake --build build --clean-first + meson setup build -Dasm=enabled + meson compile -C build cmake -E copy "build/src/libassrender.so" "dist/libassrender.so" - name: Upload artifact uses: actions/upload-artifact@v4 @@ -66,23 +37,7 @@ jobs: python -m pip install --upgrade pip pip install meson - - curl -L "${{ env.avs_repo }}/releases/download/v${{ env.avs_ver }}/AviSynthPlus_${{ env.avs_ver }}_${{ env.avs_date }}-filesonly.7z" ` - --create-dirs -o "./avsplus/avisynthplus-latest-filesonly.7z" - 7z e "avsplus\*-filesonly.7z" -o"lib\x86-32" "*\x86\c_api\AviSynth.lib" - 7z e "avsplus\*-filesonly.7z" -o"lib\x86-64" "*\x64\c_api\AviSynth.lib" - - git clone ${{ env.ass_repo }}.git -b ${{ env.ass_ver }} --depth=1 libass - - cd ./libass meson wrap update-db - meson wrap install fribidi - meson wrap install fontconfig - meson wrap install freetype2 - meson wrap install expat - meson wrap install harfbuzz - meson wrap install libpng - meson wrap install zlib - name: Setup MSVC (x64) uses: ilammy/msvc-dev-cmd@v1 with: @@ -91,22 +46,12 @@ jobs: env: PKG_CONFIG_PATH: C:/assdeps/x64/lib/pkgconfig run: | - cd libass meson setup build_x64 ` --prefix "C:/assdeps/x64" ` --libdir "lib" ` - -Ddefault_library=static ` - -Dbuildtype=release ` -Dasm=enabled ` -Db_vscrt=static_from_buildtype ` - -Dc_std=c11 ` - -Dcpp_std=c++17 meson compile -C build_x64 - meson install -C build_x64 - cd .. - - cmake -D CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -A x64 -S . -B build_x64 - msbuild /t:Rebuild /m /p:Configuration=Release /p:Platform=x64 ".\build_x64\assrender.sln" cmake -E copy "build_x64\src\Release\assrender.dll" "dist\Release_x64\assrender.dll" - name: Setup MSVC (Win32) uses: ilammy/msvc-dev-cmd@v1 @@ -116,22 +61,12 @@ jobs: env: PKG_CONFIG_PATH: C:/assdeps/x86/lib/pkgconfig run: | - cd libass meson setup build_Win32 ` --prefix "C:/assdeps/x86" ` --libdir "lib" ` - -Ddefault_library=static ` - -Dbuildtype=release ` -Dasm=enabled ` -Db_vscrt=static_from_buildtype ` - -Dc_std=c11 ` - -Dcpp_std=c++17 meson compile -C build_Win32 - meson install -C build_Win32 - cd .. - - cmake -D CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -A Win32 -S . -B build_Win32 - msbuild /t:Rebuild /m /p:Configuration=Release /p:Platform=Win32 ".\build_Win32\assrender.sln" cmake -E copy "build_Win32\src\Release\assrender.dll" "dist\Release_Win32\assrender.dll" - name: Upload artifact uses: actions/upload-artifact@v4 From 1a4f2986725ebf7fb74f0a80a63ceee0b7a0cae0 Mon Sep 17 00:00:00 2001 From: seiya-git Date: Thu, 29 Jan 2026 15:34:04 +0300 Subject: [PATCH 4/4] Remove asm enabled flag from Meson setup commands in CI workflow --- .github/workflows/github-ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index bb407df..7692900 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -17,7 +17,7 @@ jobs: meson wrap update-db - name: Build & Save binary run: | - meson setup build -Dasm=enabled + meson setup build meson compile -C build cmake -E copy "build/src/libassrender.so" "dist/libassrender.so" - name: Upload artifact @@ -49,7 +49,6 @@ jobs: meson setup build_x64 ` --prefix "C:/assdeps/x64" ` --libdir "lib" ` - -Dasm=enabled ` -Db_vscrt=static_from_buildtype ` meson compile -C build_x64 cmake -E copy "build_x64\src\Release\assrender.dll" "dist\Release_x64\assrender.dll" @@ -64,7 +63,6 @@ jobs: meson setup build_Win32 ` --prefix "C:/assdeps/x86" ` --libdir "lib" ` - -Dasm=enabled ` -Db_vscrt=static_from_buildtype ` meson compile -C build_Win32 cmake -E copy "build_Win32\src\Release\assrender.dll" "dist\Release_Win32\assrender.dll"