pkg

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: Apache-2.0 Imports: 15 Imported by: 17

Documentation

Index

Constants

View Source
const DEFAULT_KCL_FILE_CONTENT = "The_first_kcl_program = 'Hello World!'"
View Source
const DEFAULT_KCL_FILE_NAME = "main.k"
View Source
const LOCK_FILE_NAME = "kcl.mod.lock"
View Source
const TAR_SUFFIX = ".tar"

Variables

This section is empty.

Functions

This section is empty.

Types

type KclPkg

type KclPkg struct {
	HomePath string
	// The dependencies in the current kcl package are the dependencies of kcl.mod.lock,
	// not the dependencies in kcl.mod.
	modfile.Dependencies
	// contains filtered or unexported fields
}

func LoadKclPkg

func LoadKclPkg(pkgPath string) (*KclPkg, error)

Load the kcl package from directory containing kcl.mod and kcl.mod.lock file.

func LoadKclPkgFromTar

func LoadKclPkgFromTar(pkgTarPath string) (*KclPkg, error)

LoadKclPkgFromTar will load a kcl package from a tar path.

func NewKclPkg

func NewKclPkg(opts *opt.InitOptions) KclPkg

func (*KclPkg) AddDeps

func (kclPkg *KclPkg) AddDeps(opt *opt.AddOptions) error

AddDeps will add the dependencies to current kcl package and update kcl.mod and kcl.mod.lock.

func (*KclPkg) Compile

func (kclPkg *KclPkg) Compile(kpmHome string, kclvmCompiler *runner.Compiler) (*kcl.KCLResultList, error)

CompileWithEntryFile will call kcl compiler to compile the current kcl package and its dependent packages.

func (*KclPkg) CreateDefaultKclProgram

func (kclPkg *KclPkg) CreateDefaultKclProgram() error

CreateDefaultKclProgram will create a default kcl program "The_first_kcl_program = 'Hello World!'" in 'main.k'.

func (*KclPkg) DefaultTarPath

func (kclPkg *KclPkg) DefaultTarPath() string

DefaultTarPath will return "<kcl_package_path>/<package_name>-<package_version>.tar"

func (*KclPkg) DownloadDep

func (kclPkg *KclPkg) DownloadDep(d *modfile.Dependency, localPath string) error

DownloadDep will download the corresponding dependency.

func (*KclPkg) GetEntryKclFilesFromModFile

func (kclPkg *KclPkg) GetEntryKclFilesFromModFile() []string

GetEntryKclFilesFromModFile will return the entry kcl files from kcl.mod.

func (*KclPkg) GetKclOpts

func (kclPkg *KclPkg) GetKclOpts() *kcl.Option

GetKclOpts will return the kcl options from kcl.mod.

func (*KclPkg) GetLockFilePath

func (kclPkg *KclPkg) GetLockFilePath() string

GetLockFilePath returns the abs path of kcl.mod.lock.

func (*KclPkg) GetPkgFullName

func (kclPkg *KclPkg) GetPkgFullName() string

GetPkgFullName returns the full name of package. The full name is "<pkg_name>-<pkg_version>", <pkg_name> is the name of package. <pkg_version> is the version of package

func (*KclPkg) GetPkgName

func (kclPkg *KclPkg) GetPkgName() string

GetPkgName returns name of package.

func (*KclPkg) GetPkgTag

func (kclPkg *KclPkg) GetPkgTag() string

GetPkgTag returns version of package.

func (*KclPkg) GetPkgTarName

func (kclPkg *KclPkg) GetPkgTarName() string

GetPkgTarName returns the kcl package tar name "<package_name>-v<package_version>.tar"

func (*KclPkg) InitEmptyPkg

func (kclPkg *KclPkg) InitEmptyPkg() error

InitEmptyModule inits an empty kcl module and create a default kcl.modfile.

func (*KclPkg) IsVendorMode

func (kclPkg *KclPkg) IsVendorMode() bool

func (*KclPkg) LocalVendorPath

func (kclPkg *KclPkg) LocalVendorPath() string

Return the full vendor path.

func (*KclPkg) LockDepsVersion

func (kclPkg *KclPkg) LockDepsVersion() error

LockDepsVersion locks the dependencies of the current kcl package into kcl.mod.lock.

func (*KclPkg) PackageCurrentPkgPath

func (kclPkg *KclPkg) PackageCurrentPkgPath() (string, error)

PackageCurrentPkg will package the current kcl package into the current path and return the tar path. And the tar will be named "<package_name>-<package_version>.tar" <package_name> is the package name specified in kcl.mod. <package_version> is the package version specified in kcl.mod.

func (*KclPkg) PackageKclPkg

func (kclPkg *KclPkg) PackageKclPkg(kpmHome string, tarPath string) error

PackageKclPkg will save all dependencies to the 'vendor' in current pacakge and package the current package into tar

func (*KclPkg) PackageToTarball

func (kclPkg *KclPkg) PackageToTarball(tarPath string) error

PkgCurrentPackageIntoTarPath will package the current kcl package into 'tarPath'.

func (*KclPkg) ResolveDeps

func (kclPkg *KclPkg) ResolveDeps(kpmHome string) (map[string]string, error)

ResolveDeps will return a map between dependency name and its local path, and analyze the dependencies of the current kcl package, look for the package in the $KCL_PKG_PATH or kcl package vendor subdirectory, if find it, ResolveDeps will remember the local path of the dependency, if can’t find it, re-download the dependency and remember the local path.

func (*KclPkg) ResolveDepsMetadata

func (kclPkg *KclPkg) ResolveDepsMetadata(kpmHome string, update bool) error

ResolveDepsMetadata will calculate the local storage path of the external package, and check whether the package exists locally. If the package does not exist, it will re-download to the local.

func (*KclPkg) ResolveDepsMetadataInJsonStr

func (kclPkg *KclPkg) ResolveDepsMetadataInJsonStr(kpmHome string, update bool) (string, error)

ResolveDepsMetadataInJsonStr will calculate the local storage path of the external package, and check whether the package exists locally. If the package does not exist, it will re-download to the local. Finally, the calculated metadata of the dependent packages is serialized into a json string and returned.

func (*KclPkg) SetVendorMode

func (kclPkg *KclPkg) SetVendorMode(vendorMode bool)

func (*KclPkg) UpdateModAndLockFile

func (kclPkg *KclPkg) UpdateModAndLockFile() error

updateModAndLockFile will update kcl.mod and kcl.mod.lock

func (*KclPkg) ValidateKpmHome

func (kclPkg *KclPkg) ValidateKpmHome(kpmHome string) error

Verify that the environment variable KPM HOME is set correctly

func (*KclPkg) VendorDeps

func (kclPkg *KclPkg) VendorDeps(cachePath string) error

Vendor all dependencies to the 'vendor' in current pacakge.

Jump to

Keyboard shortcuts

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