File: SConstruct

package info (click to toggle)
xsettingsd 1.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 204 kB
  • sloc: cpp: 2,135; makefile: 19; sh: 6
file content (83 lines) | stat: -rw-r--r-- 2,134 bytes parent folder | download | duplicates (2)
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
# -*- python -*-
# Copyright 2009 Daniel Erat <dan@erat.org>
# All rights reserved.

import os
import subprocess

Help('''
Type: 'scons xsettingsd' to build xsettingsd
      'scons dump_xsettings' to build dump_xsettings
      'scons test' to build and run all tests
''')


def run_tests(target, source, env):
  '''Run all test binaries listed in 'source'.'''

  tests = sorted([str(t) for t in source])
  max_length = max([len(t) for t in tests])

  for test in tests:
    padded_name = test + ' ' * (max_length - len(test))

    proc = subprocess.Popen('./%s' % test,
                            stdout=subprocess.PIPE,
                            stderr=subprocess.STDOUT,
                            close_fds=True)
    [stdout, stderr] = proc.communicate()
    proc.wait()
    if proc.returncode == 0:
      print('%s OK' % padded_name)
    else:
      print("%s FAILED\n" % padded_name)
      print(stdout)

run_tests_builder = Builder(action=run_tests)


env = Environment(
    BUILDERS = {
      'RunTests': run_tests_builder,
    })

env.Append(CPPFLAGS=os.environ.get('CPPFLAGS', ''),
           CFLAGS=os.environ.get('CFLAGS', ''),
           CXXFLAGS=os.environ.get('CXXFLAGS', ''),
           LINKFLAGS=os.environ.get('LDFLAGS', ''))

env.Append(CCFLAGS='-Wall -Werror -Wno-narrowing')


srcs = Split('''\
  common.cc
  config_parser.cc
  data_reader.cc
  data_writer.cc
  setting.cc
  settings_manager.cc
''')
libxsettingsd = env.Library('xsettingsd', srcs)
env['LIBS'] = libxsettingsd
env.ParseConfig('pkg-config --cflags --libs x11')

xsettingsd     = env.Program('xsettingsd', 'xsettingsd.cc')
dump_xsettings = env.Program('dump_xsettings', 'dump_xsettings.cc')

Default([xsettingsd, dump_xsettings])


gtest_env = env.Clone()
gtest_env.Append(CCFLAGS='-I/usr/src/gtest')
gtest_env.VariantDir('.', '/usr/src/gtest/src', duplicate=0)
libgtest = gtest_env.Library('gtest', 'gtest-all.cc')

test_env = env.Clone()
test_env.Append(CCFLAGS='-D__TESTING')
test_env['LIBS'] += [libgtest, 'pthread']

tests = []
for file in Glob('*_test.cc', strings=True):
  tests += test_env.Program(file)
test_env.RunTests('test', tests)