Exemple #1
0
// addFiles adds a required input to cu for each file whose basename or path is
// given in names.  If base != "", it is prejoined to each name.
// The path of the input will have root/ trimmed from the beginning.
// The digest will be the complete path as written -- this will be replaced
// with the content digest in the fetcher.
func (*Package) addFiles(cu *apb.CompilationUnit, root, base string, names []string) {
	for _, name := range names {
		path := name
		if base != "" {
			path = filepath.Join(base, name)
		}
		cu.RequiredInput = append(cu.RequiredInput, &apb.CompilationUnit_FileInput{
			Info: &apb.FileInfo{
				Path:   strings.TrimPrefix(path, root+"/"),
				Digest: path,
			},
		})
	}
}
Exemple #2
0
// addFlag adds a flag and its arguments to the command line, if len(values) != 0.
func (*Package) addFlag(cu *apb.CompilationUnit, name string, values ...string) {
	if len(values) != 0 {
		cu.Argument = append(cu.Argument, name)
		cu.Argument = append(cu.Argument, values...)
	}
}
Exemple #3
0
// addEnv adds an environment variable to cu.
func (*Package) addEnv(cu *apb.CompilationUnit, name, value string) {
	cu.Environment = append(cu.Environment, &apb.CompilationUnit_Env{
		Name:  name,
		Value: value,
	})
}
Exemple #4
0
// addSource acts as addFiles, and in addition marks each trimmed path as a
// source input for the compilation.
func (p *Package) addSource(cu *apb.CompilationUnit, root, base string, names []string) {
	p.addFiles(cu, root, base, names)
	for _, in := range cu.RequiredInput[len(cu.RequiredInput)-len(names):] {
		cu.SourceFile = append(cu.SourceFile, in.Info.Path)
	}
}