Skip to content

Commit ad799f8

Browse files
committed
Allow overriding lib version from conds
1 parent e977ddf commit ad799f8

File tree

13 files changed

+34
-36
lines changed

13 files changed

+34
-36
lines changed

cli/build/manifest.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,14 @@ type AppManifest struct {
5050
}
5151

5252
type FWAppManifestLibHandled struct {
53-
Lib SWModule `yaml:"lib,omitempty" json:"name"`
54-
Path string `yaml:"path,omitempty" json:"path"`
55-
Deps []string `yaml:"deps,omitempty" json:"deps"`
56-
InitDeps []string `yaml:"init_deps,omitempty" json:"init_deps"`
57-
Sources []string `yaml:"sources,omitempty" json:"sources"`
58-
Version string `yaml:"version,omitempty" json:"version"`
59-
Manifest *FWAppManifest `yaml:"-" json:"-"`
53+
Lib SWModule `yaml:"lib,omitempty" json:"name"`
54+
Path string `yaml:"path,omitempty" json:"path"`
55+
Deps []string `yaml:"deps,omitempty" json:"deps"`
56+
InitDeps []string `yaml:"init_deps,omitempty" json:"init_deps"`
57+
Sources []string `yaml:"sources,omitempty" json:"sources"`
58+
Version string `yaml:"version,omitempty" json:"version"`
59+
RepoVersion string `yaml:"repo_version,omitempty" json:"version"`
60+
Manifest *FWAppManifest `yaml:"-" json:"-"`
6061
}
6162

6263
// FWAppManifest is the app manifest for firmware apps

cli/manifest_parser/manifest_parser.go

+14-16
Original file line numberDiff line numberDiff line change
@@ -223,16 +223,18 @@ func ReadManifestFinal(
223223
return nil, nil, errors.Trace(err)
224224
}
225225

