blob: 8db2769756976a581d7b0ac8a73d519d52ed5e6c [file] [log] [blame]
Peter Collingbourne7ddf8322015-02-14 01:46:01 +00001//===- zdefaultcc.go - default compiler locations -------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file provides a default location for cc.
11//
12//===----------------------------------------------------------------------===//
13
14package main
15
16import (
17 "path/filepath"
18 "os"
19 "os/exec"
20)
21
22var defaultCC string
23
24func getInstPrefix() (string, error) {
25 path, err := exec.LookPath(os.Args[0])
26 if err != nil {
27 return "", err
28 }
29
30 path, err = filepath.EvalSymlinks(path)
31 if err != nil {
32 return "", err
33 }
34
35 prefix := filepath.Join(path, "..", "..", "..", "..")
36 return prefix, nil
37}
38
39func init() {
40 prefix, err := getInstPrefix()
41 if err != nil {
42 panic(err.Error())
43 }
44
45 defaultCC = filepath.Join(prefix, "bin", "clang")
46}