Debian Codegraph @

Lib/notobuilder/__main__.py

raw symbols SCIP
1 import subprocess
2 from os import chdir
3 import os
4 from pathlib import Path
5 import yaml
6 import sys
7
8 from gftools.builder import GFBuilder, BASE_SCHEMA
9
10
11 # These days I'm just gftools-builder in a funny hat.
12 def main(args=None):
13 import argparse
14
15 parser = argparse.ArgumentParser()
16 parser.add_argument(
17 "--graph", help="Draw a graph of the build process", action="store_true"
18 )
19 parser.add_argument("--no-ninja", help="Do not run ninja", action="store_true")
20 parser.add_argument("--no-static", help="Do not build statics", action="store_true")
21 parser.add_argument(
22 "--generate",
23 help="Just generate and output recipe from recipe builder",
24 action="store_true",
25 )
26 parser.add_argument("config", help="Path to config file")
27 args = parser.parse_args(args)
28
29 with open(args.config, "r") as file:
30 config = yaml.safe_load(file.read())
31 chdir(Path(args.config).resolve().parent)
32
33 config["recipeProvider"] = "noto"
34 if args.no_static:
35 config["buildStatic"] = False
36 # Only build OTFs if it's a release
37 if "refs/tags" not in os.environ.get("GITHUB_REF", ""):
38 config["buildOTF"] = False
39 pd = GFBuilder(config)
40 if args.generate:
41 print(yaml.dump(pd.config))
42 return
43 pd.config_to_objects()
44 pd.build_graph()
45 pd.walk_graph()
46 if args.graph:
47 pd.draw_graph()
48 if not args.no_ninja:
49 result = subprocess.run(["ninja"])
50 sys.exit(result.returncode)
51
52
53 if __name__ == "__main__":
54 main()