xref: /aosp_15_r20/external/angle/build/config/siso/gn_logs.star (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1# -*- bazel-starlark -*-
2# Copyright 2024 The Chromium Authors
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5"""gn_logs module to access gn_logs data."""
6
7load("@builtin//struct.star", "module")
8
9def __read(ctx):
10    fname = ctx.fs.canonpath("./gn_logs.txt")
11    if not ctx.fs.exists(fname):
12        return {}
13    gn_logs = ctx.fs.read(fname)
14    vars = {}
15    for line in str(gn_logs).splitlines():
16        if line.startswith("#"):
17            continue
18        if not "=" in line:
19            continue
20        kv = line.split("=", 1)
21        vars[kv[0].strip()] = kv[1].strip()
22    return vars
23
24gn_logs = module(
25    "gn_logs",
26    read = __read,
27)
28