diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2014-06-04 20:58:40 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2014-06-04 20:58:40 +0300 |
commit | eef91d1b2f186cb9178f38daa2f8ba5776492dfa (patch) | |
tree | 54a608dcff8d747b87020371718f2b9c9f330987 /tools/cmake2meson.py | |
parent | 451f6247f372ddaaf085ab4a37f302497ed6e324 (diff) | |
download | meson-eef91d1b2f186cb9178f38daa2f8ba5776492dfa.zip meson-eef91d1b2f186cb9178f38daa2f8ba5776492dfa.tar.gz meson-eef91d1b2f186cb9178f38daa2f8ba5776492dfa.tar.bz2 |
Working if else indents.
Diffstat (limited to 'tools/cmake2meson.py')
-rwxr-xr-x | tools/cmake2meson.py | 23 |
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 == '': |