aboutsummaryrefslogtreecommitdiff
path: root/compiler_wrapper/main.go
blob: 046cf5a554c3fd12f785388471153fbe997a97c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2019 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This binary requires the following linker variables:
// - main.UseCCache: Whether to use ccache.
// - main.ConfigName: Name of the configuration to use.
//   See config.go for the supported values.
//
// The script ./build simplifies the call to `go build`.
// E.g. ./build --use_ccache=true --config=cros.hardened will build a
// binary that uses the ccache for ChromeOS with hardened flags.
//
// Test arguments:
// - updategolden: To update the golden results for the wrapper. Without it,
//   the tests will verify that the wrapper output matches the goldens.
// - rungolden: To filter the golden tests by a regex for the wrapper env, path and args.
//
// Examples:
// - run all tests in isolation:
// 		go test third_party/toolchain-utils/compiler_wrapper/ -v
package main

import (
	"log"
	"os"
)

func main() {
	env, err := newProcessEnv()
	if err != nil {
		log.Fatal(err)
	}
	cfg, err := getRealConfig()
	if err != nil {
		log.Fatal(err)
	}
	// Note: callCompiler will exec the command. Only in case of
	// an error or when we run other commands like bisect
	// will this os.Exit be called.
	os.Exit(callCompiler(env, cfg, newProcessCommand()))
}