diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2020-02-20 18:50:24 +0000 |
---|---|---|
committer | Jon Turney <jon.turney@dronecode.org.uk> | 2020-02-28 11:54:08 +0000 |
commit | c8f8d58273a40d94c820dccab54a7ae2d948cb8a (patch) | |
tree | efa0c738fd4a0e6fc921194e857914a620cd0cbd /mesonbuild/rewriter.py | |
parent | 585bf2b86726373f58224f005bfb5ec6f07c2a46 (diff) | |
download | meson-c8f8d58273a40d94c820dccab54a7ae2d948cb8a.zip meson-c8f8d58273a40d94c820dccab54a7ae2d948cb8a.tar.gz meson-c8f8d58273a40d94c820dccab54a7ae2d948cb8a.tar.bz2 |
Rename 'subdir' -> 'filename' in location objects
Diffstat (limited to 'mesonbuild/rewriter.py')
-rw-r--r-- | mesonbuild/rewriter.py | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/mesonbuild/rewriter.py b/mesonbuild/rewriter.py index 2a65746..39d8337 100644 --- a/mesonbuild/rewriter.py +++ b/mesonbuild/rewriter.py @@ -651,8 +651,8 @@ class Rewriter: mlog.log(' -- Source', mlog.green(i), 'is already defined for the target --> skipping') continue mlog.log(' -- Adding source', mlog.green(i), 'at', - mlog.yellow('{}:{}'.format(node.subdir, node.lineno))) - token = Token('string', node.subdir, 0, 0, 0, None, i) + mlog.yellow('{}:{}'.format(node.filename, node.lineno))) + token = Token('string', node.filename, 0, 0, 0, None, i) to_append += [StringNode(token)] # Append to the AST at the right place @@ -695,7 +695,7 @@ class Rewriter: arg_node = root assert(arg_node is not None) mlog.log(' -- Removing source', mlog.green(i), 'from', - mlog.yellow('{}:{}'.format(string_node.subdir, string_node.lineno))) + mlog.yellow('{}:{}'.format(string_node.filename, string_node.lineno))) arg_node.arguments.remove(string_node) # Mark the node as modified @@ -712,24 +712,24 @@ class Rewriter: id_base = re.sub(r'[- ]', '_', cmd['target']) target_id = id_base + '_exe' if cmd['target_type'] == 'executable' else '_lib' source_id = id_base + '_sources' - subdir = os.path.join(cmd['subdir'], environment.build_filename) + filename = os.path.join(cmd['subdir'], environment.build_filename) # Build src list - src_arg_node = ArgumentNode(Token('string', subdir, 0, 0, 0, None, '')) + src_arg_node = ArgumentNode(Token('string', filename, 0, 0, 0, None, '')) src_arr_node = ArrayNode(src_arg_node, 0, 0, 0, 0) - src_far_node = ArgumentNode(Token('string', subdir, 0, 0, 0, None, '')) - src_fun_node = FunctionNode(subdir, 0, 0, 0, 0, 'files', src_far_node) - src_ass_node = AssignmentNode(subdir, 0, 0, source_id, src_fun_node) - src_arg_node.arguments = [StringNode(Token('string', subdir, 0, 0, 0, None, x)) for x in cmd['sources']] + src_far_node = ArgumentNode(Token('string', filename, 0, 0, 0, None, '')) + src_fun_node = FunctionNode(filename, 0, 0, 0, 0, 'files', src_far_node) + src_ass_node = AssignmentNode(filename, 0, 0, source_id, src_fun_node) + src_arg_node.arguments = [StringNode(Token('string', filename, 0, 0, 0, None, x)) for x in cmd['sources']] src_far_node.arguments = [src_arr_node] # Build target - tgt_arg_node = ArgumentNode(Token('string', subdir, 0, 0, 0, None, '')) - tgt_fun_node = FunctionNode(subdir, 0, 0, 0, 0, cmd['target_type'], tgt_arg_node) - tgt_ass_node = AssignmentNode(subdir, 0, 0, target_id, tgt_fun_node) + tgt_arg_node = ArgumentNode(Token('string', filename, 0, 0, 0, None, '')) + tgt_fun_node = FunctionNode(filename, 0, 0, 0, 0, cmd['target_type'], tgt_arg_node) + tgt_ass_node = AssignmentNode(filename, 0, 0, target_id, tgt_fun_node) tgt_arg_node.arguments = [ - StringNode(Token('string', subdir, 0, 0, 0, None, cmd['target'])), - IdNode(Token('string', subdir, 0, 0, 0, None, source_id)) + StringNode(Token('string', filename, 0, 0, 0, None, cmd['target'])), + IdNode(Token('string', filename, 0, 0, 0, None, source_id)) ] src_ass_node.accept(AstIndentationGenerator()) @@ -742,7 +742,7 @@ class Rewriter: to_remove = target['node'] self.to_remove_nodes += [to_remove] mlog.log(' -- Removing target', mlog.green(cmd['target']), 'at', - mlog.yellow('{}:{}'.format(to_remove.subdir, to_remove.lineno))) + mlog.yellow('{}:{}'.format(to_remove.filename, to_remove.lineno))) elif cmd['operation'] == 'info': # T.List all sources in the target @@ -777,8 +777,8 @@ class Rewriter: self.functions[cmd['type']](cmd) def apply_changes(self): - assert(all(hasattr(x, 'lineno') and hasattr(x, 'colno') and hasattr(x, 'subdir') for x in self.modefied_nodes)) - assert(all(hasattr(x, 'lineno') and hasattr(x, 'colno') and hasattr(x, 'subdir') for x in self.to_remove_nodes)) + assert(all(hasattr(x, 'lineno') and hasattr(x, 'colno') and hasattr(x, 'filename') for x in self.modefied_nodes)) + assert(all(hasattr(x, 'lineno') and hasattr(x, 'colno') and hasattr(x, 'filename') for x in self.to_remove_nodes)) assert(all(isinstance(x, (ArrayNode, FunctionNode)) for x in self.modefied_nodes)) assert(all(isinstance(x, (ArrayNode, AssignmentNode, FunctionNode)) for x in self.to_remove_nodes)) # Sort based on line and column in reversed order @@ -797,7 +797,7 @@ class Rewriter: printer.post_process() new_data = printer.result.strip() data = { - 'file': i['node'].subdir, + 'file': i['node'].filename, 'str': new_data, 'node': i['node'], 'action': i['action'] |