aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2013-08-24 23:32:13 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2013-08-24 23:32:13 +0300
commit21e4fcc6b0fb1a78c8cb75a5efc816e5bf46f717 (patch)
tree5faf81845e3c54253012e5716a7a19da9eafd18d
parent211781482634dd53e068b4b78f0b3dd624f2a27f (diff)
downloadmeson-21e4fcc6b0fb1a78c8cb75a5efc816e5bf46f717.zip
meson-21e4fcc6b0fb1a78c8cb75a5efc816e5bf46f717.tar.gz
meson-21e4fcc6b0fb1a78c8cb75a5efc816e5bf46f717.tar.bz2
Get has_function from cross file.
-rw-r--r--cross/ubuntu-armhf.txt3
-rw-r--r--environment.py26
-rw-r--r--interpreter.py2
-rwxr-xr-xrun_cross_test.py2
4 files changed, 26 insertions, 7 deletions
diff --git a/cross/ubuntu-armhf.txt b/cross/ubuntu-armhf.txt
index 3363d7c..ae52972 100644
--- a/cross/ubuntu-armhf.txt
+++ b/cross/ubuntu-armhf.txt
@@ -6,3 +6,6 @@ pkg-config = '/usr/bin/arm-linux-gnueabihf-pkg-config'
sizeof_int = 4
sizeof_wchar_t = 4
+
+has_function_printf = true
+has_function_hfkerhisadf = false
diff --git a/environment.py b/environment.py
index 9be73f6..991bbaa 100644
--- a/environment.py
+++ b/environment.py
@@ -24,7 +24,7 @@ class EnvironmentException(MesonException):
def __init(self, *args, **kwargs):
Exception.__init__(self, *args, **kwargs)
-class CrossNoRunException(Exception):
+class CrossNoRunException(MesonException):
def __init(self, *args, **kwargs):
Exception.__init__(self, *args, **kwargs)
@@ -287,7 +287,7 @@ int main(int argc, char **argv) {
return diff
raise EnvironmentException('Could not determine alignment of %s. Sorry. You might want to file a bug.' % typename)
- def has_function(self, funcname, prefix):
+ def has_function(self, funcname, prefix, env):
# This fails (returns true) if funcname is a ptr or a variable.
# The correct check is a lot more difficult.
# Fix this to do that eventually.
@@ -297,7 +297,23 @@ int main(int argc, char **argv) {
return 0;
};
'''
- res = self.run(templ % (prefix, funcname))
+ varname = 'has function ' + funcname
+ varname = varname.replace(' ', '_')
+ if self.is_cross:
+ val = env.cross_info.get(varname)
+ if val is not None:
+ if isinstance(val, bool):
+ return val
+ raise EnvironmentException('Cross variable {0} is not an boolean.'.format(varname))
+ cross_failed = False
+ try:
+ res = self.run(templ % (prefix, funcname))
+ except CrossNoRunException:
+ cross_failed = True
+ if cross_failed:
+ message = '''Can not determine existance {0} because cross compiled binaries are not runnable.
+Please define variable {1} in your cross compilation definition file.'''.format(funcname, varname)
+ raise EnvironmentException(message)
return res.compiled
def has_member(self, typename, membername, prefix):
@@ -1055,7 +1071,7 @@ class CrossBuildInfo():
raise EnvironmentException('Cross file must specify "name".')
def ok_type(self, i):
- return isinstance(i, str) or isinstance(i, int)
+ return isinstance(i, str) or isinstance(i, int) or isinstance(i, bool)
def parse_datafile(self, filename):
# This is a bit hackish at the moment.
@@ -1071,7 +1087,7 @@ class CrossBuildInfo():
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, {})
+ res = eval(value, {'true' : True, 'false' : False})
except Exception:
raise EnvironmentException('Malformed line in cross file %s:%d.' % (filename, linenum))
if self.ok_type(res):
diff --git a/interpreter.py b/interpreter.py
index 7cbdfb9..3784de1 100644
--- a/interpreter.py
+++ b/interpreter.py
@@ -733,7 +733,7 @@ class CompilerHolder(InterpreterObject):
prefix = kwargs.get('prefix', '')
if not isinstance(prefix, str):
raise InterpreterException('Prefix argument of has_function must be a string.')
- had = self.compiler.has_function(funcname, prefix)
+ had = self.compiler.has_function(funcname, prefix, self.environment)
if had:
hadtxt = mlog.green('YES')
else:
diff --git a/run_cross_test.py b/run_cross_test.py
index 093f30d..f74be63 100755
--- a/run_cross_test.py
+++ b/run_cross_test.py
@@ -78,7 +78,7 @@ def run_tests():
except OSError:
pass
print('\nRunning cross compilation tests.\n')
- commontests = commontests[:28] + commontests[28:]
+ commontests = commontests[:28] + commontests[30:38] + commontests[39:]
[run_test(t) for t in commontests]
if __name__ == '__main__':