aboutsummaryrefslogtreecommitdiff
path: root/tools/cmake2meson.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2014-06-02 01:04:44 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2014-06-02 01:04:44 +0300
commit18cee0fca2430450fd3b890bde7dd52f53b74eaa (patch)
tree63a15072720f9101b3d39a937d1a60e7fc603545 /tools/cmake2meson.py
parent0c31155b0a572522ea6e623add3d76318b091993 (diff)
downloadmeson-18cee0fca2430450fd3b890bde7dd52f53b74eaa.zip
meson-18cee0fca2430450fd3b890bde7dd52f53b74eaa.tar.gz
meson-18cee0fca2430450fd3b890bde7dd52f53b74eaa.tar.bz2
Convert a few more functions, can generate a simple skeleton.
Diffstat (limited to 'tools/cmake2meson.py')
-rwxr-xr-xtools/cmake2meson.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/tools/cmake2meson.py b/tools/cmake2meson.py
index 8cc9d55..6f936e8 100755
--- a/tools/cmake2meson.py
+++ b/tools/cmake2meson.py
@@ -133,24 +133,40 @@ class Parser():
yield(self.statement())
class Converter:
+ ignored_funcs = {'cmake_minimum_required' : True}
def __init__(self, cmake_root):
self.cmake_root = cmake_root
self.indent_unit = ' '
self.indent_level = 0
def write_entry(self, outfile, t):
+ if t.name in Converter.ignored_funcs:
+ return
+
indent = self.indent_level*self.indent_unit
if t.name == '_':
line = t.args[0]
elif t.name == 'add_subdirectory':
- line = 'subdir(' + t.args[0].value + ')'
+ line = "subdir('" + t.args[0].value + "')"
elif t.name == 'pkg_search_module' or t.name == 'pkg_search_modules':
varname = t.args[0].value.lower()
- mods = ['dependency(%s)' % i.value for i in t.args[1:]]
+ mods = ["dependency('%s')" % i.value for i in t.args[1:]]
if len(mods) == 1:
line = '%s = %s' % (varname, mods[0])
else:
- line = '%s = [%s]' % (varname, ', '.join(mods))
+ line = '%s = [%s]' % (varname, ', '.join(["'%s'" % i for i in mods]))
+ elif t.name == 'find_package':
+ line = '%s_dep = dependency(%s)' % (t.args[0].value, t.args[0].value)
+ elif t.name == 'project':
+ pname = t.args[0].value
+ args = [pname]
+ for l in t.args[1:]:
+ l = l.value.lower()
+ if l == 'cxx':
+ l = 'cpp'
+ args.append(l)
+ args = ["'%s'" % i for i in args]
+ line = 'project(' + ', '.join(args) + ')'
else:
line = '''# %s''' % t.name
outfile.write(indent)