diff options
author | Tobias Bosch <tbosch@google.com> | 2019-06-24 09:31:39 -0700 |
---|---|---|
committer | Tobias Bosch <tbosch@google.com> | 2019-06-28 19:00:23 +0000 |
commit | 900dbc92800d8fc927905db29cb302461054cf97 (patch) | |
tree | c74ecbfb01ee4ee679090139596aef3546f19d9b /compiler_wrapper/main.go | |
parent | 739e6abb2cd03b60e579df31ad55870a4a00260a (diff) | |
download | toolchain-utils-900dbc92800d8fc927905db29cb302461054cf97.tar.gz |
Introduce infrastructure for calling and testing nested
commands, error messages and exit codes.
Also:
- implements the -Xclang-path= flag as use case of calling
a nested command.
- adds tests for forwarding errors, comparing against the
old wrapper, and exit codes.
- captures the source locations of errors in error messages.
- compares exit codes of new wrapper and old wrapper.
BUG=chromium:773875
TEST=unit test
Change-Id: I919e58091d093d68939809f676f799a68ec7a34e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1676833
Reviewed-by: George Burgess <gbiv@chromium.org>
Tested-by: Tobias Bosch <tbosch@google.com>
Diffstat (limited to 'compiler_wrapper/main.go')
-rw-r--r-- | compiler_wrapper/main.go | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/compiler_wrapper/main.go b/compiler_wrapper/main.go index 9e131329..10132543 100644 --- a/compiler_wrapper/main.go +++ b/compiler_wrapper/main.go @@ -21,12 +21,10 @@ package main import ( "log" - "os/exec" - "syscall" + "os" ) func main() { - wrapperCmd := newProcessCommand() env, err := newProcessEnv() if err != nil { log.Fatal(err) @@ -35,23 +33,8 @@ func main() { if err != nil { log.Fatal(err) } - if shouldForwardToOldWrapper(env, wrapperCmd) { - err := forwardToOldWrapper(env, cfg, wrapperCmd) - if err != nil { - log.Fatal(err) - } - return - } - - cmd, err := calcCompilerCommandAndCompareToOld(env, cfg, wrapperCmd) - if err != nil { - log.Fatal(err) - } - if err := execCmd(newExecCmd(env, cmd)); err != nil { - log.Fatal(err) - } -} - -func execCmd(cmd *exec.Cmd) error { - return syscall.Exec(cmd.Path, cmd.Args, cmd.Env) + // Note: callCompiler will exec the command. Only in case of + // an error or when we are comparing against the old wrapper + // will this os.Exit be called. + os.Exit(callCompiler(env, cfg, newProcessCommand())) } |