Commit 195f28ea authored by Niklas Haas's avatar Niklas Haas

3rdparty: use meson subprojects instead

Major refactor of the source code structure. Now uses meson subprojects
for "third party" dependencies (including bstr and talloc), and moves a
lot of the meson boilerplate from src/meson.build to the top-level
meson.build.

We choose the name 'xtalloc' to make sure we don't collide with samba
libtalloc, and to reflect the fact that our wrappers abort on OOM.
parent 5c88b30a
Pipeline #3255 passed with stages
in 4 minutes and 7 seconds
......@@ -2,6 +2,70 @@ project('libplacebo', ['c', 'cpp'],
license: 'LGPL2.1+',
default_options: ['c_std=c99'],
meson_version: '>=0.47',
version: '1.7.0',
)
# Version number
version = meson.project_version()
version_pretty = 'v' + version
version_split = version.split('.')
majorver = version_split[0]
apiver = version_split[1]
fixver = version_split[2]
# update `version_pretty` with `git describe` information if available
git = find_program('git', required: false)
if git.found()
gitdesc = run_command(git, 'describe')
if gitdesc.returncode() == 0
version_pretty = gitdesc.stdout().strip()
endif
endif
# Global build options
build_opts = [
# Warnings
'-Wall', '-Wundef', '-Wshadow', '-Wparentheses', '-Wpointer-arith',
# Warnings to treat as errors
'-Werror=implicit-function-declaration',
]
link_args = []
cc = meson.get_compiler('c')
cxx = meson.get_compiler('cpp')
c_opts = [
'-D_ISOC99_SOURCE', '-D_GNU_SOURCE', '-D_XOPEN_SOURCE=700',
'-U__STRICT_ANSI__', '-fvisibility=hidden',
'-Wmissing-prototypes', '-Wno-pointer-sign'
]
# glslang needs c++11
cpp_opts = [
'-std=c++11', '-fvisibility=hidden',
]
if cc.has_argument('-Wincompatible-pointer-types')
build_opts += ['-Werror=incompatible-pointer-types']
endif
# clang's version of -Wmissing-braces rejects the common {0} initializers
if cc.get_id() == 'clang'
build_opts += ['-Wno-missing-braces']
endif
# don't leak library symbols if possible
vflag = '-Wl,--exclude-libs=ALL'
if cc.has_link_argument(vflag)
link_args += [vflag]
endif
add_global_arguments(build_opts + c_opts, language: 'c')
add_global_arguments(build_opts + cpp_opts, language: 'cpp')
add_global_link_arguments(link_args, language: 'c')
subdir('src')
......@@ -24,11 +24,13 @@
#include <stdint.h>
#include <inttypes.h>
#include "ta/talloc.h"
#include "config.h"
#include "config_internal.h"
#include "pl_assert.h"
#include <xtalloc.h>
#include <bstr.h>
// Include all of the symbols that should be public in a way that marks them
// as being externally visible. (Otherwise, all symbols are hidden by default)
#pragma GCC visibility push(default)
......
......@@ -18,8 +18,6 @@
#pragma once
#include <stdarg.h>
#include "bstr/bstr.h"
#include "common.h"
struct pl_context {
......
......@@ -19,7 +19,7 @@
#include <pthread.h>
extern "C" {
#include "ta/talloc.h"
#include <xtalloc.h>
}
#include <glslang/Include/ResourceLimits.h>
......
......@@ -18,7 +18,6 @@
#pragma once
#include "common.h"
#include "bstr/bstr.h"
// Compute a transformation from one color profile to another, and fill the
// provided array by the resulting 3DLUT. The array must have room for four
......
majorver = '1'
apiver = '7'
fixver = '0'
version = majorver + '.' + apiver + '.' + fixver
# Configuration
conf_public = configuration_data()
conf_internal = configuration_data()
conf_public.set('majorver', majorver)
conf_public.set('apiver', apiver)
conf_public.set('fixver', fixver)
conf_public.set_quoted('version', 'v' + version)
## Update PL_VERSION with `git describe` information if available
git = find_program('git', required: false)
if git.found()
gitdesc = run_command(git, 'describe')
if gitdesc.returncode() == 0
conf_public.set_quoted('version', gitdesc.stdout().strip())
endif
endif
c_opts = [
'-D_ISOC99_SOURCE', '-D_GNU_SOURCE', '-D_XOPEN_SOURCE=700',
'-U__STRICT_ANSI__', '-fvisibility=hidden',
'-Wmissing-prototypes', '-Wno-pointer-sign'
]
# glslang needs c++11
cpp_opts = [
'-std=c++11', '-fvisibility=hidden',
]
# Build options mostly taken from mpv
build_opts = [
# Warnings
'-Wall', '-Wundef', '-Wshadow', '-Wparentheses', '-Wpointer-arith',
# Warnings to treat as errors
'-Werror=implicit-function-declaration',
]
link_args = []
# Depedencies
cc = meson.get_compiler('c')
cxx = meson.get_compiler('cpp')
if cc.has_argument('-Wincompatible-pointer-types')
build_opts += ['-Werror=incompatible-pointer-types']
endif
# clang's version of -Wmissing-braces rejects the common {0} initializers
if cc.get_id() == 'clang'
build_opts += ['-Wno-missing-braces']
endif
vflag = '-Wl,--exclude-libs=ALL'
if cc.has_link_argument(vflag)
link_args += [vflag]
endif
# Global dependencies
build_deps = [
dependency('threads'),
cc.find_library('m', required: false),
subproject('xtalloc').get_variable('dep'),
subproject('bstr').get_variable('dep'),
]
vulkan = dependency('vulkan', version: '>=1.0.42', required: get_option('vulkan'))
# Source files
sources = [
'colorspace.c',
'common.c',
'context.c',
'dither.c',
'dispatch.c',
'filters.c',
'gpu.c',
'renderer.c',
'shaders.c',
'shaders/av1.c',
'shaders/colorspace.c',
'shaders/sampling.c',
'spirv.c',
'swapchain.c',
'utils/upload.c',
# Helpers ported from mpv or other projects
'bstr/bstr.c',
'bstr/format.c',
'3rdparty/siphash.c',
'ta/ta.c',
'ta/ta_utils.c',
'ta/talloc.c',
]
# configuration data
conf_public = configuration_data()
conf_internal = configuration_data()
conf_public.set('majorver', majorver)
conf_public.set('apiver', apiver)
conf_public.set('fixver', fixver)
conf_public.set_quoted('version', version_pretty)
tests = [
'context.c',
'colorspace.c',
'dither.c',
'filters.c',
'utils.c',
]
# Work-arounds for shaderc braindeath
# work-arounds for shaderc braindeath
shaderc_names = [
'shaderc_shared',
'shaderc_combined',
......@@ -124,7 +40,7 @@ if shaderc.found()
))
endif
# Work-arounds for glslang braindeath
# work-arounds for glslang braindeath
glslang_combined = disabler()
glslang_min_ver = 2763
glslang_req = get_option('glslang')
......@@ -173,6 +89,35 @@ if glslang_found
endif
endif
# Source files
sources = [
'colorspace.c',
'common.c',
'context.c',
'dither.c',
'dispatch.c',
'filters.c',
'gpu.c',
'renderer.c',
'shaders.c',
'shaders/av1.c',
'shaders/colorspace.c',
'shaders/sampling.c',
'spirv.c',
'swapchain.c',
'utils/upload.c',
]
tests = [
'context.c',
'colorspace.c',
'dither.c',
'filters.c',
'utils.c',
]
# Optional dependencies / components
components = [
{
......@@ -204,7 +149,6 @@ components = [
}
]
# Build process
defs = ''
comps = configuration_data()
......@@ -223,7 +167,7 @@ foreach c : components
endif
endforeach
# Check to see if libplacebo built this way is sane
# check to see if libplacebo built this way is sane
if not comps.has('vulkan')
warning('Building without support for Vulkan. Currently, libplacebo only ' +
'supports the Vulkan graphics API. libplacebo built this way still ' +
......@@ -237,7 +181,8 @@ if comps.has('vulkan') and not (comps.has('shaderc') or comps.has('glslang'))
'compile GLSL to SPIR-V (needed by the Vulkan API)!')
endif
# Generate the config headers
# Build process
conf_public.set('extra_defs', defs)
configure_file(
......@@ -252,9 +197,6 @@ configure_file(
configuration: conf_internal
)
# Build process
add_project_arguments(build_opts + c_opts, language: 'c')
add_project_arguments(build_opts + cpp_opts, language: 'cpp')
inc = include_directories('./include')
lib = library('placebo', sources,
install: true,
......@@ -264,6 +206,7 @@ lib = library('placebo', sources,
link_args: link_args,
)
# Install process
install_subdir('include/libplacebo', install_dir: get_option('includedir'))
......@@ -275,6 +218,7 @@ pkg.generate(
version: version,
)
# Tests
tdeps = [ declare_dependency(link_with: lib) ]
......
......@@ -18,7 +18,6 @@
#include <stdio.h>
#include <math.h>
#include "bstr/bstr.h"
#include "common.h"
#include "context.h"
#include "shaders.h"
......
......@@ -18,7 +18,6 @@
#pragma once
#include <stdio.h>
#include "bstr/bstr.h"
#include "common.h"
#include "context.h"
......
......@@ -24,8 +24,7 @@
#include <stdio.h>
#include <limits.h>
#include "ta/talloc.h"
#include "bstr.h"
#include "include/bstr.h"
#include "ctype.h"
#define MIN(a, b) ((a) > (b) ? (b) : (a))
......
......@@ -20,7 +20,7 @@
#include <stdio.h>
#include <stdarg.h>
#include "bstr.h"
#include "include/bstr.h"
int ccStrPrintInt32( char *str, int32_t n );
int ccStrPrintUint32( char *str, uint32_t n );
......
......@@ -23,9 +23,10 @@
#include <stdbool.h>
#include <stdarg.h>
#include "osdep/compiler.h"
#include "ta/talloc.h"
#include "3rdparty/siphash.h"
#include "../osdep.h"
#include "../siphash.h"
#include <xtalloc.h>
/* NOTE: 'len' is size_t, but most string-handling functions below assume
* that input size has been sanity checked and len fits in an int.
......
project('bstr', 'c')
sources = [
'bstr.c',
'format.c',
'siphash.c',
]
deps = [
subproject('xtalloc').get_variable('dep'),
]
lib = static_library('3rdparty',
sources,
dependencies: deps,
install: false,
)
dep = declare_dependency(
include_directories: include_directories('include'),
link_with: lib
)
......@@ -13,13 +13,13 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef TA_TALLOC_H_
#define TA_TALLOC_H_
#ifndef TA_XTALLOC_H_
#define TA_XTALLOC_H_
#include <string.h>
#include <assert.h>
#include "ta.h"
#include "../ta.h"
// Note: all talloc wrappers are wired to the "x" functions, which abort on OOM.
// libtalloc doesn't do that, but the mplayer2/mpv internal copies of it did.
......
project('xtalloc', 'c')
sources = [
'ta.c',
'ta_utils.c',
'xtalloc.c',
]
deps = [
dependency('threads'),
]
lib = static_library('xtalloc',
sources,
dependencies: deps,
install: false,
)
dep = declare_dependency(
include_directories: include_directories('include'),
link_with: lib
)
......@@ -18,7 +18,7 @@
#include <stdio.h>
#include <pthread.h>
#include "talloc.h"
#include "include/xtalloc.h"
char *ta_talloc_strdup_append(char *s, const char *a)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment