build

package
v0.0.0-...-b44964e Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: Apache-2.0, Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2020 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2020 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	ManifestTypeApp = "app"
	ManifestTypeLib = "lib"

	MosModuleName  = "mongoose-os"
	MosDefaultRepo = "https://github.com/cesanta/mongoose-os"
)
View Source
const DepsManifestVersion = "2021-03-26"

Variables

This section is empty.

Functions

func BuildCredsToGitCreds

func BuildCredsToGitCreds(creds *Credentials) *ourgit.Credentials

func ValidateDepsRequirements

func ValidateDepsRequirements(have, want *DepsManifest) error

Types

type AppManifest

type AppManifest struct {
	Name    string `yaml:"name,omitempty" json:"name"`
	Type    string `yaml:"type,omitempty" json:"type"`
	Version string `yaml:"version,omitempty" json:"version"`
	Summary string `yaml:"summary,omitempty" json:"summary"`
}

AppManifest contains the common app manifest fields

type BuildParams

type BuildParams struct {
	ManifestAdjustments
	Clean                 bool
	DryRun                bool
	Verbose               bool
	BuildTarget           string
	CustomLibLocations    map[string]string
	CustomModuleLocations map[string]string
	LibsUpdateInterval    time.Duration
	NoPlatformCheck       bool
	SaveBuildStat         bool
	PreferPrebuiltLibs    bool

	// Host -> credentials, used for authentication when fetching libs.
	Credentials map[string]Credentials
}

Note: this struct gets transmitted to the server

func (*BuildParams) GetCredentialsForHost

func (bp *BuildParams) GetCredentialsForHost(host string) *Credentials

type ConfigSchemaItem

type ConfigSchemaItem []interface{}

ConfigSchemaItem represents a single config schema item, like this:

["foo.bar", "default value"]

or this:

["foo.bar", "o", {"title": "Some title"}]

Unfortunately we can't just use []interface{}, because {"title": "Some title"} gets unmarshaled as map[interface{}]interface{}, which is an invalid type for JSON, so we have to create a custom type which implements json.Marshaler interface.

func (ConfigSchemaItem) MarshalJSON

func (c ConfigSchemaItem) MarshalJSON() ([]byte, error)

type Credentials

type Credentials struct {
	User string
	Pass string
}

func GetCredentialsForHost

func GetCredentialsForHost(credsMap map[string]Credentials, host string) *Credentials

type DepsBlobEntry

type DepsBlobEntry struct {
	Name   string `yaml:"name,omitempty" json:"name,omitempty"`
	Size   int    `yaml:"size,omitempty" json:"size,omitempty"`
	SHA256 string `yaml:"cs_sha256,omitempty" json:"cs_sha256,omitempty"`
}

type DepsManifest

type DepsManifest struct {
	AppName string `yaml:"app_name,omitempty" json:"app_name,omitempty"`

	Libs    []*DepsManifestEntry `yaml:"libs,omitempty" json:"libs,omitempty"`
	Modules []*DepsManifestEntry `yaml:"modules,omitempty" json:"modules,omitempty"`

	ManifestVersion string `yaml:"manifest_version,omitempty" json:"manifest_version,omitempty"`
}

DepsManifest describes exact versions of libraries, modules and binary blobs that went into firmware.

func GenerateDepsManifest

func GenerateDepsManifest(manifest *FWAppManifest) (*DepsManifest, error)

func (*DepsManifest) FindBlobEntry

func (dm *DepsManifest) FindBlobEntry(libName, blobName string) *DepsBlobEntry

func (*DepsManifest) FindLibEntry

func (dm *DepsManifest) FindLibEntry(name string) *DepsManifestEntry

func (*DepsManifest) FindModuleEntry

func (dm *DepsManifest) FindModuleEntry(name string) *DepsManifestEntry

type DepsManifestEntry

type DepsManifestEntry struct {
	Name        string           `yaml:"name,omitempty" json:"name,omitempty"`
	Location    string           `yaml:"location,omitempty" json:"location,omitempty"`
	Version     string           `yaml:"version,omitempty" json:"version,omitempty"`
	UserVersion string           `yaml:"user_version,omitempty" json:"version,omitempty"`
	RepoVersion string           `yaml:"repo_version,omitempty" json:"repo_version,omitempty"`
	RepoDirty   bool             `yaml:"repo_dirty,omitempty" json:"repo_dirty,omitempty"`
	Blobs       []*DepsBlobEntry `yaml:"blobs,omitempty" json:"blobs,omitempty"`
}

type FSFilterEntry

