Documentation ¶
Index ¶
- Constants
- func ParseDepsFile(filename string) ([]string, error)
- func ParseObjectLine(line string, r *regexp.Regexp) (error, *symbol.SymbolInfo)
- func RunJob(record CompilerJob) error
- type CompileCommand
- type Compiler
- func (c *Compiler) AddDeps(depFilenames ...string)
- func (c *Compiler) AddInfo(info *CompilerInfo)
- func (c *Compiler) BuildSplitArchiveCmd(archiveFile string) string
- func (c *Compiler) CompileArchive(archiveFile string) error
- func (c *Compiler) CompileArchiveCmd(archiveFile string, objFiles []string) []string
- func (c *Compiler) CompileAs(filename string) error
- func (c *Compiler) CompileBinary(dstFile string, options map[string]bool, objFiles []string, ...) error
- func (c *Compiler) CompileBinaryCmd(dstFile string, options map[string]bool, objFiles []string, ...) []string
- func (c *Compiler) CompileC(filename string) error
- func (c *Compiler) CompileCpp(filename string) error
- func (c *Compiler) CompileElf(binFile string, objFiles []string, keepSymbols []string, elfLib string) error
- func (c *Compiler) CompileFile(file string, compilerType int) error
- func (c *Compiler) CompileFileCmd(file string, compilerType int) ([]string, error)
- func (c *Compiler) ConvertBinToHex(inFile string, outFile string, baseAddr int) error
- func (c *Compiler) CopyArchive(filename string) error
- func (c *Compiler) CopySymbols(infile string, outfile string, sm *symbol.SymbolMap) error
- func (c *Compiler) CopySymbolsCmd(infile string, outfile string, sm *symbol.SymbolMap) []string
- func (c *Compiler) DstDir() string
- func (c *Compiler) GenDepsForFile(file string, compilerType int) error
- func (c *Compiler) GetArPath() string
- func (c *Compiler) GetAsPath() string
- func (c *Compiler) GetCcPath() string
- func (c *Compiler) GetCompileCommands() []CompileCommand
- func (c *Compiler) GetCompilerInfo() CompilerInfo
- func (c *Compiler) GetCppPath() string
- func (c *Compiler) GetLdResolveCircularDeps() bool
- func (c *Compiler) GetLocalCompilerInfo() CompilerInfo
- func (c *Compiler) GetObjcopyPath() string
- func (c *Compiler) GetObjdumpPath() string
- func (c *Compiler) GetSizePath() string
- func (c *Compiler) ParseLibrary(libraryFile string) (error, []byte)
- func (c *Compiler) ParseLibraryCmd(libraryFile string) []string
- func (c *Compiler) PrintSize(elfFilename string) (string, error)
- func (c *Compiler) RecursiveCollectEntries(cType int, ignDirs []string) ([]CompilerJob, error)
- func (c *Compiler) RenameSymbols(sm *symbol.SymbolMap, libraryFile string, ext string) error
- func (c *Compiler) RenameSymbolsCmd(sm *symbol.SymbolMap, libraryFile string, ext string) []string
- func (c *Compiler) SetSrcDir(srcDir string)
- func (c *Compiler) ShouldIgnoreFile(file string) bool
- func (c *Compiler) SkipSourceFile(srcFile string) error
- type CompilerInfo
- type CompilerJob
- type DepTracker
- func (tracker *DepTracker) ArchiveRequired(archiveFile string, objFiles []string) (bool, error)
- func (tracker *DepTracker) CompileRequired(srcFile string, compilerType int) (bool, error)
- func (tracker *DepTracker) CopyRequired(srcFile string) (bool, error)
- func (tracker *DepTracker) LinkRequired(dstFile string, options map[string]bool, objFiles []string, ...) (bool, error)
- func (tracker *DepTracker) ProcessFileTime(file string) error
- func (tracker *DepTracker) RomElfBuildRequired(dstFile string, elfFile string, archFiles []string) (bool, error)
- func (d *DepTracker) SetMostRecent(name string, t time.Time)
Constants ¶
const ( COMPILER_TYPE_C = 0 COMPILER_TYPE_ASM = 1 COMPILER_TYPE_CPP = 2 COMPILER_TYPE_ARCHIVE = 3 )
const COMPILER_FILENAME string = "compiler.yml"
Variables ¶
This section is empty.
Functions ¶
func ParseDepsFile ¶
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 ¶
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 Compiler ¶
type Compiler struct { LinkerScripts []string // contains filtered or unexported fields }
func NewCompiler ¶
func (*Compiler) AddInfo ¶
func (c *Compiler) AddInfo(info *CompilerInfo)
func (*Compiler) BuildSplitArchiveCmd ¶
calculates the command-line invocation necessary to build a split all archive from the collection of archive files
func (*Compiler) CompileArchive ¶
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 ¶
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 ¶
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) CompileCpp ¶
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 ¶
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 ¶
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 (*Compiler) CopyArchive ¶
Copies all archive files matching the specified file glob.
@param match The file glob specifying which assembly files
to compile.
func (*Compiler) CopySymbols ¶
func (*Compiler) CopySymbolsCmd ¶
func (*Compiler) GenDepsForFile ¶
Generates a dependency Makefile (.d) for the specified source file.
@param file The name of the source file.
func (*Compiler) GetCompileCommands ¶
func (c *Compiler) GetCompileCommands() []CompileCommand
func (*Compiler) GetCompilerInfo ¶
func (c *Compiler) GetCompilerInfo() CompilerInfo
func (*Compiler) GetCppPath ¶
func (*Compiler) GetLdResolveCircularDeps ¶
func (*Compiler) GetLocalCompilerInfo ¶
func (c *Compiler) GetLocalCompilerInfo() CompilerInfo
func (*Compiler) GetObjcopyPath ¶
func (*Compiler) GetObjdumpPath ¶
func (*Compiler) GetSizePath ¶
func (*Compiler) ParseLibraryCmd ¶
func (*Compiler) RecursiveCollectEntries ¶
func (c *Compiler) RecursiveCollectEntries(cType int, ignDirs []string) ([]CompilerJob, error)
func (*Compiler) RenameSymbols ¶
func (*Compiler) RenameSymbolsCmd ¶
func (*Compiler) ShouldIgnoreFile ¶
func (*Compiler) SkipSourceFile ¶
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 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)