aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorYann Dirson <ydirson@free.fr>2020-02-23 19:19:13 +0100
committerGitHub <noreply@github.com>2020-02-23 20:19:13 +0200
commitee94cb6c15732c8b5f329164af7f2b0a63f4fa6d (patch)
treede830e59bc7055d38b8e9082804c90fd0b64e8ea /tools
parent8bf937b012ef0d59e632aa6c7e83226e7b7d77f8 (diff)
downloadmeson-ee94cb6c15732c8b5f329164af7f2b0a63f4fa6d.zip
meson-ee94cb6c15732c8b5f329164af7f2b0a63f4fa6d.tar.gz
meson-ee94cb6c15732c8b5f329164af7f2b0a63f4fa6d.tar.bz2
cmake2meson fix if nesting (#6676)
Diffstat (limited to 'tools')
-rwxr-xr-xtools/cmake2meson.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/tools/cmake2meson.py b/tools/cmake2meson.py
index 5a27a51..05acd8f 100755
--- a/tools/cmake2meson.py
+++ b/tools/cmake2meson.py
@@ -139,6 +139,16 @@ class Parser:
while not self.accept('eof'):
yield(self.statement())
+def token_or_group(arg):
+ if isinstance(arg, Token):
+ return ' ' + arg.value
+ elif isinstance(arg, list):
+ line = ' ('
+ for a in arg:
+ line += ' ' + token_or_group(a)
+ line += ' )'
+ return line
+
class Converter:
ignored_funcs = {'cmake_minimum_required': True,
'enable_testing': True,
@@ -237,17 +247,16 @@ class Converter:
except AttributeError: # complex if statements
line = t.name
for arg in t.args:
- if isinstance(arg, Token):
- line += ' ' + arg.value
- elif isinstance(arg, list):
- line += ' ('
- for a in arg:
- line += ' ' + a.value
- line += ' )'
+ line += token_or_group(arg)
elif t.name == 'elseif':
preincrement = -1
postincrement = 1
- line = 'elif %s' % self.convert_args(t.args, False)
+ try:
+ line = 'elif %s' % self.convert_args(t.args, False)
+ except AttributeError: # complex if statements
+ line = t.name
+ for arg in t.args:
+ line += token_or_group(arg)
elif t.name == 'else':
preincrement = -1
postincrement = 1