diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2016-12-09 12:28:42 +0000 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2017-01-25 12:36:20 +0000 |
commit | 08cc4d021dc523c4243a23b2b4ba432af760716b (patch) | |
tree | 9a00922a7ddcf66d3ba8107b6e12ca970a2dfb86 /meson.build | |
parent | e2e2fedbdb6cbf4155919c548545956dd6cacc4c (diff) | |
download | libepoxy-08cc4d021dc523c4243a23b2b4ba432af760716b.tar.gz |
build: Add Meson build files
Meson is a Python-based build system that generates build rules of
Ninja, Visual Studio, and XCode. It's designed to be fast, and have a
small, non-Turing complete language to describe the build process,
tests, and dependencies. It's simpler than CMake, and faster than
autotools.
As a direct comparison in terms of speed, three build and check runs for
libepoxy from a clean Git repository clone yield these results on my
Kabylake Core i7 7500U (nproc=4):
- Autotools (make)
Run #1 (cold) real: 22.384s, user: 20.011s, sys: 3.689s
Run #2 (warm) real: 22.429s, user: 20.220s, sys: 3.708s
Run #3 (warm) real: 22.068s, user: 19.743s, sys: 3.594s
- Meson (ninja)
Run #1 (cold) real: 5.932s, user: 9.371s, sys: 1.625s
Run #2 (warm) real: 6.273s, user: 10.066, sys: 1.740s
Run #3 (warm) real: 5.796s, user: 9.233s, sys: 1.607s
Which means that Meson and ninja are approximately 4x faster than
autotools.
In terms of simplicity, the autotools build takes six files and a total
of 645 lines; Meson requires 3 files, and 361 lines to achieve the same
result. Additionally, Meson automatically builds in a separate build
directory and does not leave files inside the source directory; and Meson
does not use libtool.
Since Meson is quite new and still actively developed, we're going to
leave the autotools build in place for a while, with the intention of
switching to Meson in the future.
Diffstat (limited to 'meson.build')
-rw-r--r-- | meson.build | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..101788c --- /dev/null +++ b/meson.build @@ -0,0 +1,125 @@ +project('libepoxy', 'c', version: '1.3.1', + default_options: [ + 'buildtype=debug', + 'c_std=gnu99', + 'warning_level=1', + ], + license: 'MIT', + meson_version: '>= 0.36.0') + +epoxy_version = meson.project_version().split('.') +epoxy_major_version = epoxy_version[0].to_int() +epoxy_minor_version = epoxy_version[1].to_int() +epoxy_micro_version = epoxy_version[2].to_int() + +epoxy_prefix = get_option('prefix') +epoxy_libdir = join_paths(epoxy_prefix, get_option('libdir')) +epoxy_datadir = join_paths(epoxy_prefix, get_option('datadir')) +epoxy_includedir = join_paths(epoxy_prefix, get_option('includedir')) + +cc = meson.get_compiler('c') +host_system = host_machine.system() + +conf = configuration_data() +conf.set_quoted('PACKAGE_NAME', meson.project_name()) +conf.set_quoted('PACKAGE_VERSION', meson.project_version()) +conf.set_quoted('PACKAGE_STRING', '@0@-@1@'.format(meson.project_name(), meson.project_version())) +conf.set_quoted('PACKAGE_DATADIR', join_paths(get_option('prefix'), get_option('datadir'))) +conf.set_quoted('PACKAGE_LIBDIR', join_paths(get_option('prefix'), get_option('libdir'))) +conf.set_quoted('PACKAGE_LOCALEDIR', join_paths(get_option('prefix'), get_option('datadir'), 'locale')) +conf.set_quoted('PACKAGE_LIBEXECDIR', join_paths(get_option('prefix'), get_option('libexecdir'))) +conf.set('HAVE_KHRPLATFORM_H', cc.has_header('KHR/khrplatform.h', required: false)) + +if host_system == 'windows' + build_glx = false + build_egl = false + build_apple = false + build_wgl = true + has_znow = true +elif host_system == 'darwin' + build_glx = false + build_egl = false + build_apple = true + build_wgl = false + has_znow = false +else + build_glx = true + build_egl = true + build_apple = false + build_wgl = false + has_znow = true +endif + +# Compiler flags, taken from the Xorg macros +test_cflags = [ + '-Wall', + '-Wpointer-arith', + '-Wmissing-declarations', + '-Wformat=2', + '-Wstrict-prototypes', + '-Wmissing-prototypes', + '-Wnested-externs', + '-Wbad-function-cast', + '-Wold-style-definition', + '-Wdeclaration-after-statement', + '-Wunused', + '-Wuninitialized', + '-Wshadow', + '-Wmissing-noreturn', + '-Wmissing-format-attribute', + '-Wredundant-decls', + '-Wlogical-op', + '-Werror=implicit', + '-Werror=nonnull', + '-Werror=init-self', + '-Werror=main', + '-Werror=missing-braces', + '-Werror=sequence-point', + '-Werror=return-type', + '-Werror=trigraphs', + '-Werror=array-bounds', + '-Werror=write-strings', + '-Werror=address', + '-Werror=int-to-pointer-cast', + '-Werror=pointer-to-int-cast', + '-fno-strict-aliasing', + '-Wno-int-conversion', +] +common_cflags = [] +foreach cflag: test_cflags + if cc.has_argument(cflag) + common_cflags += [ cflag ] + endif +endforeach + +# Dependencies +dl_dep = cc.find_library('dl', required: false) +gl_dep = dependency('gl', required: false) +egl_dep = dependency('egl', required: false) + +# Optional dependencies for tests +x11_dep = dependency('x11', required: false) +gles1_dep = cc.find_library('libGLESv1_CM', required: false) +gles2_dep = cc.find_library('libGLESv2', required: false) + +epoxy_include = include_directories('include') + +# PkgConfig file +pkgconf = configuration_data() +pkgconf.set('prefix', epoxy_prefix) +pkgconf.set('exec_prefix', epoxy_prefix) +pkgconf.set('libdir', epoxy_libdir) +pkgconf.set('includedir', epoxy_includedir) +pkgconf.set('PACKAGE_VERSION', meson.project_version()) +if dl_dep.found() + pkgconf.set('DLOPEN_LIBS', '-ldl') +endif + +configure_file(input: 'epoxy.pc.in', + output: 'epoxy.pc', + configuration: pkgconf, + install: true, + install_dir: join_paths(epoxy_libdir, 'pkgconfig')) + +subdir('src') +subdir('test') |