226-
for k, v := range manifest.LibsHandled {
226+
for i, v := range manifest.LibsHandled {
227227
name, err := v.Lib.GetName()
228228
if err != nil {
229229
return nil, nil, errors.Trace(err)
230230
}
231231
interpreter.SetLibVars(interp.MVars, name, v.Path)
232-
manifest.LibsHandled[k].Sources, err = interpreter.ExpandVarsSlice(interp, v.Sources, false)
232+
manifest.LibsHandled[i].Sources, err = interpreter.ExpandVarsSlice(interp, v.Sources, false)
233233
if err != nil {
234234
return nil, nil, errors.Trace(err)
235235
}
236+
manifest.LibsHandled[i].Version = v.Manifest.Version
237+
manifest.LibsHandled[i].RepoVersion, _ = v.Lib.GetLocalVersion()
236238
}
237239

238240
manifest.Includes, err = interpreter.ExpandVarsSlice(interp, manifest.Includes, false)
@@ -968,7 +970,6 @@ func prepareLib(
968970
Lib: *m,
969971
Path: libLocalDir,
970972
Deps: pc.deps.GetDeps(name),
971-
Version: libManifest.Version,
972973
Manifest: libManifest,
973974
}
974975
pc.libsHandled[name] = lh
@@ -1432,17 +1433,14 @@ func ExpandManifestConds(
14321433
}); err != nil {
14331434
return errors.Trace(err)
14341435
}
1435-
// Conds in app's manifest can override name, description and version.
1436-
if isAppManifest {
1437-
if cond.Apply.Name != "" {
1438-
dstManifest.Name = cond.Apply.Name
1439-
}
1440-
if cond.Apply.Description != "" {
1441-
dstManifest.Description = cond.Apply.Description
1442-
}
1443-
if cond.Apply.Version != "" {
1444-
dstManifest.Version = cond.Apply.Version
1445-
}
1436+
if isAppManifest && cond.Apply.Name != "" {
1437+
dstManifest.Name = cond.Apply.Name
1438+
}
1439+
if cond.Apply.Description != "" {
1440+
dstManifest.Description = cond.Apply.Description
1441+
}
1442+
if cond.Apply.Version != "" {
1443+
dstManifest.Version = cond.Apply.Version
14461444
}
14471445
}
14481446
}
@@ -1684,8 +1682,8 @@ func getDepsInitCCode(manifest *build.FWAppManifest, mosHash string) ([]byte, er
16841682
}
16851683
}
16861684
lv := lh.Version
1687-
if llv, err := lh.Lib.GetLocalVersion(); err == nil {
1688-
lv = fmt.Sprintf("%s/%s", lv, llv)
1685+
if lh.RepoVersion != "" {
1686+
lv = fmt.Sprintf("%s/%s", lv, lh.RepoVersion)
16891687
}
16901688
initFunc := "NULL"
16911689
if len(lh.Sources) > 0 {

cli/manifest_parser/test_manifests/testset_02_conds_switch_without_arch_manifests/libs_common/mylib1/mos.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ config_schema:
1414
conds:
1515
- when: '"1" == "1"'
1616
apply:
17-
# Top-level attributes can only be overriden in app's conds
17+
# Name can only be overriden in app's conds
1818
name: Does not
19-
description: work
20-
version: from here
19+
version: 2.0
2120

2221
manifest_version: 2017-09-29

cli/manifest_parser/test_manifests/testset_02_conds_switch_without_arch_manifests/test_01_app_doesnt_override/expected/esp32/mos_final.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ libs_handled:
8181
- core
8282
sources:
8383
- __APP_ROOT__/libs/mylib1/src/mylib1_src1.c
84-
version: "1.0"
84+
version: "2.0"
8585
- lib:
8686
origin: https://github.com/mongoose-os-libs/mylib2
8787
location: https://github.com/mongoose-os-libs/mylib2

cli/manifest_parser/test_manifests/testset_02_conds_switch_without_arch_manifests/test_01_app_doesnt_override/expected/esp8266/mos_final.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ libs_handled:
8080
- core
8181
sources:
8282
- __APP_ROOT__/libs/mylib1/src/mylib1_src1.c
83-
version: "1.0"
83+
version: "2.0"
8484
- lib:
8585
origin: https://github.com/mongoose-os-libs/mylib2
8686
location: https://github.com/mongoose-os-libs/mylib2

cli/manifest_parser/test_manifests/testset_02_conds_switch_without_arch_manifests/test_02_app_overrides_to_1/expected/esp32/mos_final.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ libs_handled:
8181
- core
8282
sources:
8383
- __APP_ROOT__/libs/mylib1/src/mylib1_src1.c
84-
version: "1.0"
84+
version: "2.0"
8585
- lib:
8686
origin: https://github.com/mongoose-os-libs/mylib2
8787
location: https://github.com/mongoose-os-libs/mylib2

cli/manifest_parser/test_manifests/testset_02_conds_switch_without_arch_manifests/test_02_app_overrides_to_1/expected/esp8266/mos_final.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ libs_handled:
7979
- core
8080
sources:
8181
- __APP_ROOT__/libs/mylib1/src/mylib1_src1.c
82-
version: "1.0"
82+
version: "2.0"
8383
- lib:
8484
origin: https://github.com/mongoose-os-libs/mylib2
8585
location: https://github.com/mongoose-os-libs/mylib2

cli/manifest_parser/test_manifests/testset_02_conds_switch_without_arch_manifests/test_03_app_overrides_to_0/expected/esp32/mos_final.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ libs_handled:
8080
- core
8181
sources:
8282
- __APP_ROOT__/libs/mylib1/src/mylib1_src1.c
83-
version: "1.0"
83+
version: "2.0"
8484
- lib:
8585
origin: https://github.com/mongoose-os-libs/mylib2
8686
location: https://github.com/mongoose-os-libs/mylib2

cli/manifest_parser/test_manifests/testset_02_conds_switch_without_arch_manifests/test_03_app_overrides_to_0/expected/esp8266/mos_final.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ libs_handled:
7878
- core
7979
sources:
8080
- __APP_ROOT__/libs/mylib1/src/mylib1_src1.c
81-
version: "1.0"
81+
version: "2.0"
8282
- lib:
8383
origin: https://github.com/mongoose-os-libs/mylib2
8484
location: https://github.com/mongoose-os-libs/mylib2

cli/manifest_parser/test_manifests/testset_02_conds_switch_without_arch_manifests/test_04_app_overrides_to_1_cli_overrides_to_0/expected/esp32/mos_final.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ libs_handled:
8080
- core
8181
sources:
8282
- __APP_ROOT__/libs/mylib1/src/mylib1_src1.c
83-
version: "1.0"
83+
version: "2.0"
8484
- lib:
8585
origin: https://github.com/mongoose-os-libs/mylib2
8686
location: https://github.com/mongoose-os-libs/mylib2

cli/manifest_parser/test_manifests/testset_02_conds_switch_without_arch_manifests/test_04_app_overrides_to_1_cli_overrides_to_0/expected/esp8266/mos_final.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ libs_handled:
7878
- core
7979
sources:
8080
- __APP_ROOT__/libs/mylib1/src/mylib1_src1.c
81-
version: "1.0"
81+
version: "2.0"
8282
- lib:
8383
origin: https://github.com/mongoose-os-libs/mylib2
8484
location: https://github.com/mongoose-os-libs/mylib2

cli/manifest_parser/test_manifests/testset_02_conds_switch_without_arch_manifests/test_05_app_overrides_to_0_cli_overrides_to_1/expected/esp32/mos_final.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ libs_handled:
8181
- core
8282
sources:
8383
- __APP_ROOT__/libs/mylib1/src/mylib1_src1.c
84-
version: "1.0"
84+
version: "2.0"
8585
- lib:
8686
origin: https://github.com/mongoose-os-libs/mylib2
8787
location: https://github.com/mongoose-os-libs/mylib2

cli/manifest_parser/test_manifests/testset_02_conds_switch_without_arch_manifests/test_05_app_overrides_to_0_cli_overrides_to_1/expected/esp8266/mos_final.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ libs_handled:
7979
- core
8080
sources:
8181
- __APP_ROOT__/libs/mylib1/src/mylib1_src1.c
82-
version: "1.0"
82+
version: "2.0"
8383
- lib:
8484
origin: https://github.com/mongoose-os-libs/mylib2
8585
location: https://github.com/mongoose-os-libs/mylib2

0 commit comments

Comments
 (0)