aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/envconfig.py
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2020-06-11 16:04:50 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2020-06-29 20:16:21 +0300
commit1c8731a10018e8ba1e6b30411a290ca50fa45d81 (patch)
tree9c5332199c2acd2f26bb131429e1251b76cd7dfa /mesonbuild/envconfig.py
parent5696a5abbaaff75279d9c50d431de47f35dc6228 (diff)
downloadmeson-1c8731a10018e8ba1e6b30411a290ca50fa45d81.zip
meson-1c8731a10018e8ba1e6b30411a290ca50fa45d81.tar.gz
meson-1c8731a10018e8ba1e6b30411a290ca50fa45d81.tar.bz2
envconfig: Add [constants] section in machine files
Machine files already supports `+` operator as an implementation detail, since it's using eval(). Now make it an officially supported feature and add a way to define constants that are used while evaluating an entry value.
Diffstat (limited to 'mesonbuild/envconfig.py')
-rw-r--r--mesonbuild/envconfig.py29
1 files changed, 1 insertions, 28 deletions
diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py
index 10464a2..219b62e 100644
--- a/mesonbuild/envconfig.py
+++ b/mesonbuild/envconfig.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import configparser, os, subprocess
+import os, subprocess
import typing as T
from . import mesonlib
@@ -83,33 +83,6 @@ CPU_FAMILES_64_BIT = [
'x86_64',
]
-class MesonConfigFile:
- @classmethod
- def from_config_parser(cls, parser: configparser.ConfigParser) -> T.Dict[str, T.Dict[str, T.Dict[str, str]]]:
- out = {}
- # This is a bit hackish at the moment.
- for s in parser.sections():
- section = {}
- for entry in parser[s]:
- value = parser[s][entry]
- # Windows paths...
- value = value.replace('\\', '\\\\')
- if ' ' in entry or '\t' in entry or "'" in entry or '"' in entry:
- raise EnvironmentException('Malformed variable name {} in cross file..'.format(entry))
- try:
- res = eval(value, {'__builtins__': None}, {'true': True, 'false': False})
- except Exception:
- raise EnvironmentException('Malformed value in cross file variable {}.'.format(entry))
-
- for i in (res if isinstance(res, list) else [res]):
- if not isinstance(i, (str, int, bool)):
- raise EnvironmentException('Malformed value in cross file variable {}.'.format(entry))
-
- section[entry] = res
-
- out[s] = section
- return out
-
def get_env_var_pair(for_machine: MachineChoice,
is_cross: bool,
var_name: str) -> T.Tuple[T.Optional[str], T.Optional[str]]: