commands

package
v0.0.0-...-6155d41 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CompileCommand = &cli.Command{
	Name:        "compile",
	Aliases:     []string{"c"},
	Usage:       "gecko compile ...sources",
	Description: compileHelp,
	Action: func(ctx *cli.Context) error {
		if ctx.Args().Len() == 0 {
			println("No sources provided")
			return nil
		}

		for _, pos := range ctx.Args().Slice() {
			outFile := compiler.Compile(pos, &config.CompileCfg{
				Arch:     ctx.String("target-arch"),
				Platform: ctx.String("target-platform"),
				Vendor:   ctx.String("target-vendor"),
				CFlags:   []string{},
				CLFlags:  []string{},
				CObjects: []string{},
				Ctx:      ctx,
			})

			if outFile != "" {
				CopyFile(outFile, pos+".o")
			}
		}

		compiler.PrintErrorSummary()

		return nil
	},
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:  "output-dir",
			Value: ".",
			Usage: "Output directory path " + color.HiYellowString("(warning: this overrides the build configuration's output directory)"),
		},
		&cli.StringFlag{
			Name:  "type",
			Value: "executable",
			Usage: "Output type for program. (executable | library)",
		},
		&cli.StringFlag{
			Name:  "backend",
			Value: "llvm",
			Usage: "The compilation backend to use (llvm | c)",
		},
		&cli.StringFlag{
			Name:  "target-arch",
			Value: runtime.GOARCH,
			Usage: "The compilation target architecture",
		},
		&cli.StringFlag{
			Name:  "target-platform",
			Value: runtime.GOOS,
			Usage: "The compilation target operating system",
		},
		&cli.StringFlag{
			Name:  "target-vendor",
			Value: "",
			Usage: "The compilation target vendor of file type",
		},
		&cli.BoolFlag{
			Name:  "print-ir",
			Value: false,
			Usage: "Print the file's LLVM IR",
		},
		&cli.BoolFlag{
			Name:  "ir-only",
			Value: false,
			Usage: "Only compile to IR",
		},
		&cli.StringSliceFlag{
			Name:  "llc-args",
			Value: &cli.StringSlice{},
			Usage: "Pass arguments to underlying llc command",
		},
	},
}
View Source
var GeckoCommands = []*cli.Command{
	CompileCommand,
}

Functions

func CopyFile

func CopyFile(src, dst string) (err error)

CopyFile copies a file from src to dst. If src and dst files exist, and are the same, then return success. Otherise, attempt to create a hard link between the two files. If that fail, copy the file contents from src to dst.

Types

This section is empty.

Jump to

Keyboard shortcuts

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