toolchain

package
v0.0.0-...-56472e5 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	COMPILER_TYPE_C       = 0
	COMPILER_TYPE_ASM     = 1
	COMPILER_TYPE_CPP     = 2
	COMPILER_TYPE_ARCHIVE = 3
)
View Source
const COMPILER_FILENAME string = "compiler.yml"

Variables

This section is empty.

Functions

func ParseDepsFile

func ParseDepsFile(filename string) ([]string, error)

Parses a dependency (.d) file generated by gcc. On success, the returned string array is populated with the dependency filenames. This function expects each line of a dependency file to have the following format:

<file>.o: <file>.c a.h b.h c.h \
 d.h e.h f.h

Only the first dependent object(<file>.o) is considered.

@return []string Populated with the dependencies' filenames.

func ParseObjectLine

func ParseObjectLine(line string, r *regexp.Regexp) (error, *symbol.SymbolInfo)
This is a tricky thing to parse. Right now, I keep all the
* flags together and just store the offset, size, name and flags.

* 00012970 l .bss 00000000 _end * 00011c60 l .init_array 00000000 __init_array_start * 00011c60 l .init_array 00000000 __preinit_array_start * 000084b0 g F .text 00000034 os_arch_start * 00000000 g .debug_aranges 00000000 __HeapBase * 00011c88 g O .data 00000008 g_os_task_list * 000082cc g F .text 0000004c os_idle_task * 000094e0 g F .text 0000002e .hidden __gnu_uldivmod_helper * 00000000 g .svc_table 00000000 SVC_Count * 000125e4 g O .bss 00000004 g_console_is_init * 00009514 g F .text 0000029c .hidden __divdi3 * 000085a8 g F .text 00000054 os_eventq_put

func RunJob

func RunJob(record CompilerJob) error

Types

type CompileCommand

type CompileCommand struct {
	Directory string `json:"directory"`
	Command   string `json:"command"`
	File      string `json:"file"`
}

type Compiler

type Compiler struct {
	LinkerScripts []string
	// contains filtered or unexported fields
}

func NewCompiler

func NewCompiler(compilerDir string, dstDir string,
	buildProfile string) (*Compiler, error)

func (*Compiler) AddDeps

func (c *Compiler) AddDeps(depFilenames ...string)

func (*Compiler) AddInfo

func (c *Compiler) AddInfo(info *CompilerInfo)

func (*Compiler) BuildSplitArchiveCmd

func (c *Compiler) BuildSplitArchiveCmd(archiveFile string) string

calculates the command-line invocation necessary to build a split all archive from the collection of archive files

func (*Compiler) CompileArchive

func (c *Compiler) CompileArchive(archiveFile string) error

Archives the specified static library.

@param archiveFile The filename of the library to archive. @param objFiles An array of the source .o filenames.

func (*Compiler) CompileArchiveCmd

func (c *Compiler) CompileArchiveCmd(archiveFile string,
	objFiles []string) []string

Calculates the command-line invocation necessary to archive the specified static library.

@param archiveFile The filename of the library to archive. @param objFiles An array of the source .o filenames.

@return The command string.

func (*Compiler) CompileAs

func (c *Compiler) CompileAs(filename string) error

Compiles all assembly files matching the specified file glob.

@param match The file glob specifying which assembly files

to compile.

func (*Compiler) CompileBinary

func (c *Compiler) CompileBinary(dstFile string, options map[string]bool,
	objFiles []string, keepSymbols []string, elfLib string) error

Links the specified elf file.

@param dstFile The filename of the destination elf file to

link.

@param options Some build options specifying how the elf file

gets generated.

@param objFiles An array of the source .o and .a filenames.

func (*Compiler) CompileBinaryCmd

func (c *Compiler) CompileBinaryCmd(dstFile string, options map[string]bool,
	objFiles []string, keepSymbols []string, elfLib string) []string

Calculates the command-line invocation necessary to link the specified elf file.

@param dstFile The filename of the destination elf file to

link.

@param options Some build options specifying how the elf file

gets generated.

