Documentation ¶
Index ¶
- Variables
- func AddPackages(repos *gir.Repositories, pkgs []Package) error
- func AppendGoFiles(path string, contents map[string]string) error
- func CleanDirectory(path string, except []string) error
- func EnsureDirectory(path string, expects ...[]string) error
- func Generate(repos gir.Repositories, data Data)
- func GenerateAll(gen *girgen.Generator, dst string, except []string) []error
- func GeneratePackages(gen *girgen.Generator, dst string, pkgs []Package, except []string) []error
- func LoadExternOverrides(mod string, repos gir.Repositories) map[string]string
- func LoadPackages(pkgs []Package) (gir.Repositories, error)
- func MajorVersion(nsp *gir.Namespace) int
- func ModulePath(module string, overrides map[string]string) func(*gir.Namespace) string
- func MustAddPackages(repos *gir.Repositories, pkgs []Package)
- func MustLoadPackages(pkgs []Package) gir.Repositories
- func ParseFlag()
- func PrintAddedPkgs(repos gir.Repositories)
- func Run(data Data)
- func StringSet(strs ...[]string) map[string]struct{}
- func WriteNamespace(ng *girgen.NamespaceGenerator, basePath string) error
- type Data
- type Package
Constants ¶
This section is empty.
Variables ¶
var ( Output string Verbose bool ListPkg bool CgoLink bool )
Functions ¶
func AddPackages ¶
func AddPackages(repos *gir.Repositories, pkgs []Package) error
AddPackages adds the given list of packages into the repository.
func AppendGoFiles ¶
AppendGoFiles appends the value of the given contents map into the files at its keys and run go fmt on it.
func CleanDirectory ¶
CleanDirectory cleans up the directory at the given path. Files listed inside except will not be wiped.
func EnsureDirectory ¶
EnsureDirectory ensures that all files inside the given directory path are present in the given list of string slices.
func Generate ¶
func Generate(repos gir.Repositories, data Data)
Generate generates the packages based on the given data.
func GenerateAll ¶
GenerateAll generates all namespaces inside the given generator into the given dst path. It uses WriteNamespace to do so. The namespaces will be generated in parallel. If a versioned namespace is in the except slice, then it is skipped.
func GeneratePackages ¶
GeneratePackages generates the given pkgs list into the given dst directory. It uses WriteNamespace to do so. The namespaces will be generated in parallel. Most external GIR generators should call this.
func LoadExternOverrides ¶
func LoadExternOverrides(mod string, repos gir.Repositories) map[string]string
LoadExternOverrides creates a map of GIR versioned namespace names to the Go import path from the given list of all repositories.
func LoadPackages ¶
func LoadPackages(pkgs []Package) (gir.Repositories, error)
LoadPackages loads all GIR repositories from the given list of packages.
func MajorVersion ¶
MajorVersion returns the major version of the GIR namespace in int.
func ModulePath ¶
ModulePath crafts the full module path from the given base module path. If the overrides map is given, then the function will use that as the list of special cases.
func MustAddPackages ¶
func MustAddPackages(repos *gir.Repositories, pkgs []Package)
MustAddPackages bails if packages fail to be added.
func MustLoadPackages ¶
func MustLoadPackages(pkgs []Package) gir.Repositories
MustLoadPackages bails if packages fail to load.
func ParseFlag ¶
func ParseFlag()
ParseFlag calls flag.Parse() and initializes external global options.
func PrintAddedPkgs ¶
func PrintAddedPkgs(repos gir.Repositories)
PrintAddedPkgs prints to console the added packages.
func StringSet ¶
StringSet joins the given slices of strings into a map with the keys as the values of each of the given slices.
func WriteNamespace ¶
func WriteNamespace(ng *girgen.NamespaceGenerator, basePath string) error
WriteNamespace generates everything in the given namespace and writes it to the given basePath.
Types ¶
type Data ¶
type Data struct { // Module is the Go Module name that the generator is running for. An // example is "github.com/brotholo/gotk4/pkg". Module string // Packages lists pkg-config packages and optionally the namespaces to be // generated. If the list of namespaces is nil, then everything is // generated. Packages []Package // KnownPackages is similar to Packages, but no packages in this list will // be used to generate code. This list automatically includes Packages. KnownPackages []Package // ImportOverrides is the list of imports to defer to another library, // usually because it's tedious or impossible to generate. // // Not included: coreglib (gotk3/gotk3/glib). ImportOverrides map[string]string // ExternOverrides adds into ImportOverrides packages that were generated // from the given GIR repositories, with the map key being the Go module // root for those packages. It internally invokes LoadExternOverrides. ExternOverrides map[string]gir.Repositories // PkgExceptions contains a list of file names that won't be deleted off of // pkg/. PkgExceptions []string // GenerateExceptions contains the keys of the underneath ImportOverrides // map. GenerateExceptions []string // PkgGenerated contains a list of file names that are packages generated // using the given Packages list. It is manually updated. PkgGenerated []string // Preprocessors defines a list of preprocessors that the main generator // will use. It's mostly used for renaming colliding types/identifiers. Preprocessors []types.Preprocessor // Postprocessors is a map of versioned namespace names to a list of // functions that are called to modify any file before it is written out. Postprocessors map[string][]girgen.Postprocessor // ExtraGoContents contains the contents of files that are appended into // generated outputs. It is used to add custom implementations of missing // functions. It is a simpler version of Postprocessors. ExtraGoContents map[string]string // Filters defines a list of GIR types to be filtered. The map key is the // namespace, and the values are list of names. Filters []types.FilterMatcher // ProcessConverters is a list of things that can override a type converter. ProcessConverters []typeconv.ConversionProcessor // DynamicLinkNamespaces lists namespaces that should be generated directly // using Cgo. It includes important core packages as well as packages that // are small but performance-sensitive. DynamicLinkNamespaces []string // SingleFile, if true, will make all NamespaceGenerators generate a single // output file per package instead of correlating it to the source file. SingleFile bool }
Data contains generation data that genmain uses to generate.