aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2021-05-28 13:03:41 -0400
committerXavier Claessens <xclaesse@gmail.com>2021-05-28 17:34:25 -0400
commit25fa2d4f7ba0978d8a224cf2cba3d697a3bbfb3d (patch)
tree322fd8fa4f07b31501a0bea49ebe99dfbbb552f2
parenta9b65b421e09cabdb5c383b69b32e2787fbeadc1 (diff)
downloadmeson-25fa2d4f7ba0978d8a224cf2cba3d697a3bbfb3d.zip
meson-25fa2d4f7ba0978d8a224cf2cba3d697a3bbfb3d.tar.gz
meson-25fa2d4f7ba0978d8a224cf2cba3d697a3bbfb3d.tar.bz2
vsenv: Recommend using "meson compile" wrapper
When meson has setup the VS environment, running ninja to build won't work, user should use meson wrapper to compile.
-rw-r--r--mesonbuild/backend/ninjabackend.py8
-rw-r--r--mesonbuild/mesonmain.py5
2 files changed, 12 insertions, 1 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 525e051..6bd7ba6 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -46,6 +46,7 @@ from ..mesonlib import get_compiler_for_source, has_path_sep, OptionKey
from .backends import CleanTrees
from ..build import GeneratedList, InvalidArguments, ExtractedObjects
from ..interpreter import Interpreter
+from ..mesonmain import need_setup_vsenv
if T.TYPE_CHECKING:
from ..linkers import StaticLinker
@@ -508,6 +509,13 @@ int dummy;
def generate(self):
ninja = environment.detect_ninja_command_and_version(log=True)
+ if need_setup_vsenv:
+ builddir = Path(self.environment.get_build_dir())
+ builddir = builddir.relative_to(Path.cwd())
+ meson_command = mesonlib.join_args(mesonlib.get_meson_command())
+ mlog.log()
+ mlog.log('Visual Studio environment is needed to run Ninja. It is recommended to use Meson wrapper:')
+ mlog.log(f'{meson_command} compile -C {builddir}')
if ninja is None:
raise MesonException('Could not detect Ninja v1.8.2 or newer')
(self.ninja_command, self.ninja_version) = ninja
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py
index c25e0e3..809ccdf 100644
--- a/mesonbuild/mesonmain.py
+++ b/mesonbuild/mesonmain.py
@@ -27,6 +27,8 @@ from .mesonlib import MesonException
from .environment import detect_msys2_arch
from .wrap import wraptool
+need_setup_vsenv = False
+
bat_template = '''@ECHO OFF
call "{}"
@@ -111,7 +113,8 @@ def setup_vsenv():
continue
k, v = bat_line.split('=', 1)
os.environ[k] = v
-
+ global need_setup_vsenv
+ need_setup_vsenv = True
# Note: when adding arguments, please also add them to the completion