diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2018-06-01 13:00:17 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2018-06-01 19:20:04 +0000 |
commit | 0a035dea6d0b1416fc76e323bbd7b0ab5a60a4af (patch) | |
tree | 0399ae08fe7cd92d23563db29a401f5454b68693 /mesonbuild/mesonlib.py | |
parent | 14750b50ea9c9f53237bed59a79365e1ebbdacda (diff) | |
download | meson-0a035dea6d0b1416fc76e323bbd7b0ab5a60a4af.zip meson-0a035dea6d0b1416fc76e323bbd7b0ab5a60a4af.tar.gz meson-0a035dea6d0b1416fc76e323bbd7b0ab5a60a4af.tar.bz2 |
Set the meson command to use when we know what it is
Instead of using fragile guessing to figure out how to invoke meson,
set the value when meson is run. Also rework how we pass of
meson_script_launcher to regenchecker.py -- it wasn't even being used
With this change, we only need to guess the meson path when running
the tests, and in that case:
1. If MESON_EXE is set in the env, we know how to run meson
for project tests.
2. MESON_EXE is not set, which means we run the configure in-process
for project tests and need to guess what meson to run, so either
- meson.py is found next to run_tests.py, or
- meson, meson.py, or meson.exe is in PATH
Otherwise, you can invoke meson in the following ways:
1. meson is installed, and mesonbuild is available in PYTHONPATH:
- meson, meson.py, meson.exe from PATH
- python3 -m mesonbuild.mesonmain
- python3 /path/to/meson.py
- meson is a shell wrapper to meson.real
2. meson is not installed, and is run from git:
- Absolute path to meson.py
- Relative path to meson.py
- Symlink to meson.py
All these are tested in test_meson_commands.py, except meson.exe since
that involves building the meson msi and installing it.
Diffstat (limited to 'mesonbuild/mesonlib.py')
-rw-r--r-- | mesonbuild/mesonlib.py | 48 |
1 files changed, 1 insertions, 47 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index 6a38479..5305ecb 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -38,58 +38,12 @@ 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 + [detect_meson_py_location()] +meson_command = None def is_ascii_string(astring): try: |