diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2013-08-24 23:40:11 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2013-08-24 23:40:11 +0300 |
commit | 195fb0d967a0c60d0425b95d9596347a703aed20 (patch) | |
tree | da5cbef1223bb267bba676c292ee7ab9ced97e23 | |
parent | 21e4fcc6b0fb1a78c8cb75a5efc816e5bf46f717 (diff) | |
download | meson-195fb0d967a0c60d0425b95d9596347a703aed20.zip meson-195fb0d967a0c60d0425b95d9596347a703aed20.tar.gz meson-195fb0d967a0c60d0425b95d9596347a703aed20.tar.bz2 |
Get alignment from cross file.
-rw-r--r-- | cross/ubuntu-armhf.txt | 7 | ||||
-rw-r--r-- | environment.py | 20 | ||||
-rw-r--r-- | interpreter.py | 2 |
3 files changed, 25 insertions, 4 deletions
diff --git a/cross/ubuntu-armhf.txt b/cross/ubuntu-armhf.txt index ae52972..57c8e2a 100644 --- a/cross/ubuntu-armhf.txt +++ b/cross/ubuntu-armhf.txt @@ -2,10 +2,15 @@ name = 'linux' c = '/usr/bin/arm-linux-gnueabihf-gcc' cpp = '/usr/bin/arm-linux-gnueabihf-g++' root = '/usr/arm-linux-gnueabihf' -pkg-config = '/usr/bin/arm-linux-gnueabihf-pkg-config' +pkg_config = '/usr/bin/arm-linux-gnueabihf-pkg-config' sizeof_int = 4 sizeof_wchar_t = 4 +sizeof_void* = 4 + +alignment_char = 1 +alignment_void* = 4 +alignment_double = 4 # Don't know if this is correct... has_function_printf = true has_function_hfkerhisadf = false diff --git a/environment.py b/environment.py index 991bbaa..804d931 100644 --- a/environment.py +++ b/environment.py @@ -227,7 +227,7 @@ Please define the corresponding variable {1} in your cross compilation definitio raise EnvironmentException('Could not run sizeof test binary.') return int(res.stdout) - def alignment(self, typename): + def alignment(self, typename, env): # A word of warning: this algoritm may be totally incorrect. # However it worked for me on the cases I tried. # There is probably a smarter and more robust way to get this @@ -273,7 +273,23 @@ int main(int argc, char **argv) { return 0; } ''' - res = self.run(templ % typename) + varname = 'alignment ' + typename + varname = varname.replace(' ', '_') + if self.is_cross: + val = env.cross_info.get(varname) + if val is not None: + if isinstance(val, int): + return val + raise EnvironmentException('Cross variable {0} is not an integer.'.format(varname)) + cross_failed = False + try: + res = self.run(templ % typename) + except CrossNoRunException: + cross_failed = True + if cross_failed: + message = '''Can not determine alignment of {0} because cross compiled binaries are not runnable. +Please define the corresponding variable {1} in your cross compilation definition file.'''.format(typename, varname) + raise EnvironmentException(message) if not res.compiled: raise EnvironmentException('Could not compile alignment test.') if res.returncode != 0: diff --git a/interpreter.py b/interpreter.py index 3784de1..9b47a3a 100644 --- a/interpreter.py +++ b/interpreter.py @@ -674,7 +674,7 @@ class CompilerHolder(InterpreterObject): typename = args[0] if not isinstance(typename, str): raise InterpreterException('First argument is not a string.') - result = self.compiler.alignment(typename) + result = self.compiler.alignment(typename, self.environment) mlog.log('Checking for alignment of "', mlog.bold(typename), '": ', result, sep='') return result |