本文整理汇总了Golang中go/build.ArchChar函数的典型用法代码示例。如果您正苦于以下问题:Golang ArchChar函数的具体用法?Golang ArchChar怎么用?Golang ArchChar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ArchChar函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: GcToolchain
func GcToolchain(opts ...func(*gcoption)) func(c *Context) error {
defaults := []func(*gcoption){
func(opt *gcoption) {
opt.goos = runtime.GOOS
},
func(opt *gcoption) {
opt.goarch = runtime.GOARCH
},
}
var options gcoption
for _, opt := range append(defaults, opts...) {
opt(&options)
}
return func(c *Context) error {
goroot := runtime.GOROOT()
goos := options.goos
goarch := options.goarch
archchar, err := build.ArchChar(goarch)
if err != nil {
return err
}
tooldir := filepath.Join(goroot, "pkg", "tool", goos+"_"+goarch)
c.tc = &gcToolchain{
goos: goos,
goarch: goarch,
gc: filepath.Join(tooldir, archchar+"g"),
ld: filepath.Join(tooldir, archchar+"l"),
as: filepath.Join(tooldir, archchar+"a"),
cc: filepath.Join(tooldir, archchar+"c"),
pack: filepath.Join(tooldir, "pack"),
}
return nil
}
}
开发者ID:wmadisonDev,项目名称:gb,代码行数:35,代码来源:gc14.go
示例2: main
func main() {
gochar, err := build.ArchChar(runtime.GOARCH)
if err != nil {
log.Fatal(err)
}
f, err := os.Create("builtin.go")
if err != nil {
log.Fatal(err)
}
defer f.Close()
w := bufio.NewWriter(f)
fmt.Fprintln(w, "// AUTO-GENERATED by mkbuiltin.go; DO NOT EDIT")
fmt.Fprintln(w, "")
fmt.Fprintln(w, "package gc")
for _, name := range os.Args[1:] {
mkbuiltin(w, gochar, name)
}
if err := w.Flush(); err != nil {
log.Fatal(err)
}
}
开发者ID:klueska,项目名称:go-akaros,代码行数:25,代码来源:mkbuiltin.go
示例3: init
func (b *builder) init() {
var err error
b.actionCache = make(map[cacheKey]*action)
b.mkdirCache = make(map[string]bool)
b.goarch = buildContext.GOARCH
b.goos = buildContext.GOOS
b.goroot = build.Path[0].Path
b.gobin = build.Path[0].BinDir()
if b.goos == "windows" {
b.exe = ".exe"
}
b.gcflags = strings.Fields(os.Getenv("GCFLAGS"))
b.arch, err = build.ArchChar(b.goarch)
if err != nil {
fatalf("%s", err)
}
if buildN {
b.work = "$WORK"
} else {
b.work, err = ioutil.TempDir("", "go-build")
if err != nil {
fatalf("%s", err)
}
if buildX {
fmt.Printf("WORK=%s\n", b.work)
}
atexit(func() { os.RemoveAll(b.work) })
}
}
开发者ID:krasin,项目名称:go-deflate,代码行数:31,代码来源:build.go
示例4: main
func main() {
if runtime.Compiler != "gc" || runtime.GOOS == "nacl" {
return
}
a, err := build.ArchChar(runtime.GOARCH)
check(err)
err = os.Chdir(filepath.Join("fixedbugs", "issue9355.dir"))
check(err)
out := run("go", "tool", a+"g", "-S", "a.go")
os.Remove("a." + a)
// 6g/8g print the offset as dec, but 5g/9g print the offset as hex.
patterns := []string{
`rel 0\+\d t=1 \"\"\.x\+8\r?\n`, // y = &x.b
`rel 0\+\d t=1 \"\"\.x\+(28|1c)\r?\n`, // z = &x.d.q
`rel 0\+\d t=1 \"\"\.b\+5\r?\n`, // c = &b[5]
`rel 0\+\d t=1 \"\"\.x\+(88|58)\r?\n`, // w = &x.f[3].r
}
for _, p := range patterns {
if ok, err := regexp.Match(p, out); !ok || err != nil {
println(string(out))
panic("can't find pattern " + p)
}
}
}
开发者ID:klueska,项目名称:go-akaros,代码行数:27,代码来源:issue9355.go
示例5: setEnvironment
// setEnvironment assembles the configuration for gotest and its subcommands.
func setEnvironment() {
// Basic environment.
GOROOT = runtime.GOROOT()
addEnv("GOROOT", GOROOT)
GOARCH = build.DefaultContext.GOARCH
addEnv("GOARCH", GOARCH)
var err error
O, err = build.ArchChar(GOARCH)
if err != nil {
Fatalf("unknown architecture: %s", err)
}
// Commands and their flags.
gc := os.Getenv("GC")
if gc == "" {
gc = O + "g"
}
var gcflags []string
if gf := strings.TrimSpace(os.Getenv("GCFLAGS")); gf != "" {
gcflags = strings.Fields(gf)
}
XGC = append([]string{gc, "-I", "_test", "-o", "_xtest_." + O}, gcflags...)
GC = append(append([]string{gc, "-I", "_test"}, gcflags...), "_testmain.go")
gl := os.Getenv("GL")
if gl == "" {
gl = O + "l"
}
GL = []string{gl, "-L", "_test", "_testmain." + O}
// Silence make on Linux
addEnv("MAKEFLAGS", "")
addEnv("MAKELEVEL", "")
}
开发者ID:krasin,项目名称:go-deflate,代码行数:34,代码来源:gotest.go
示例6: init
func init() {
if char, err := build.ArchChar(runtime.GOARCH); err == nil {
gcPath = filepath.Join(build.ToolDir, char+"g")
return
}
gcPath = "unknown-GOARCH-compiler"
}
开发者ID:rfliam,项目名称:tools,代码行数:7,代码来源:gcimporter_test.go
示例7: GcToolchain
func GcToolchain(opts ...func(*gcoption)) func(c *Context) error {
return func(c *Context) error {
// TODO(dfc) this should come from the context, not the runtime.
goroot := runtime.GOROOT()
// cross-compliation is not supported yet #31
if c.gohostos != c.gotargetos || c.gohostarch != c.gotargetarch {
return fmt.Errorf("cross compilation from host %s/%s to target %s/%s not supported with Go 1.4", c.gohostos, c.gohostarch, c.gotargetos, c.gotargetarch)
}
archchar, err := build.ArchChar(c.gotargetarch)
if err != nil {
return err
}
tooldir := filepath.Join(goroot, "pkg", "tool", c.gohostos+"_"+c.gohostarch)
c.tc = &gcToolchain{
gc: filepath.Join(tooldir, archchar+"g"),
ld: filepath.Join(tooldir, archchar+"l"),
as: filepath.Join(tooldir, archchar+"a"),
cc: filepath.Join(tooldir, archchar+"c"),
pack: filepath.Join(tooldir, "pack"),
}
return nil
}
}
开发者ID:srid,项目名称:vessel,代码行数:25,代码来源:gc14.go
示例8: compile
func compile(t *testing.T, dirname, filename string) string {
cmd := exec.Command(gcPath, filename)
cmd.Dir = dirname
out, err := cmd.CombinedOutput()
if err != nil {
t.Logf("%s", out)
t.Fatalf("%s %s failed: %s", gcPath, filename, err)
}
archCh, _ := build.ArchChar(runtime.GOARCH)
// filename should end with ".go"
return filepath.Join(dirname, filename[:len(filename)-2]+archCh)
}
开发者ID:rocky,项目名称:go-gcimporter,代码行数:12,代码来源:gcimporter_test.go
示例9: init
func init() {
goarch = buildContext.GOARCH
goos = buildContext.GOOS
if goos == "windows" {
exeSuffix = ".exe"
}
var err error
archChar, err = build.ArchChar(goarch)
if err != nil {
fatalf("%s", err)
}
}
开发者ID:funkygao,项目名称:govtil,代码行数:12,代码来源:build.go
示例10: GcToolchain
func GcToolchain(opts ...func(*gcoption)) func(c *Context) error {
envor := func(key, def string) string {
if v := os.Getenv(key); v != "" {
return v
} else {
return def
}
}
defaults := []func(*gcoption){
func(opt *gcoption) {
opt.goos = envor("GOOS", runtime.GOOS)
},
func(opt *gcoption) {
opt.goarch = envor("GOARCH", runtime.GOARCH)
},
}
var options gcoption
for _, opt := range append(defaults, opts...) {
opt(&options)
}
return func(c *Context) error {
goroot := runtime.GOROOT()
goos := options.goos
goarch := options.goarch
// cross-compliation is not supported yet #31
if goos != runtime.GOOS || goarch != runtime.GOARCH {
return fmt.Errorf("cross compilation from host %s/%s to target %s/%s not supported. See issue #31", runtime.GOOS, runtime.GOARCH, goos, goarch)
}
archchar, err := build.ArchChar(goarch)
if err != nil {
return err
}
tooldir := filepath.Join(goroot, "pkg", "tool", goos+"_"+goarch)
c.tc = &gcToolchain{
goos: goos,
goarch: goarch,
gc: filepath.Join(tooldir, archchar+"g"),
ld: filepath.Join(tooldir, archchar+"l"),
as: filepath.Join(tooldir, archchar+"a"),
cc: filepath.Join(tooldir, archchar+"c"),
pack: filepath.Join(tooldir, "pack"),
}
return nil
}
}
开发者ID:nakalsio,项目名称:gb,代码行数:50,代码来源:gc14.go
示例11: main
func main() {
a, err := build.ArchChar(runtime.GOARCH)
if err != nil {
fmt.Println("BUG:", err)
os.Exit(1)
}
run("go", "tool", a+"g", filepath.Join("fixedbugs", "bug302.dir", "p.go"))
run("go", "tool", "pack", "grc", "pp.a", "p."+a)
run("go", "tool", a+"g", "-I", ".", filepath.Join("fixedbugs", "bug302.dir", "main.go"))
os.Remove("p." + a)
os.Remove("pp.a")
os.Remove("main." + a)
}
开发者ID:klueska,项目名称:go-akaros,代码行数:14,代码来源:bug302.go
示例12: main
func main() {
flag.Parse()
// source of unique numbers
go func() {
for i := 0; ; i++ {
uniq <- i
}
}()
// set archChar
var err os.Error
archChar, err = build.ArchChar(runtime.GOARCH)
if err != nil {
log.Fatal(err)
}
// find and serve the go tour files
t, _, err := build.FindTree(basePkg)
if err != nil {
log.Fatalf("Couldn't find tour files: %v", err)
}
root := filepath.Join(t.SrcDir(), basePkg)
root := basePkg
log.Println("Serving content from", root)
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/favicon.ico" || r.URL.Path == "/" {
fn := filepath.Join(root, "static", r.URL.Path[1:])
http.ServeFile(w, r, fn)
return
}
http.Error(w, "not found", 404)
})
http.Handle("/static/", http.FileServer(http.Dir(root)))
http.HandleFunc("/kill", kill)
// set include path for ld and gc
pkgDir = t.PkgDir()
if !strings.HasPrefix(*httpListen, "127.0.0.1") &&
!strings.HasPrefix(*httpListen, "localhost") {
log.Print(localhostWarning)
}
log.Printf("Serving at http://%s/", *httpListen)
log.Fatal(http.ListenAndServe(*httpListen, nil))
}
开发者ID:k001,项目名称:Golang-spanish-documentation,代码行数:47,代码来源:local.go
示例13: main
func main() {
a, err := build.ArchChar(build.Default.GOARCH)
check(err)
err = os.Chdir(filepath.Join(".", "fixedbugs", "bug369.dir"))
check(err)
run("go", "tool", a+"g", "-N", "-o", "slow."+a, "pkg.go")
run("go", "tool", a+"g", "-o", "fast."+a, "pkg.go")
run("go", "tool", a+"g", "-o", "main."+a, "main.go")
run("go", "tool", a+"l", "-o", "a.exe", "main."+a)
run("." + string(filepath.Separator) + "a.exe")
os.Remove("slow." + a)
os.Remove("fast." + a)
os.Remove("main." + a)
os.Remove("a.exe")
}
开发者ID:klueska,项目名称:go-akaros,代码行数:18,代码来源:bug369.go
示例14: GcToolchain
func GcToolchain() func(c *Context) error {
return func(c *Context) error {
// TODO(dfc) this should come from the context, not the runtime.
goroot := runtime.GOROOT()
if gc14 && (c.gohostos != c.gotargetos || c.gohostarch != c.gotargetarch) {
// cross-compliation is not supported yet #31
return fmt.Errorf("cross compilation from host %s/%s to target %s/%s not supported with Go 1.4", c.gohostos, c.gohostarch, c.gotargetos, c.gotargetarch)
}
tooldir := filepath.Join(goroot, "pkg", "tool", c.gohostos+"_"+c.gohostarch)
exe := ""
if c.gohostos == "windows" {
exe += ".exe"
}
switch {
case gc14:
archchar, err := build.ArchChar(c.gotargetarch)
if err != nil {
return err
}
c.tc = &gcToolchain{
gc: filepath.Join(tooldir, archchar+"g"+exe),
ld: filepath.Join(tooldir, archchar+"l"+exe),
as: filepath.Join(tooldir, archchar+"a"+exe),
cc: filepath.Join(tooldir, archchar+"c"+exe),
pack: filepath.Join(tooldir, "pack"+exe),
}
case gc15:
c.tc = &gcToolchain{
gc: filepath.Join(tooldir, "compile"+exe),
ld: filepath.Join(tooldir, "link"+exe),
as: filepath.Join(tooldir, "asm"+exe),
pack: filepath.Join(tooldir, "pack"+exe),
}
default:
return fmt.Errorf("unsupported Go version: %v", runtime.Version)
}
return nil
}
}
开发者ID:dradtke,项目名称:gb,代码行数:41,代码来源:gc.go
示例15: main
func main() {
letter, err := build.ArchChar(build.Default.GOARCH)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
cmd := exec.Command("go", "tool", letter+"g", "-S", "sinit.go")
out, err := cmd.CombinedOutput()
if err != nil {
fmt.Println(string(out))
fmt.Println(err)
os.Exit(1)
}
os.Remove("sinit." + letter)
if bytes.Contains(out, []byte("initdone")) {
fmt.Println("sinit generated an init function")
os.Exit(1)
}
}
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:21,代码来源:sinit_run.go
示例16: main
func main() {
a, err := build.ArchChar(build.Default.GOARCH)
check(err)
// TODO: If we get rid of errchk, re-enable this test on Windows.
errchk, err := filepath.Abs("errchk")
check(err)
err = os.Chdir(filepath.Join("fixedbugs", "bug248.dir"))
check(err)
run("go", "tool", a+"g", "bug0.go")
run("go", "tool", a+"g", "bug1.go")
run("go", "tool", a+"g", "bug2.go")
run(errchk, "go", "tool", a+"g", "-e", "bug3.go")
run("go", "tool", a+"l", "bug2."+a)
run(fmt.Sprintf(".%c%s.out", filepath.Separator, a))
os.Remove("bug0." + a)
os.Remove("bug1." + a)
os.Remove("bug2." + a)
os.Remove(a + ".out")
}
开发者ID:klueska,项目名称:go-akaros,代码行数:23,代码来源:bug248.go
示例17: main
func main() {
flag.Parse()
goos = getenv("GOOS", runtime.GOOS)
goarch = getenv("GOARCH", runtime.GOARCH)
findExecCmd()
// Disable parallelism if printing or if using a simulator.
if *verbose || len(findExecCmd()) > 0 {
*numParallel = 1
}
ratec = make(chan bool, *numParallel)
rungatec = make(chan bool, *runoutputLimit)
var err error
letter, err = build.ArchChar(build.Default.GOARCH)
check(err)
gc = letter + "g"
ld = letter + "l"
var tests []*test
if flag.NArg() > 0 {
for _, arg := range flag.Args() {
if arg == "-" || arg == "--" {
// Permit running:
// $ go run run.go - env.go
// $ go run run.go -- env.go
// $ go run run.go - ./fixedbugs
// $ go run run.go -- ./fixedbugs
continue
}
if fi, err := os.Stat(arg); err == nil && fi.IsDir() {
for _, baseGoFile := range goFiles(arg) {
tests = append(tests, startTest(arg, baseGoFile))
}
} else if strings.HasSuffix(arg, ".go") {
dir, file := filepath.Split(arg)
tests = append(tests, startTest(dir, file))
} else {
log.Fatalf("can't yet deal with non-directory and non-go file %q", arg)
}
}
} else {
for _, dir := range dirs {
for _, baseGoFile := range goFiles(dir) {
tests = append(tests, startTest(dir, baseGoFile))
}
}
}
failed := false
resCount := map[string]int{}
for _, test := range tests {
<-test.donec
status := "ok "
errStr := ""
if _, isSkip := test.err.(skipError); isSkip {
test.err = nil
errStr = "unexpected skip for " + path.Join(test.dir, test.gofile) + ": " + errStr
status = "FAIL"
}
if test.err != nil {
status = "FAIL"
errStr = test.err.Error()
}
if status == "FAIL" {
failed = true
}
resCount[status]++
if status == "skip" && !*verbose && !*showSkips {
continue
}
dt := fmt.Sprintf("%.3fs", test.dt.Seconds())
if status == "FAIL" {
fmt.Printf("# go run run.go -- %s\n%s\nFAIL\t%s\t%s\n",
path.Join(test.dir, test.gofile),
errStr, test.goFileName(), dt)
continue
}
if !*verbose {
continue
}
fmt.Printf("%s\t%s\t%s\n", status, test.goFileName(), dt)
}
if *summary {
for k, v := range resCount {
fmt.Printf("%5d %s\n", v, k)
}
}
if failed {
os.Exit(1)
}
}
开发者ID:bibbyflyaway,项目名称:go,代码行数:96,代码来源:run.go
示例18: CompileBinary
func CompileBinary(scriptPath string, binaryPath string, goBuild bool) {
scriptDir := filepath.Dir(scriptPath)
binaryDir := filepath.Dir(binaryPath)
// Open source file for modifications
file, err := os.OpenFile(scriptPath, os.O_RDWR, 0)
if err != nil {
log.Fatalf("Could not open file: %s", err)
}
defer func() {
if err := file.Close(); err != nil {
log.Fatalf("Could not close file: %s", err)
}
}()
// Comment hashbang line in source file
hasHashbang := CheckForHashbang(file)
if hasHashbang {
CommentHashbang(file, "//")
}
defer func() {
// Restore hashbang line in source file
if hasHashbang {
CommentHashbang(file, "#!")
}
// Recover build panic and use it for log.Fatal after hashbang has been restored
if r := recover(); r != nil {
log.Fatal(r)
}
}()
// Use "go build"
if goBuild {
// Get current directory
currentDir, err := os.Getwd()
if err != nil {
panic(err)
}
currentDir, err = filepath.Abs(currentDir)
if err != nil {
panic(err)
}
if currentDir != scriptDir {
// Change into scripts directory
if err := os.Chdir(scriptDir); err != nil {
panic(err)
}
defer func() {
// Go back to previous directory
if err := os.Chdir(currentDir); err != nil {
panic(err)
}
}()
}
// Build current/scripts directory
out, err := exec.Command("go", "build", "-o", binaryPath).CombinedOutput()
if err != nil {
panic(fmt.Errorf("%s\n%s\n", err, out))
}
} else {
// Set toolchain
archChar, err := build.ArchChar(runtime.GOARCH)
if err != nil {
panic(err)
}
// Compile source file
objectPath := filepath.Join(binaryDir, "_go_."+archChar)
cmd := exec.Command(filepath.Join(build.ToolDir, archChar+"g"), "-o", objectPath, scriptPath)
out, err := cmd.CombinedOutput()
if err != nil {
panic(fmt.Errorf("%s\n%s", cmd.Args, out))
}
// Link executable
out, err = exec.Command(filepath.Join(build.ToolDir, archChar+"l"), "-o", binaryPath, objectPath).CombinedOutput()
if err != nil {
panic(fmt.Errorf("Linker failed: %s\n%s", err, out))
}
// Cleaning
if err := os.Remove(objectPath); err != nil {
panic(fmt.Errorf("Could not remove object file: %s", err))
}
}
}
开发者ID:theclapp,项目名称:goplay,代码行数:88,代码来源:goplay.go
示例19: main
func main() {
flag.Parse()
// Disable parallelism if printing
if *verbose {
*numParallel = 1
}
ratec = make(chan bool, *numParallel)
rungatec = make(chan bool, *runoutputLimit)
var err error
letter, err = build.ArchChar(build.Default.GOARCH)
check(err)
gc = letter + "g"
ld = letter + "l"
var tests []*test
if flag.NArg() > 0 {
for _, arg := range flag.Args() {
if arg == "-" || arg == "--" {
// Permit running:
// $ go run run.go - env.go
// $ go run run.go -- env.go
// $ go run run.go - ./fixedbugs
// $ go run run.go -- ./fixedbugs
continue
}
if fi, err := os.Stat(arg); err == nil && fi.IsDir() {
for _, baseGoFile := range goFiles(arg) {
tests = append(tests, startTest(arg, baseGoFile))
}
} else if strings.HasSuffix(arg, ".go") {
dir, file := filepath.Split(arg)
tests = append(tests, startTest(dir, file))
} else {
log.Fatalf("can't yet deal with non-directory and non-go file %q", arg)
}
}
} else {
for _, dir := range dirs {
for _, baseGoFile := range goFiles(dir) {
tests = append(tests, startTest(dir, baseGoFile))
}
}
}
failed := false
resCount := map[string]int{}
for _, test := range tests {
<-test.donec
_, isSkip := test.err.(skipError)
errStr := "pass"
if test.err != nil {
errStr = test.err.Error()
if !isSkip {
failed = true
}
}
if isSkip && !skipOkay[path.Join(test.dir, test.gofile)] {
errStr = "unexpected skip for " + path.Join(test.dir, test.gofile) + ": " + errStr
isSkip = false
failed = true
}
resCount[errStr]++
if isSkip && !*verbose && !*showSkips {
continue
}
if !*verbose && test.err == nil {
continue
}
fmt.Printf("# go run run.go -- %s\n%-20s %-20s: %s\n", path.Join(test.dir, test.gofile), test.action, test.goFileName(), errStr)
}
if *summary {
for k, v := range resCount {
fmt.Printf("%5d %s\n", v, k)
}
}
if failed {
os.Exit(1)
}
}
开发者ID:spiralgenetics,项目名称:golang,代码行数:83,代码来源:run.go
示例20: main
func main() {
flag.Parse()
if *verbose {
*numParallel = 1
}
ratec = make(chan bool, *numParallel)
var err error
letter, err = build.ArchChar(build.DefaultContext.GOARCH)
check(err)
gc = letter + "g"
ld = letter + "l"
var tests []*test
if flag.NArg() > 0 {
for _, arg := range flag.Args() {
if arg == "-" || arg == "--" {
// Permit running either:
// $ go run run.go - env.go
// $ go run run.go -- env.go
continue
}
if !strings.HasSuffix(arg, ".go") {
log.Fatalf("can't yet deal with non-go file %q", arg)
}
dir, file := filepath.Split(arg)
tests = append(tests, startTest(dir, file))
}
} else {
for _, dir := range dirs {
for _, baseGoFile := range goFiles(dir) {
tests = append(tests, startTest(dir, baseGoFile))
}
}
}
failed := false
resCount := map[string]int{}
for _, test := range tests {
<-test.donec
_, isSkip := test.err.(skipError)
errStr := "pass"
if isSkip {
errStr = "skip"
}
if test.err != nil {
errStr = test.err.Error()
if !isSkip {
failed = true
}
}
resCount[errStr]++
if isSkip && !*verbose && !*showSkips {
continue
}
if !*verbose && test.err == nil {
continue
}
fmt.Printf("%-10s %-20s: %s\n", test.action, test.goFileName(), errStr)
}
if *summary {
for k, v := range resCount {
fmt.Printf("%5d %s\n", v, k)
}
}
if failed {
os.Exit(1)
}
}
开发者ID:joninvski,项目名称:go,代码行数:71,代码来源:run.go
注:本文中的go/build.ArchChar函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论