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 /src/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 'src/meson.build')
-rw-r--r-- | src/meson.build | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..1ca4117 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,88 @@ +common_sources = [ + 'dispatch_common.c', + 'dispatch_common.h', +] + +# Configuration file +configure_file(output: 'config.h', configuration: conf) + +# Generate the dispatch tables +gen_dispatch_py = find_program('gen_dispatch.py') + +gen_dispatch = generator(gen_dispatch_py, + output: [ '@BASENAME@_generated.h', '@BASENAME@_generated_dispatch.c', ], + arguments: [ '--dir=@BUILD_DIR@', '@INPUT@' ]) + +gl_generated = gen_dispatch.process(join_paths(meson.source_root(), 'registry/gl.xml')) +gl_headers = [ join_paths(meson.source_root(), 'include/epoxy/gl.h'), 'gl_generated.h', ] +gl_sources = gl_generated + +egl_headers = [] +egl_sources = [] +if build_egl + egl_generated = gen_dispatch.process(join_paths(meson.source_root(), 'registry/egl.xml')) + egl_headers += [ join_paths(meson.source_root(), 'include/epoxy/egl.h'), 'egl_generated.h', ] + egl_sources += [ egl_generated, 'dispatch_egl.c', ] +endif + +glx_headers = [] +glx_sources = [] +if build_glx + glx_generated = gen_dispatch.process(join_paths(meson.source_root(), 'registry/glx.xml')) + glx_headers += [ join_paths(meson.source_root(), 'include/epoxy/glx.h'), 'glx_generated.h', ] + glx_sources += [ glx_generated, 'dispatch_glx.c', ] +endif + +wgl_headers = [] +wgl_sources = [] +if build_wgl + wgl_generated = gen_dispatch.process(join_paths(meson.source_root(), 'registry/wgl.xml')) + wgl_headers += [ join_paths(meson.source_root(), 'include/epoxy/wgl.h'), 'wgl_generated.h', ] + wgl_sources += [ wgl_generated, 'dispatch_wgl.c', ] +endif + +if cc.get_id() == 'msvc' + common_ldflags = [] +else + common_ldflags = [ '-Wl,-Bsymbolic', ] +endif + +epoxy_deps = [ dl_dep, ] +if host_system == 'windows' + ogl_dep = cc.find_library('opengl32', required: true) + epoxy_deps += [ ogl_dep, ] +endif + +libepoxy_inc = [ epoxy_include, include_directories('.'), ] + +# Allow building a static version of epoxy +libtype = get_option('default_library') + +if libtype != 'shared' + libepoxy_static = static_library('epoxy', + common_sources + [ gl_sources, egl_sources, glx_sources, wgl_sources ], + install: true, + dependencies: epoxy_deps, + include_directories: libepoxy_inc, + c_args: common_cflags, + link_args: common_ldflags) + libepoxy = libepoxy_static +endif + +if libtype != 'static' + libepoxy_shared = shared_library('epoxy', + sources: common_sources + [ gl_sources, egl_sources, glx_sources, wgl_sources ], + version: '0.0.0', + install: true, + dependencies: epoxy_deps, + include_directories: libepoxy_inc, + c_args: common_cflags, + link_args: common_ldflags) + libepoxy = libepoxy_shared +endif + +libepoxy_dep = declare_dependency(link_with: libepoxy, + include_directories: libepoxy_inc, + dependencies: dl_dep) + +install_headers(gl_headers + glx_headers + egl_headers + wgl_headers, subdir: 'epoxy') |