adamod

package
v0.0.0-...-5f788bf Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultVariableSet = VariableSet{
	"BuildDir": "${ModulePath}/.build",
	"ObjDir":   "${BuildDir}/obj",
	"LibDir":   "${BuildDir}/lib",
	"ExeDir":   "${BuildDir}/exe",
	"GprDir":   "${BuildDir}/gpr",
}

DefaultVariableSet is the default variable set

Functions

func ModuleName

func ModuleName(name string) string

ModuleName returns the module name part of the builder part name

func PartID

func PartID(name string) string

PartID returns the id part of the partname

Types

type AdaMod

type AdaMod struct {

	// Name of the modules
	Name       string
	Dictionary string
	Parts      []*ModulePart
	// contains filtered or unexported fields
}

AdaMod is a description of an ada module

func (*AdaMod) DefaultExePartID

func (a *AdaMod) DefaultExePartID() (string, error)

DefaultExePartID returns the fully qualified part id of the default part of the module

func (*AdaMod) DefaultLibraryPartID

func (a *AdaMod) DefaultLibraryPartID() (string, error)

DefaultLibraryPartID returns the fully qualified part id of the default part of the module

func (*AdaMod) Dump

func (a *AdaMod) Dump()

Dump dumps internal data to the logger

func (*AdaMod) FqPartID

func (a *AdaMod) FqPartID(pid string) string

FqPartID returns the fully qualified part id of the part

func (*AdaMod) Part

func (a *AdaMod) Part(id string) *ModulePart

Part returns the part associated with id, or nil else

type Builder

type Builder struct {
	Module    *AdaMod
	Variables VariableSet
	Parts     PartSet
	// contains filtered or unexported fields
}

Builder knows how to build gpr files and ada artifacts

func NewBuilder

func NewBuilder(r *Registry, t *Toolchain, ModulePath string) (*Builder, error)

NewBuilder creates a new Builder for the module at ModulePath

func (*Builder) Build

func (b *Builder) Build(parts ...string) error

Build builds parts defined as fully qualified part names

func (*Builder) CompileFile

func (b *Builder) CompileFile(filename string) error

CompileFile compiles one file part of the b.Module

func (*Builder) FindBuilderPart

func (b *Builder) FindBuilderPart(filename string) (*BuilderPart, string, error)

FindBuilderPart returns the builder part that contains the filename

func (*Builder) Get

func (b *Builder) Get(varName string) string

Get a variable value

func (*Builder) GetBuilderParts

func (b *Builder) GetBuilderParts(parts ...string) ([]*BuilderPart, error)

GetBuilderParts returns the builder parts that are associated with the part names. The parts will be fully loaded

func (*Builder) PrettyPrint

func (b *Builder) PrettyPrint(filename string) error

PrettyPrint formats the code of the files in filePath. If no files specified, the entire module is formatted

func (*Builder) StartVsCode

func (b *Builder) StartVsCode(partname string, generateTasks, generateSettings, generateLaunch bool) error

StartVsCode starts vscode and possibly generates files if told so

type BuilderPart

type BuilderPart struct {
	Name          string // 'test_runner', 'libjson'...
	ModuleRef     *ModulePart
	SrcDirsAbs    []string
	ImportedParts []*BuilderPart
	Builder       *Builder
}

BuilderPart contains information about a specific part in the module There exists a tree structure of BuilderParts that reflect the structure of ModuleParts.

func (*BuilderPart) AllFiles

func (bp *BuilderPart) AllFiles() ([]string, error)

AllFiles returns all files in the BuilderPart

func (*BuilderPart) CollectBuilderParts

func (bp *BuilderPart) CollectBuilderParts(set *PartSet) error

CollectBuilderParts collects the parts needed to build the part.

func (*BuilderPart) Dictionaries

func (bp *BuilderPart) Dictionaries(dictionaries *hit) error

Dictionaries returns the conglomerated list of dictionaries affecting this builder part

func (*BuilderPart) FindFile

func (bp *BuilderPart) FindFile(filename string) (string, error)

FindFile returns the full path of the filename, or the empty string, if the filename is beneath any of the source directories specified in the part.

func (*BuilderPart) FqPartName

func (bp *BuilderPart) FqPartName() string

FqPartName returns the fully qualified partname in the form <moduleName>:<partName>

func (*BuilderPart) GenerateAllGprs

func (bp *BuilderPart) GenerateAllGprs() error

GenerateAllGprs generates all the neccessary GPR files needed to build this part

func (*BuilderPart) GenerateGpr

func (bp *BuilderPart) GenerateGpr() error

GenerateGpr generates a GPR file

func (*BuilderPart) Get

func (bp *BuilderPart) Get(varname string) string

Get a variable name.

func (*BuilderPart) GprFile

func (bp *BuilderPart) GprFile() string

GprFile returns the corresponding gpr filename for the part

func (*BuilderPart) LinkerOptions

func (bp *BuilderPart) LinkerOptions(options *hit) error

LinkerOptions returns the conglomerated list of linker options

type ConfigData

type ConfigData struct {
	AdaModulesPath string
	ToolchainPath  string
}

ConfigData ...

type LaunchData

type LaunchData struct {
	PartName    string
	ExeLocation string
}

LaunchData contains data for the tmplVsCodeLaunch template

type ModulePart

