Esempio n. 1
0
// CreateMakefile creates a Makefile to build a tree. The cwd should
// be the root of the tree you want to make (due to some probably
// unnecessary assumptions that CreateMaker makes).
func CreateMakefile(execOpt ToolchainExecOpt, cacheOpt BuildCacheOpt) (*makex.Makefile, error) {
	localRepo, err := OpenRepo(".")
	if err != nil {
		return nil, err
	}
	buildStore, err := buildstore.LocalRepo(localRepo.RootDir)
	if err != nil {
		return nil, err
	}

	treeConfig, err := config.ReadCached(buildStore.Commit(localRepo.CommitID))
	if err != nil {
		return nil, err
	}
	if len(treeConfig.SourceUnits) == 0 {
		log.Println("No source unit files found. Did you mean to run `src config`? (This is not an error; it just means that src didn't find anything to build or analyze here.)")
	}

	toolchainExecOptArgs, err := flagutil.MarshalArgs(&execOpt)
	if err != nil {
		return nil, err
	}

	// TODO(sqs): buildDataDir is hardcoded.
	buildDataDir := filepath.Join(buildstore.BuildDataDirName, localRepo.CommitID)
	mf, err := plan.CreateMakefile(buildDataDir, buildStore, localRepo.VCSType, treeConfig, plan.Options{
		ToolchainExecOpt: strings.Join(toolchainExecOptArgs, " "),
		NoCache:          cacheOpt.NoCacheWrite,
	})
	if err != nil {
		return nil, err
	}
	return mf, nil
}
Esempio n. 2
0
File: scan.go Progetto: sombr/ccat
func Scan(scanner toolchain.Tool, opt Options, treeConfig map[string]interface{}) ([]*unit.SourceUnit, error) {
	args, err := flagutil.MarshalArgs(&opt)
	if err != nil {
		return nil, err
	}

	if opt.Quiet {
		scanner.SetLogger(log.New(ioutil.Discard, "", 0))
	}
	var units []*unit.SourceUnit
	if err := scanner.Run(args, treeConfig, &units); err != nil {
		return nil, err
	}

	for _, u := range units {
		u.Repo = opt.Repo
	}

	return units, nil
}