aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-05-31 15:40:10 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2018-05-31 15:40:10 +0530
commitf56b402a5b98fbb2c2f3af4ebdac3f53313c5ab1 (patch)
tree6b34356b429ef9282214ed80ba6437a72944cf41 /mesonbuild
parent05f8b1bd7829c425a8a4838394b8c2d5964c7553 (diff)
downloadmeson-f56b402a5b98fbb2c2f3af4ebdac3f53313c5ab1.zip
meson-f56b402a5b98fbb2c2f3af4ebdac3f53313c5ab1.tar.gz
meson-f56b402a5b98fbb2c2f3af4ebdac3f53313c5ab1.tar.bz2
Revert "mesonlib: handle meson exe wrappers"
This reverts commit 0627e9d616dc311b7c9b0ef17301f680ac9e78a7. Breaks installation: https://github.com/mesonbuild/meson/issues/3647 Will be restored once that can be fixed.
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/mesonlib.py48
-rw-r--r--mesonbuild/mesonmain.py8
2 files changed, 47 insertions, 9 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index 28ae7b5..fe426c5 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -38,12 +38,58 @@ except Exception:
from glob import glob
+def detect_meson_py_location():
+ c = sys.argv[0]
+ c_dir, c_fname = os.path.split(c)
+
+ # get the absolute path to the <mesontool> folder
+ m_dir = None
+ if os.path.isabs(c):
+ # $ /foo/<mesontool>.py <args>
+ m_dir = c_dir
+ elif c_dir == '':
+ # $ <mesontool> <args> (gets run from /usr/bin/<mesontool>)
+ in_path_exe = shutil.which(c_fname)
+ if in_path_exe:
+ if not os.path.isabs(in_path_exe):
+ m_dir = os.getcwd()
+ c_fname = in_path_exe
+ else:
+ m_dir, c_fname = os.path.split(in_path_exe)
+ else:
+ m_dir = os.path.abspath(c_dir)
+
+ # find meson in m_dir
+ if m_dir is not None:
+ for fname in ['meson', 'meson.py']:
+ m_path = os.path.join(m_dir, fname)
+ if os.path.exists(m_path):
+ return m_path
+
+ # No meson found, which means that either:
+ # a) meson is not installed
+ # b) meson is installed to a non-standard location
+ # c) the script that invoked mesonlib is not the one of meson tools (e.g. run_unittests.py)
+ fname = os.path.normpath(os.path.join(os.path.dirname(__file__), '..', 'meson.py'))
+ if os.path.exists(fname):
+ return fname
+ # If meson is still not found, we might be imported by out-of-source tests
+ # https://github.com/mesonbuild/meson/issues/3015
+ exe = shutil.which('meson')
+ if exe is None:
+ exe = shutil.which('meson.py')
+ if exe is not None:
+ return exe
+ # Give up.
+ raise RuntimeError('Could not determine how to run Meson. Please file a bug with details.')
+
if os.path.basename(sys.executable) == 'meson.exe':
# In Windows and using the MSI installed executable.
+ meson_command = [sys.executable]
python_command = [sys.executable, 'runpython']
else:
python_command = [sys.executable]
-meson_command = python_command + ['-m', 'mesonbuild.mesonmain']
+ meson_command = python_command + [detect_meson_py_location()]
def is_ascii_string(astring):
try:
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py
index d77d148..4a977a1 100644
--- a/mesonbuild/mesonmain.py
+++ b/mesonbuild/mesonmain.py
@@ -382,11 +382,3 @@ 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())