diff options
author | Quentin Glidic <sardemff7+git@sardemff7.net> | 2017-05-04 13:45:11 +0200 |
---|---|---|
committer | Quentin Glidic <sardemff7+git@sardemff7.net> | 2017-05-04 21:50:07 +0200 |
commit | 7fd8ce4c0afa295816db384622f56e70a12b1f32 (patch) | |
tree | 7f5addcb10fe6267b802126faedf3c73c48541ec /meson.build | |
parent | 9302ef59f38913d024b7b1edebb40ebce3275753 (diff) |
Add Meson build system support
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Diffstat (limited to 'meson.build')
-rw-r--r-- | meson.build | 441 |
1 files changed, 441 insertions, 0 deletions
diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..6c95ad01 --- /dev/null +++ b/meson.build @@ -0,0 +1,441 @@ +project('rofi', 'c', + version: '1.3.1', + meson_version: '>=0.39.1', + license: [ 'MIT' ], + default_options: [ + 'c_std=c99', + 'warning_level=3', + ], +) + +c_compiler = meson.get_compiler('c') + +plugindir = join_paths(get_option('prefix'), get_option('libdir'), meson.project_name()) +themedir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name(), 'themes') + +deps = [ + dependency('glib-2.0', version: '>= 2.40'), + dependency('gio-unix-2.0'), + dependency('gmodule-2.0'), + dependency('cairo'), + dependency('pango'), + dependency('pangocairo'), + dependency('xkbcommon', version: '>= 0.5.0'), + c_compiler.find_library('m', required: false), +] + +# XCB stuff +deps += [ + subproject('libgwater/xcb').get_variable('libgwater_xcb'), + dependency('xcb-aux'), + dependency('xcb-xkb'), + dependency('xkbcommon-x11'), + dependency('xcb-ewmh'), + dependency('xcb-icccm'), + dependency('xcb-xrm'), + dependency('xcb-randr'), + dependency('xcb-xinerama'), + dependency('cairo-xcb'), + dependency('libstartup-notification-1.0'), +] + +check = dependency('check', version: '>= 0.11.0', required: get_option('enable-check')) + +header_conf = configuration_data() +header_conf.set_quoted('PACKAGE_NAME', meson.project_name()) +header_conf.set_quoted('PACKAGE_VERSION', meson.project_version()) +header_conf.set_quoted('GETTEXT_PACKAGE', meson.project_name()) +header_conf.set_quoted('PACKAGE_BUGREPORT', 'https://github.com/DaveDavenport/rofi/') +header_conf.set_quoted('PACKAGE_URL', 'https://reddit.com/r/qtools/') + +header_conf.set('THEME_CONVERTER', true) +header_conf.set('_GNU_SOURCE', true) + +git = find_program('git', required: false) +if git.found() + git_version = run_command(git, '--git-dir', join_paths(meson.source_root(), '.git'), 'describe', '--tags', '--always', '--dirty') + git_branch = run_command(git, '--git-dir', join_paths(meson.source_root(), '.git'), 'describe', '--tags', '--always', '--all') + if git_version.returncode() == 0 and git_branch.returncode() == 0 + git_branch_parts = [] + foreach b : git_branch.stdout().strip().split('/') + if b != 'heads' + git_branch_parts += b + endif + endforeach + header_conf.set_quoted('GIT_VERSION', '@0@ - @1@ (@2@)'.format(meson.project_version(), git_version.stdout().strip(), '/'.join(git_branch_parts))) + endif +endif + +header_conf.set('ENABLE_DRUN', get_option('enable-drun')) +header_conf.set('WINDOW_MODE', get_option('enable-window')) + +header_conf.set_quoted('MANPAGE_PATH', join_paths(get_option('prefix'), get_option('mandir'))) +header_conf.set_quoted('SYSCONFDIR', join_paths(get_option('prefix'), get_option('sysconfdir'))) +header_conf.set_quoted('PLUGIN_PATH', plugindir) +header_conf.set_quoted('THEME_DIR', themedir) + +config_h = configure_file(output: 'config.h', configuration: header_conf) + +add_project_arguments( + '-fvisibility=hidden', + '-I@0@'.format(meson.build_root()), + '-I@0@'.format(join_paths(meson.source_root(), 'include')), + language: 'c' +) + +flags = [ + '-Wparentheses', + '-Winline', + '-Wunreachable-code', + '-Werror=missing-prototypes', +] +if get_option('enable-asan') + flags += [ + '-fsanitize=address', + '-fno-omit-frame-pointer', + ] +endif +foreach f : flags + if c_compiler.has_argument(f) + add_project_arguments(f, language: 'c') + endif +endforeach + + +install_headers([ + 'include/mode.h', + 'include/mode-private.h', + 'include/helper.h', + ], + subdir: meson.project_name(), +) +install_data( + 'script/rofi-sensible-terminal', + 'script/rofi-theme-selector', + install_dir: join_paths(get_option('prefix'), get_option('bindir')) +) + +flex = generator(find_program('flex'), + output: '@BASENAME@.c', + arguments: [ '-o', '@OUTPUT@', '@INPUT@' ] +) +bison = generator(find_program('bison'), + output: [ '@BASENAME@.c', '@BASENAME@.h' ], + arguments: [ '-y', '@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@' ] +) + +rofi_sources = files( + 'source/rofi.c', + 'source/view.c', + 'source/mode.c', + 'source/keyb.c', + 'config/config.c', + 'source/helper.c', + 'source/timings.c', + 'source/history.c', + 'source/theme.c', + 'source/widgets/box.c', + 'source/widgets/container.c', + 'source/widgets/widget.c', + 'source/widgets/textbox.c', + 'source/widgets/listview.c', + 'source/widgets/scrollbar.c', + 'source/xrmoptions.c', + 'source/x11-helper.c', + 'source/dialogs/run.c', + 'source/dialogs/ssh.c', + 'source/dialogs/drun.c', + 'source/dialogs/dmenu.c', + 'source/dialogs/combi.c', + 'source/dialogs/window.c', + 'source/dialogs/script.c', + 'source/dialogs/help-keys.c', + 'include/xcb.h', + 'include/xcb-internal.h', + 'include/rofi.h', + 'include/mode.h', + 'include/mode-private.h', + 'include/settings.h', + 'include/keyb.h', + 'include/view.h', + 'include/view-internal.h', + 'include/helper.h', + 'include/helper-theme.h', + 'include/timings.h', + 'include/history.h', + 'include/theme.h', + 'include/default-theme.h', + 'include/widgets/box.h', + 'include/widgets/container.h', + 'include/widgets/widget.h', + 'include/widgets/widget-internal.h', + 'include/widgets/textbox.h', + 'include/widgets/listview.h', + 'include/widgets/scrollbar.h', + 'include/xrmoptions.h', + 'include/x11-helper.h', + 'include/dialogs/ssh.h', + 'include/dialogs/run.h', + 'include/dialogs/drun.h', + 'include/dialogs/dmenu.h', + 'include/dialogs/combi.h', + 'include/dialogs/script.h', + 'include/dialogs/window.h', + 'include/dialogs/dialogs.h', + 'include/dialogs/help-keys.h', + 'include/xkb.h', + 'include/xkb-internal.h', +) +theme_lexer_sources = files('lexer/theme-lexer.l') +theme_parser_sources = files('lexer/theme-parser.y') + +theme_lexer = flex.process(theme_lexer_sources) +theme_parser = bison.process(theme_parser_sources) +rofi = executable('rofi', rofi_sources + [ + theme_lexer, + theme_parser, + ], + dependencies: deps, + install: true, +) + +subdir('doc') +install_man( + 'doc/rofi.1', + 'doc/rofi-sensible-terminal.1', +) + +install_data( + 'themes/Adapta-Nokto.rasi', + 'themes/Arc.rasi', + 'themes/DarkBlue.rasi', + 'themes/Indego.rasi', + 'themes/Monokai.rasi', + 'themes/Paper.rasi', + 'themes/android_notification.rasi', + 'themes/arthur.rasi', + 'themes/blue.rasi', + 'themes/c64.rasi', + 'themes/glue_pro_blue.rasi', + 'themes/gruvbox-dark-hard.rasi', + 'themes/gruvbox-dark-soft.rasi', + 'themes/gruvbox-dark.rasi', + 'themes/gruvbox-light-hard.rasi', + 'themes/gruvbox-light-soft.rasi', + 'themes/gruvbox-light.rasi', + 'themes/lb.rasi', + 'themes/paper-float.rasi', + 'themes/purple.rasi', + 'themes/sidebar.rasi', + 'themes/solarized.rasi', + 'themes/solarized_alternate.rasi', + install_dir: themedir +) + + + +test('history test', executable('history.test', [ + 'test/history-test.c', + ], + objects: rofi.extract_objects([ + 'source/history.c', + 'config/config.c', + ]), + dependencies: deps, +)) + +test('helper_pidfile test', executable('helper_pidfile.test', [ + 'test/helper-pidfile.c', + ], + objects: rofi.extract_objects([ + 'config/config.c', + 'source/helper.c', + 'source/xrmoptions.c', + 'source/x11-helper.c', + ]), + dependencies: deps, +)) + +test('helper_tokenize test', executable('helper_tokenize.test', [ + 'test/helper-tokenize.c', + ], + objects: rofi.extract_objects([ + 'config/config.c', + 'source/helper.c', + 'source/xrmoptions.c', + 'source/x11-helper.c', + ]), + dependencies: deps, +)) + +test('widget test', executable('widget.test', [ + 'test/widget-test.c', + theme_parser, + theme_lexer, + ], + objects: rofi.extract_objects([ + 'source/widgets/widget.c', + 'source/widgets/textbox.c', + 'source/theme.c', + 'source/helper.c', + 'source/x11-helper.c', + 'config/config.c', + ]), + dependencies: deps, +)) + +test('box test', executable('box.test', [ + 'test/box-test.c', + theme_parser, + theme_lexer, + ], + objects: rofi.extract_objects([ + 'source/widgets/widget.c', + 'source/widgets/box.c', + 'source/theme.c', + 'config/config.c', + ]), + dependencies: deps, +)) + +test('scrollbar test', executable('scrollbar.test', [ + 'test/scrollbar-test.c', + theme_parser, + theme_lexer, + ], + objects: rofi.extract_objects([ + 'source/widgets/widget.c', + 'source/widgets/scrollbar.c', + 'source/theme.c', + 'config/config.c', + ]), + dependencies: deps, +)) + +test('textbox test', executable('textbox.test', [ + 'test/textbox-test.c', + theme_parser, + theme_lexer, + ], + objects: rofi.extract_objects([ + 'source/widgets/widget.c', + 'source/widgets/textbox.c', + 'source/theme.c', + 'source/helper.c', + 'source/x11-helper.c', + 'config/config.c', + ]), + dependencies: deps, +)) + +test('helper test', executable('helper.test', [ + 'test/helper-test.c', + ], + objects: rofi.extract_objects([ + 'config/config.c', + 'source/helper.c', + 'source/xrmoptions.c', + 'source/x11-helper.c', + ]), + dependencies: deps, +)) + +test('helper_expand test', executable('helper_expand.test', [ + 'test/helper-expand.c', + ], + objects: rofi.extract_objects([ + 'config/config.c', + 'source/helper.c', + 'source/xrmoptions.c', + 'source/x11-helper.c', + ]), + dependencies: deps, +)) + +test('helper_config_cmdline_parser test', executable('helper_config_cmdline_parser.test', [ + 'test/helper-config-cmdline-parser.c', + ], + objects: rofi.extract_objects([ + 'config/config.c', + 'source/helper.c', + 'source/xrmoptions.c', + 'source/x11-helper.c', + ]), + dependencies: deps, +)) + +if check.found() + deps+= [ check ] + + test('theme_parser test', executable('theme_parser.test', [ + 'test/theme-parser-test.c', + theme_lexer, + theme_parser, + ], + objects: rofi.extract_objects([ + 'config/config.c', + 'source/helper.c', + 'source/xrmoptions.c', + 'source/x11-helper.c', + 'source/theme.c', + ]), + dependencies: deps, + )) + + test('mode test', executable('mode.test', [ + 'test/mode-test.c', + ], + objects: rofi.extract_objects([ + 'config/config.c', + 'source/dialogs/help-keys.c', + 'source/helper.c', + 'source/mode.c', + 'source/xrmoptions.c', + 'source/keyb.c', + ]), + dependencies: deps, + )) +endif + + +run_target('test-x', command: [ 'test/run_all_tests.sh' ]) + +uncrustify = find_program('uncrustify', required: false) +if uncrustify.found() + run_target('indent', + command: [ + uncrustify, + '-c', join_paths(meson.source_root(), 'data', 'uncrustify.cfg'), + rofi_sources + ], + ) +endif + +rofi_sources += theme_lexer_sources +rofi_sources += theme_parser_sources + +cppcheck = find_program('cppcheck', required: false) +if cppcheck.found() + run_target('cppcheck', + command: [ + cppcheck, + '--std=@0@'.format(get_option('c_std')), + '--platform=unix64', + '--enable=all', + '-Uerror_dialog', + '--inconclusive', + '-I@0@'.format(join_paths(meson.source_root(), 'include')), + rofi_sources + ], + ) +endif + +ohcount = find_program('ohcount', required: false) +if ohcount.found() + run_target('ohcount', + command: [ + ohcount, + rofi_sources + ], + ) +endif |