Even though they're specific to the web CMakeLists proj, it's good to have all build scripts in one place
61 lines
1.5 KiB
Python
61 lines
1.5 KiB
Python
import json
|
|
import os
|
|
from pathlib import Path
|
|
from core.logging import exec_and_log_error
|
|
from core.file_utils import SparkPaths
|
|
import argparse
|
|
|
|
|
|
def _get_arg_parser():
|
|
parser = argparse.ArgumentParser(description='Generate a tsconfig (that extends a base tsconfig) for web build')
|
|
|
|
parser.add_argument(
|
|
'--config-base',
|
|
metavar='path',
|
|
help='The base tsconfig file to use',
|
|
required=True)
|
|
|
|
parser.add_argument(
|
|
'--config-out',
|
|
metavar='path',
|
|
help='The tsconfig file to create',
|
|
required=True)
|
|
|
|
parser.add_argument(
|
|
'--protos',
|
|
nargs='+',
|
|
help='The protocol buffers to transpile')
|
|
|
|
parser.add_argument(
|
|
'--build-out',
|
|
help='The build output directory',
|
|
required=True)
|
|
|
|
parser.set_defaults(mode='development')
|
|
return parser
|
|
|
|
|
|
def _main():
|
|
parser = _get_arg_parser()
|
|
args = parser.parse_args()
|
|
src_path = SparkPaths.root().joinpath('src', 'web', 'api')
|
|
os.chdir(src_path)
|
|
cfg_base = Path(args.config_base).absolute()
|
|
cfg_out = Path(args.config_out).absolute()
|
|
build_out = Path(args.build_out).absolute()
|
|
cfg = {
|
|
'extends': str(cfg_base),
|
|
'compilerOptions': {
|
|
'outDir': str(build_out),
|
|
'paths': {
|
|
'proto': [str(build_out.joinpath('proto'))]
|
|
}
|
|
}
|
|
}
|
|
with open(str(cfg_out), 'w') as f_out:
|
|
json.dump(cfg, f_out, indent=2)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
exec_and_log_error(_main, name=__file__)
|