Repository: mesonbuild/meson

Issue:
Setting custom -Doptimization causes failure
1. `meson build .`
2. `meson configure build -Doptimization=s`
3. `ninja -C build/ -v`

```
Traceback (most recent call last):
  File "/home/soap/gitz/meson/mesonbuild/mesonmain.py", line 364, in run
    app.generate()
  File "/home/soap/gitz/meson/mesonbuild/mesonmain.py", line 136, in generate
    self._generate(env)
  File "/home/soap/gitz/meson/mesonbuild/mesonmain.py", line 185, in _generate
    intr.backend.generate(intr)
  File "/home/soap/gitz/meson/mesonbuild/backend/ninjabackend.py", line 224, in generate
    self.generate_target(t, outfile)
  File "/home/soap/gitz/meson/mesonbuild/backend/ninjabackend.py", line 472, in generate_target
    obj_list.append(self.generate_single_compile(target, outfile, src, False, [], header_deps))
  File "/home/soap/gitz/meson/mesonbuild/backend/ninjabackend.py", line 2051, in generate_single_compile
    commands = self._generate_single_compile(target, compiler, is_generated)
  File "/home/soap/gitz/meson/mesonbuild/backend/ninjabackend.py", line 1972, in _generate_single_compile
    commands += self.generate_basic_compiler_args(target, compiler, no_warn_args)
  File "/home/soap/gitz/meson/mesonbuild/backend/backends.py", line 538, in generate_basic_compiler_args
    commands += compiler.get_buildtype_args(self.get_option_for_target('buildtype', target))
  File "/home/soap/gitz/meson/mesonbuild/compilers/compilers.py", line 1306, in get_buildtype_args
    return gnulike_buildtype_args[buildtype]
KeyError: 'custom'
FAILED: build.ninja
```


Discussion:

Resolving patch:
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -127,19 +127,24 @@ def is_library(fname):
                           'debug': [],
                           'debugoptimized': [],
                           'release': [],
-                          'minsize': []}
+                          'minsize': [],
+                          'custom': [],
+                          }
 
 armclang_buildtype_args = {'plain': [],
                            'debug': ['-O0', '-g'],
                            'debugoptimized': ['-O1', '-g'],
                            'release': ['-Os'],
-                           'minsize': ['-Oz']}
+                           'minsize': ['-Oz'],
+                           'custom': [],
+                           }
 
 arm_buildtype_args = {'plain': [],
                       'debug': ['-O0', '--debug'],
                       'debugoptimized': ['-O1', '--debug'],
                       'release': ['-O3', '-Otime'],
                       'minsize': ['-O3', '-Ospace'],
+                      'custom': [],
                       }
 
 msvc_buildtype_args = {'plain': [],
@@ -147,6 +152,7 @@ def is_library(fname):
                        'debugoptimized': ["/Zi", "/Ob1"],
                        'release': ["/Ob2", "/Gw"],
                        'minsize': ["/Zi", "/Gw"],
+                       'custom': [],
                        }
 
 apple_buildtype_linker_args = {'plain': [],
@@ -154,6 +160,7 @@ def is_library(fname):
                                'debugoptimized': [],
                                'release': [],
                                'minsize': [],
+                               'custom': [],
                                }
 
 gnulike_buildtype_linker_args = {'plain': [],
@@ -161,6 +168,7 @@ def is_library(fname):
                                  'debugoptimized': [],
                                  'release': ['-Wl,-O1'],
                                  'minsize': [],
+                                 'custom': [],
                                  }
 
 arm_buildtype_linker_args = {'plain': [],
@@ -168,6 +176,7 @@ def is_library(fname):
                              'debugoptimized': [],
                              'release': [],
                              'minsize': [],
+                             'custom': [],
                              }
 
 msvc_buildtype_linker_args = {'plain': [],
@@ -178,6 +187,7 @@ def is_library(fname):
                               # REF implies ICF.
                               'release': ['/OPT:REF'],
                               'minsize': ['/INCREMENTAL:NO', '/OPT:REF'],
+                              'custom': [],
                               }
 
 java_buildtype_args = {'plain': [],
@@ -185,6 +195,7 @@ def is_library(fname):
                        'debugoptimized': ['-g'],
                        'release': [],
                        'minsize': [],
+                       'custom': [],
                        }
 
 rust_buildtype_args = {'plain': [],
@@ -192,6 +203,7 @@ def is_library(fname):
                        'debugoptimized': [],
                        'release': [],
                        'minsize': [],
+                       'custom': [],
                        }
 
 d_gdc_buildtype_args = {'plain': [],
@@ -199,6 +211,7 @@ def is_library(fname):
                         'debugoptimized': ['-finline-functions'],
                         'release': ['-frelease', '-finline-functions'],
                         'minsize': [],
+                        'custom': [],
                         }
 
 d_ldc_buildtype_args = {'plain': [],
@@ -206,6 +219,7 @@ def is_library(fname):
                         'debugoptimized': ['-enable-inlining', '-Hkeep-all-bodies'],
                         'release': ['-release', '-enable-inlining', '-Hkeep-all-bodies'],
                         'minsize': [],
+                        'custom': [],
                         }
 
 d_dmd_buildtype_args = {'plain': [],
@@ -213,6 +227,7 @@ def is_library(fname):
                         'debugoptimized': ['-inline'],
                         'release': ['-release', '-inline'],
                         'minsize': [],
+                        'custom': [],
                         }
 
 mono_buildtype_args = {'plain': [],
@@ -220,6 +235,7 @@ def is_library(fname):
                        'debugoptimized': ['-optimize+'],
                        'release': ['-optimize+'],
                        'minsize': [],
+                       'custom': [],
                        }
 
 swift_buildtype_args = {'plain': [],
@@ -227,6 +243,7 @@ def is_library(fname):
                         'debugoptimized': [],
                         'release': [],
                         'minsize': [],
+                        'custom': [],
                         }
 
 gnu_winlibs = ['-lkernel32', '-luser32', '-lgdi32', '-lwinspool', '-lshell32',


Test patch: