cc

package
v0.0.0-...-211e212 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2021 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func IsActionOpt(str string) bool

IsActionOpt returns true if the given string is an ActionOpt, otherwise false.

func IsSourceFile

func IsSourceFile(f string) bool

IsSourceFile returns true if the given file is a source file recognized by GCC, otherwise false.

func NewCompileTask

func NewCompileTask(tc *types.Toolchain, ap *ArgParser, opts ...run.TaskOption) run.Task

func NewPreprocessTask

func NewPreprocessTask(tc *types.Toolchain, ap *ArgParser, opts ...run.TaskOption) run.Task

func ReplaceExtension

func ReplaceExtension(path string, newExt string) string

ReplaceExtension replaces the file extension of the given path.

func ShouldRunLocal

func ShouldRunLocal(f string) bool

ShouldRunLocal returns true if the given file should be compiled locally as a special case.

func SourceFileLanguage

func SourceFileLanguage(f string) (string, error)

Types

type ActionOpt

type ActionOpt string

func (ActionOpt) String

func (opt ActionOpt) String() string

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

func NewArgParser(ctx context.Context, args []string) *ArgParser

NewArgParser creates a new ArgsInfo struct from the provided args Args should NOT include the command (argv[0]).

func NewArgParserFromOS

func NewArgParserFromOS(ctx context.Context) *ArgParser

NewArgsInfoFromOS creates a new ArgsInfo struct from os.Args.

func (*ArgParser) ActionOpt

func (ap *ArgParser) ActionOpt() ActionOpt

ActionOpt returns the current action according to the argument list.

func (ArgParser) CanRunRemote

func (ap ArgParser) CanRunRemote() bool

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) DeepCopy

func (ap *ArgParser) DeepCopy() run.ArgParser

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

func (ap *ArgParser) PrependExplicitPICArgs(tc *types.Toolchain)

ConfigurePIC prepends -fPIC and/or -fPIE to the arguments if the toolchain has these enabled by default.

func (*ArgParser) PrependLanguageFlag

func (ap *ArgParser) PrependLanguageFlag(input string) error

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

func (ap *ArgParser) ReplaceInputPath(newPath string) error

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

func (ap *ArgParser) ReplaceOutputPath(newPath string) error

ReplaceOutputPath replaces the output path (the path after -o) with a new path.

func (*ArgParser) SetActionOpt

func (ap *ArgParser) SetActionOpt(opt ActionOpt) error

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

type RunMode

type RunMode int
const (
	Unset RunMode = iota
	RunLocal
	RunRemote
)

func (RunMode) String

func (rm RunMode) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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