Even though they're specific to the web CMakeLists proj, it's good to have all build scripts in one place
28 lines
819 B
Python
28 lines
819 B
Python
import termcolor
|
|
|
|
class BuildStep:
|
|
def __init__(self, header, body=None, begin_color='green', end_color='cyan'):
|
|
self.header = header
|
|
self.body = body
|
|
self.begin_color = begin_color
|
|
self.end_color = end_color
|
|
|
|
def _desc_parts(self):
|
|
parts = [self.header]
|
|
if self.body is not None:
|
|
parts.append(self.body)
|
|
return parts
|
|
|
|
def __str__(self):
|
|
return ': '.join(self._desc_parts())
|
|
|
|
def __enter__(self):
|
|
termcolor.cprint(
|
|
f'\n* BEGIN {self.header}', color=self.begin_color, flush=True)
|
|
if self.body is not None:
|
|
print(f'{self.body}', flush=True)
|
|
|
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
termcolor.cprint(
|
|
f'* END {self.header}', color=self.end_color, flush=True)
|