aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2013-08-23 23:05:22 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2013-08-23 23:05:22 +0300
commit5d38cbfadef5623f1ac3df2dd48dafa19bb97f3b (patch)
tree4d96982410bdd0a3f012bac0ffb09883c9f6ddc7
parenta3f88e1a495b03f70a1b92564eff949a14c1149b (diff)
downloadmeson-5d38cbfadef5623f1ac3df2dd48dafa19bb97f3b.zip
meson-5d38cbfadef5623f1ac3df2dd48dafa19bb97f3b.tar.gz
meson-5d38cbfadef5623f1ac3df2dd48dafa19bb97f3b.tar.bz2
A journey to cross-compilation starts with a single step.
-rw-r--r--coredata.py1
-rw-r--r--cross/ubuntu-mingw.txt5
-rw-r--r--environment.py45
-rwxr-xr-xmeson.py6
4 files changed, 57 insertions, 0 deletions
diff --git a/coredata.py b/coredata.py
index 78a8ef0..94a1cda 100644
--- a/coredata.py
+++ b/coredata.py
@@ -34,6 +34,7 @@ class CoreData():
self.buildtype = options.buildtype
self.strip = options.strip
self.coverage = options.coverage
+ self.cross_file = options.cross_file
self.compilers = {}
self.deps = {}
diff --git a/cross/ubuntu-mingw.txt b/cross/ubuntu-mingw.txt
new file mode 100644
index 0000000..af53197
--- /dev/null
+++ b/cross/ubuntu-mingw.txt
@@ -0,0 +1,5 @@
+name = 'windows'
+exe_runner = 'wine'
+c = '/usr/bin/i586-mingw32msvc-gcc'
+cpp = '/usr/bin/i586-mingw32msvc-g++'
+root = '/usr/i586-mingw32msvc'
diff --git a/environment.py b/environment.py
index cb62a8b..a06ed4c 100644
--- a/environment.py
+++ b/environment.py
@@ -709,6 +709,9 @@ class Environment():
self.static_lib_suffix = 'a'
self.static_lib_prefix = 'lib'
self.object_suffix = 'o'
+
+ def is_cross_build(self):
+ return self.coredata.cross_file is not None
def generating_finished(self):
cdf = os.path.join(self.get_build_dir(), Environment.coredata_file)
@@ -958,3 +961,45 @@ def get_library_dirs():
unixdirs += glob('/lib/' + plat + '*')
unixdirs.append('/usr/local/lib')
return unixdirs
+
+class CrossbuildInfo():
+ def __init__(self, filename):
+ self.items = {}
+ self.parse_datafile(filename)
+ if not 'name' in self:
+ raise EnvironmentException('Cross file must specify "name".')
+
+ def parse_datafile(self, filename):
+ # This is a bit hackish at the moment.
+ for linenum, line in enumerate(open(filename)):
+ line = line.strip()
+ if line == '':
+ continue
+ if '=' not in line:
+ raise EnvironmentException('Malformed line in cross file %s:%d.' % (filename, linenum))
+ (varname, value) = line.split('=', 1)
+ varname = varname.strip()
+ if ' ' in varname or '\t' in varname or "'" in varname or '"' in varname:
+ raise EnvironmentException('Malformed variable name in cross file %s:%d.' % (filename, linenum))
+ try:
+ res = eval(value)
+ except Exception:
+ raise EnvironmentException('Malformed line in cross file %s:%d.' % (filename, linenum))
+ if isinstance(res, str):
+ self.items[varname] = res
+ elif isinstance(res, list):
+ for i in res:
+ if not isinstance(i, str):
+ raise EnvironmentException('Malformed line in cross file %s:%d.' % (filename, linenum))
+ self.items[varname] = res
+ else:
+ raise EnvironmentException('Malformed line in cross file %s:%d.' % (filename, linenum))
+
+ def __getitem__(self, ind):
+ return self.items[ind]
+
+ def __contains__(self, item):
+ return item in self.items
+
+ def get(self, *args, **kwargs):
+ return self.items.get(*args, **kwargs)
diff --git a/meson.py b/meson.py
index cad449e..9312be2 100755
--- a/meson.py
+++ b/meson.py
@@ -56,6 +56,8 @@ parser.add_option('--strip', action='store_true', dest='strip', default=False,\
help='strip targets on install (default: %default)')
parser.add_option('--enable-gcov', action='store_true', dest='coverage', default=False,\
help='measure test coverage')
+parser.add_option('--cross-file', default=None, dest='cross_file',
+ help='file describing cross compilation environment')
class MesonApp():
@@ -100,6 +102,10 @@ class MesonApp():
mlog.log(' version:', coredata.version)
mlog.log('Source dir:', mlog.bold(app.source_dir))
mlog.log('Build dir:', mlog.bold(app.build_dir))
+ if env.is_cross_build():
+ mlog.log('Build type:', mlog.bold('cross build'))
+ else:
+ mlog.log('Build type:', mlog.bold('native build'))
b = build.Build(env)
intr = interpreter.Interpreter(b)
intr.run()