diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index 53f18d8..7692900 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 + 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,11 @@ 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 +60,11 @@ 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 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..cf84c47 --- /dev/null +++ b/meson.build @@ -0,0 +1,37 @@ +project( + 'assrender', + ['c', 'cpp'], + default_options: [ + 'default_library=static', + 'buildtype=release', + '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