type FSFilterEntry struct {
	Include string `yaml:"include,omitempty" json:"include"`
	Exclude string `yaml:"exclude,omitempty" json:"exclude"`
}

type FWAppManifest

type FWAppManifest struct {
	AppManifest `yaml:",inline"`
	// arch was deprecated at 2017/08/15 and should eventually be removed.
	ArchOld     string   `yaml:"arch,omitempty" json:"arch"`
	Platform    string   `yaml:"platform,omitempty" json:"platform"`
	Platforms   []string `yaml:"platforms,omitempty" json:"platforms"`
	Author      string   `yaml:"author,omitempty" json:"author"`
	Description string   `yaml:"description,omitempty" json:"description"`
	Sources     []string `yaml:"sources,omitempty" json:"sources"`
	Includes    []string `yaml:"includes,omitempty" json:"includes"`
	// Globs of files to include.
	Filesystem []string `yaml:"filesystem,omitempty" json:"filesystem"`
	// File filters. Only supported on the app level.
	// Consists of glob patterns that include or exclude files by their name.
	// If file does not match any of the filters, it is included by default.
	FSFilters []*FSFilterEntry `yaml:"fs_filters,omitempty" json:"fs_filters"`

	BinaryLibs     []string           `yaml:"binary_libs,omitempty" json:"binary_libs"`
	ExtraFiles     []string           `yaml:"extra_files,omitempty" json:"extra_files"`
	FFISymbols     []string           `yaml:"ffi_symbols,omitempty" json:"ffi_symbols"`
	Tests          []string           `yaml:"tests,omitempty" json:"tests"`
	Modules        []SWModule         `yaml:"modules,omitempty" json:"modules"`
	Libs           []SWModule         `yaml:"libs,omitempty" json:"libs"`
	InitAfter      []string           `yaml:"init_after,omitempty" json:"init_after"`
	InitBefore     []string           `yaml:"init_before,omitempty" json:"init_before"`
	NoImplInitDeps bool               `yaml:"no_implicit_init_deps,omitempty" json:"no_implicit_init_deps"`
	ConfigSchema   []ConfigSchemaItem `yaml:"config_schema,omitempty" json:"config_schema"`
	BuildVars      map[string]string  `yaml:"build_vars,omitempty" json:"build_vars"`
	CFlags         []string           `yaml:"cflags,omitempty" json:"cflags"`
	CXXFlags       []string           `yaml:"cxxflags,omitempty" json:"cxxflags"`
	CDefs          map[string]string  `yaml:"cdefs,omitempty" json:"cdefs"`
	Tags           []string           `yaml:"tags,omitempty" json:"tags"`

	// The following two are mostly intended to be used in conds.
	// If mos encounters a manifest with this key during build, it will print the text and continue.
	Warning string `yaml:"warning,omitempty" json:"warning"`
	// If mos encounters a manifest with this key during build, it will print the text and fail the build.
	Error string `yaml:"error,omitempty" json:"error"`

	LibsVersion       string `yaml:"libs_version,omitempty" json:"libs_version"`
	ModulesVersion    string `yaml:"modules_version,omitempty" json:"modules_version"`
	MongooseOsVersion string `yaml:"mongoose_os_version,omitempty" json:"mongoose_os_version"`

	Conds []ManifestCond `yaml:"conds,omitempty" json:"conds"`

	ManifestVersion string `yaml:"manifest_version,omitempty" json:"manifest_version"`

	// are names of the libraries which need to be initialized before the
	// application. The user doesn't have to set this field manually, it's set
	// automatically during libs "expansion" (see Libs above)
	LibsHandled []FWAppManifestLibHandled `yaml:"libs_handled,omitempty" json:"libs_handled"`

	InitDeps []string `yaml:"init_deps,omitempty" json:"init_deps"`

	// Origin of this manifest - file name or something else that will help user identify the location.
	// This field is not persisted and is only kept at runtime.
	Origin string `yaml:"-" json:"-"`
}

FWAppManifest is the app manifest for firmware apps

type FWAppManifestLibHandled

type FWAppManifestLibHandled struct {
	Lib         SWModule       `yaml:"lib,omitempty" json:"name"`
	Path        string         `yaml:"path,omitempty" json:"path"`
	Deps        []string       `yaml:"deps,omitempty" json:"deps"`
	InitDeps    []string       `yaml:"init_deps,omitempty" json:"init_deps"`
	Sources     []string       `yaml:"sources,omitempty" json:"sources"`
	BinaryLibs  []string       `yaml:"binary_libs,omitempty" json:"binary_libs"`
	Version     string         `yaml:"version,omitempty" json:"version"`
	UserVersion string         `yaml:"user_version,omitempty" json:"version"`
	RepoVersion string         `yaml:"repo_version,omitempty" json:"version"`
	RepoDirty   bool           `yaml:"repo_dirty,omitempty" json:"repo_dirty"`
	Manifest    *FWAppManifest `yaml:"-" json:"-"`
}

