A journey to cross-compilation starts with a single step.

pull/15/head
Jussi Pakkanen 12 years ago
parent a3f88e1a49
commit 5d38cbfade
  1. 1
      coredata.py
  2. 5
      cross/ubuntu-mingw.txt
  3. 45
      environment.py
  4. 6
      meson.py

@ -34,6 +34,7 @@ class CoreData():
self.buildtype = options.buildtype self.buildtype = options.buildtype
self.strip = options.strip self.strip = options.strip
self.coverage = options.coverage self.coverage = options.coverage
self.cross_file = options.cross_file
self.compilers = {} self.compilers = {}
self.deps = {} self.deps = {}

@ -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'

@ -709,6 +709,9 @@ class Environment():
self.static_lib_suffix = 'a' self.static_lib_suffix = 'a'
self.static_lib_prefix = 'lib' self.static_lib_prefix = 'lib'
self.object_suffix = 'o' self.object_suffix = 'o'
def is_cross_build(self):
return self.coredata.cross_file is not None
def generating_finished(self): def generating_finished(self):
cdf = os.path.join(self.get_build_dir(), Environment.coredata_file) cdf = os.path.join(self.get_build_dir(), Environment.coredata_file)
@ -958,3 +961,45 @@ def get_library_dirs():
unixdirs += glob('/lib/' + plat + '*') unixdirs += glob('/lib/' + plat + '*')
unixdirs.append('/usr/local/lib') unixdirs.append('/usr/local/lib')
return unixdirs 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)

@ -56,6 +56,8 @@ parser.add_option('--strip', action='store_true', dest='strip', default=False,\
help='strip targets on install (default: %default)') help='strip targets on install (default: %default)')
parser.add_option('--enable-gcov', action='store_true', dest='coverage', default=False,\ parser.add_option('--enable-gcov', action='store_true', dest='coverage', default=False,\
help='measure test coverage') help='measure test coverage')
parser.add_option('--cross-file', default=None, dest='cross_file',
help='file describing cross compilation environment')
class MesonApp(): class MesonApp():
@ -100,6 +102,10 @@ class MesonApp():
mlog.log(' version:', coredata.version) mlog.log(' version:', coredata.version)
mlog.log('Source dir:', mlog.bold(app.source_dir)) mlog.log('Source dir:', mlog.bold(app.source_dir))
mlog.log('Build dir:', mlog.bold(app.build_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) b = build.Build(env)
intr = interpreter.Interpreter(b) intr = interpreter.Interpreter(b)
intr.run() intr.run()

Loading…
Cancel
Save