Repository: mesonbuild/meson

Issue:
custom_target: install:true without install_dir crashes
**Describe the bug**
When defining a `custom_target` with `install:true`, `meson build` will crash. If `install_dir` is provided, build works as expected.

Traceback:
```
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/mesonbuild/mesonmain.py", line 138, in run
    return options.run_func(options)
  File "/usr/local/lib/python3.8/dist-packages/mesonbuild/msetup.py", line 294, in run
    app.generate()
  File "/usr/local/lib/python3.8/dist-packages/mesonbuild/msetup.py", line 185, in generate
    self._generate(env)
  File "/usr/local/lib/python3.8/dist-packages/mesonbuild/msetup.py", line 247, in _generate
    intr.backend.generate()
  File "/usr/local/lib/python3.8/dist-packages/mesonbuild/backend/ninjabackend.py", line 557, in generate
    self.generate_install()
  File "/usr/local/lib/python3.8/dist-packages/mesonbuild/backend/ninjabackend.py", line 1120, in generate_install
    self.create_install_data_files()
  File "/usr/local/lib/python3.8/dist-packages/mesonbuild/backend/backends.py", line 1495, in create_install_data_files
    pickle.dump(self.create_install_data(), ofile)
  File "/usr/local/lib/python3.8/dist-packages/mesonbuild/backend/backends.py", line 1483, in create_install_data
    self.generate_target_install(d)
  File "/usr/local/lib/python3.8/dist-packages/mesonbuild/backend/backends.py", line 1627, in generate_target_install
    dir_name = os.path.join('{prefix}', outdir)
  File "/usr/lib/python3.8/posixpath.py", line 90, in join
    genericpath._check_arg_types('join', a, *p)
  File "/usr/lib/python3.8/genericpath.py", line 152, in _check_arg_types
    raise TypeError(f'{funcname}() argument must be str, bytes, or '
TypeError: join() argument must be str, bytes, or os.PathLike object, not 'NoneType'
```

**To Reproduce**
```meson
project('test')

custom_target(
    output: 'bug.txt',
    install: true,
    capture: true,
    command: ['echo', 'foobar']
)
```

**Expected behavior**
Either an error of some sort ("install:true requires install_dir to be set") or default fallback (`install_dir: '.'` ??)

**system parameters**
* Native build
* Ubuntu 20.04
* Python 3.8.10
* Using the commit at time of bug report: d23ae8b58e73665d6418137446b259a2666af345
* Ninja 1.10.0


Discussion:
This happens because some code, but not all code, is migrated to use typed_kwargs. And the CustomTarget implementation just emits the relevant error if install_dir is not in the kwargs, but it might be passed and not truthy.

Seems like a simple solution.

Resolving patch:
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -2457,7 +2457,7 @@ def process_kwargs(self, kwargs, backend):
             if not isinstance(self.install, bool):
                 raise InvalidArguments('"install" must be boolean.')
             if self.install:
-                if 'install_dir' not in kwargs:
+                if not kwargs.get('install_dir', False):
                     raise InvalidArguments('"install_dir" must be specified '
                                            'when installing a target')
 


Test patch: