Skip to content

Commit

Permalink
Allow overriding lib version from conds
Browse files Browse the repository at this point in the history
  • Loading branch information
rojer committed Mar 11, 2021
1 parent e977ddf commit ad799f8
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 36 deletions.
15 changes: 8 additions & 7 deletions cli/build/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ type AppManifest struct {
}

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"`
Version string `yaml:"version,omitempty" json:"version"`
Manifest *FWAppManifest `yaml:"-" json:"-"`
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"`
Version string `yaml:"version,omitempty" json:"version"`
RepoVersion string `yaml:"repo_version,omitempty" json:"version"`
Manifest *FWAppManifest `yaml:"-" json:"-"`
}

// FWAppManifest is the app manifest for firmware apps
Expand Down
30 changes: 14 additions & 16 deletions cli/manifest_parser/manifest_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,18 @@ func ReadManifestFinal(
return nil, nil, errors.Trace(err)
}

for k, v := range manifest.LibsHandled {
for i, v := range manifest.LibsHandled {
name, err := v.Lib.GetName()
if err != nil {
return nil, nil, errors.Trace(err)
}
interpreter.SetLibVars(interp.MVars, name, v.Path)
manifest.LibsHandled[k].Sources, err = interpreter.ExpandVarsSlice(interp, v.Sources, false)
manifest.LibsHandled[i].Sources, err = interpreter.ExpandVarsSlice(interp, v.Sources, false)
if err != nil {
return nil, nil, errors.Trace(err)
}
manifest.LibsHandled[i].Version = v.Manifest.Version
manifest.LibsHandled[i].RepoVersion, _ = v.Lib.GetLocalVersion()
}

manifest.Includes, err = interpreter.ExpandVarsSlice(interp, manifest.Includes, false)
Expand Down Expand Up @@ -968,7 +970,6 @@ func prepareLib(
Lib: *m,
Path: libLocalDir,
Deps: pc.deps.GetDeps(name),
Version: libManifest.Version,
Manifest: libManifest,
}
pc.libsHandled[name] = lh
Expand Down Expand Up @@ -1432,17 +1433,14 @@ func ExpandManifestConds(
}); err != nil {
return errors.Trace(err)
}
// Conds in app's manifest can override name, description and version.
if isAppManifest {
if cond.Apply.Name != "" {
dstManifest.Name = cond.Apply.Name
}
if cond.Apply.Description != "" {
dstManifest.Description = cond.Apply.Description
}
if cond.Apply.Version != "" {
dstManifest.Version = cond.Apply.Version
}
if isAppManifest && cond.Apply.Name != "" {
dstManifest.Name = cond.Apply.Name
}
if cond.Apply.Description != "" {
dstManifest.Description = cond.Apply.Description
}
if cond.Apply.Version != "" {
dstManifest.Version = cond.Apply.Version
}
}
}
Expand Down Expand Up @@ -1684,8 +1682,8 @@ func getDepsInitCCode(manifest *build.FWAppManifest, mosHash string) ([]byte, er
}
}
lv := lh.Version
if llv, err := lh.Lib.GetLocalVersion(); err == nil {
lv = fmt.Sprintf("%s/%s", lv, llv)
if lh.RepoVersion != "" {
lv = fmt.Sprintf("%s/%s", lv, lh.RepoVersion)
}
initFunc := "NULL"
if len(lh.Sources) > 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ config_schema:
conds:
- when: '"1" == "1"'
apply:
# Top-level attributes can only be overriden in app's conds
# Name can only be overriden in app's conds
name: Does not
description: work
version: from here
version: 2.0

manifest_version: 2017-09-29
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ libs_handled:
- core
sources:
- __APP_ROOT__/libs/mylib1/src/mylib1_src1.c
version: "1.0"
version: "2.0"
- lib:
origin: https://github.com/mongoose-os-libs/mylib2
location: https://github.com/mongoose-os-libs/mylib2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ libs_handled:
- core
sources:
- __APP_ROOT__/libs/mylib1/src/mylib1_src1.c
version: "1.0"
version: "2.0"
- lib:
origin: https://github.com/mongoose-os-libs/mylib2
location: https://github.com/mongoose-os-libs/mylib2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ libs_handled:
- core
sources:
- __APP_ROOT__/libs/mylib1/src/mylib1_src1.c
version: "1.0"
version: "2.0"
- lib:
origin: https://github.com/mongoose-os-libs/mylib2
location: https://github.com/mongoose-os-libs/mylib2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ libs_handled:
- core
sources:
- __APP_ROOT__/libs/mylib1/src/mylib1_src1.c
version: "1.0"
version: "2.0"
- lib:
origin: https://github.com/mongoose-os-libs/mylib2
location: https://github.com/mongoose-os-libs/mylib2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ libs_handled:
- core
sources:
- __APP_ROOT__/libs/mylib1/src/mylib1_src1.c
version: "1.0"
version: "2.0"
- lib:
origin: https://github.com/mongoose-os-libs/mylib2
location: https://github.com/mongoose-os-libs/mylib2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ libs_handled:
- core
sources:
- __APP_ROOT__/libs/mylib1/src/mylib1_src1.c
version: "1.0"
version: "2.0"
- lib:
origin: https://github.com/mongoose-os-libs/mylib2
location: https://github.com/mongoose-os-libs/mylib2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ libs_handled:
- core
sources:
- __APP_ROOT__/libs/mylib1/src/mylib1_src1.c
version: "1.0"
version: "2.0"
- lib:
origin: https://github.com/mongoose-os-libs/mylib2
location: https://github.com/mongoose-os-libs/mylib2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ libs_handled:
- core
sources:
- __APP_ROOT__/libs/mylib1/src/mylib1_src1.c
version: "1.0"
version: "2.0"
- lib:
origin: https://github.com/mongoose-os-libs/mylib2
location: https://github.com/mongoose-os-libs/mylib2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ libs_handled:
- core
sources:
- __APP_ROOT__/libs/mylib1/src/mylib1_src1.c
version: "1.0"
version: "2.0"
- lib:
origin: https://github.com/mongoose-os-libs/mylib2
location: https://github.com/mongoose-os-libs/mylib2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ libs_handled:
- core
sources:
- __APP_ROOT__/libs/mylib1/src/mylib1_src1.c
version: "1.0"
version: "2.0"
- lib:
origin: https://github.com/mongoose-os-libs/mylib2
location: https://github.com/mongoose-os-libs/mylib2
Expand Down

0 comments on commit ad799f8

Please sign in to comment.