本文整理汇总了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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}