当前位置: 首页>>代码示例>>Golang>>正文


Golang build.ArchChar函数代码示例

本文整理汇总了Golang中go/build.ArchChar函数的典型用法代码示例。如果您正苦于以下问题:Golang ArchChar函数的具体用法?Golang ArchChar怎么用?Golang ArchChar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ArchChar函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的go/build.ArchChar函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。