Repository: mesonbuild/meson

Issue:
Empty compiler env variables crash meson
When meson is invoked with empty env variables for the compiler, it crashes meson.

```
cd dav1d && CC= CXX= LD= AR= CCAS= RANLIB= STRIP= PATH="/Users/epirat/Projects/VideoLAN/VLC/build-test/contrib/arm64-apple-iOS_9.0/bin:/Users/epirat/Projects/VideoLAN/VLC/extras/tools/build/bin:/Users/epirat/Projects/VideoLAN/VLC/contrib/x86_64-apple-darwin16/bin:/Users/epirat/Projects/VideoLAN/VLC/extras/tools/build/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin" CPPFLAGS= CFLAGS= CXXFLAGS= LDFLAGS= meson --default-library static --prefix "/Users/epirat/Projects/VideoLAN/VLC/build-test/contrib/arm64-apple-iOS_9.0" --backend ninja -Dlibdir=lib --buildtype release --cross-file /Users/epirat/Projects/VideoLAN/VLC/contrib/contrib-arm64-apple-iOS_9.0/crossfile.meson -D build_tests=false -D build_tools=false build
The Meson build system
Version: 0.50.1
Source dir: /Users/epirat/Projects/VideoLAN/VLC/contrib/contrib-arm64-apple-iOS_9.0/dav1d
Build dir: /Users/epirat/Projects/VideoLAN/VLC/contrib/contrib-arm64-apple-iOS_9.0/dav1d/build
Build type: cross build
Project name: dav1d
Project version: 0.3.1
Traceback (most recent call last):
  File "/Users/epirat/Projects/VideoLAN/VLC/extras/tools/meson/mesonbuild/mesonmain.py", line 122, in run
    return options.run_func(options)
  File "/Users/epirat/Projects/VideoLAN/VLC/extras/tools/meson/mesonbuild/msetup.py", line 246, in run
    app.generate()
  File "/Users/epirat/Projects/VideoLAN/VLC/extras/tools/meson/mesonbuild/msetup.py", line 163, in generate
    self._generate(env)
  File "/Users/epirat/Projects/VideoLAN/VLC/extras/tools/meson/mesonbuild/msetup.py", line 180, in _generate
    intr = interpreter.Interpreter(b)
  File "/Users/epirat/Projects/VideoLAN/VLC/extras/tools/meson/mesonbuild/interpreter.py", line 2026, in __init__
    self.parse_project()
  File "/Users/epirat/Projects/VideoLAN/VLC/extras/tools/meson/mesonbuild/interpreterbase.py", line 392, in parse_project
    self.evaluate_codeblock(self.ast, end=1)
  File "/Users/epirat/Projects/VideoLAN/VLC/extras/tools/meson/mesonbuild/interpreterbase.py", line 431, in evaluate_codeblock
    raise e
  File "/Users/epirat/Projects/VideoLAN/VLC/extras/tools/meson/mesonbuild/interpreterbase.py", line 425, in evaluate_codeblock
    self.evaluate_statement(cur)
  File "/Users/epirat/Projects/VideoLAN/VLC/extras/tools/meson/mesonbuild/interpreterbase.py", line 436, in evaluate_statement
    return self.function_call(cur)
  File "/Users/epirat/Projects/VideoLAN/VLC/extras/tools/meson/mesonbuild/interpreterbase.py", line 762, in function_call
    return func(node, posargs, kwargs)
  File "/Users/epirat/Projects/VideoLAN/VLC/extras/tools/meson/mesonbuild/interpreterbase.py", line 143, in wrapped
    return f(*wrapped_args, **wrapped_kwargs)
  File "/Users/epirat/Projects/VideoLAN/VLC/extras/tools/meson/mesonbuild/interpreterbase.py", line 174, in wrapped
    return f(*wrapped_args, **wrapped_kwargs)
  File "/Users/epirat/Projects/VideoLAN/VLC/extras/tools/meson/mesonbuild/interpreter.py", line 2619, in func_project
    self.add_languages(proj_langs, True)
  File "/Users/epirat/Projects/VideoLAN/VLC/extras/tools/meson/mesonbuild/interpreter.py", line 2691, in add_languages
    (comp, cross_comp) = self.environment.detect_compilers(lang, need_cross_compiler)
  File "/Users/epirat/Projects/VideoLAN/VLC/extras/tools/meson/mesonbuild/environment.py", line 1125, in detect_compilers
    (comp, cross_comp) = self.compilers_from_language(lang, need_cross_compiler)
  File "/Users/epirat/Projects/VideoLAN/VLC/extras/tools/meson/mesonbuild/environment.py", line 1063, in compilers_from_language
    comp = self.detect_c_compiler(False)
  File "/Users/epirat/Projects/VideoLAN/VLC/extras/tools/meson/mesonbuild/environment.py", line 769, in detect_c_compiler
    return self._detect_c_or_cpp_compiler('c', want_cross)
  File "/Users/epirat/Projects/VideoLAN/VLC/extras/tools/meson/mesonbuild/environment.py", line 620, in _detect_c_or_cpp_compiler
    compilers, ccache, is_cross, exe_wrap = self._get_compilers(lang, want_cross)
  File "/Users/epirat/Projects/VideoLAN/VLC/extras/tools/meson/mesonbuild/environment.py", line 592, in _get_compilers
    compilers, ccache = BinaryTable.parse_entry(value)
  File "/Users/epirat/Projects/VideoLAN/VLC/extras/tools/meson/mesonbuild/envconfig.py", line 363, in parse_entry
    if compiler[0] == 'ccache':
IndexError: list index out of range
make: *** [.dav1d] Error 2
```


Discussion:

Resolving patch:
diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py
--- a/mesonbuild/envconfig.py
+++ b/mesonbuild/envconfig.py
@@ -340,6 +340,10 @@ def lookup_entry(self, name: str) -> typing.Optional[typing.List[str]]:
             command = os.environ.get(evar)
             if command is not None:
                 command = shlex.split(command)
+
+        # Do not return empty string entries
+        if command is not None and len(command) == 0:
+            return None
         return command
 
 class Directories:


Test patch: