-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxcode-easy-build.py
64 lines (51 loc) · 1.74 KB
/
xcode-easy-build.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
import yaml
import argparse
from build_command import BuildCommand
from run_command import RunCommand
from commands_runner import ICommandsRunner, CommandsRunner, VerboseCommandRunner, DryRunCommandRunner, CompositeCommandRunner
def readCommand(
file: str,
configurationName: str,
commandsRunner: ICommandsRunner):
yamlFile = open(file, "r")
actionTree = yaml.safe_load(yamlFile)[configurationName]
if "build" in actionTree.keys():
buildAction = actionTree["build"]
return BuildCommand(buildAction, commandsRunner)
elif "run" in actionTree.keys():
buildAction = actionTree["run"]
return RunCommand(buildAction, commandsRunner)
def parseArguments():
parser = argparse.ArgumentParser()
parser.add_argument(
"--input-file",
type=str,
help="""
Input YAML file name.
By default, the script looks for \"buildCommands.yml\"
""")
parser.add_argument(
"commandNames",
type=str,
nargs="+",
help="""
Mandatory: configuration name to look inside the
yml configuration file
""")
args = parser.parse_args()
return args
def main():
args = parseArguments()
filename = args.input_file
if filename is None:
filename = "buildCommands.yml"
verboseRunner = VerboseCommandRunner()
dryRunner = DryRunCommandRunner()
commandsRunner = CompositeCommandRunner(
verboseRunner=verboseRunner,
dryRunner=dryRunner)
for commandName in args.commandNames:
command = readCommand(filename, commandName, commandsRunner)
command.performAction()
if __name__ == "__main__":
main()