2013-03-25 01:38:44 +08:00
|
|
|
#!/usr/bin/env python3
|
2023-12-14 03:38:41 +08:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
2016-01-16 05:37:22 +08:00
|
|
|
# Copyright 2016 The Meson development team
|
2023-12-14 03:38:41 +08:00
|
|
|
# Copyright © 2023 Intel Corporation
|
2016-01-16 05:37:22 +08:00
|
|
|
|
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.
2018-06-01 15:30:17 +08:00
|
|
|
import sys
|
2022-06-22 22:15:31 +08:00
|
|
|
|
|
|
|
# Check python version before importing anything else, we might have an older
|
|
|
|
# Python that would error on f-string syntax for example.
|
|
|
|
if sys.version_info < (3, 7):
|
|
|
|
print('Meson works correctly only with python 3.7+.')
|
|
|
|
print('You have python {}.'.format(sys.version))
|
|
|
|
print('Please update your environment')
|
|
|
|
sys.exit(1)
|
|
|
|
|
2020-11-21 06:56:29 +08:00
|
|
|
from pathlib import Path
|
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.
2018-06-01 15:30:17 +08:00
|
|
|
|
|
|
|
# If we're run uninstalled, add the script directory to sys.path to ensure that
|
|
|
|
# we always import the correct mesonbuild modules even if PYTHONPATH is mangled
|
|
|
|
meson_exe = Path(sys.argv[0]).resolve()
|
|
|
|
if (meson_exe.parent / 'mesonbuild').is_dir():
|
2018-06-10 01:40:04 +08:00
|
|
|
sys.path.insert(0, str(meson_exe.parent))
|
2018-05-31 18:10:10 +08:00
|
|
|
|
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.
2018-06-01 15:30:17 +08:00
|
|
|
from mesonbuild import mesonmain
|
2016-10-02 20:28:06 +08:00
|
|
|
|
2016-10-10 08:19:15 +08:00
|
|
|
if __name__ == '__main__':
|
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.
2018-06-01 15:30:17 +08:00
|
|
|
sys.exit(mesonmain.main())
|