source: appstream-generator/meson.build @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 6.8 KB
Line 
1project('AppStream Generator', 'd',
2    meson_version: '>=0.40.0',
3    subproject_dir: 'contrib/subprojects'
4)
5
6source_root = meson.source_root()
7build_root = meson.build_root()
8
9#
10# Sources
11#
12asgen_sources = ['src/app.d',
13    'src/asgen/zarchive.d',
14    'src/asgen/bindings/appstream_utils.d',
15    'src/asgen/bindings/cairo.d',
16    'src/asgen/bindings/freetype.d',
17    'src/asgen/bindings/freetypeTypes.d',
18    'src/asgen/bindings/fontconfig.d',
19    'src/asgen/bindings/pango.d',
20    'src/asgen/bindings/gdkpixbuf.d',
21    'src/asgen/bindings/libarchive.d',
22    'src/asgen/bindings/lmdb.d',
23    'src/asgen/bindings/rsvg.d',
24    'src/asgen/config.d',
25    'src/asgen/contentsstore.d',
26    'src/asgen/datastore.d',
27    'src/asgen/engine.d',
28    'src/asgen/extractor.d',
29    'src/asgen/handlers/desktopparser.d',
30    'src/asgen/handlers/fonthandler.d',
31    'src/asgen/handlers/iconhandler.d',
32    'src/asgen/handlers/metainfoparser.d',
33    'src/asgen/handlers/metainfovalidator.d',
34    'src/asgen/handlers/package.d',
35    'src/asgen/handlers/screenshothandler.d',
36    'src/asgen/hint.d',
37    'src/asgen/font.d',
38    'src/asgen/image.d',
39    'src/asgen/logging.d',
40    'src/asgen/reportgenerator.d',
41    'src/asgen/result.d',
42    'src/asgen/utils.d'
43]
44
45backend_sources = [
46    'src/asgen/backends/interfaces.d',
47
48    'src/asgen/backends/dummy/package.d',
49    'src/asgen/backends/dummy/dummypkg.d',
50    'src/asgen/backends/dummy/pkgindex.d',
51
52    'src/asgen/backends/archlinux/package.d',
53    'src/asgen/backends/archlinux/alpkg.d',
54    'src/asgen/backends/archlinux/alpkgindex.d',
55    'src/asgen/backends/archlinux/listfile.d',
56
57    'src/asgen/backends/debian/package.d',
58    'src/asgen/backends/debian/debpkg.d',
59    'src/asgen/backends/debian/debpkgindex.d',
60    'src/asgen/backends/debian/tagfile.d',
61    'src/asgen/backends/debian/debutils.d',
62
63    'src/asgen/backends/ubuntu/package.d',
64    'src/asgen/backends/ubuntu/ubupkg.d',
65    'src/asgen/backends/ubuntu/ubupkgindex.d',
66
67    'src/asgen/backends/rpmmd/package.d',
68    'src/asgen/backends/rpmmd/rpmpkg.d',
69    'src/asgen/backends/rpmmd/rpmpkgindex.d',
70]
71
72#
73# Sanitizers & quirk fixes
74#
75
76# Set a few flags to work around compiler bugs
77if meson.get_compiler('d').get_id() == 'gcc'
78    add_global_arguments(['-Wl,--push-state,-no-as-needed -lcurl -Wl,--pop-state', '-no-pie'], language : 'd')
79    add_global_link_arguments('-no-pie', language : 'd')
80endif
81if meson.get_compiler('d').get_id() == 'llvm'
82    # work around: https://github.com/ldc-developers/ldc/issues/1727
83    add_global_arguments('-enable-cross-module-inlining=false', language : 'd')
84endif
85
86# TODO: Make this a real option, not something to manually enable.
87#add_global_arguments(['-sanitize=address'], language : 'd')
88#add_global_link_arguments('-L-l:libasan.so.4.0.0', language : 'd')
89
90#
91# Dependencies
92#
93src_dir = include_directories('src/')
94
95glib_dep      = dependency('glib-2.0')
96gobject_dep   = dependency('gobject-2.0')
97gio_dep       = dependency('gio-2.0')
98appstream_dep = dependency('appstream', version : '>= 0.10')
99lmdb_dep      = dependency('lmdb', version : '>= 0.9')
100mustache_dep  = dependency('mustache-d', required: false)
101archive_dep   = dependency('libarchive', version : '>= 3.2')
102cairo_dep     = dependency('cairo', version : '>= 1.12')
103gdkpixbuf_dep = dependency('gdk-pixbuf-2.0')
104rsvg_dep      = dependency('librsvg-2.0')
105curl_dep      = dependency('libcurl')
106freetype_dep  = dependency('freetype2')
107pango_dep     = dependency('pango')
108fontconfig_dep  = dependency('fontconfig')
109
110if not mustache_dep.found()
111    mustache_sp = subproject('mustache-d')
112    mustache_dep = declare_dependency(link_with: mustache_sp.get_variable('mustache_lib'),
113        include_directories: mustache_sp.get_variable('src_dir')
114    )
115endif
116
117#
118# Build interfaces from GIR
119#
120gir_to_d_prog = find_program('girtod')
121gir_wrap_dir = source_root + '/contrib/girwrap/'
122gir_d_intf_dir = build_root + '/girepo/'
123
124message('Generating D interfaces from GIR...')
125girtod_gen = run_command(gir_to_d_prog.path(),
126                         '-i', gir_wrap_dir,
127                         '-o', gir_d_intf_dir)
128if girtod_gen.returncode() != 0
129    error('Unable to build D intefaces from GIR:\n' + girtod_gen.stderr() + girtod_gen.stdout())
130endif
131gir_bind_dir = include_directories('girepo')
132
133# Enlist D GIR interface sources
134dgir_glob_script = run_command(source_root + '/contrib/girwrap/find-d-intf-files.sh')
135gir_binding_sources = dgir_glob_script.stdout().strip().split('\n')
136
137#
138# Download JS stuff and additional sources if we couldn't find them
139#
140
141# Download JavaScript assets if requested
142download_js = get_option('download_js')
143if download_js
144    message('Downloading JavaScript libraries...')
145    if run_command('[', '-d', 'data/templates/default/static/js', ']').returncode() != 0
146        getjs_cmd = run_command([source_root + '/contrib/setup/build_js.sh'])
147        if getjs_cmd.returncode() != 0
148            error('Unable to download JavaScript files with Bower:\n' + getjs_cmd.stdout() + getjs_cmd.stderr())
149        endif
150    endif
151endif
152
153#
154# Build and test
155#
156girbind_lib = static_library('girbindings',
157    [gir_binding_sources],
158    include_directories: [gir_bind_dir]
159)
160
161asgen_exe = executable('appstream-generator',
162    [asgen_sources,
163     backend_sources],
164    include_directories: [src_dir,
165                          gir_bind_dir],
166    dependencies: [glib_dep,
167                   gobject_dep,
168                   gio_dep,
169                   appstream_dep,
170                   lmdb_dep,
171                   archive_dep,
172                   mustache_dep,
173                   cairo_dep,
174                   gdkpixbuf_dep,
175                   rsvg_dep,
176                   curl_dep,
177                   freetype_dep,
178                   fontconfig_dep,
179                   pango_dep],
180    link_with: [girbind_lib],
181    install: true
182)
183
184asgen_test_exe = executable('asgen_test',
185    [asgen_sources,
186    backend_sources],
187    include_directories: [src_dir,
188                          gir_bind_dir],
189    dependencies: [glib_dep,
190                   gobject_dep,
191                   gio_dep,
192                   appstream_dep,
193                   lmdb_dep,
194                   archive_dep,
195                   mustache_dep,
196                   cairo_dep,
197                   gdkpixbuf_dep,
198                   rsvg_dep,
199                   curl_dep,
200                   freetype_dep,
201                   fontconfig_dep,
202                   pango_dep],
203    link_with: [girbind_lib],
204    d_args: meson.get_compiler('d').unittest_args()
205)
206test('asgen_tests', asgen_test_exe)
207
208#
209# Install
210#
211
212# data
213install_data('data/asgen-hints.json', install_dir: 'share/appstream')
214install_data('data/hicolor-theme-index.theme', install_dir: 'share/appstream')
215
216# templates
217#install_subdir('data/templates/', install_dir: 'share/appstream') # FIXME: Doesn't handle dir symlinks correctly
218meson.add_install_script(source_root + '/contrib/setup/meson-install-templates.sh')
Note: See TracBrowser for help on using the repository browser.