1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
project('smolbote', ['cpp'],
version: '0.1.0',
default_options: ['cpp_std=c++2a', 'warning_level=3'],
license: 'GPL3',
meson_version: '>=0.55.0'
)
summary({
'prefix': get_option('prefix'),
'bindir': get_option('bindir'),
'libdir': get_option('libdir'),
'datadir': get_option('datadir')
}, section: 'Install locations')
kconfig = import('unstable-keyval')
cdata = configuration_data(kconfig.load(host_machine.system() + '/.config'))
version_h = vcs_tag(
command: [find_program('git').full_path(), 'describe', '--long', '--abbrev=40'],
#fallback: defaults to meson.project_version(),
input: 'src/version.h.in',
output: 'version.h'
)
# add -DQT_NO_DEBUG to non-debug builds
if not get_option('debug')
add_project_arguments('-DQT_NO_DEBUG', language: 'cpp')
endif
sourceset = import('sourceset')
cxx = meson.get_compiler('cpp')
summary({
'id': cxx.get_id(),
'version': cxx.version(),
'linker': cxx.get_linker_id(),
}, section: 'Compiler')
# add some specific flags
add_project_arguments(cxx.get_supported_arguments([
'-ffunction-sections', # Place each function into its own section, better ASLR but larger executables
'-fstack-protector-all', # Emit code to check for buffer overflows on all functions
'-fstack-clash-protection', # Emit code to check for stack clash attacks
# gcc specific
'-fconcepts', # gcc9 c++20 compat
# clang specific
'-mspeculative-load-hardening', # Spectre v1 mitigation
'-Xclang -plugin-arg-clazy -Xclang level0,level1', # clazy default warning level
## warnings
# variables
'-Wunused', # warn on anything being unused
'-Wshadow', # if variable declaration shadows one from a parent context
# functions
'-Wnon-virtual-dtor', # if class with virtual functions has non-virtual dtor
'-Wmissing-declarations', # missing function declarations in header files
'-Werror=redundant-decls',
'-Woverloaded-virtual', # warn if you overload (not override) a virtual function
'-Werror=return-type',
# style
'-Wformat=2', # security issues around printf
'-Wdate-time', # __TIME__ and __DATE__ macros
'-Werror=missing-field-initializers',
# objects
'-Wnull-dereference',
'-Wconsumed', # use-after-move warnings
'-Wlifetime', # object lifetime issues
# logic
'-Wlogical-op', # logical operations being used where bitwise were probably wanted
'-Wimplicit-fallthrough',
'-Wduplicated-cond', # if/else chain has duplicated conditions
'-Wduplicated-branches', # if/else branches have duplicated code
# casts
'-Wold-style-cast',
'-Wcast-align', # potential performance problem casts
'-Wuseless-cast', # cast to same type
'-Wconversion', # type conversions that may lose data
'-Wsign-conversion', # sign conversions
'-Wdouble-promotion', # float is promoted to double
# others
'-Werror=pedantic', # if non-standard c++ is used
#'-Weffc++',
]), language: 'cpp')
# Dependencies
mod_qt5 = import('qt5')
dep_qt5 = dependency('qt5',
modules: [ 'Core', 'Network', 'Widgets', 'Svg', 'WebEngine', 'WebEngineWidgets', 'Concurrent' ],
include_type: 'system'
)
dep_spdlog = dependency('spdlog', fallback: ['spdlog', 'spdlog_dep'], version: '>=1.3.1')
dep_catch = dependency('catch2', required: true, fallback: ['catch2', 'catch2_dep'] )
dep_SingleApplication = dependency('singleapplication', fallback: [ 'singleapplication', 'SingleApplication_dep' ])
# Generate config header
poi_sourceset = sourceset.source_set()
subdir('include')
smolbote_interfaces = include_directories('include')
subdir('lib/bookmarks')
subdir('lib/configuration')
subdir('lib/downloads')
subdir('lib/pluginloader')
subdir('lib/session_formats')
subdir('lib/smolblok')
subdir('src')
subdir('lang')
subdir('doc')
subdir('plugins/ProfileEditor')
subdir('plugins/HostlistFilter')
subdir('plugins/AdblockFilter')
subdir('test/firefox-bookmarks-json-parser')
ssconfig = poi_sourceset.apply(cdata)
poi_exe = executable(get_option('poi'),
cpp_args: ['-DQAPPLICATION_CLASS=QApplication'],
sources: [ssconfig.sources()],
include_directories: [ plugininterfaces_include, include_directories('src') ],
dependencies: [ dep_qt5, dep_spdlog, dep_SingleApplication, dep_bookmarks, dep_configuration, dep_downloads, dep_pluginloader, ssconfig.dependencies(), lib_session_formats ],
install: true,
)
test('poi-bookmarks_xbel', poi_exe, args: [ 'bookmarks', '-x', files('test/bookmarks.xbel'), '--export=stdout' ])
subdir(host_machine.system())
# cppcheck target
cppcheck = find_program('cppcheck', required: false)
if cppcheck.found()
run_target('cppcheck',
command: [cppcheck, '--enable=all', '--project=' + meson.build_root() / 'compile_commands.json']
)
endif
|