diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2016-12-04 18:28:25 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2016-12-04 18:28:25 +0200 |
commit | 14ca7d602c92b6f97fe32230cf694d4a51d8a524 (patch) | |
tree | 20d3c02f48ac5d80b94b3da5de3d62347fe867c0 /mesonbuild/astinterpreter.py | |
parent | 6aa24362cd4c9e08e274f524773bbfee92c0d9f4 (diff) | |
download | meson-14ca7d602c92b6f97fe32230cf694d4a51d8a524.zip meson-14ca7d602c92b6f97fe32230cf694d4a51d8a524.tar.gz meson-14ca7d602c92b6f97fe32230cf694d4a51d8a524.tar.bz2 |
Store subdir information for each node so we can remove files set in other subdirectories.
Diffstat (limited to 'mesonbuild/astinterpreter.py')
-rw-r--r-- | mesonbuild/astinterpreter.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/mesonbuild/astinterpreter.py b/mesonbuild/astinterpreter.py index c29c1ea..3691d64 100644 --- a/mesonbuild/astinterpreter.py +++ b/mesonbuild/astinterpreter.py @@ -46,6 +46,7 @@ REMOVE_SOURCE = 1 class AstInterpreter(interpreterbase.InterpreterBase): def __init__(self, source_root, subdir): super().__init__(source_root, subdir) + self.asts = {} self.funcs.update({'project' : self.func_do_nothing, 'test' : self.func_do_nothing, 'benchmark' : self.func_do_nothing, @@ -133,7 +134,8 @@ class AstInterpreter(interpreterbase.InterpreterBase): code = f.read() assert(isinstance(code, str)) try: - codeblock = mparser.Parser(code).parse() + codeblock = mparser.Parser(code, self.subdir).parse() + self.asts[subdir] = codeblock except mesonlib.MesonException as me: me.file = buildfilename raise me @@ -162,6 +164,7 @@ class AstInterpreter(interpreterbase.InterpreterBase): def transform(self): self.load_root_meson_file() + self.asts[''] = self.ast self.sanity_check_ast() self.parse_project() self.run() @@ -202,7 +205,7 @@ class AstInterpreter(interpreterbase.InterpreterBase): commaspan = args.commas[i].bytespan if commaspan[0] < namespan[0]: commaspan, namespan = namespan, commaspan - buildfilename = os.path.join(self.source_root, self.subdir, environment.build_filename) + buildfilename = os.path.join(self.source_root, args.subdir, environment.build_filename) raw_data = open(buildfilename, 'r').read() intermediary = raw_data[0:commaspan[0]] + raw_data[commaspan[1]:] updated = intermediary[0:namespan[0]] + intermediary[namespan[1]:] @@ -210,7 +213,7 @@ class AstInterpreter(interpreterbase.InterpreterBase): sys.exit(0) def hacky_find_and_remove(self, node_to_remove): - for a in self.ast.lines: + for a in self.asts[node_to_remove.subdir].lines: if a.lineno == node_to_remove.lineno: if isinstance(a, mparser.AssignmentNode): v = a.value |