From 668f71be2d3eaa78346d6dc0ca03d38ba54d4463 Mon Sep 17 00:00:00 2001 From: akarin Date: Fri, 20 Jan 2023 23:39:19 +0900 Subject: [PATCH] Add GHA CI Signed-off-by: akarin --- .github/workflows/build.yaml | 63 ++++++++++++++++++++++++++++++++++++ meson.build | 35 +++++++++++++------- 2 files changed, 87 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..7fdbdb7 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,63 @@ +name: Build +on: + - push + - release + - pull_request + - workflow_dispatch + +jobs: + build: + runs-on: windows-latest + strategy: + matrix: + arch: + - amd64 + steps: + - uses: actions/checkout@v3 + - name: setup MS dev commands + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: ${{ matrix.arch }} + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + - name: install meson and ninja + run: pip install meson ninja + + - name: Install pkg-config lite and nasm + shell: bash + run: | + # pkg-config + curl -o pcl.zip -L https://github.com/AmusementClub/blobs/releases/download/blob-pkgconfiglite/pkg-config-lite-0.28-1_bin-win32.zip + 7z x pcl.zip + echo "$(cygpath --absolute --long-name --windows $(pwd)/pkg-config-lite-0.28-1/bin)" >> $GITHUB_PATH + # nasm + curl -o nasm.zip -L https://www.nasm.us/pub/nasm/releasebuilds/2.16.01/win64/nasm-2.16.01-win64.zip + 7z x nasm.zip + echo "$(cygpath --absolute --long-name --windows $(pwd)/nasm-2.16.01)" >> $GITHUB_PATH + cat $GITHUB_PATH + + - name: Run vcpkg + uses: lukka/run-vcpkg@v7 + with: + vcpkgArguments: 'fftw3[avx2]:x64-windows-static' + vcpkgDirectory: '${{ github.workspace }}/vcpkg' + vcpkgGitCommitId: 5568f110b509a9fd90711978a7cb76bae75bb092 # 2021.05.12 release + + - name: download VS headers and patch header location + shell: bash + run: | + git clone https://github.com/AmusementClub/vapoursynth-classic --depth=1 --branch doodle2 vapoursynth + cp vapoursynth/include/*.h src/ + sed -i -e '/#include |""|' src/*.[ch] src/*.cpp + - name: Meson setup + run: meson setup builddir/ -Db_vscrt=mt -Dpkg_config_path=${{ github.workspace }}/vcpkg/installed/x64-windows-static/lib/pkgconfig + - name: Meson compile + run: meson compile -C builddir/ -v + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: release-${{matrix.arch}} + path: | + builddir/mvtools.dll diff --git a/meson.build b/meson.build index 8ec6f8a..87ec1ab 100644 --- a/meson.build +++ b/meson.build @@ -1,8 +1,9 @@ project('MVTools', 'c', 'cpp', version: '23', default_options: ['c_std=c99', 'cpp_std=c++11', 'buildtype=release', 'b_lto=true'], - meson_version: '>=0.46') + meson_version: '>=0.49') +gcc_syntax = meson.get_compiler('cpp').get_argument_syntax() == 'gcc' warnings = [ '-Wall', @@ -11,10 +12,14 @@ warnings = [ ] cflags = [ - warnings, - '-fvisibility=hidden', '-DPACKAGE_VERSION="@0@"'.format(meson.project_version()), ] +if gcc_syntax + cflags += [ + warnings, + '-fvisibility=hidden', + ] +endif ldflags = [ ] @@ -30,7 +35,11 @@ nasm_flags = [ ] -vapoursynth_dep = dependency('vapoursynth').partial_dependency(includes: true, compile_args: true) +if gcc_syntax + vapoursynth_dep = [dependency('vapoursynth').partial_dependency(includes: true, compile_args: true)] +else + vapoursynth_dep = [] +endif sources = [ @@ -82,8 +91,10 @@ host_system = host_machine.system() if host_system == 'windows' or host_system == 'cygwin' if host_cpu_family == 'x86' - cflags += '-mstackrealign' - ldflags += '-Wl,--kill-at' + if gcc_syntax + cflags += '-mstackrealign' + ldflags += '-Wl,--kill-at' + endif nasm_flags += '-DPREFIX' endif @@ -109,7 +120,10 @@ helper_libs = [] if host_cpu_family.startswith('x86') - cflags += ['-mfpmath=sse', '-msse2', '-DMVTOOLS_X86=1'] + cflags += [ '-DMVTOOLS_X86=1' ] + if gcc_syntax + cflags += ['-mfpmath=sse', '-msse2' ] + endif nasm_sources = [ @@ -156,7 +170,7 @@ if host_cpu_family.startswith('x86') helper_libs += static_library('avx2', libavx2_sources, dependencies: vapoursynth_dep, - cpp_args: [cflags, '-mavx2', '-mtune=haswell'], + cpp_args: cflags + (gcc_syntax ? ['-mavx2', '-mtune=haswell'] : []), install: false) endif @@ -164,9 +178,8 @@ endif cxx = meson.get_compiler('cpp') -deps = [ - vapoursynth_dep, - dependency('fftw3f'), +deps = vapoursynth_dep + [ + build_machine.system() == 'windows' ? dependency('fftwf') : dependency('fftw3f'), cxx.find_library('m', required: false), ]