| 1 |
|
| 2 |
|
| 3 |
from os import walk |
| 4 |
|
| 5 |
from outpututils import rewriteIfChanged |
| 6 |
|
| 7 |
|
| 8 |
def scanSources(baseDir): |
| 9 |
files = [] |
| 10 |
dirs = [] |
| 11 |
for dirPath, dirNames, fileNames in walk(baseDir): |
| 12 |
assert dirPath.startswith(baseDir) |
| 13 |
prefix = dirPath[len(baseDir):] |
| 14 |
if prefix: |
| 15 |
if not (prefix == 'unittest' or prefix.endswith('__pycache__')): |
| 16 |
dirs.append(prefix) |
| 17 |
prefix += '/' |
| 18 |
else: |
| 19 |
dirs.append('.') |
| 20 |
files += ( |
| 21 |
prefix + name |
| 22 |
for name in fileNames |
| 23 |
if name.endswith('.cc') |
| 24 |
) |
| 25 |
return files, dirs |
| 26 |
|
| 27 |
def mesonSources(): |
| 28 |
files, dirs = scanSources('src/') |
| 29 |
testSources = [] |
| 30 |
yield "sources = files(" |
| 31 |
for name in sorted(files): |
| 32 |
if name.startswith('unittest/'): |
| 33 |
testSources.append(name) |
| 34 |
elif not (name == 'main.cc' |
| 35 |
or name.endswith('Test.cc') |
| 36 |
or name.endswith('_test.cc') |
| 37 |
): |
| 38 |
yield " '%s'," % name |
| 39 |
yield " )" |
| 40 |
yield "" |
| 41 |
yield "main_sources = files(" |
| 42 |
yield " 'main.cc'," |
| 43 |
yield " )" |
| 44 |
yield "" |
| 45 |
yield "test_sources = files(" |
| 46 |
for name in testSources: |
| 47 |
yield " '%s'," % name |
| 48 |
yield " )" |
| 49 |
yield "" |
| 50 |
yield "incdirs = include_directories(" |
| 51 |
for name in dirs: |
| 52 |
yield " '%s'," % name |
| 53 |
yield " )" |
| 54 |
|
| 55 |
if __name__ == '__main__': |
| 56 |
rewriteIfChanged('src/meson.build', mesonSources()) |