Repository: mesonbuild/meson

Issue:
Running "meson configure" in source directory raises an exception
First bad commit is 939b011114838b886d48521806988973205aecb4, cc @mensinda 

```
[0] [akari@navi] [*powersurge ← /home/akari/git/taisei]
 % meson configure
Unable to evaluate subdir([]) in AstInterpreter --> Skipping
Traceback (most recent call last):
  File "/data/git/meson/mesonbuild/mesonmain.py", line 115, in run
    return options.run_func(options)
  File "/data/git/meson/mesonbuild/mconf.py", line 200, in run
    c = Conf(builddir)
  File "/data/git/meson/mesonbuild/mconf.py", line 56, in __init__
    intr.analyze()
  File "/data/git/meson/mesonbuild/ast/introspection.py", line 255, in analyze
    self.run()
  File "/data/git/meson/mesonbuild/interpreterbase.py", line 407, in run
    self.evaluate_codeblock(self.ast, start=1)
  File "/data/git/meson/mesonbuild/interpreterbase.py", line 431, in evaluate_codeblock
    raise e
  File "/data/git/meson/mesonbuild/interpreterbase.py", line 425, in evaluate_codeblock
    self.evaluate_statement(cur)
  File "/data/git/meson/mesonbuild/interpreterbase.py", line 436, in evaluate_statement
    return self.function_call(cur)
  File "/data/git/meson/mesonbuild/interpreterbase.py", line 762, in function_call
    return func(node, posargs, kwargs)
  File "/data/git/meson/mesonbuild/ast/interpreter.py", line 148, in func_subdir
    self.evaluate_codeblock(codeblock)
  File "/data/git/meson/mesonbuild/interpreterbase.py", line 431, in evaluate_codeblock
    raise e
  File "/data/git/meson/mesonbuild/interpreterbase.py", line 425, in evaluate_codeblock
    self.evaluate_statement(cur)
  File "/data/git/meson/mesonbuild/interpreterbase.py", line 438, in evaluate_statement
    return self.assignment(cur)
  File "/data/git/meson/mesonbuild/ast/interpreter.py", line 203, in assignment
    self.evaluate_statement(node.value) # Evaluate the value just in case
  File "/data/git/meson/mesonbuild/interpreterbase.py", line 436, in evaluate_statement
    return self.function_call(cur)
  File "/data/git/meson/mesonbuild/interpreterbase.py", line 762, in function_call
    return func(node, posargs, kwargs)
  File "/data/git/meson/mesonbuild/ast/introspection.py", line 209, in func_executable
    return self.build_target(node, args, kwargs, Executable)
  File "/data/git/meson/mesonbuild/ast/introspection.py", line 148, in build_target
    name = self.flatten_args(args)[0]
IndexError: list index out of range

[2] [akari@navi] [*powersurge ← /home/akari/git/taisei]
 % ls
COPYING  README.rst  atlas  doc  external  meson.build  meson_options.txt  misc  resources  scripts  src  subprojects  taisei.kdev4  trees  xdg
```


Discussion:

Resolving patch:
diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py
--- a/mesonbuild/ast/introspection.py
+++ b/mesonbuild/ast/introspection.py
@@ -142,10 +142,11 @@ def func_dependency(self, node, args, kwargs):
         }]
 
     def build_target(self, node, args, kwargs, targetclass):
+        args = self.flatten_args(args)
         if not args:
             return
         kwargs = self.flatten_kwargs(kwargs, True)
-        name = self.flatten_args(args)[0]
+        name = args[0]
         srcqueue = [node]
         if 'sources' in kwargs:
             srcqueue += kwargs['sources']


Test patch:
diff --git a/test cases/unit/53 introspect buildoptions/main.c b/test cases/unit/53 introspect buildoptions/main.c
new file mode 100644
--- /dev/null
+++ b/test cases/unit/53 introspect buildoptions/main.c	
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main() {
+  printf("Hello World");
+  return 0;
+}
diff --git a/test cases/unit/53 introspect buildoptions/meson.build b/test cases/unit/53 introspect buildoptions/meson.build
--- a/test cases/unit/53 introspect buildoptions/meson.build	
+++ b/test cases/unit/53 introspect buildoptions/meson.build	
@@ -2,6 +2,11 @@ project('introspect buildargs', ['c'], default_options: ['c_std=c11', 'cpp_std=c
 
 subA = subproject('projectA')
 
+target_name = 'MAIN'
+target_src = ['main.c']
+
+executable(target_name, target_src)
+
 r = run_command(find_program('c_compiler.py'))
 if r.returncode() != 0
   error('FAILED')