import "go.chromium.org/goma/server/command/descriptor"
Package descriptor provides command descriptor utilities.
descriptor.go doc.go elf.go load.go relocate.go save.go
func AbsCmdPath(setup *pb.CmdDescriptor_Setup) (string, error)
AbsCmdPath returns absolute command path of the setup.
ClangClTarget returns clang target from output of `clang-cl.exe -###` See ClangClVersion about the expected input.
ClangClVersion returns clang version from output of `clang-cl.exe -###`.
`clang-cl -###` output is like the following:
clang version 3.5.0 (trunk 225621) Target: i686-pc-windows-msvc clang version 6.0.0 (trunk 308728) Target: x86_64-pc-windows-msvc clang version 9.0.0 (https://github.com/llvm/llvm-project/ 67510fac36d27b2e22c7cd955fc167136b737b93) Target: x86_64-pc-windows-msvc Thread model: posix InstalledDir: /var/tmp/clang/third_party/llvm-build/Release+Asserts/bin
Note that endline might be CRLF.
ClexeTarget returns target string of CL.exe.
ClexeVersion returns version string of CL.exe.
DartAnalyzerVersion returns the dartanalyzer's version from output of `dartanalyzer --version`
func IsRelocatable(setup *pb.CmdDescriptor_Setup) (bool, error)
IsRelocatable returns true if this setup can be relocated to where client put a compiler or a subprogram. setup must have valid path type.
JavaVersion returns version string of javac.
func Load(dir string) ([]*pb.CmdDescriptor, error)
func Relocate(setup *pb.CmdDescriptor_Setup, cmdpath string) (*pb.CmdDescriptor_Setup, error)
Relocate relocates cmdpath and setup files.
func RelocateCmd(cmdPath string, setup *pb.CmdDescriptor_Setup, subprogSetups map[string]*pb.CmdDescriptor_Setup) ([]*pb.FileSpec, error)
RelocateCmd relocates main program and subprograms if necessary. subprogSetups is a map from subprogram client path to subprogram setup. It returns commands' FileSpec to be used. Actual command path will be first FileSpec's Path.
func Save(dir string, desc *pb.CmdDescriptor) error
Save saves given cmd descriptor to a file in dir.
Target returns target field of command spec/selector from -dumpmachine output.
Version returns version field for command spec/selector from -dumpversion output and --version output.
type Config struct { Key string // Key used for selection. Filename string // relative to pwd (prefix) in server path AbsoluteBinaryHashFrom string // use Filename for binary hash if emtpy Target string // cross target if specified Runner Runner ToClientPath func(string) (string, error) PathType pb.CmdDescriptor_PathType // compiler specific // https://clang.llvm.org/docs/CrossCompilation.html#target-triple ClangNeedTarget bool // true if -target is needed. }
Config used for setting up cmd descriptor.
type Descriptor struct { *pb.CmdDescriptor Runner Runner ToClientPath func(string) (string, error) PathType pb.CmdDescriptor_PathType // contains filtered or unexported fields }
Descriptor represents a command descriptor.
func New(c Config) (*Descriptor, error)
New creates cmd descriptor for c.
func (d *Descriptor) Add(fname string) error
Add adds fname for command. fname should be absolute path, or relative to cwd. It will emit relative path to command if cmd is relocatable. It just adds fname as is. i.e. not resolve symlink, resolve shared obj etc.
func (d *Descriptor) CmdSetup() error
CmdSetup sets up command descriptor.
type FilePath interface { // IsAbs reports whether the path is absolute. IsAbs(path string) bool // Base returns the last element of path, typically // the filename. Base(string) string // Dir returns all but the last element of path, typically // the path's directory. // Different filepath.Dir, it won't clean "..". Dir(string) string // Join joins any number of path elements into a single path. // Different filepath.Dir, it won't clean "..". Join(...string) string // Rel returns a relative path that is lexically equivalent // to targpath when joined to basepath with an intervening separator. Rel(basepath, targpath string) (string, error) // Clean returns the shortest path name equivalent to path by purely lexical processing. Clean(path string) string // SplitElem splits path by path separator. SplitElem(path string) []string // PathSep returns the path separator. PathSep() string }
FilePath provides client's filepath.
func FilePathOf(pt pb.CmdDescriptor_PathType) (FilePath, error)
FilePathOf returns FilePath of path type.
Runner runs command and get combined output.
Path | Synopsis |
---|---|
posixpath | Package posixpath handles posix-path (Unix style; slash separeted path). |
winpath | Package winpath handles windows-path (backslash separated path). |
Package descriptor imports 17 packages (graph) and is imported by 2 packages. Updated 2020-10-27. Refresh now. Tools for package owners.