aboutsummaryrefslogtreecommitdiff
path: root/tools/cmake2meson.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2014-06-04 20:58:40 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2014-06-04 20:58:40 +0300
commiteef91d1b2f186cb9178f38daa2f8ba5776492dfa (patch)
tree54a608dcff8d747b87020371718f2b9c9f330987 /tools/cmake2meson.py
parent451f6247f372ddaaf085ab4a37f302497ed6e324 (diff)
downloadmeson-eef91d1b2f186cb9178f38daa2f8ba5776492dfa.zip
meson-eef91d1b2f186cb9178f38daa2f8ba5776492dfa.tar.gz
meson-eef91d1b2f186cb9178f38daa2f8ba5776492dfa.tar.bz2
Working if else indents.
Diffstat (limited to 'tools/cmake2meson.py')
-rwxr-xr-xtools/cmake2meson.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/tools/cmake2meson.py b/tools/cmake2meson.py
index 0d3f3c6..248762e 100755
--- a/tools/cmake2meson.py
+++ b/tools/cmake2meson.py
@@ -162,8 +162,8 @@ class Converter:
def write_entry(self, outfile, t):
if t.name in Converter.ignored_funcs:
return
-
- indent = self.indent_level*self.indent_unit
+ preincrement = 0
+ postincrement = 0
if t.name == '_':
line = t.args[0]
elif t.name == 'add_subdirectory':
@@ -190,12 +190,29 @@ class Converter:
elif t.name == 'set':
varname = t.args[0].value.lower()
line = '%s = %s\n' % (varname, self.convert_args(t.args[1:]))
+ elif t.name == 'if':
+ postincrement = 1
+ line = 'if %s' % self.convert_args(t.args)
+ elif t.name == 'elseif':
+ preincrement = -1
+ postincrement = 1
+ line = 'elif %s' % self.convert_args(t.args)
+ elif t.name == 'else':
+ preincrement = -1
+ postincrement = 1
+ line = 'else'
+ elif t.name == 'endif':
+ preincrement = -1
+ line = 'endif'
else:
- line = '''# %s''' % t.name
+ line = '''# %s(%s)''' % (t.name, self.convert_args(t.args))
+ self.indent_level += preincrement
+ indent = self.indent_level*self.indent_unit
outfile.write(indent)
outfile.write(line)
if not(line.endswith('\n')):
outfile.write('\n')
+ self.indent_level += postincrement
def convert(self, subdir=''):
if subdir == '':