type ModulePart struct {
	Name string `yaml:",omitempty"`

	// library or exec
	ModuleType string

	// Path to the main entitity in the part (Executable .adb file)
	Path string `yaml:",omitempty"`

	// Imports can either be relative to the ModulesPath or absolute
	// An import is specified using <mod>:<part>, where mod is the
	// name of the module and part is the name of the part. If part
	// is omitted, the first library part is selected of the module
	// If an executable doesn't specify any import, it will always import
	// the first library part of it's own module
	// Examples:
	//   - uuid (Relative to either ADA_MODULES_PATH, or ./uuid. First library)
	//   - xml:sax (library sax of xml)
	//   - /home/adam/src/modA:lib1 (Fully qualified)
	//   - :lib  (reference to containing modules 'lib' library)
	Imports []string `yaml:",omitempty"`

	// GprImports can either be relative to the system gpr search path or
	// absolute
	GprImports []string `yaml:",omitempty"`

	// SrcDirs are always relative to the module dir
	SrcDirs []string `yaml:",omitempty"`

	// Options that is needed to provide the linker
	LinkerOptions []string

	// Parent module
	Parent *AdaMod
}

ModulePart describes a part of a module

type ModuleSet

type ModuleSet []*AdaMod

ModuleSet is a set of ada modules. All unique. It's an error to try to add a module with a name that already exists, but with a different path

func (*ModuleSet) Add

func (m *ModuleSet) Add(mod *AdaMod) error

Add a module to the set

func (*ModuleSet) Exists

func (m *ModuleSet) Exists(name string) bool

Exists checks if the module exists in the set

type PartSet

type PartSet []*BuilderPart

PartSet is a set of build parts. All unique.

func (*PartSet) Add

func (s *PartSet) Add(part *BuilderPart) error

Add a module to the set

func (*PartSet) Dump

func (s *PartSet) Dump()

Dump the content

func (*PartSet) Get

func (s *PartSet) Get(partQualifier string) *BuilderPart

Get returns a part from a fully qualified part spec "Mod:PartID" If no part found then return nil

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry is a registry of AdaModules. Primary key is the absolute file location of the module.

func NewRegistry

func NewRegistry(ModulesPath string) (*Registry, error)

NewRegistry creates a new registry to store AdaMods in

func (*Registry) AbsModPath

func (r *Registry) AbsModPath(modPath string) string

AbsModPath returns the absolute path to the module

func (*Registry) AddExtraPath

func (r *Registry) AddExtraPath(module string, absPath string)

AddExtraPath adds an extra mapping between a module name and an absolute path

func (*Registry) Get

func (r *Registry) Get(modpath string) (*AdaMod, error)

Get returns a module corresponding to the path p. First check if it's already in the registry else try load it.

func (*Registry) Load

func (r *Registry) Load(modpath string) (*AdaMod, error)

Load a adamod.yml file into an AdaMod

func (*Registry) Save

func (r *Registry) Save(a *AdaMod) error

Save an AdaMod to an adamod.yml file

type SettingsData

type SettingsData struct {
	ProjectFile string
}

SettingsData contains data for the tmplVsCodeSettings template

type TasksData

type TasksData struct {
	FqPartName string
}

TasksData ...

type TmplData

type TmplData struct {
	Builder     *Builder
	Module      *AdaMod
	BuilderPart BuilderPart
	ModulePart  ModulePart
}

TmplData contains the data needed for the templates

func NewTmplData

func NewTmplData(b *Builder, a *AdaMod, builderPart BuilderPart, modPart ModulePart, name string) TmplData

NewTmplData returns a new tmplData struct filled with values

func (*TmplData) ModuleDir

func (t *TmplData) ModuleDir(p string) string

ModuleDir returns a path relative to the absolute path of the module.

type Toolchain

type Toolchain struct {
	// contains filtered or unexported fields
}

Toolchain is the toolchain used to build

func NewToolchain

func NewToolchain(target string) (*Toolchain, error)

NewToolchain creates a new toolchain for the target. It will verify that the tools needed exists.

func (*Toolchain) Gcc

func (t *Toolchain) Gcc(args ...string) error

Gcc executes gcc for target

func (*Toolchain) Gnatls

func (t *Toolchain) Gnatls(args ...string) error

Gnatls ...

func (*Toolchain) Gnatpp

func (t *Toolchain) Gnatpp(args ...string) error

Gnatpp ...

func (*Toolchain) Gprbuild

func (t *Toolchain) Gprbuild(args ...string) error

Gprbuild uses gprbuild to build someting

func (*Toolchain) SetPath

func (t *Toolchain) SetPath() error

SetPath prepends the toolchain to the PATH variable

type VariableSet

type VariableSet map[string]string

VariableSet is a set of variables that can contain references to other variables in the set.

func (*VariableSet) Resolve

func (set *VariableSet) Resolve(s string) string

Resolve a variable in the set. The set will be updated

func (*VariableSet) ResolveAll

func (set *VariableSet) ResolveAll()

ResolveAll will resolve all varibles in the set

type VsCodeTemplateData

type VsCodeTemplateData struct {
	Folder   string
	Launch   *LaunchData
	Settings *SettingsData
	Config   *ConfigData
	Tasks    *TasksData
}

VsCodeTemplateData ...

func (*VsCodeTemplateData) CreateVsCodeFiles

func (d *VsCodeTemplateData) CreateVsCodeFiles() error

CreateVsCodeFiles creates settings for vscode that is compatible with adamod

func (*VsCodeTemplateData) Generate

func (d *VsCodeTemplateData) Generate(tmpl string, data interface{}, filename ...string) error

Generate a file from a template and data

Jump to

Keyboard shortcuts

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