Debian Codegraph @

mini_soong/model.py

raw symbols SCIP
1 #!/usr/bin/python3
2 # Soong parsed model
3 #
4 # Copyright 2020 Andrej Shadura
5 #
6 # SPDX-License-Identifier: MIT
7 #
8 # Permission is hereby granted, free of charge, to any person obtaining
9 # a copy of this software and associated documentation files (the
10 # "Software"), to deal in the Software without restriction, including
11 # without limitation the rights to use, copy, modify, merge, publish,
12 # distribute, sublicense, and/or sell copies of the Software, and to
13 # permit persons to whom the Software is furnished to do so, subject to
14 # the following conditions:
15 #
16 # The above copyright notice and this permission notice shall be
17 # included in all copies or substantial portions of the Software.
18 #
19 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
27 from dataclasses import dataclass
28
29 all_modules = list()
30 all_targets = list()
31
32 defaults = dict()
33
34 current_recipe = dict()
35
36 @dataclass
37 class Assignment:
38 # NOT currently used
39 variable: str
40 value: object
41
42 def __init__(self, tokens):
43 self.variable = tokens[0][0]
44 self.value = tokens[0][1]
45
46 def run(self):
47 global variables
48 variables[self.variable] = self.value
49
50 @dataclass
51 class Module:
52 name: str
53 arguments: dict
54
55 def __init__(self, tokens):
56 self.name = tokens[0][0]
57 self.arguments = tokens[0][1].asDict()
58
59 def run(self):
60 from . import builders
61 if self.name in builders.methods:
62 builders.methods[self.name](**self.arguments)
63 else:
64 import sys
65 print(f"WARNING: {self.name} not yet supported", file=sys.stderr)