compiler

package
v0.0.0-...-0fcddf3 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

func Compile(ctx context.Context, source string, opt ...Option) (string, error)

Types

type Option

type Option func(*options)

func WithCFlags

func WithCFlags(cflag ...string) Option

WithCFlags flags passed to the compiler, may contain quoted arguments. These flags are specified will append at the end of the compile arguments. That means, if some input flags are dupilicated with the standard flags, it will be ignored.

func WithCompiler

func WithCompiler(cc string) Option

func WithInclude

func WithInclude(include ...string) Option

WithInclude add the specified directory to the search path for include files

func WithOutputDir

func WithOutputDir(path string) Option

WithOutputDir the output directory. This function will try to create the output directory if specified. Please note that, the input path should contain only the directory WITHOUT the output filename. If you want to specify the output filename, you need to use WithOutputName option.

Default: . (current directory)

func WithOutputName

func WithOutputName(name string) Option

WithOutputName is the expected (base) filename produced from the source.

func WithOutputType

func WithOutputType(typ OutputType) Option

WithOutputType determine the type of output. If the input type as OutputTypeSource, this function will run as -E flag (C-Preprocessor) Available options: OutputTypeObject, OutputTypeSource

Default: OutputTypeObject

func WithTargetArch

func WithTargetArch(arch string) Option

WithTargetAch this not actually impact to the outputs format. Instead, this option will attach a -D__TARGET_ARCH_<linux_arch> into the compile args. If not specified, the compiler will try to resolve the linux arch by runtime.GOARCH

type OutputType

type OutputType string
const (
	OutputTypeObject OutputType = "o"
	OutputTypeSource OutputType = "c"
)

func (OutputType) IsValid

func (typ OutputType) IsValid() bool

Jump to

Keyboard shortcuts

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