Can get arbitrary data from cross file properties.

This commit is contained in:
Jussi Pakkanen committed 2016-07-02 00:00:03 +03:00
1 parent cc775d64c9
commit c0057da133
4 files changed
+25

No files matched your search

+4
View File
@@ -1,5 +1,9 @@
project('own libc', 'c')
# Not related to this test, but could not find a better place for this test.
assert(meson.get_cross_property('nonexisting', 'defaultvalue') == 'defaultvalue',
'Cross prop getting is broken.')
# A simple project that uses its own libc.
# Note that we don't need to specify anything, the flags to use
+3
View File
@@ -771,6 +771,9 @@ class CrossBuildInfo():
def get_stdlib(self, language):
return self.config['properties'][language + '_stdlib']
def get_properties(self):
return self.config['properties']
# Wehn compiling a cross compiler we use the native compiler for everything.
# But not when cross compiling a cross compiler.
def need_cross_compiler(self):
+15
View File
@@ -866,6 +866,7 @@ class MesonMain(InterpreterObject):
'install_dependency_manifest': self.install_dependency_manifest_method,
'project_version': self.project_version_method,
'project_name' : self.project_name_method,
'get_cross_property': self.get_cross_property_method,
})
def add_install_script_method(self, args, kwargs):
@@ -965,6 +966,20 @@ class MesonMain(InterpreterObject):
def project_name_method(self, args, kwargs):
return self.interpreter.active_projectname
def get_cross_property_method(self, args, kwargs):
if len(args) < 1 or len(args) > 2:
raise InterpreterException('Must have one or two arguments.')
propname = args[0]
if not isinstance(propname, str):
raise InterpreterException('Property name must be string.')
try:
props = self.interpreter.environment.cross_info.get_properties()
return props[propname]
except Exception:
if len(args) == 2:
return args[1]
raise InterpreterException('Unknown cross property: %s.' % propname)
class Interpreter():
def __init__(self, build, backend, subproject='', subdir='', subproject_dir='subprojects'):
@@ -0,0 +1,3 @@
project('no crossprop', 'c')
message(meson.get_cross_property('nonexisting'))