type ManifestAdjustments

type ManifestAdjustments struct {
	Platform  string
	BuildVars map[string]string
	CDefs     map[string]string
	CFlags    []string
	CXXFlags  []string
	ExtraLibs []SWModule

	// Libs and module version requirements.
	DepsVersions       *DepsManifest
	StrictDepsVersions bool
}

Last-minute adjustments for the manifest, typically constructed from command line

type ManifestCond

type ManifestCond struct {
	// The whole cond structure is considered if only When expression evaluates
	// to true (see EvaluateExprBool())
	When string `yaml:"when,omitempty" json:"when,omitempty"`

	// If non-nil, outer manifest gets extended with this one.
	Apply *FWAppManifest `yaml:"apply,omitempty" json:"apply,omitempty"`

	// If not an empty string, results in an error being returned.
	Error string `yaml:"error,omitempty" json:"error,omitempty"`
}

ManifestCond represents a conditional addition to the manifest.

type SWModule

type SWModule struct {
	Type     string `yaml:"type,omitempty" json:"type,omitempty"`
	Name     string `yaml:"name,omitempty" json:"name,omitempty"`
	Location string `yaml:"location,omitempty" json:"location,omitempty"`
	// Origin is deprecated since 2017/08/18
	OriginOld string `yaml:"origin,omitempty" json:"origin,omitempty"`
	Version   string `yaml:"version,omitempty" json:"version,omitempty"`
	Variant   string `yaml:"variant,omitempty" json:"variant,omitempty"`

	// API used to download binary assets. If not specified, will take a guess based on location.
	AssetAPI SWModuleAssetAPIType `yaml:"asset_api,omitempty" json:"asset_api,omitempty"`
	// contains filtered or unexported fields
}

func (*SWModule) FetchPrebuiltBinary

func (m *SWModule) FetchPrebuiltBinary(platform, defaultVersion, tgt string) error

func (*SWModule) FetchableFromWeb

func (m *SWModule) FetchableFromWeb() (bool, error)

FetchableFromInternet returns whether the library could be fetched from the web

func (*SWModule) GetCredentials

func (m *SWModule) GetCredentials() *Credentials

func (*SWModule) GetHostName

func (m *SWModule) GetHostName() string

func (*SWModule) GetLocalDir

func (m *SWModule) GetLocalDir(libsDir, defaultVersion string) (string, error)

func (*SWModule) GetName

func (m *SWModule) GetName() (string, error)

func (*SWModule) GetName2

func (m *SWModule) GetName2() (string, error)

func (*SWModule) GetRepoVersion

func (m *SWModule) GetRepoVersion() (string, bool, error)

func (*SWModule) GetType

func (m *SWModule) GetType() SWModuleType

func (*SWModule) GetVersion

func (m *SWModule) GetVersion(defaultVersion string) string

func (*SWModule) Normalize

func (m *SWModule) Normalize() error

func (*SWModule) PrepareLocalDir

func (m *SWModule) PrepareLocalDir(
	libsDir string, logWriter io.Writer, deleteIfFailed bool, defaultVersion string,
	pullInterval time.Duration, cloneDepth int,
) (string, error)

PrepareLocalDir prepares local directory, if that preparation is needed in the first place, and returns the path to it. If defaultVersion is an empty string or "latest", then the default will depend on the kind of lib (e.g. for git it's "master")

func (*SWModule) SetCredentials

func (m *SWModule) SetCredentials(creds *Credentials)

func (*SWModule) SetLocalPathAndRepoVersion

func (m *SWModule) SetLocalPathAndRepoVersion(localPath, repoVersion string, isDirty bool)

For testing

func (*SWModule) SetVersionOverride

func (m *SWModule) SetVersionOverride(version string)

type SWModuleAssetAPIType

type SWModuleAssetAPIType string
const (
	AssetAPIGitHub SWModuleAssetAPIType = "github"
	AssetAPIGitLab                      = "gitlab"
)

type SWModuleType

type SWModuleType int
const (
	SWModuleTypeInvalid SWModuleType = iota
	SWModuleTypeLocal
	SWModuleTypeGit
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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