Documentation ¶
Index ¶
- Variables
- func IsActionOpt(str string) bool
- func IsSourceFile(f string) bool
- func NewCompileTask(tc *types.Toolchain, ap *ArgParser, opts ...run.TaskOption) run.Task
- func NewPreprocessTask(tc *types.Toolchain, ap *ArgParser, opts ...run.TaskOption) run.Task
- func ReplaceExtension(path string, newExt string) string
- func ShouldRunLocal(f string) bool
- func SourceFileLanguage(f string) (string, error)
- type ActionOpt
- type ArgParser
- func (ap *ArgParser) ActionOpt() ActionOpt
- func (ap ArgParser) CanRunRemote() bool
- func (ap *ArgParser) ConfigurePreprocessorOptions()
- func (ap *ArgParser) DeepCopy() run.ArgParser
- func (a *ArgParser) MarshalLogObject(enc zapcore.ObjectEncoder) error
- func (ap *ArgParser) Parse()
- func (ap *ArgParser) PrependExplicitPICArgs(tc *types.Toolchain)
- func (ap *ArgParser) PrependLanguageFlag(input string) error
- func (ap *ArgParser) RemoveLocalArgs()
- func (ap *ArgParser) ReplaceInputPath(newPath string) error
- func (ap *ArgParser) ReplaceOutputPath(newPath string) error
- func (ap *ArgParser) SetActionOpt(opt ActionOpt) error
- type CCFinder
- type RunMode
Constants ¶
This section is empty.
Variables ¶
var ( ProfileArgs = mapset.NewSet( "-fprofile-arcs", "-ftest-coverage", "--coverage", "-fprofile-correction", ) ProfilePrefixArgs = []string{ "-fprofile-generate", "-fprofile-use", "-fauto-profile", } LocalArgsWithValues = mapset.NewSet( "-D", "-I", "-U", "-L", "-l", "-MF", "-MT", "-MQ", "-include", "-imacros", "-iprefix", "-iwithprefix", "-isystem", "-imultilib", "-iplugindir", "-iquote", "-isysroot", "-iwithprefixbefore", "-idirafter", ) LocalArgsNoValues = mapset.NewSet( "-undef", "-nostdinc", "-nostdinc++", "-MD", "-MMD", "-MG", "-MP", ) PICArgs = mapset.NewSet( "-fPIC", "-fPIE", "-fpic", "-fpie", "-fno-pic", "-fno-pie", "-fno-PIC", "-fno-PIE", ) LocalPrefixArgs = []string{ "-Wp,", "-Wl,", "-D", "-U", "-I", "-l", "-L", "-MF", "-MT", "-MQ", "-isystem", "-stdlib", } LinkTimeOptimizationFlags = []string{ "-flto", "-flto-partition", "-flto-compression-level", } Compile ActionOpt = "-c" Preprocess ActionOpt = "-E" GenAssembly ActionOpt = "-S" None ActionOpt = "" )
Functions ¶
func IsActionOpt ¶
IsActionOpt returns true if the given string is an ActionOpt, otherwise false.
func IsSourceFile ¶
IsSourceFile returns true if the given file is a source file recognized by GCC, otherwise false.
func NewCompileTask ¶
func NewPreprocessTask ¶
func ReplaceExtension ¶
ReplaceExtension replaces the file extension of the given path.
func ShouldRunLocal ¶
ShouldRunLocal returns true if the given file should be compiled locally as a special case.
func SourceFileLanguage ¶
Types ¶
type ArgParser ¶
type ArgParser struct { Args []string Mode RunMode InputArgIndex int OutputArgIndex int FlagIndexMap map[string]int // contains filtered or unexported fields }
ArgParser represents GCC arguments.
func NewArgParser ¶
NewArgParser creates a new ArgsInfo struct from the provided args Args should NOT include the command (argv[0]).
func NewArgParserFromOS ¶
NewArgsInfoFromOS creates a new ArgsInfo struct from os.Args.
func (ArgParser) CanRunRemote ¶
func (*ArgParser) ConfigurePreprocessorOptions ¶
func (ap *ArgParser) ConfigurePreprocessorOptions()
ConfigurePreprocessorOptions expands gcc preprocessor arguments according to the following rules: 1. Replace "-Wp,-X,-Y,-Z" with "-X -Y -Z" 2. Replace "-Wp,-MD,path" or "-Wp,-MMD,path" with "-M[M]D -MF path"
func (*ArgParser) MarshalLogObject ¶
func (a *ArgParser) MarshalLogObject(enc zapcore.ObjectEncoder) error
func (*ArgParser) Parse ¶
func (ap *ArgParser) Parse()
Parse will parse the arguments in argsInfo.Args and store indexes of several flags and values. Most of this logic is borrowed from distcc, with some adjustments.
func (*ArgParser) PrependExplicitPICArgs ¶
ConfigurePIC prepends -fPIC and/or -fPIE to the arguments if the toolchain has these enabled by default.
func (*ArgParser) PrependLanguageFlag ¶
PrependLanguageFlag adds the necessary -x <lang> argument. Used when replacing the input argument with '-'
func (*ArgParser) RemoveLocalArgs ¶
func (ap *ArgParser) RemoveLocalArgs()
RemoveLocalArgs removes arguments that do not need to be sent to the remote agent for compiling. These args are related to preprocessing and linking.
func (*ArgParser) ReplaceInputPath ¶
ReplaceInputPath replaces the input path (the path after the action opt) with a new path. This function will append '-ffile-prefix-map=old=new' to the args list. This definitely will not work with paths with spaces
func (*ArgParser) ReplaceOutputPath ¶
ReplaceOutputPath replaces the output path (the path after -o) with a new path.
func (*ArgParser) SetActionOpt ¶
SetActionOpt modifies the arguments to replace the action opt with a new one.
type CCFinder ¶
type CCFinder struct{}
func (CCFinder) FindToolchains ¶
func (f CCFinder) FindToolchains(ctx context.Context, opts ...toolchains.FindOption) *toolchains.Store