capigen

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package capigen generates raw CGo binding packages from spec YAML and manifest configuration. It produces the capi/{module}/ packages that idiomgen-generated code imports.

Index

Constants

View Source
const BaseAPILevel = 35

BaseAPILevel is the default Android API level. Functions at or below this level go into the main generated file; functions above it are emitted into separate build-tagged files.

Variables

This section is empty.

Functions

func ExportName

func ExportName(name string) string

ExportName returns an exported Go identifier from a C name. Strips leading underscores and capitalizes the first letter. If the name is all underscores, returns it unchanged.

func GeneratePackage

func GeneratePackage(
	spec *specmodel.Spec,
	manifest *Manifest,
	outDir string,
	apiLevels ...map[string]int,
) error

GeneratePackage generates a complete capi/ Go package from the spec and manifest. It writes doc.go, types.go, const.go, cgo_helpers.go, cgo_helpers.h, and {module}.go into outDir.

apiLevels is an optional map from C function name to the minimum Android API level required. Functions above BaseAPILevel are placed in separate files with //go:build android_ndk{N} tags.

Types

type FlagGroup

type FlagGroup struct {
	Name  string   `yaml:"name"`
	Flags []string `yaml:"flags"`
}

FlagGroup is a named set of compiler/linker flags.

type Manifest

type Manifest struct {
	Generator struct {
		PackageName        string      `yaml:"PackageName"`
		PackageDescription string      `yaml:"PackageDescription"`
		Includes           []string    `yaml:"Includes"`
		FlagGroups         []FlagGroup `yaml:"FlagGroups"`
		ExcludeFunctions   []string    `yaml:"ExcludeFunctions"`
	} `yaml:"GENERATOR"`
}

Manifest holds the relevant manifest fields for capi package generation.

Jump to

Keyboard shortcuts

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