| 1 |
// +build !nacl,!js,gc |
| 2 |
// run |
| 3 |
|
| 4 |
// Copyright 2010 The Go Authors. All rights reserved. |
| 5 |
// Use of this source code is governed by a BSD-style |
| 6 |
// license that can be found in the LICENSE file. |
| 7 |
|
| 8 |
package main |
| 9 |
|
| 10 |
import ( |
| 11 |
"fmt" |
| 12 |
"io/ioutil" |
| 13 |
"os" |
| 14 |
"os/exec" |
| 15 |
"path/filepath" |
| 16 |
) |
| 17 |
|
| 18 |
var tmpDir string |
| 19 |
|
| 20 |
func main() { |
| 21 |
fb, err := filepath.Abs("fixedbugs") |
| 22 |
if err == nil { |
| 23 |
tmpDir, err = ioutil.TempDir("", "bug302") |
| 24 |
} |
| 25 |
if err != nil { |
| 26 |
fmt.Println(err) |
| 27 |
os.Exit(1) |
| 28 |
} |
| 29 |
defer os.RemoveAll(tmpDir) |
| 30 |
|
| 31 |
run("go", "tool", "compile", filepath.Join(fb, "bug302.dir", "p.go")) |
| 32 |
run("go", "tool", "pack", "grc", "pp.a", "p.o") |
| 33 |
run("go", "tool", "compile", "-I", ".", filepath.Join(fb, "bug302.dir", "main.go")) |
| 34 |
} |
| 35 |
|
| 36 |
func run(cmd string, args ...string) { |
| 37 |
c := exec.Command(cmd, args...) |
| 38 |
c.Dir = tmpDir |
| 39 |
out, err := c.CombinedOutput() |
| 40 |
if err != nil { |
| 41 |
fmt.Println(string(out)) |
| 42 |
fmt.Println(err) |
| 43 |
os.Exit(1) |
| 44 |
} |
| 45 |
} |