meson.build 2.8 KB
Newer Older
1 2
project(
    'squeekboard',
3
    'c', 'rust',
4
    version: '1.14.0',
5
    license: 'GPLv3',
6
    meson_version: '>=0.51.0',
7 8 9 10 11
    default_options: [
        'warning_level=1',
        'buildtype=debugoptimized',
        'c_std=gnu11'
    ]
12 13
)

14 15 16 17 18
add_project_arguments(
  [
    '-Werror=implicit-function-declaration',
    '-Werror=implicit-fallthrough=3',
    '-Werror=maybe-uninitialized',
19
    '-Werror=missing-field-initializers',
20
    '-Werror=incompatible-pointer-types',
21
    '-Werror=int-conversion',
22
    '-Werror=redundant-decls',
23
    '-Werror=parentheses',
24
    '-Wformat-nonliteral',
25
    '-Wformat-security',
26
    '-Wformat',
Guido Gunther's avatar
Guido Gunther committed
27
    '-Winit-self',
28
    '-Wmaybe-uninitialized',
29
    '-Wold-style-definition',
30
    '-Wredundant-decls',
31
    '-Wstrict-prototypes',
32
    '-Wunused',
33 34 35 36
  ],
  language: 'c'
)

David Boddie's avatar
David Boddie committed
37 38
i18n = import('i18n')

Guido Gunther's avatar
Guido Gunther committed
39 40
conf_data = configuration_data()

41 42 43
if get_option('buildtype').startswith('debug')
    add_project_arguments('-DDEBUG=1', language : 'c')
endif
44 45 46 47

if get_option('strict')
    add_project_arguments(
        [
48
            '-Werror',
49 50 51 52 53
        ],
        language: 'c'
    )
endif

54 55 56
if get_option('buildtype') != 'plain'
    add_project_arguments('-fstack-protector-strong', language: 'c')
endif
57 58 59 60 61
if get_option('buildtype') == 'release'
    cargo_build_flags = ['--release'] # for artifacts
else
    cargo_build_flags = []
endif
62

63
prefix = get_option('prefix')
64
bindir = join_paths(prefix, get_option('bindir'))
65
datadir = join_paths(prefix, get_option('datadir'))
66
desktopdir = join_paths(datadir, 'applications')
67
pkgdatadir = join_paths(datadir, meson.project_name())
68 69 70 71 72 73
if get_option('depdatadir') == ''
  depdatadir = datadir
else
  depdatadir = get_option('depdatadir')
endif
dbusdir = join_paths(depdatadir, 'dbus-1/interfaces')
74

Guido Gunther's avatar
Guido Gunther committed
75 76 77 78 79 80 81 82 83 84
summary = [
        '',
        '------------------',
        'squeekboard @0@'.format(meson.project_version()),
        '',
        '------------------',
        ''
]
message('\n'.join(summary))

85
# Rust deps are changing, depending on compile flags. Cargo can't handle it alone.
86
# As a side effect, Cargo.toml never gets used.
87 88 89 90 91 92 93 94 95 96 97 98 99
cargo_toml_in = files('Cargo.toml.in')
path_data = configuration_data()
path_data.set('path', meson.source_root())
cargo_toml_base = configure_file(
    input: 'Cargo.toml.in',
    output: 'Cargo.toml.base',
    configuration: path_data,
)


cargo_deps = files('Cargo.deps')

if get_option('legacy') == true
100
    cargo_build_flags += ['--features', 'gtk_v0_5,gio_v0_5,rustc_less_1_36']
101 102 103 104 105 106 107 108 109 110 111
    cargo_deps = files('Cargo.deps.legacy')
endif
    
cat = find_program('cat')
cargo_toml = custom_target(
    'Cargo.toml',
    output: 'Cargo.toml',
    command: [cat, cargo_toml_base, cargo_deps],
    capture: true,
)

112
dep_cargo = find_program('cargo')
113
cargo_script = find_program('cargo.sh')
Dorota Czaplejewicz's avatar
Dorota Czaplejewicz committed
114
cargo_build = find_program('cargo_build.py')
115

116
subdir('data')
Dorota Czaplejewicz's avatar
Dorota Czaplejewicz committed
117
subdir('protocols')
118
subdir('src')
119
subdir('tools')
120
subdir('tests')