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.
Index ¶
- func ExpandVars(interp *MosInterpreter, s string, skipFailed bool) (string, error)
- func ExpandVarsSlice(interp *MosInterpreter, slice []string, skipFailed bool) ([]string, error)
- func GetMVarName(names ...string) string
- func GetMVarNameLib(libName string) string
- func GetMVarNameLibPath(libName string) string
- func GetMVarNameManifest() string
- func GetMVarNameModule(moduleName string) string
- func GetMVarNameModulePath(moduleName string) string
- func GetMVarNameMos() string
- func GetMVarNameMosPlatform() string
- func GetMVarNameMosVersion() string
- func SetLibVars(mVars *MosVars, libName, path string)
- func SetManifestVars(mVars *MosVars, manifest *build.FWAppManifest) error
- func SetModuleVars(mVars *MosVars, moduleName, path string)
- func WrapMosExpr(s string) string
- type MosInterpreter
- type MosVars
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExpandVars ¶
func ExpandVars(interp *MosInterpreter, s string, skipFailed bool) (string, error)
func ExpandVarsSlice ¶
func ExpandVarsSlice(interp *MosInterpreter, slice []string, skipFailed bool) ([]string, error)
func GetMVarName ¶
func GetMVarNameLib ¶
GetMVarNameLib returns a string like "mos.libs.foo"
func GetMVarNameLibPath ¶
GetMVarNameLibPath returns a string like "mos.libs.foo.path"
func GetMVarNameModule ¶
GetMVarNameModule returns a string like "mos.modules.foo"
func GetMVarNameModulePath ¶
GetMVarNameModulePath returns a string like "mos.modules.foo.path"
func GetMVarNameMosPlatform ¶
func GetMVarNameMosPlatform() string
GetMVarNameMosPlatform returns "mos.platform"
func GetMVarNameMosVersion ¶
func GetMVarNameMosVersion() string
GetMVarNameMosVersion returns "mos.version"
func SetLibVars ¶
SetLibVars populates "mos.libs.<libName>".
func SetManifestVars ¶
func SetManifestVars(mVars *MosVars, manifest *build.FWAppManifest) error
SetManifestVars makes all variables from the given manifest available at the top level and under "manifest". Any previously existing manifest variables are removed.
func SetModuleVars ¶
SetModuleVars populates "mos.modules.<moduleName>".
func WrapMosExpr ¶
Types ¶
type MosInterpreter ¶
type MosInterpreter struct {
MVars *MosVars
}
MosInterpreter can evaluate very simple expressions, see EvaluateExpr. Expressions are evaluated against enclosed MosVars.
func NewInterpreter ¶
func NewInterpreter(mVars *MosVars) *MosInterpreter
func (*MosInterpreter) Copy ¶
func (mi *MosInterpreter) Copy() *MosInterpreter
func (*MosInterpreter) EvaluateExpr ¶
func (mi *MosInterpreter) EvaluateExpr(expr string) (interface{}, error)
EvaluateExpr can evaluate expressions of the following form:
- operand
- operand1 op operand2
Where either operand can be a string like "foo", or an expression suitable for MosVars.GetVar, e.g. foo.bar.baz. Operation can be either == or !=.
Examples:
- arch
- build_vars.FOO_BAR == "foo"
- "bar"
In the future it will be hopefully refactored into a proper expression parsing and evaluation, but so far it's a quick hack which solves the problem at hand.
func (*MosInterpreter) EvaluateExprBool ¶
func (mi *MosInterpreter) EvaluateExprBool(expr string) (bool, error)
EvaluateExprBool calls EvaluateExpr and if the result is boolean, then returns it; otherwise returns an error
func (*MosInterpreter) EvaluateExprString ¶
func (mi *MosInterpreter) EvaluateExprString(expr string) (string, error)
EvaluateExprString calls EvaluateExpr and converts the result to string
type MosVars ¶
type MosVars struct {
// contains filtered or unexported fields
}
MosVars is a wrapper around datamap.DataMap with get-fail-handler which provides some shortcut phantom values, e.g. it makes everything under "manifest" available at the top level, and also provides backward compatibility: maps "foo_bar_path" to "mos.modules.foo_bar.path" (and prints a warning if such old name is used).
There are also a couple of helper functions to set mos-specific variables: SetModuleVars() and SetManifestVars.
func NewMosVars ¶
func NewMosVars() *MosVars