aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends.py2
-rw-r--r--build.py21
-rw-r--r--coredata.py2
-rw-r--r--environment.py14
-rw-r--r--interpreter.py5
-rwxr-xr-xmesonconf.py54
-rw-r--r--ninjabackend.py2
7 files changed, 65 insertions, 35 deletions
diff --git a/backends.py b/backends.py
index 1aecadd..285cb6c 100644
--- a/backends.py
+++ b/backends.py
@@ -320,7 +320,7 @@ class Backend():
commands = []
commands += compiler.get_always_flags()
commands += self.build.get_global_flags(compiler)
- commands += self.build.get_external_args(compiler)
+ commands += self.environment.coredata.external_args[compiler.get_language()]
commands += target.get_extra_args(compiler.get_language())
if self.environment.coredata.buildtype != 'plain':
commands += compiler.get_debug_flags()
diff --git a/build.py b/build.py
index 7a0b374..7d9dd6b 100644
--- a/build.py
+++ b/build.py
@@ -33,8 +33,6 @@ class Build:
self.compilers = []
self.cross_compilers = []
self.global_args = {}
- self.external_args = {} # These are set from "the outside" with e.g. mesonconf
- self.external_link_args = {}
self.tests = []
self.headers = []
self.man = []
@@ -60,25 +58,6 @@ class Build:
if self.has_language(compiler.get_language()):
return
self.compilers.append(compiler)
- self.get_flags_from_envvars(compiler)
-
- def get_flags_from_envvars(self, compiler):
- lang = compiler.get_language()
- if lang == 'c':
- compile_flags = os.environ.get('CFLAGS', '').split()
- compile_flags += os.environ.get('CPPFLAGS', '').split()
- link_flags = compile_flags + os.environ.get('LDFLAGS', '').split()
- elif lang == 'cpp':
- compile_flags = os.environ.get('CXXFLAGS', '').split()
- compile_flags += os.environ.get('CPPFLAGS', '').split()
- link_flags = compile_flags + os.environ.get('LDFLAGS', '').split()
- else:
- compile_flags = []
- link_flags = []
- if len(compile_flags) > 0:
- self.external_args[lang] = compile_flags
- if len(link_flags) > 0:
- self.external_link_args[lang] = link_flags
def add_cross_compiler(self, compiler):
if len(self.cross_compilers) == 0:
diff --git a/coredata.py b/coredata.py
index 75d387c..5ae1f82 100644
--- a/coredata.py
+++ b/coredata.py
@@ -41,6 +41,8 @@ class CoreData():
self.unity = options.unity
self.coverage = options.coverage
self.user_options = {}
+ self.external_args = {} # These are set from "the outside" with e.g. mesonconf
+ self.external_link_args = {}
if options.cross_file is not None:
self.cross_file = os.path.join(os.getcwd(), options.cross_file)
else:
diff --git a/environment.py b/environment.py
index 15ff7da..e335895 100644
--- a/environment.py
+++ b/environment.py
@@ -1449,6 +1449,20 @@ def get_library_dirs():
unixdirs.append('/usr/local/lib')
return unixdirs
+def get_flags_from_envvars(lang):
+ if lang == 'c':
+ compile_flags = os.environ.get('CFLAGS', '').split()
+ compile_flags += os.environ.get('CPPFLAGS', '').split()
+ link_flags = compile_flags + os.environ.get('LDFLAGS', '').split()
+ elif lang == 'cpp':
+ compile_flags = os.environ.get('CXXFLAGS', '').split()
+ compile_flags += os.environ.get('CPPFLAGS', '').split()
+ link_flags = compile_flags + os.environ.get('LDFLAGS', '').split()
+ else:
+ compile_flags = []
+ link_flags = []
+ return (compile_flags, link_flags)
+
class CrossBuildInfo():
def __init__(self, filename):
self.items = {}
diff --git a/interpreter.py b/interpreter.py
index 517335f..fe51c9b 100644
--- a/interpreter.py
+++ b/interpreter.py
@@ -955,6 +955,11 @@ class Interpreter():
if cross_comp is not None:
self.coredata.cross_compilers[lang] = cross_comp
mlog.log('Using native %s compiler "' % lang, mlog.bold(' '.join(comp.get_exelist())), '". (%s %s)' % (comp.id, comp.version), sep='')
+ if not comp.get_language() in self.coredata.external_args:
+ print('getting from envvars')
+ (ext_compile_flags, ext_link_flags) = environment.get_flags_from_envvars(comp.get_language())
+ self.coredata.external_args[comp.get_language()] = ext_compile_flags
+ self.coredata.external_link_args[comp.get_language()] = ext_link_flags
self.build.add_compiler(comp)
if is_cross:
mlog.log('Using cross %s compiler "' % lang, mlog.bold(' '.join(cross_comp.get_exelist())), '". (%s %s)' % (cross_comp.id, cross_comp.version), sep='')
diff --git a/mesonconf.py b/mesonconf.py
index c18906e..f4408ca 100755
--- a/mesonconf.py
+++ b/mesonconf.py
@@ -47,6 +47,9 @@ class Conf:
def save(self):
# Only called if something has changed so overwrite unconditionally.
pickle.dump(self.coredata, open(self.coredata_file, 'wb'))
+ # We don't write the build file because any changes to it
+ # are erased when Meson is executed the nex time, i.e. the next
+ # time Ninja is run.
def print_aligned(self, arr):
if len(arr) == 0:
@@ -115,9 +118,7 @@ class Conf:
if os.path.isabs(v):
raise ConfException('Locale dir %s must not be an absolute path.' % v)
self.coredata.localedir = v
- else:
- if k not in self.coredata.user_options:
- raise ConfException('Unknown option %s.' % k)
+ elif k in self.coredata.user_options:
tgt = self.coredata.user_options[k]
if isinstance(tgt, optinterpreter.UserBooleanOption):
tgt.set_value(self.tobool(v))
@@ -131,6 +132,24 @@ class Conf:
tgt.set_value(v)
else:
raise ConfException('Internal error, unknown option type.')
+ elif k.endswith('linkflags'):
+ lang = k[:-9]
+ if not lang in self.coredata.external_link_args:
+ raise ConfException('Unknown language %s in linkflags.' % lang)
+ # TODO, currently split on spaces, make it so that user
+ # can pass in an array string.
+ newvalue = v.split()
+ self.coredata.external_link_args[lang] = newvalue
+ elif k.endswith('flags'):
+ lang = k[:-5]
+ if not lang in self.coredata.external_args:
+ raise ConfException('Unknown language %s in compile flags' % lang)
+ # TODO same fix as above
+ newvalue = v.split()
+ self.coredata.external_args[lang] = newvalue
+ else:
+ raise ConfException('Unknown option %s.' % k)
+
def print_conf(self):
print('Core properties\n')
@@ -146,6 +165,14 @@ class Conf:
carr.append(['unity', 'Unity build', self.coredata.unity])
self.print_aligned(carr)
print('')
+ print('Compiler flags\n')
+ for (lang, flags) in self.coredata.external_args.items():
+ print(lang + 'flags', str(flags))
+ print('')
+ print('Linker flags\n')
+ for (lang, flags) in self.coredata.external_link_args.items():
+ print(lang + 'linkflags', str(flags))
+ print('')
print('Directories\n')
parr = []
parr.append(['installprefix', 'Install prefix', self.coredata.prefix])
@@ -157,15 +184,18 @@ class Conf:
parr.append(['localedir', 'Locale file directory', self.coredata.localedir])
self.print_aligned(parr)
print('')
- print('Project options\n')
- options = self.coredata.user_options
- keys = list(options.keys())
- keys.sort()
- optarr = []
- for key in keys:
- opt = options[key]
- optarr.append([key, opt.description, opt.value])
- self.print_aligned(optarr)
+ if len(self.coredata.user_options) == 0:
+ print('This project does not have any options')
+ else:
+ print('Project options\n')
+ options = self.coredata.user_options
+ keys = list(options.keys())
+ keys.sort()
+ optarr = []
+ for key in keys:
+ opt = options[key]
+ optarr.append([key, opt.description, opt.value])
+ self.print_aligned(optarr)
if __name__ == '__main__':
(options, args) = parser.parse_args(sys.argv)
diff --git a/ninjabackend.py b/ninjabackend.py
index 5a6418f..c79fc78 100644
--- a/ninjabackend.py
+++ b/ninjabackend.py
@@ -817,7 +817,7 @@ class NinjaBackend(backends.Backend):
commands += linker.get_linker_always_flags()
commands += linker.get_buildtype_linker_flags(self.environment.coredata.buildtype)
if not(isinstance(target, build.StaticLibrary)):
- commands += self.build.get_external_link_args(linker)
+ commands += self.environment.coredata.external_link_args[linker.get_language()]
if isinstance(target, build.Executable):
commands += linker.get_std_exe_link_flags()
elif isinstance(target, build.SharedLibrary):