@param objFiles An array of the source .o and .a filenames.

@return (success) The command tokens.

func (*Compiler) CompileC

func (c *Compiler) CompileC(filename string) error

Compiles all C files matching the specified file glob.

func (*Compiler) CompileCpp

func (c *Compiler) CompileCpp(filename string) error

Compiles all CPP files

func (*Compiler) CompileElf

func (c *Compiler) CompileElf(binFile string, objFiles []string,
	keepSymbols []string, elfLib string) error

Links the specified elf file and generates some associated artifacts (lst, bin, and map files).

@param binFile The filename of the destination elf file to

link.

@param options Some build options specifying how the elf file

gets generated.

@param objFiles An array of the source .o and .a filenames.

func (*Compiler) CompileFile

func (c *Compiler) CompileFile(file string, compilerType int) error

Compile the specified C or assembly file.

@param file The filename of the source file to compile. @param compilerType One of the COMPILER_TYPE_[...] constants.

func (*Compiler) CompileFileCmd

func (c *Compiler) CompileFileCmd(file string, compilerType int) (
	[]string, error)

Calculates the command-line invocation necessary to compile the specified C or assembly file.

@param file The filename of the source file to compile. @param compilerType One of the COMPILER_TYPE_[...] constants.

@return (success) The command arguments.

func (*Compiler) ConvertBinToHex

func (c *Compiler) ConvertBinToHex(inFile string, outFile string, baseAddr int) error

func (*Compiler) CopyArchive

func (c *Compiler) CopyArchive(filename string) error

Copies all archive files matching the specified file glob.

@param match The file glob specifying which assembly files

to compile.

func (*Compiler) CopySymbols

func (c *Compiler) CopySymbols(infile string, outfile string, sm *symbol.SymbolMap) error

func (*Compiler) CopySymbolsCmd

func (c *Compiler) CopySymbolsCmd(infile string, outfile string, sm *symbol.SymbolMap) []string

func (*Compiler) DstDir

func (c *Compiler) DstDir() string

func (*Compiler) GenDepsForFile

func (c *Compiler) GenDepsForFile(file string, compilerType int) error

Generates a dependency Makefile (.d) for the specified source file.

@param file The name of the source file.

func (*Compiler) GetArPath

func (c *Compiler) GetArPath() string

func (*Compiler) GetAsPath

func (c *Compiler) GetAsPath() string

func (*Compiler) GetCcPath

func (c *Compiler) GetCcPath() string

func (*Compiler) GetCompileCommands

func (c *Compiler) GetCompileCommands() []CompileCommand

func (*Compiler) GetCompilerInfo

func (c *Compiler) GetCompilerInfo() CompilerInfo

func (*Compiler) GetCppPath

func (c *Compiler) GetCppPath() string

func (*Compiler) GetLdResolveCircularDeps

func (c *Compiler) GetLdResolveCircularDeps() bool

func (*Compiler) GetLocalCompilerInfo

func (c *Compiler) GetLocalCompilerInfo() CompilerInfo

func (*Compiler) GetObjcopyPath

func (c *Compiler) GetObjcopyPath() string

func (*Compiler) GetObjdumpPath

func (c *Compiler) GetObjdumpPath() string

func (*Compiler) GetSizePath

func (c *Compiler) GetSizePath() string

func (*Compiler) ParseLibrary

func (c *Compiler) ParseLibrary(libraryFile string) (error, []byte)

func (*Compiler) ParseLibraryCmd

func (c *Compiler) ParseLibraryCmd(libraryFile string) []string

func (*Compiler) PrintSize

func (c *Compiler) PrintSize(elfFilename string) (string, error)

func (*Compiler) RecursiveCollectEntries

func (c *Compiler) RecursiveCollectEntries(cType int,
	ignDirs []string) ([]CompilerJob, error)

func (*Compiler) RenameSymbols

func (c *Compiler) RenameSymbols(sm *symbol.SymbolMap, libraryFile string, ext string) error

func (*Compiler) RenameSymbolsCmd

