diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2014-06-04 21:24:57 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2014-06-04 21:24:57 +0300 |
commit | 7c6861268ab62131374544f120758b93dd6f037a (patch) | |
tree | 1cf85ba2dbb7b74fe352e0fe11ea8845cd8f49e7 /tools | |
parent | abebfe7927385bf4ac3766f3f004261b7a114eac (diff) | |
download | meson-7c6861268ab62131374544f120758b93dd6f037a.zip meson-7c6861268ab62131374544f120758b93dd6f037a.tar.gz meson-7c6861268ab62131374544f120758b93dd6f037a.tar.bz2 |
Convert build options.
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/cmake2meson.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/cmake2meson.py b/tools/cmake2meson.py index 9fcaf74..1e7ca87 100755 --- a/tools/cmake2meson.py +++ b/tools/cmake2meson.py @@ -140,6 +140,7 @@ class Converter: self.cmake_root = cmake_root self.indent_unit = ' ' self.indent_level = 0 + self.options = [] def convert_args(self, args, as_array=True): res = [] @@ -185,6 +186,15 @@ class Converter: line = "%s_dep = dependency('%s')" % (t.args[0].value, t.args[0].value) elif t.name == 'find_library': line = "%s = find_library('%s')" % (t.args[0].value.lower(), t.args[0].value) + elif t.name == 'option': + optname = t.args[0].value + description = t.args[1].value + if len(t.args) > 2: + default = t.args[2].value + else: + default = None + self.options.append((optname, description, default)) + return elif t.name == 'project': pname = t.args[0].value args = [pname] @@ -239,6 +249,27 @@ class Converter: self.convert(os.path.join(subdir, t.args[0].value)) #print('\nReturning to', self.cmake_root, '\n') self.write_entry(outfile, t) + if subdir == self.cmake_root and len(self.options) > 0: + self.write_options() + + def write_options(self): + optfile = open(os.path.join(self.cmake_root, 'meson_options.txt'), 'w') + for o in self.options: + (optname, description, default) = o + if default is None: + defaultstr = '' + else: + if default == 'OFF': + typestr = ' type : boolean,' + default = 'false' + elif default == 'ON': + default = 'true' + typestr = ' type : boolean,' + else: + typestr = ' type : string,' + defaultstr = ' value : %s,' % default + line = "option(%s,%s%s description : '%s')\n" % (optname, typestr, defaultstr, description) + optfile.write(line) if __name__ == '__main__': if len(sys.argv) != 2: |