build-script: validate arguments before running `sccache` (#61375)
When a user passes `--sccache` flag when `sccache` is not installed, we still attempt to make a shell invocation to `sccache`, which leads to an inscrutable error:
```
Traceback (most recent call last):
File "/root/swift-source/swift/utils/build-script", line 789, in <module>
exit_code = main()
File "/root/swift-source/swift/utils/build-script", line 784, in main
return main_normal()
File "/root/swift-source/swift/utils/build-script", line 687, in main_normal
shell.capture([toolchain.sccache, "--show-stats"])
File "/root/swift-source/swift/utils/swift_build_support/swift_build_support/shell.py", line 133, in capture
return subprocess.check_output(command, env=_env, stderr=stderr,
File "/usr/lib/python3.10/subprocess.py", line 420, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/lib/python3.10/subprocess.py", line 501, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/lib/python3.10/subprocess.py", line 969, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.10/subprocess.py", line 1720, in _execute_child
and os.path.dirname(executable)
File "/usr/lib/python3.10/posixpath.py", line 152, in dirname
p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType
```
`validate_arguments` should be called before `shell.capture([toolchain.sccache, "--show-stats"])` so that a more meaningful error message is shown to the user, asking them to install `sccache`.