Simplify the code generation rules for Meson

The code generation rules are explicitly built for each supported API
target, but they ought to be refactored since they are pretty much
identical.

In order to do that, we can store the arguments to the custom_target
rules inside an array and then iterate over each element.

This cuts down the complexity of the Meson build, and the chances of
getting something wrong due to duplication.
macos/v1.5.9
Emmanuele Bassi 8 years ago
parent d6c4784401
commit 3eaddbef62
  1. 98
      include/epoxy/meson.build
  2. 102
      src/meson.build

@ -1,82 +1,42 @@
headers = [ 'common.h' ] headers = [ 'common.h' ]
gl_generated = custom_target('gl_generated.h', # GL is always generated
input: gl_registry, generated_headers = [ [ 'gl.h', 'gl_generated.h', gl_registry ] ]
output: [
'gl_generated.h',
],
command: [
python,
gen_dispatch_py,
'--header',
'--no-source',
'--outputdir=@OUTDIR@',
'@INPUT@'
],
install: true,
install_dir: join_paths(epoxy_includedir, 'epoxy'))
gen_headers = [ gl_generated ]
headers += [ 'gl.h', ]
if build_egl if build_egl
egl_generated = custom_target('egl_generated.h', generated_headers += [ [ 'egl.h', 'egl_generated.h', egl_registry ] ]
input: egl_registry,
output: [
'egl_generated.h',
],
command: [
python,
gen_dispatch_py,
'--header',
'--no-source',
'--outputdir=@OUTDIR@',
'@INPUT@'
],
install: true,
install_dir: join_paths(epoxy_includedir, 'epoxy'))
gen_headers += [ egl_generated ]
headers += [ 'egl.h' ]
endif endif
if build_glx if build_glx
glx_generated = custom_target('glx_generated.h', generated_headers += [ [ 'glx.h', 'glx_generated.h', glx_registry ] ]
input: glx_registry,
output: [
'glx_generated.h',
],
command: [
python,
gen_dispatch_py,
'--header',
'--no-source',
'--outputdir=@OUTDIR@',
'@INPUT@'
],
install: true,
install_dir: join_paths(epoxy_includedir, 'epoxy'))
gen_headers += [ glx_generated ]
headers += [ 'glx.h' ]
endif endif
if build_wgl if build_wgl
wgl_generated = custom_target('wgl_generated.h', generated_headers += [ [ 'wgl.h', 'wgl_generated.h', wgl_registry ] ]
input: wgl_registry,
output: [
'wgl_generated.h',
],
command: [
python,
gen_dispatch_py,
'--header',
'--no-source',
'--outputdir=@OUTDIR@',
'@INPUT@'
],
install: true,
install_dir: join_paths(epoxy_includedir, 'epoxy'))
gen_headers += [ wgl_generated ]
headers += [ 'wgl.h' ]
endif endif
gen_headers = []
foreach g: generated_headers
header = g[0]
gen_header = g[1]
registry = g[2]
generated = custom_target(gen_header,
input: registry,
output: [ gen_header ],
command: [
python,
gen_dispatch_py,
'--header',
'--no-source',
'--outputdir=@OUTDIR@',
'@INPUT@',
],
install: true,
install_dir: join_paths(epoxy_includedir, 'epoxy'))
gen_headers += [ generated ]
headers += [ header ]
endforeach
install_headers(headers, subdir: 'epoxy') install_headers(headers, subdir: 'epoxy')

@ -1,83 +1,51 @@
common_sources = [
'dispatch_common.c',
'dispatch_common.h',
]
# Configuration file # Configuration file
configure_file(output: 'config.h', configuration: conf) configure_file(output: 'config.h', configuration: conf)
gl_generated = custom_target('gl_generated_dispatch.c', # List of generated sources:
input: gl_registry, # - name of the generated file
output: [ # - registry source file
'gl_generated_dispatch.c', # - additional sources
], generated_sources = [
command: [ [ 'gl_generated_dispatch.c', gl_registry, [ 'dispatch_common.c', 'dispatch_common.h' ] ]
python, ]
gen_dispatch_py,
'--source',
'--no-header',
'--outputdir=@OUTDIR@',
'@INPUT@',
])
gen_sources = [ gl_generated ]
sources = common_sources
if build_egl if build_egl
egl_generated = custom_target('egl_generated_dispatch.c', generated_sources += [ [ 'egl_generated_dispatch.c', egl_registry, 'dispatch_egl.c' ] ]
input: egl_registry,
output: [
'egl_generated_dispatch.c',
],
command: [
python,
gen_dispatch_py,
'--source',
'--no-header',
'--outputdir=@OUTDIR@',
'@INPUT@',
])
gen_sources += [ egl_generated ]
sources += [ 'dispatch_egl.c' ]
endif endif
if build_glx if build_glx
glx_generated = custom_target('glx_generated_dispatch.c', generated_sources += [ [ 'glx_generated_dispatch.c', glx_registry, 'dispatch_glx.c' ] ]
input: glx_registry,
output: [
'glx_generated_dispatch.c',
],
command: [
python,
gen_dispatch_py,
'--source',
'--no-header',
'--outputdir=@OUTDIR@',
'@INPUT@',
])
gen_sources += [ glx_generated ]
sources += [ 'dispatch_glx.c' ]
endif endif
if build_wgl if build_wgl
wgl_generated = custom_target('wgl_generated_dispatch.c', generated_sources += [ [ 'wgl_generated_dispatch.c', wgl_registry, 'dispatch_wgl.c' ] ]
input: wgl_registry,
output: [
'wgl_generated_dispatch.c',
],
command: [
python,
gen_dispatch_py,
'--source',
'--no-header',
'--outputdir=@OUTDIR@',
'@INPUT@',
])
gen_sources += [ wgl_generated ]
sources += [ 'dispatch_wgl.c' ]
endif endif
epoxy_sources = common_sources + sources + gen_sources gen_sources = [ ]
sources = [ ]
foreach g: generated_sources
gen_source = g[0]
registry = g[1]
source = g[2]
generated = custom_target(gen_source,
input: registry,
output: [ gen_source ],
command: [
python,
gen_dispatch_py,
'--source',
'--no-header',
'--outputdir=@OUTDIR@',
'@INPUT@',
])
gen_sources += [ generated ]
sources += [ source ]
endforeach
epoxy_sources = sources + gen_sources
epoxy_headers = gen_headers epoxy_headers = gen_headers
foreach h: headers foreach h: headers
epoxy_headers += join_paths(meson.source_root(), 'include/epoxy/@0@'.format(h)) epoxy_headers += join_paths(meson.source_root(), 'include/epoxy/@0@'.format(h))

Loading…
Cancel
Save