func (c *Compiler) RenameSymbolsCmd(
	sm *symbol.SymbolMap, libraryFile string, ext string) []string

func (*Compiler) SetSrcDir

func (c *Compiler) SetSrcDir(srcDir string)

func (*Compiler) ShouldIgnoreFile

func (c *Compiler) ShouldIgnoreFile(file string) bool

func (*Compiler) SkipSourceFile

func (c *Compiler) SkipSourceFile(srcFile string) error

Skips compilation of the specified C or assembly file, but adds the name of the object file that would have been generated to the compiler's list of object files. This function is used when the object file is already up to date, so no compilation is necessary. The name of the object file should still be remembered so that it gets linked in to the final library or executable.

type CompilerInfo

type CompilerInfo struct {
	Includes    []string
	Cflags      []string
	CXXflags    []string
	Lflags      []string
	Aflags      []string
	IgnoreFiles []*regexp.Regexp
	IgnoreDirs  []*regexp.Regexp
}

func NewCompilerInfo

func NewCompilerInfo() *CompilerInfo

func (*CompilerInfo) AddCflags

func (ci *CompilerInfo) AddCflags(cflags []string)

func (*CompilerInfo) AddCompilerInfo

func (ci *CompilerInfo) AddCompilerInfo(newCi *CompilerInfo)

type CompilerJob

type CompilerJob struct {
	Filename     string
	Compiler     *Compiler
	CompilerType int
}

type DepTracker

type DepTracker struct {
	// Most recent .o modification time.
	MostRecentName string
	MostRecentTime time.Time
	// contains filtered or unexported fields
}

func NewDepTracker

func NewDepTracker(c *Compiler) DepTracker

func (*DepTracker) ArchiveRequired

func (tracker *DepTracker) ArchiveRequired(archiveFile string,
	objFiles []string) (bool, error)

Determines if the specified static library needs to be rearchived. The library needs to be archived if any of the following is true:

  • The destination library file does not exist.
  • The existing library file was built with a different compiler invocation.
  • One or more source object files has a newer modification time than the library file.

func (*DepTracker) CompileRequired

func (tracker *DepTracker) CompileRequired(srcFile string,
	compilerType int) (bool, error)

Determines if the specified C or assembly file needs to be built. A compile is required if any of the following is true:

  • The destination object file does not exist.
  • The existing object file was built with a different compiler invocation.
  • The source file has a newer modification time than the object file.
  • One or more included header files has a newer modification time than the object file.

func (*DepTracker) CopyRequired

func (tracker *DepTracker) CopyRequired(srcFile string) (bool, error)

Determines if the specified static library needs to be copied. The library needs to be archived if any of the following is true:

  • The destination library file does not exist.
  • Source object files has a newer modification time than the target file.

func (*DepTracker) LinkRequired

func (tracker *DepTracker) LinkRequired(dstFile string,
	options map[string]bool, objFiles []string,
	keepSymbols []string, elfLib string) (bool, error)

Determines if the specified elf file needs to be linked. Linking is necessary if the elf file does not exist or has an older modification time than any source object or library file. Determines if the specified static library needs to be rearchived. The library needs to be archived if any of the following is true:

  • The destination library file does not exist.
  • The existing library file was built with a different compiler invocation.
  • One or more source object files has a newer modification time than the library file.

func (*DepTracker) ProcessFileTime

func (tracker *DepTracker) ProcessFileTime(file string) error

Updates the dependency tracker's most recent timestamp according to the modification time of the specified file. If the specified file is older than the tracker's currently most-recent time, this function has no effect.

func (*DepTracker) RomElfBuildRequired

func (tracker *DepTracker) RomElfBuildRequired(dstFile string, elfFile string,
	archFiles []string) (bool, error)

Building a ROM elf is used for shared application linking. * A ROM elf requires a rebuild if any of archives (.a files) are newer * than the rom elf, or if the elf file is newer than the rom_elf

func (*DepTracker) SetMostRecent

func (d *DepTracker) SetMostRecent(name string, t time.Time)

Jump to

Keyboard shortcuts

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