swiftpkg

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package swiftpkg represents the unified information about a Swift package.

Information from the Swift description JSON and the Swit dump JSON is merged to create the types in this package.

Index

Constants

This section is empty.

Variables

View Source
var TestDirectoryPathSuffixes = PathSuffixes{"tests", "test"}

TestDirectoryPathSuffixes lists the suffixes used for Swift test directories.

View Source
var TestFilePathSuffixes = PathSuffixes{"tests.swift", "test.swift"}

TestFilePathSuffixes lists the suffixes used for Swift test files.

Functions

This section is empty.

Types

type ByNameReference

type ByNameReference struct {
	// Product name or target name
	Name string
}

A ByNameReference references a product or target by name.

func NewByNameReferenceFromManifestInfo

func NewByNameReferenceFromManifestInfo(dumpBNR *spdump.ByNameReference) *ByNameReference

NewByNameReferenceFromManifestInfo returns a by-name reference from manifest information.

type ClangSettings

type ClangSettings struct {
	Defines []string
}

A ClangSettings represents the clang-specific settings for a Swift target.

func NewClangSettingsFromManifestInfo

func NewClangSettingsFromManifestInfo(dumpTS []spdump.TargetSetting) (*ClangSettings, error)

NewClangSettingsFromManifestInfo returns the clang settings from manfiest information.

type Dependencies

type Dependencies []*Dependency

A Dependencies represents a list of external dependencies.

func (Dependencies) Identities

func (deps Dependencies) Identities() []string

Identities returns the identity values for the dependencies.

type Dependency

type Dependency struct {
	SourceControl *SourceControl
	FileSystem    *FileSystem
}

A Dependency represents an external dependency.

func NewDependencyFromManifestInfo

func NewDependencyFromManifestInfo(dumpD *spdump.Dependency) (*Dependency, error)

NewDependencyFromManifestInfo returns an external dependency based upon the manifest information.

func (*Dependency) Identity

func (d *Dependency) Identity() string

Identity returns the unique identity for the external dependency.

func (*Dependency) URL

func (d *Dependency) URL() string

URL returns the URL for the external dependency.

type DependencyRequirement

type DependencyRequirement struct {
	Ranges []*VersionRange
}

func NewDependencyRequirementFromManifestInfo

func NewDependencyRequirementFromManifestInfo(dr *spdump.DependencyRequirement) *DependencyRequirement

type FileSystem

type FileSystem struct {
	Identity string
	Path     string
}

func NewFileSystemFromManifestInfo

func NewFileSystemFromManifestInfo(fs *spdump.FileSystem) *FileSystem

type ModuleType

type ModuleType int

A ModuleType is an enum for the Swift manifest module type.

const (
	UnknownModuleType ModuleType = iota
	SwiftModuleType
	ClangModuleType
	BinaryModuleType
	PluginModuleType
)

func NewModuleType

func NewModuleType(str string) ModuleType

NewModuleType returns the module type from the provided string value.

type PackageInfo

type PackageInfo struct {
	Name                string
	DisplayName         string
	Path                string
	ToolsVersion        string
	Targets             Targets
	Platforms           []*Platform
	Products            []*Product
	Dependencies        Dependencies
	CLanguageStandard   string
	CxxLanguageStandard string
}

A PackageInfo encapsulates all of the information about a Swift package.

func NewPackageInfo

func NewPackageInfo(sw swiftbin.Executor, dir, buildDir string) (*PackageInfo, error)

NewPackageInfo returns the Swift package information from a Swift package on disk.

func (*PackageInfo) ExportedTargets

func (pi *PackageInfo) ExportedTargets() ([]*Target, error)

ExportedTargets returns targets that are made available outside of the package via a Product reference.

func (*PackageInfo) ProductReferences

func (pi *PackageInfo) ProductReferences() []*ProductReference

ProductReferences returns a uniq slice of the product references used in the manifest.

type PathSuffixes added in v0.8.0

type PathSuffixes []string

PathSuffixes provides a means for testing a path having one of the listed suffixes.

func (PathSuffixes) HasSuffix added in v0.8.0

func (ds PathSuffixes) HasSuffix(path string) bool

HasSuffix checks if the path has one of the suffixes.

func (PathSuffixes) IsUnderDirWithSuffix added in v0.8.0

func (ds PathSuffixes) IsUnderDirWithSuffix(path string) bool

IsUnderDirWithSuffix checks if the path has a directory that includes one of the suffixes.

type Platform

type Platform struct {
	Name    string
	Version string
}

A Platform represents a Swift package platform.

func NewPlatfromFromManifestInfo

func NewPlatfromFromManifestInfo(descP *spdesc.Platform) *Platform

NewPlatfromFromManifestInfo returns a Swift package platform from manifest information.

type Product

type Product struct {
	Name    string
	Targets []string
	Type    ProductType
}

A Product represents a Swift product.

func NewProductFromManifestInfo

func NewProductFromManifestInfo(dumpP *spdump.Product) (*Product, error)

NewProductFromManifestInfo returns a Swift product from manifest information.

type ProductReference

type ProductReference struct {
	// Product name
	ProductName string
	// External dependency identity
	Identity string
}

A ProductReference represents a reference to a product.

func NewProductReferenceFromManifestInfo

func NewProductReferenceFromManifestInfo(dumpPR *spdump.ProductReference) *ProductReference

NewProductReferenceFromManifestInfo returns a product reference from manifest information.

func (*ProductReference) UniqKey

func (pr *ProductReference) UniqKey() string

UniqKey returns the value used to lookup a Swift product from a reference.

type ProductType

type ProductType int

A ProductType is an enum for the type of Swift product.

const (
	UnknownProductType ProductType = iota
	ExecutableProductType
	LibraryProductType
	PluginProductType
)

