server: Index | Files | Directories

package descriptor

import ""

Package descriptor provides command descriptor utilities.


Package Files

descriptor.go doc.go elf.go load.go relocate.go save.go

func AbsCmdPath Uses

func AbsCmdPath(setup *pb.CmdDescriptor_Setup) (string, error)

AbsCmdPath returns absolute command path of the setup.

func ClangClTarget Uses

func ClangClTarget(out []byte) (string, error)

ClangClTarget returns clang target from output of `clang-cl.exe -###` See ClangClVersion about the expected input.

func ClangClVersion Uses

func ClangClVersion(out []byte) (string, error)

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 ( 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.

func ClexeTarget Uses

func ClexeTarget(out []byte) (string, error)

ClexeTarget returns target string of CL.exe.

func ClexeVersion Uses

func ClexeVersion(out []byte) (string, error)

ClexeVersion returns version string of CL.exe.

func DartAnalyzerVersion Uses

func DartAnalyzerVersion(out []byte) (string, error)

DartAnalyzerVersion returns the dartanalyzer's version from output of `dartanalyzer --version`

func IsRelocatable Uses

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.

func JavaVersion Uses

func JavaVersion(out []byte) (string, error)

JavaVersion returns version string of javac.

func Load Uses

func Load(dir string) ([]*pb.CmdDescriptor, error)

func Relocate Uses

func Relocate(setup *pb.CmdDescriptor_Setup, cmdpath string) (*pb.CmdDescriptor_Setup, error)

Relocate relocates cmdpath and setup files.

func RelocateCmd Uses

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 Uses

func Save(dir string, desc *pb.CmdDescriptor) error

Save saves given cmd descriptor to a file in dir.

func Target Uses

func Target(out []byte) string

Target returns target field of command spec/selector from -dumpmachine output.

func Version Uses

func Version(dout, vout []byte) string

Version returns version field for command spec/selector from -dumpversion output and --version output.

type Config Uses

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
    ClangNeedTarget bool // true if -target is needed.

Config used for setting up cmd descriptor.

type Descriptor Uses

type Descriptor struct {

    Runner       Runner
    ToClientPath func(string) (string, error)
    PathType     pb.CmdDescriptor_PathType
    // contains filtered or unexported fields

Descriptor represents a command descriptor.

func New Uses

func New(c Config) (*Descriptor, error)

New creates cmd descriptor for c.

func (*Descriptor) Add Uses

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 (*Descriptor) CmdSetup Uses

func (d *Descriptor) CmdSetup() error

CmdSetup sets up command descriptor.

type FilePath Uses

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 Uses

func FilePathOf(pt pb.CmdDescriptor_PathType) (FilePath, error)

FilePathOf returns FilePath of path type.

type Runner Uses

type Runner func(cmds ...string) ([]byte, error)

Runner runs command and get combined output.


posixpathPackage posixpath handles posix-path (Unix style; slash separeted path).
winpathPackage 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.