2019-05-17 14:46:54 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
2021-02-07 17:08:04 +01:00
|
|
|
import os
|
|
|
|
|
|
2019-05-17 14:46:54 +02:00
|
|
|
from pathlib import Path
|
|
|
|
|
from subprocess import PIPE, run
|
|
|
|
|
|
|
|
|
|
examples = [
|
|
|
|
|
x for x in Path(__file__).parent.iterdir() if x.is_dir() and (x / 'CMakeLists.txt').exists()
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
assert(len(examples) > 0)
|
|
|
|
|
|
2021-02-07 17:08:04 +01:00
|
|
|
|
2019-05-17 14:46:54 +02:00
|
|
|
def runCommand(command):
|
|
|
|
|
print('- %s' % command)
|
|
|
|
|
result = run(command, stdout=PIPE, stderr=PIPE, universal_newlines=True, shell=True)
|
|
|
|
|
if result.returncode != 0:
|
2021-02-07 17:08:04 +01:00
|
|
|
print("error while running '%s':\n" % command, ' ' + str(result.stderr).replace('\n', '\n '))
|
2019-05-17 14:46:54 +02:00
|
|
|
exit(result.returncode)
|
|
|
|
|
return result.stdout
|
|
|
|
|
|
2021-02-07 17:08:04 +01:00
|
|
|
|
2019-05-17 14:46:54 +02:00
|
|
|
print('')
|
|
|
|
|
for example in examples:
|
|
|
|
|
print("running example %s" % example.name)
|
|
|
|
|
print("================" + ('=' * len(example.name)))
|
|
|
|
|
project = Path(".") / 'build' / example.name
|
2022-01-27 17:45:35 -05:00
|
|
|
configure = runCommand('cmake -S%s -B%s' % (example, project))
|
2019-05-17 14:46:54 +02:00
|
|
|
print(' ' + '\n '.join([line for line in configure.split('\n') if 'CPM:' in line]))
|
2021-02-07 17:08:04 +01:00
|
|
|
build = runCommand('cmake --build %s -- -j%i' % (project, os.cpu_count() / 2))
|
2019-05-17 14:46:54 +02:00
|
|
|
print(' ' + '\n '.join([line for line in build.split('\n') if 'Built target' in line]))
|
|
|
|
|
print('')
|