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


Golang Context.Exec方法代码示例

本文整理汇总了Golang中sevki/org/build.Context.Exec方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.Exec方法的具体用法?Golang Context.Exec怎么用?Golang Context.Exec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sevki/org/build.Context的用法示例。


在下文中一共展示了Context.Exec方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Build

func (cl *CLib) Build(c *build.Context) error {
	params := []string{"-c"}
	params = append(params, cl.CompilerOptions...)
	params = append(params, cl.LinkerOptions...)
	params = append(params, cl.Sources...)
	params = append(params, cl.Includes.Includes()...)

	if err := c.Exec(Compiler(), CCENV, params); err != nil {
		c.Println(err.Error())
		return fmt.Errorf(cl.buf.String())
	}

	libName := fmt.Sprintf("%s.a", cl.Name)
	params = []string{"-rs", libName}
	params = append(params, cl.LinkerOptions...)
	// This is done under the assumption that each src file put in this thing
	// here will comeout as a .o file
	for _, f := range cl.Sources {
		_, filename := filepath.Split(f)
		params = append(params, fmt.Sprintf("%s.o", filename[:strings.LastIndex(filename, ".")]))
	}

	if err := c.Exec(Archiver(), CCENV, params); err != nil {
		c.Println(err.Error())
		return fmt.Errorf(cl.buf.String())
	}

	return nil
}
开发者ID:ftrvxmtrx,项目名称:build,代码行数:29,代码来源:clib.go

示例2: Build

func (s *Strip) Build(c *build.Context) error {
	params := []string{"-o"}
	params = append(params, s.Name)
	params = append(params, filepath.Join("bin", split(s.Dependencies[0], ":")))
	if err := c.Exec(Stripper(), nil, params); err != nil {
		return fmt.Errorf(err.Error())
	}
	return nil
}
开发者ID:ftrvxmtrx,项目名称:build,代码行数:9,代码来源:strip.go

示例3: Build

func (g *GenRule) Build(c *build.Context) error {
	for _, cmd := range g.Commands {
		strs := strings.Split(cmd, " ")

		if err := c.Exec(strs[0], nil, strs[1:]); err != nil {
			c.Println(err.Error())
			return err
		}
	}
	return nil
}
开发者ID:ftrvxmtrx,项目名称:build,代码行数:11,代码来源:genrule.go

示例4: Build

func (oc *ObjCopy) Build(c *build.Context) error {
	params := []string{}
	params = append(params, "-I")
	params = append(params, oc.In)
	params = append(params, "-O")
	params = append(params, oc.Out)
	params = append(params, filepath.Join("bin", split(oc.Dependencies[0], ":")))
	params = append(params, oc.Name)
	if err := c.Exec(Copier(), nil, params); err != nil {
		return fmt.Errorf(err.Error())
	}
	return nil
}
开发者ID:ftrvxmtrx,项目名称:build,代码行数:13,代码来源:objcopy.go

示例5: Build

func (y *Yacc) Build(c *build.Context) error {

	params := []string{}
	params = append(params, y.YaccOptions...)
	params = append(params, y.Sources...)

	c.Println(strings.Join(append([]string{"yacc"}, params...), " "))

	if err := c.Exec("yacc", nil, params); err != nil {
		c.Println(err.Error())
		return fmt.Errorf(y.buf.String())
	}

	return nil
}
开发者ID:ftrvxmtrx,项目名称:build,代码行数:15,代码来源:yacc.go

示例6: Build

func (mp *ManPage) Build(c *build.Context) error {
	for _, m := range mp.Sources {
		params := []string{"<"}
		params = append(params, m)

		params = append(params, ">")
		params = append(params, fmt.Sprintf("%s.html", m))

		c.Println(strings.Join(append([]string{"man2html"}, params...), " "))

		if err := c.Exec("man2html", nil, params); err != nil {
			return err
		}
	}
	return nil
}
开发者ID:ftrvxmtrx,项目名称:build,代码行数:16,代码来源:man.go

示例7: Build

func (npm *NpmPackage) Build(c *build.Context) error {
	if npm.Version == "" {
		return fmt.Errorf("NPM package %s failed to install, no version string")
	}

	params := []string{}
	params = append(params, "install")

	params = append(params, fmt.Sprintf("%[email protected]%s", npm.Name, npm.Version))
	c.Println(strings.Join(append([]string{"npm"}, params...), " "))

	if err := c.Exec("npm", nil, params); err != nil {
		c.Println(err.Error())
		return fmt.Errorf(err.Error())
	}
	return nil
}
开发者ID:ftrvxmtrx,项目名称:build,代码行数:17,代码来源:npm.go

示例8: Build

func (cb *CBin) Build(c *build.Context) error {
	c.Println(prettyprint.AsJSON(cb))
	params := []string{}
	params = append(params, cb.CompilerOptions...)
	params = append(params, cb.Sources...)

	params = append(params, cb.Includes.Includes()...)

	if err := c.Exec(Compiler(), CCENV, params); err != nil {
		return fmt.Errorf(err.Error())
	}

	ldparams := []string{"-o", cb.Name}
	ldparams = append(ldparams, cb.LinkerOptions...)
	if cb.LinkerFile != "" {
		ldparams = append(ldparams, cb.LinkerFile)
	}
	// This is done under the assumption that each src file put in this thing
	// here will comeout as a .o file
	for _, f := range cb.Sources {
		_, fname := filepath.Split(f)
		ldparams = append(ldparams, fmt.Sprintf("%s.o", fname[:strings.LastIndex(fname, ".")]))
	}

	ldparams = append(ldparams, "-L", "lib")

	for _, dep := range cb.Dependencies {
		d := split(dep, ":")
		if len(d) < 3 {
			continue
		}
		if d[:3] == "lib" {
			ldparams = append(ldparams, fmt.Sprintf("-l%s", d[3:]))
		}
	}

	if err := c.Exec(Linker(), CCENV, ldparams); err != nil {
		return fmt.Errorf(err.Error())
	}

	return nil
}
开发者ID:ftrvxmtrx,项目名称:build,代码行数:42,代码来源:cbin.go


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