File: meson_update_sources.py

package info (click to toggle)
openmsx 20.0%2Bdfsg-1.2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 27,544 kB
  • sloc: cpp: 236,922; xml: 49,948; tcl: 15,056; python: 5,385; perl: 281; sh: 77; makefile: 53
file content (56 lines) | stat: -rwxr-xr-x 1,234 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
#!/usr/bin/env python3

from os import walk

from outpututils import rewriteIfChanged


def scanSources(baseDir):
	files = []
	dirs = []
	for dirPath, dirNames, fileNames in walk(baseDir):
		assert dirPath.startswith(baseDir)
		prefix = dirPath[len(baseDir):]
		if prefix:
			if not (prefix == 'unittest' or prefix.endswith('__pycache__')):
				dirs.append(prefix)
			prefix += '/'
		else:
			dirs.append('.')
		files += (
			prefix + name
			for name in fileNames
			if name.endswith('.cc')
			)
	return files, dirs

def mesonSources():
	files, dirs = scanSources('src/')
	testSources = []
	yield "sources = files("
	for name in sorted(files):
		if name.startswith('unittest/'):
			testSources.append(name)
		elif not (name == 'main.cc'
				or name.endswith('Test.cc')
				or name.endswith('_test.cc')
				):
			yield "    '%s'," % name
	yield "    )"
	yield ""
	yield "main_sources = files("
	yield "    'main.cc',"
	yield "    )"
	yield ""
	yield "test_sources = files("
	for name in testSources:
		yield "    '%s'," % name
	yield "    )"
	yield ""
	yield "incdirs = include_directories("
	for name in dirs:
		yield "    '%s'," % name
	yield "    )"

if __name__ == '__main__':
	rewriteIfChanged('src/meson.build', mesonSources())