Don't allow people to run meson inside the uninstalled env
authorNirbheek Chauhan <nirbheek@centricular.com>
Tue, 25 Jun 2019 15:25:36 +0000 (20:55 +0530)
committerNirbheek Chauhan <nirbheek@centricular.com>
Tue, 25 Jun 2019 15:25:36 +0000 (20:55 +0530)
People should not run `meson` on gst-build inside the uninstalled env.
It will cause problems because meson will detect the already-built
libraries and pkg-config files.

This is not obvious to people, and they often make this mistake.

meson.build

index 22551d2..a599806 100644 (file)
@@ -11,6 +11,20 @@ glib_req = '>= 2.44.0'
 build_system = build_machine.system()
 cc = meson.get_compiler('c')
 
+python3 = import('python').find_installation()
+# Ensure that we're not being run from inside the gst-uninstalled env
+# because that will confuse meson, and it might find the already-built
+# gstreamer. It's fine if people run `ninja` as long as it doesn't run
+# reconfigure because ninja doesn't care about the env.
+ensure_not_uninstalled = '''
+import os
+assert('GST_ENV' not in os.environ)
+'''
+cmdres = run_command(python3, '-c', ensure_not_uninstalled)
+if cmdres.returncode() != 0
+  error('Do not run `ninja` or `meson` for gst-build inside the uninstalled environment, you will run into problems')
+endif
+
 documented_projects = ''
 # Make it possible to use msys2 built zlib which fails
 # when not using the mingw toolchain as it uses unistd.h
@@ -51,7 +65,6 @@ subprojects = [
   ['gst-python', { 'option': get_option('python'), 'has-plugins': true}],
 ]
 
-python3 = import('python').find_installation()
 symlink = '''
 import os