type RemoteLocation

type RemoteLocation struct {
	URL string
}

func NewRemoteLocationFromManifestInfo

func NewRemoteLocationFromManifestInfo(rl *spdump.RemoteLocation) *RemoteLocation

type SourceControl

type SourceControl struct {
	Identity    string
	Location    *SourceControlLocation
	Requirement *DependencyRequirement
}

A SourceControl represents the source control information for an external dependency.

func NewSourceControlFromManifestInfo

func NewSourceControlFromManifestInfo(dumpSC *spdump.SourceControl) *SourceControl

NewSourceControlFromManifestInfo returns the source control info from manifest information.

type SourceControlLocation

type SourceControlLocation struct {
	Remote *RemoteLocation
}

func NewSourceControlLocationFromManifestInfo

func NewSourceControlLocationFromManifestInfo(dumpL *spdump.SourceControlLocation) *SourceControlLocation

type SourceType

type SourceType int

A SourceType is an enum that identifies the type of source files use to implement a Swift manifest target.

const (
	UnknownSourceType SourceType = iota
	SwiftSourceType
	ClangSourceType
	ObjcSourceType
	BinarySourceType
)

func NewSourceType

func NewSourceType(moduleType ModuleType, srcPaths []string) SourceType

NewSourceType returns the source type given the module type and a list of the sources for a target.

func (SourceType) MarshalJSON

func (m SourceType) MarshalJSON() ([]byte, error)

func (*SourceType) UnmarshalJSON

func (m *SourceType) UnmarshalJSON(b []byte) error

type SwiftFileInfo added in v0.6.0

type SwiftFileInfo struct {
	Rel              string
	Abs              string
	Imports          []string
	IsTest           bool
	ContainsMain     bool
	HasObjcDirective bool
}

SwiftFileInfo represents source file information that is pertinent for Swift build file generation.

func NewSwiftFileInfoFromPath added in v0.6.0

func NewSwiftFileInfoFromPath(rel, abs string) (*SwiftFileInfo, error)

NewSwiftFileInfoFromPath returns file info from a filesystem path.

func NewSwiftFileInfoFromReader added in v0.6.0

func NewSwiftFileInfoFromReader(rel, abs string, reader io.Reader) *SwiftFileInfo

NewSwiftFileInfoFromReader returns file info for a source file.

func NewSwiftFileInfoFromSrc added in v0.6.0

func NewSwiftFileInfoFromSrc(rel, abs, src string) *SwiftFileInfo

NewSwiftFileInfoFromSrc returns file info for source file's contents as a string.

type SwiftFileInfos added in v0.6.0

type SwiftFileInfos []*SwiftFileInfo

SwiftFileInfos represents a collection of SwiftFileInfo instances.

func NewSwiftFileInfosFromRelPaths added in v0.6.0

func NewSwiftFileInfosFromRelPaths(dir string, srcs []string) SwiftFileInfos

NewSwiftFileInfosFromRelPaths returns a slice of file information for the source files in a directory.

func (SwiftFileInfos) RequiresModulemap added in v0.6.0

func (sfis SwiftFileInfos) RequiresModulemap() bool

RequiresModulemap determines whether a modulemap target will be generated for this target.

type Target

type Target struct {
	Name               string
	C99name            string
	Type               TargetType
	ModuleType         ModuleType
	Path               string
	Sources            []string
	Dependencies       []*TargetDependency
	CSettings          *ClangSettings
	SrcType            SourceType
	ProductMemberships []string
	// SwiftFileInfos will only be populated if the target is a Swift target.
	SwiftFileInfos SwiftFileInfos
}

A Target represents a Swift target.

func NewTargetFromManifestInfo

func NewTargetFromManifestInfo(
	pkgPath string,
	descT *spdesc.Target,
	dumpT *spdump.Target,
	prodNames mapset.Set[string],
) (*Target, error)

NewTargetFromManifestInfo returns a Swift target from manifest information.

func (*Target) Imports

func (t *Target) Imports() []string

Imports returns the module names provided by the dependencies.

type TargetDependency

type TargetDependency struct {
	Product *ProductReference
	ByName  *ByNameReference
	Target  *TargetReference
}

A TargetDependency represents a Swift target dependency.

func NewTargetDependencyFromManifestInfo

func NewTargetDependencyFromManifestInfo(dumpTD *spdump.TargetDependency) (*TargetDependency, error)

NewTargetDependencyFromManifestInfo returns a target dependency from manifest information.

func (*TargetDependency) ImportName

func (td *TargetDependency) ImportName() string

ImportName returns the name used to import the dependency.

type TargetReference

type TargetReference struct {
	TargetName string
}

TargetReference references a target by name.

func NewTargetReferenceFromManifestInfo

func NewTargetReferenceFromManifestInfo(dumpTR *spdump.TargetReference) *TargetReference

NewTargetReferenceFromManifestInfo returns a target reference from manifest information.

type TargetType

type TargetType int

A TargetType is an enum for a Swift target type.

const (
	UnknownTargetType TargetType = iota
	ExecutableTargetType
	LibraryTargetType
	TestTargetType
	PluginTargetType
)

type Targets

type Targets []*Target

A Targets represents a slice of Swift targets.

func (Targets) FindByName

func (ts Targets) FindByName(name string) *Target

FindByName returns the target with the matching name. Otherwise, returns nil.

func (Targets) FindByPath

func (ts Targets) FindByPath(path string) *Target

FindByPath returns the target with the matching path. Otherwise, returns nil.

type VersionRange

type VersionRange struct {
	LowerBound string
	UpperBound string
}

func NewVersionRangeFromManifestInfo

func NewVersionRangeFromManifestInfo(vr *spdump.VersionRange) *VersionRange

Jump to

Keyboard shortcuts

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