コード例 #1
0
ファイル: rule.go プロジェクト: sombr/ccat
func makeDepRules(c *config.Tree, dataDir string, existing []makex.Rule, opt plan.Options) ([]makex.Rule, error) {
	const op = depresolveOp
	var rules []makex.Rule
	for _, u := range c.SourceUnits {
		toolRef := u.Ops[op]
		if toolRef == nil {
			choice, err := toolchain.ChooseTool(depresolveOp, u.Type)
			if err != nil {
				return nil, err
			}
			toolRef = choice
		}

		rules = append(rules, &ResolveDepsRule{dataDir, u, toolRef, opt})
	}
	return rules, nil
}
コード例 #2
0
ファイル: format_cmd.go プロジェクト: sombr/ccat
func (c *FmtCmd) Get() (string, error) {
	t, err := toolchain.ChooseTool(fmtOpt, c.UnitType)
	if err != nil {
		return "", err
	}
	// Only call as a program for now.
	tool, err := toolchain.OpenTool(t.Toolchain, t.Subcmd, toolchain.AsProgram)
	if err != nil {
		return "", err
	}
	cmd, err := tool.Command()
	if err != nil {
		return "", err
	}
	out := &bytes.Buffer{}
	cmd.Stdout = out
	cmd.Args = append(cmd.Args, "--unit-type", c.UnitType, "--object-type", c.ObjectType, "--format", c.Format, "--object", c.Object)
	if err := cmd.Run(); err != nil {
		return "", err
	}
	return out.String(), nil
}