descriptor

package
v0.0.19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2021 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Overview

Package descriptor provides command descriptor utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsCmdPath

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

AbsCmdPath returns absolute command path of the setup.

func ClangClTarget

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

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

func ClangClVersion

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

func ClexeTarget

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

ClexeTarget returns target string of CL.exe.

func ClexeVersion

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

ClexeVersion returns version string of CL.exe.

func DartAnalyzerVersion added in v0.0.8

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

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

func IsRelocatable

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

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

JavaVersion returns version string of javac.

func Load

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

func Relocate

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

Relocate relocates cmdpath and setup files.

func RelocateCmd

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

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

Save saves given cmd descriptor to a file in dir.

func Target

func Target(out []byte) string

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

func Version

func Version(dout, vout []byte) string

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

Types

type Config

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.
	WindowsCross    bool
}

Config used for setting up cmd descriptor.

type 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

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

New creates cmd descriptor for c.

func (*Descriptor) Add

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

func (d *Descriptor) CmdSetup() error

CmdSetup sets up command descriptor.

type FilePath

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

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

FilePathOf returns FilePath of path type.

type Runner

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

Runner runs command and get combined output.

Directories

Path Synopsis
Package posixpath handles posix-path (Unix style; slash separeted path).
Package posixpath handles posix-path (Unix style; slash separeted path).
Package winpath handles windows-path (backslash separated path).
Package winpath handles windows-path (backslash separated path).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL