aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-11-13 21:14:59 +0200
committerGitHub <noreply@github.com>2017-11-13 21:14:59 +0200
commit69bd87a71624e2e665c3d43d765a3c5fb1313c96 (patch)
treea58f541c74a1071ff916611b6316bbc62ab2b563 /mesonbuild
parentc6781744cf0ff1c64a18d07a3d32d87a45d2faa7 (diff)
parent3e0069f65e58175d7979fac687c0bb5b3544b72e (diff)
downloadmeson-69bd87a71624e2e665c3d43d765a3c5fb1313c96.zip
meson-69bd87a71624e2e665c3d43d765a3c5fb1313c96.tar.gz
meson-69bd87a71624e2e665c3d43d765a3c5fb1313c96.tar.bz2
Merge pull request #2511 from jon-turney/prefix-dependent-defaults
Make sysconfdir, localstatedir and sharedstatedir defaults depend on prefix
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/coredata.py31
-rw-r--r--mesonbuild/mesonmain.py7
2 files changed, 24 insertions, 14 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index ba5d2ac..e8b23fd 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -1,3 +1,4 @@
+
# Copyright 2012-2017 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -232,7 +233,7 @@ class CoreData:
value = self.sanitize_dir_option_value(options.prefix, key, value)
setattr(options, key, value)
else:
- value = get_builtin_option_default(key)
+ value = get_builtin_option_default(key, prefix=options.prefix)
args = [key] + builtin_options[key][1:-1] + [value]
self.builtins[key] = builtin_options[key][0](*args)
@@ -308,11 +309,19 @@ def get_builtin_option_description(optname):
else:
raise RuntimeError('Tried to get the description for an unknown builtin option \'%s\'.' % optname)
-def get_builtin_option_default(optname):
+def get_builtin_option_default(optname, prefix='', noneIfSuppress=False):
if is_builtin_option(optname):
o = builtin_options[optname]
if o[0] == UserComboOption:
return o[3]
+ if optname in builtin_dir_noprefix_options:
+ if noneIfSuppress:
+ # Return None if argparse defaulting should be suppressed for
+ # this option (so we can determine the default later based on
+ # prefix)
+ return None
+ elif prefix in builtin_dir_noprefix_options[optname]:
+ return builtin_dir_noprefix_options[optname][prefix]
return o[2]
else:
raise RuntimeError('Tried to get the default value for an unknown builtin option \'%s\'.' % optname)
@@ -331,15 +340,6 @@ builtin_options = {
'mandir': [UserStringOption, 'Manual page directory.', 'share/man'],
'infodir': [UserStringOption, 'Info page directory.', 'share/info'],
'localedir': [UserStringOption, 'Locale data directory.', 'share/locale'],
- # sysconfdir, localstatedir and sharedstatedir are a bit special. These defaults to ${prefix}/etc,
- # ${prefix}/var and ${prefix}/com but nobody uses that. Instead they always set it
- # manually to /etc, /var and /var/lib. This default values is thus pointless and not really used
- # but we set it to this for consistency with other systems.
- #
- # Projects installing to sysconfdir, localstatedir or sharedstatedir probably want
- # to set the following in project():
- #
- # default_options : ['sysconfdir=/etc', 'localstatedir=/var', 'sharedstatedir=/var/lib']
'sysconfdir': [UserStringOption, 'Sysconf data directory.', 'etc'],
'localstatedir': [UserStringOption, 'Localstate data directory.', 'var'],
'sharedstatedir': [UserStringOption, 'Architecture-independent data directory.', 'com'],
@@ -352,8 +352,13 @@ builtin_options = {
'errorlogs': [UserBooleanOption, "Whether to print the logs from failing tests.", True],
}
-# Installation directories that can reside in a path outside of the prefix
-builtin_dir_noprefix_options = {'sysconfdir', 'localstatedir', 'sharedstatedir'}
+# Special prefix-dependent defaults for installation directories that reside in
+# a path outside of the prefix in FHS and common usage.
+builtin_dir_noprefix_options = {
+ 'sysconfdir': {'/usr': '/etc'},
+ 'localstatedir': {'/usr': '/var', '/usr/local': '/var/local'},
+ 'sharedstatedir': {'/usr': '/var/lib', '/usr/local': '/var/local/lib'},
+}
forbidden_target_names = {'clean': None,
'clean-ctlist': None,
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py
index a1e7c1c..8d5fb85 100644
--- a/mesonbuild/mesonmain.py
+++ b/mesonbuild/mesonmain.py
@@ -37,7 +37,12 @@ def add_builtin_argument(name, **kwargs):
h = h.rstrip('.') + ' (default: %s).' % coredata.get_builtin_option_default(k)
if c and not b:
kwargs['choices'] = c
- parser.add_argument('--' + name, default=coredata.get_builtin_option_default(k), help=h, **kwargs)
+ default = coredata.get_builtin_option_default(k, noneIfSuppress=True)
+ if default is not None:
+ kwargs['default'] = default
+ else:
+ kwargs['default'] = argparse.SUPPRESS
+ parser.add_argument('--' + name, help=h, **kwargs)
add_builtin_argument('prefix')
add_builtin_argument('libdir')