Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
myrsloik committed Apr 4, 2024
2 parents 9c11f04 + 5dbd93c commit a4bf65c
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ jobs:
- name: Build
run: |
meson setup build
meson setup -Denable_plugin=true build
ninja -C build
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ jobs:
- name: Build
run: |
meson setup -Dcpp_link_args=-fuse-ld=lld build
meson setup -Dcpp_link_args=-fuse-ld=lld -Denable_plugin=true build
ninja -C build
8 changes: 4 additions & 4 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ jobs:
- name: Build
run: |
meson setup -Dlink_static=true build
meson setup -Ddefault_library=static -Dprefer_static=true -Db_lto=true -Dcpp_link_args=-static -Denable_plugin=true build
ninja -C build
strip build/libbestsource.dll
strip build/bestsource.dll
- uses: actions/upload-artifact@v4
with:
name: libbestsource
path: build/libbestsource.dll
name: bestsource
path: build/bestsource.dll
92 changes: 62 additions & 30 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
project('BestSource', 'cpp',
default_options: ['buildtype=release', 'b_lto=true', 'b_ndebug=if-release', 'cpp_std=c++17'],
default_options: ['buildtype=release', 'b_ndebug=if-release', 'cpp_std=c++17'],
license: 'MIT',
meson_version: '>=0.53.0',
version: '.'.join([
run_command('grep', 'BEST_SOURCE_VERSION_MAJOR', 'src/version.h', check: true).stdout().strip().split()[2],
run_command('grep', 'BEST_SOURCE_VERSION_MINOR', 'src/version.h', check: true).stdout().strip().split()[2]
run_command('grep', 'BEST_SOURCE_VERSION_MINOR', 'src/version.h', check: true).stdout().strip().split()[2],
])
)

link_static = get_option('link_static')

sources = [
api_sources = files(
'src/audiosource.cpp',
'src/avisynth.cpp',
'src/bsshared.cpp',
'src/synthshared.cpp',
'src/tracklist.cpp',
'src/videosource.cpp',
)

api_headers = files(
'src/audiosource.h',
'src/bsshared.h',
'src/tracklist.h',
'src/version.h',
'src/videosource.h',
)

plugin_sources = files(
'src/avisynth.cpp',
'src/synthshared.cpp',
'src/vapoursynth.cpp',
'src/videosource.cpp'
]
)

libs = []
p2p_args = []
Expand All @@ -28,50 +37,73 @@ if host_machine.cpu_family().startswith('x86')
endif

libs += static_library('p2p_main',
[
files(
'libp2p/p2p_api.cpp',
'libp2p/v210.cpp',
'libp2p/simd/cpuinfo_x86.cpp',
'libp2p/simd/p2p_simd.cpp'
],
'libp2p/simd/p2p_simd.cpp',
),
cpp_args: p2p_args,
gnu_symbol_visibility: 'hidden'
gnu_symbol_visibility: 'hidden',
)

if host_machine.cpu_family().startswith('x86')
p2p_args += ['-msse4.1']

libs += static_library('p2p_sse41', 'libp2p/simd/p2p_sse41.cpp',
libs += static_library('p2p_sse41', files('libp2p/simd/p2p_sse41.cpp'),
cpp_args: p2p_args,
gnu_symbol_visibility: 'hidden'
gnu_symbol_visibility: 'hidden',
)
endif

vapoursynth_dep = dependency('vapoursynth', version: '>=55').partial_dependency(compile_args: true, includes: true)

deps = [
vapoursynth_dep,
dependency('libavcodec', version: '>=60.31.0', static: link_static),
dependency('libavformat', version: '>=60.16.0', static: link_static),
dependency('libavutil', version: '>=58.29.0', static: link_static),
dependency('libxxhash', static: link_static),
dependency('libavcodec', version: '>=60.31.0'),
dependency('libavformat', version: '>=60.16.0'),
dependency('libavutil', version: '>=58.29.0'),
dependency('libxxhash'),
]

is_gnu_linker = meson.get_compiler('cpp').get_linker_id() in ['ld.bfd', 'ld.gold', 'ld.mold']
link_args = []

if host_machine.system() == 'windows' and is_gnu_linker and link_static
link_args += ['-static']
elif is_gnu_linker
if meson.get_compiler('cpp').get_linker_id() in ['ld.bfd', 'ld.gold', 'ld.mold']
link_args += ['-Wl,-Bsymbolic']
endif

shared_module('bestsource', sources,
cpp_args: ['-D_FILE_OFFSET_BITS=64'],
libbestsource = library('libbestsource', api_sources,
dependencies: deps,
gnu_symbol_visibility: 'hidden',
install: true,
install_dir: vapoursynth_dep.get_variable(pkgconfig: 'libdir') / 'vapoursynth',
link_args: link_args,
link_with: libs
link_with: libs,
name_prefix: '',
)

install_headers(api_headers,
subdir: 'bestsource',
)

pkg = import('pkgconfig')
pkg.generate(libbestsource,
description: 'A super great audio/video source and FFmpeg wrapper',
filebase: 'bestsource',
name: 'bestsource',
subdirs: 'bestsource',
)

bestsource_dep = declare_dependency(
include_directories: include_directories('src'),
link_with: libbestsource,
)

if get_option('enable_plugin')
vapoursynth_dep = dependency('vapoursynth', version: '>=55').partial_dependency(compile_args: true, includes: true)

shared_module('bestsource', plugin_sources,
dependencies: [bestsource_dep, vapoursynth_dep],
gnu_symbol_visibility: 'hidden',
install: true,
install_dir: vapoursynth_dep.get_variable(pkgconfig: 'libdir') / 'vapoursynth',
link_args: link_args,
name_prefix: '',
)
endif
4 changes: 2 additions & 2 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
option('link_static',
option('enable_plugin',
type: 'boolean',
value: false,
description: 'Use static linking'
description: 'Enable AviSynth and VapourSynth plugin',
)

0 comments on commit a4bf65c

Please sign in to comment.