diff options
author | Tobias Bosch <tbosch@google.com> | 2019-08-19 16:30:44 -0700 |
---|---|---|
committer | Tobias Bosch <tbosch@google.com> | 2019-08-20 15:54:19 +0000 |
commit | 36c19215f13c983c2ae0096ed9170fd064744622 (patch) | |
tree | fd90fb7bc384a058ef6974487c1066bfa074af75 /compiler_wrapper/command.go | |
parent | 4529f292ce64293d4650cc2be7caaa7e061196f5 (diff) | |
download | toolchain-utils-36c19215f13c983c2ae0096ed9170fd064744622.tar.gz |
Correctly parse eabi compiler names.
BUG=chromium:773875
TEST=unit tests, compile cross-armv7m-cros-eabi/newlib
Change-Id: Ia98442a69b01cff87c52b6ac84dc39c47d5e998e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1760465
Tested-by: Tobias Bosch <tbosch@google.com>
Reviewed-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'compiler_wrapper/command.go')
-rw-r--r-- | compiler_wrapper/command.go | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/compiler_wrapper/command.go b/compiler_wrapper/command.go index ade12ede..df424ad8 100644 --- a/compiler_wrapper/command.go +++ b/compiler_wrapper/command.go @@ -63,18 +63,38 @@ func getAbsCmdPath(env env, cmd *command) string { func newCommandBuilder(env env, cfg *config, cmd *command) (*commandBuilder, error) { basename := filepath.Base(cmd.Path) nameParts := strings.Split(basename, "-") - if len(nameParts) != 5 { - return nil, newErrorwithSourceLocf("expected 5 parts in the compiler name. Actual: %s", basename) + target := builderTarget{} + if len(nameParts) == 4 { + // E.g. armv7m-cros-eabi-gcc + target = builderTarget{ + arch: nameParts[0], + vendor: nameParts[1], + sys: "", + abi: nameParts[2], + compiler: nameParts[3], + } + } else if len(nameParts) == 5 { + // E.g. x86_64-cros-linux-gnu-gcc + target = builderTarget{ + arch: nameParts[0], + vendor: nameParts[1], + sys: nameParts[2], + abi: nameParts[3], + compiler: nameParts[4], + } + } else { + return nil, newErrorwithSourceLocf("unexpected compiler name pattern. Actual: %s", basename) } - compiler := nameParts[4] + target.target = basename[:strings.LastIndex(basename, "-")] var compilerType compilerType switch { - case strings.HasPrefix(compiler, "clang"): + case strings.HasPrefix(target.compiler, "clang"): compilerType = clangType default: compilerType = gccType } + target.compilerType = compilerType absWrapperPath, err := getAbsWrapperPath(env, cmd) if err != nil { return nil, err @@ -87,15 +107,7 @@ func newCommandBuilder(env env, cfg *config, cmd *command) (*commandBuilder, err cfg: cfg, rootPath: rootPath, absWrapperPath: absWrapperPath, - target: builderTarget{ - target: strings.Join(nameParts[:4], "-"), - arch: nameParts[0], - vendor: nameParts[1], - sys: nameParts[2], - abi: nameParts[3], - compiler: compiler, - compilerType: compilerType, - }, + target: target, }, nil } |