mirror of
https://github.com/mesonbuild/meson.git
synced 2026-11-06 05:16:42 +00:00
Can get arbitrary data from cross file properties.
This commit is contained in:
1 parent
cc775d64c9
commit
c0057da133
4 files changed
+25
No files matched your search
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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'))
|
||||
Reference in new issue
Block a user