summaryrefslogtreecommitdiff
path: root/src/meson.build
blob: acbe4d1a4867d489d95212f9b694b53bac75b030 (plain)
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
142
143
144
145

upowerd_deps = declare_dependency(
    include_directories: [
        include_directories('.'),
        include_directories('..'),
        include_directories('../dbus'),
    ],
    dependencies: [
        m_dep, glib_dep, gobject_dep, gio_dep, gio_unix_dep, libupower_glib_dep, upowerd_dbus_dep
    ],
    compile_args: [
        '-DUP_COMPILATION',
        '-DHISTORY_DIR="@0@"'.format(historydir),
    ],
)

upshared = {}
subdir('dummy')
subdir('linux')
subdir('bsd')
subdir('openbsd')
subdir('freebsd')

# Everything that is also needed by the tests
upowerd_private = static_library('upowerd-private',
    sources: [
        'up-constants.h',
        'up-config.h',
        'up-config.c',
        'up-daemon.h',
        'up-daemon.c',
        'up-device.h',
        'up-device.c',
        'up-device-battery.h',
        'up-device-battery.c',
        'up-device-list.h',
        'up-device-list.c',
        'up-enumerator.c',
        'up-enumerator.h',
        'up-kbd-backlight.h',
        'up-kbd-backlight.c',
        'up-history.h',
        'up-history.c',
        'up-backend.h',
        'up-native.h',
        'up-common.h',
        'up-common.c',
    ],
    dependencies: [ upowerd_deps ],
    c_args: [ '-DG_LOG_DOMAIN="UPower"' ],
)

upowerd = executable('upowerd',
    sources: [
        'up-main.c',
    ],
    dependencies: upowerd_deps,
    link_with: [ upowerd_private, upshared[os_backend] ],
    gnu_symbol_visibility: 'hidden',
    install: true,
    install_dir: get_option('prefix') / get_option('libexecdir'),
    c_args: [ '-DG_LOG_DOMAIN="UPower"' ],
)

up_self_test = executable('up_self_test',
    sources: [
        'up-self-test.c',
    ],
    c_args: [
        '-DUPOWER_CONF_PATH="@0@"'.format(meson.project_source_root() / 'etc' / 'UPower.conf'),
        '-DG_LOG_DOMAIN="UPower"',
    ],
    dependencies: upowerd_deps,
    link_with: [ upowerd_private, upshared['dummy'] ],
    gnu_symbol_visibility: 'hidden',
    build_by_default: true,
    install: false,
)

#############
# Data/Config files
#############

install_subdir('does-not-exist', install_dir: historydir, strip_directory : true)

cdata = configuration_data()
cdata.set('libexecdir', get_option('prefix') / get_option('libexecdir'))
cdata.set('historydir', historydir)

configure_file(
    input: 'org.freedesktop.UPower.service.in',
    output: 'org.freedesktop.UPower.service',
    install_dir: dbusdir / 'system-services',
    configuration: cdata,
)

configure_file(
    input: 'org.freedesktop.UPower.conf.in',
    output: 'org.freedesktop.UPower.conf',
    install_dir: dbusdir / 'system.d',
    configuration: cdata,
)

if systemdsystemunitdir != 'no'
    configure_file(
        input: 'upower.service.in',
        output: 'upower.service',
        install_dir: systemdsystemunitdir,
        configuration: cdata,
    )
endif

#############
# Tests
#############
test(
   'self-test',
   up_self_test,
)

# On Linux, we can run the additional integration test;
# defined here as we would have a circular dependency otherwise.
if os_backend == 'linux' and gobject_introspection.found()
    env = environment()
    env.prepend('top_builddir', join_paths(meson.project_build_root()))
    env.prepend('LD_LIBRARY_PATH', join_paths(meson.project_build_root(), 'libupower-glib'))
    env.prepend('GI_TYPELIB_PATH', join_paths(meson.project_build_root(), 'libupower-glib'))

    python3 = find_program('python3')
    unittest_inspector = find_program('linux/unittest_inspector.py')
    r = run_command(unittest_inspector, files('linux/integration-test.py'), check: false)
    unit_tests = r.stdout().strip().split('\n')

    foreach ut: unit_tests
        ut_args = files('linux/integration-test.py')
        ut_args += ut
        test(ut,
             python3,
             args: ut_args,
             env: env,
             depends: [ libupower_glib_typelib, upowerd ],
             timeout: 80,
            )
    endforeach
endif