-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild-dist.py
executable file
·66 lines (52 loc) · 1.88 KB
/
build-dist.py
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
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
#
# Copyright (C) 2020 Matthias Klumpp <[email protected]>
#
# SPDX-License-Identifier: LGPL-3.0+
#
# Shortcut to build the Angular application for different configurations
#
import os
import sys
import subprocess
import shutil
from argparse import ArgumentParser
FDO_BASE_HREF = 'https://www.freedesktop.org/software/appstream/metainfocreator/'
def main():
parser = ArgumentParser(description='Build MetaInfo Creator')
parser.add_argument('-c', '--config', action='store', dest='config', default=None,
help='Configuration name to build for')
# parse all arguments that this script can handle
h_args, ng_extra_args = parser.parse_known_args()
# determine our working directory
root_dir = os.path.dirname(os.path.abspath(__file__))
print('Source directory is: {}'.format(root_dir))
os.chdir(root_dir)
# check if we have the Angular executable
if not shutil.which('ng'):
print('Angular CLI was not found.')
print('Please install it via `npm install -g @angular/cli`')
sys.exit(4)
config_name = h_args.config
if config_name:
config_name = config_name.lower()
if config_name == 'fdo':
config_name = 'freedesktop'
# construct the Angular build command
ngbuild_cmd = ['ng', 'build']
if not config_name:
ngbuild_cmd.extend(['--configuration', 'production'])
elif config_name == 'freedesktop':
ngbuild_cmd.extend(['--configuration', 'freedesktop'])
ngbuild_cmd.extend(['--base-href', FDO_BASE_HREF])
else:
ngbuild_cmd.extend(['--configuration', config_name])
# run build
print('Building configuration: {}'.format(config_name))
ngbuild_cmd.extend(ng_extra_args)
r = subprocess.call(ngbuild_cmd)
if r != 0:
print('Build has failed!')
sys.exit(r)
if __name__ == '__main__':
main()