File: __main__.py

package info (click to toggle)
python-notobuilder 0%2B20250929-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 192 kB
  • sloc: python: 682; makefile: 9; sh: 1
file content (54 lines) | stat: -rw-r--r-- 1,542 bytes parent folder | download
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
import subprocess
from os import chdir
import os
from pathlib import Path
import yaml
import sys

from gftools.builder import GFBuilder, BASE_SCHEMA


# These days I'm just gftools-builder in a funny hat.
def main(args=None):
    import argparse

    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--graph", help="Draw a graph of the build process", action="store_true"
    )
    parser.add_argument("--no-ninja", help="Do not run ninja", action="store_true")
    parser.add_argument("--no-static", help="Do not build statics", action="store_true")
    parser.add_argument(
        "--generate",
        help="Just generate and output recipe from recipe builder",
        action="store_true",
    )
    parser.add_argument("config", help="Path to config file")
    args = parser.parse_args(args)

    with open(args.config, "r") as file:
        config = yaml.safe_load(file.read())
    chdir(Path(args.config).resolve().parent)

    config["recipeProvider"] = "noto"
    if args.no_static:
        config["buildStatic"] = False
    # Only build OTFs if it's a release
    if "refs/tags" not in os.environ.get("GITHUB_REF", ""):
        config["buildOTF"] = False
    pd = GFBuilder(config)
    if args.generate:
        print(yaml.dump(pd.config))
        return
    pd.config_to_objects()
    pd.build_graph()
    pd.walk_graph()
    if args.graph:
        pd.draw_graph()
    if not args.no_ninja:
        result = subprocess.run(["ninja"])
        sys.exit(result.returncode)


if __name__ == "__main__":
    main()