diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2019-01-07 12:55:29 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2019-02-11 12:09:25 -0800 |
commit | b50899419cb2de27af34e5a955695a61c2863c51 (patch) | |
tree | 699ae873ed2b7f469fd005aa47b0794130633730 | |
parent | 097faee83b73ed88325f70396808bc6fbbd17739 (diff) | |
download | meson-b50899419cb2de27af34e5a955695a61c2863c51.zip meson-b50899419cb2de27af34e5a955695a61c2863c51.tar.gz meson-b50899419cb2de27af34e5a955695a61c2863c51.tar.bz2 |
environment: Add class for storing directories from cross and config files
-rw-r--r-- | mesonbuild/environment.py | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index b23509a..8ad65d7 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -12,7 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import configparser, os, platform, re, sys, shlex, shutil, subprocess, typing +import configparser, os, platform, re, sys, shlex, shutil, subprocess +import typing from . import coredata from .linkers import ArLinker, ArmarLinker, VisualStudioLinker, DLinker, CcrxLinker @@ -1581,3 +1582,42 @@ This is probably wrong, it should always point to the native compiler.''' % evar if command is not None: command = shlex.split(command) return command + +class Directories: + + """Data class that holds information about directories for native and cross + builds. + """ + + def __init__(self, bindir: typing.Optional[str] = None, datadir: typing.Optional[str] = None, + includedir: typing.Optional[str] = None, infodir: typing.Optional[str] = None, + libdir: typing.Optional[str] = None, libexecdir: typing.Optional[str] = None, + localedir: typing.Optional[str] = None, localstatedir: typing.Optional[str] = None, + mandir: typing.Optional[str] = None, prefix: typing.Optional[str] = None, + sbindir: typing.Optional[str] = None, sharedstatedir: typing.Optional[str] = None, + sysconfdir: typing.Optional[str] = None): + self.bindir = bindir + self.datadir = datadir + self.includedir = includedir + self.infodir = infodir + self.libdir = libdir + self.libexecdir = libexecdir + self.localedir = localedir + self.localstatedir = localstatedir + self.mandir = mandir + self.prefix = prefix + self.sbindir = sbindir + self.sharedstatedir = sharedstatedir + self.sysconfdir = sysconfdir + + def __contains__(self, key: str) -> str: + return hasattr(self, key) + + def __getitem__(self, key: str) -> str: + return getattr(self, key) + + def __setitem__(self, key: str, value: typing.Optional[str]) -> None: + setattr(self, key, value) + + def __iter__(self) -> typing.Iterator[typing.Tuple[str, str]]: + return iter(self.__dict__.items()) |