Esempio n. 1
0
File: rule.go Progetto: xuy/srclib
func makeDepRules(c *config.Tree, dataDir string, existing []makex.Rule) ([]makex.Rule, error) {
	const op = depresolveOp
	var rules []makex.Rule
	for _, u := range c.SourceUnits {
		toolRef, err := toolchain.ChooseTool(depresolveOp, u.Type)
		if err != nil {
			return nil, err
		}

		rules = append(rules, &ResolveDepsRule{dataDir, u, toolRef})
	}
	return rules, nil
}
Esempio n. 2
0
File: rule.go Progetto: xuy/srclib
func makeGraphRules(c *config.Tree, dataDir string, existing []makex.Rule) ([]makex.Rule, error) {
	var rules []makex.Rule
	for _, u := range c.SourceUnits {
		// HACK: ensure backward compatibility with old behavior where
		// we assume we should `graph` if no `graph` op explicitly specified
		if _, hasGraphAll := u.Ops[graphAllOp]; hasGraphAll {
			continue
		}
		toolRef, err := toolchain.ChooseTool(graphOp, u.Type)
		if err != nil {
			return nil, err
		}
		rules = append(rules, &GraphUnitRule{dataDir, u, toolRef})
	}
	return rules, nil
}
Esempio n. 3
0
File: rule.go Progetto: abec/srclib
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
}
Esempio n. 4
0
func makeGraphRules(c *config.Tree, dataDir string, existing []makex.Rule) ([]makex.Rule, error) {
	const op = graphOp
	var rules []makex.Rule
	for _, u := range c.SourceUnits {
		toolRef := u.Ops[op]
		if toolRef == nil {
			choice, err := toolchain.ChooseTool(graphOp, u.Type)
			if err != nil {
				return nil, err
			}
			toolRef = choice
		}

		rules = append(rules, &GraphUnitRule{dataDir, u, toolRef})
	}
	return rules, nil
}
Esempio n. 5
0
func makeGraphRules(c *config.Tree, dataDir string, existing []makex.Rule, opt plan.Options) ([]makex.Rule, error) {
	const op = graphOp
	var rules []makex.Rule
	for _, u := range c.SourceUnits {
		toolRef := u.Ops[op]
		if toolRef == nil {
			choice, err := toolchain.ChooseTool(graphOp, u.Type)
			if err != nil {
				return nil, err
			}
			toolRef = choice
		}

		rules = append(rules, &GraphUnitRule{dataDir, u, toolRef, opt})
		if opt.Verbose {
			log.Printf("Created %v rule for %v %v", graphOp, toolRef.Toolchain, u.ID())
		}

	}
	return rules, nil
}
Esempio n. 6
0
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
}
Esempio n. 7
0
File: rule.go Progetto: xuy/srclib
func makeGraphAllRules(c *config.Tree, dataDir string, existing []makex.Rule) ([]makex.Rule, error) {
	// Group all graph-all units by type.
	groupedUnits := make(map[string]unit.SourceUnits)
	for _, u := range c.SourceUnits {
		if _, ok := u.Ops[graphAllOp]; !ok {
			continue
		}

		groupedUnits[u.Type] = append(groupedUnits[u.Type], u)
	}

	// Make a GraphMultiUnitsRule for each group of source units
	var rules []makex.Rule
	for unitType, units := range groupedUnits {
		toolRef, err := toolchain.ChooseTool(graphOp, unitType)
		if err != nil {
			return nil, err
		}
		rules = append(rules, &GraphMultiUnitsRule{dataDir, units, unitType, toolRef})
	}
	return rules, nil
}