diff options
author | Martin Kelly <mkelly@xevo.com> | 2018-04-24 16:57:18 -0700 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2018-05-30 18:29:16 +0000 |
commit | 0627e9d616dc311b7c9b0ef17301f680ac9e78a7 (patch) | |
tree | d58d446c9fa19d5ad4be7dc8b7fbdbed105a076d /mesonbuild/mesonmain.py | |
parent | ab599b5733539130db5c4d17c664744f4d5aacaf (diff) | |
download | meson-0627e9d616dc311b7c9b0ef17301f680ac9e78a7.zip meson-0627e9d616dc311b7c9b0ef17301f680ac9e78a7.tar.gz meson-0627e9d616dc311b7c9b0ef17301f680ac9e78a7.tar.bz2 |
mesonlib: handle meson exe wrappers
There are cases when it is useful to wrap the main meson executable with
a script that sets up environment variables, passes --cross-file, etc.
For example, in a Yocto SDK, we need to point to the right meson.cross
so that everything "just works", and we need to alter CC, CXX, etc. In
such cases, it can happen that the "meson" found in the path is actually
a wrapper script that invokes the real meson, which may be in another
location (e.g. "meson.real" or similar).
Currently, in such a situation, meson gets confused because it tries to
invoke itself using the "meson" executable (which points to the wrapper
script) instead of the actual meson (which may be called "meson.real" or
similar). In fact, the wrapper script is not necessarily even Python, so
the whole thing fails.
Fix this by using Python imports to directly find mesonmain.py instead
of trying to detect it heuristically. In addition to fixing the wrapper
issue, this should make the detection logic much more robust.
Diffstat (limited to 'mesonbuild/mesonmain.py')
-rw-r--r-- | mesonbuild/mesonmain.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index 4a977a1..d77d148 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -382,3 +382,11 @@ def run(original_args, mainfile=None): mlog.shutdown() return 0 + +def main(): + # Always resolve the command path so Ninja can find it for regen, tests, etc. + launcher = os.path.realpath(sys.argv[0]) + return run(sys.argv[1:], launcher) + +if __name__ == '__main__': + sys.exit(main()) |