@@ -183,11 +183,24 @@ func ReadManifestFinal(
183
183
return nil , nil , errors .Annotatef (err , "while expanding description" )
184
184
}
185
185
186
- manifest .Modules = append (manifest .Modules , build.SWModule {
187
- Name : build .MosModuleName ,
188
- Location : build .MosDefaultRepo ,
189
- Version : manifest .MongooseOsVersion ,
190
- })
186
+ var mosModule * build.SWModule
187
+ for i , m := range manifest .Modules {
188
+ if m .Name == build .MosModuleName {
189
+ mosModule = & manifest .Modules [i ]
190
+ break
191
+ }
192
+ }
193
+ if mosModule == nil {
194
+ manifest .Modules = append (manifest .Modules , build.SWModule {
195
+ Name : build .MosModuleName ,
196
+ Location : build .MosDefaultRepo ,
197
+ Version : manifest .MongooseOsVersion ,
198
+ })
199
+ } else {
200
+ if mosModule .Version == "" {
201
+ mosModule .Version = manifest .MongooseOsVersion
202
+ }
203
+ }
191
204
192
205
// Prepare local copies of all sw modules {{{
193
206
// Modules are collected from the bottom of the dependency chain,
@@ -786,21 +799,20 @@ func readManifestWithLibs2(dir string, pc *manifestParseContext) (*build.FWAppMa
786
799
}
787
800
788
801
func prepareLibs (parentNodeName string , manifest * build.FWAppManifest , pc * manifestParseContext ) (time.Time , error ) {
789
- wg := & sync.WaitGroup {}
802
+ var wg sync.WaitGroup
790
803
wg .Add (len (manifest .Libs ))
791
804
792
- lpres := make (chan libPrepareResult )
793
-
794
- for i := range manifest .Libs {
795
- go prepareLib (parentNodeName , & manifest .Libs [i ], manifest , pc , lpres , wg )
796
- }
797
-
805
+ lpres := make (chan libPrepareResult , 1000 )
798
806
// Closer goroutine
799
807
go func () {
800
808
wg .Wait ()
801
809
close (lpres )
802
810
}()
803
811
812
+ for i := range manifest .Libs {
813
+ go prepareLib (parentNodeName , & manifest .Libs [i ], manifest , pc , lpres , & wg )
814
+ }
815
+
804
816
// Handle all lib prepare results
805
817
var mtime time.Time
806
818
for res := range lpres {
@@ -966,8 +978,10 @@ func prepareLib(
966
978
)
967
979
968
980
pc .mtx .Lock ()
969
- if pc .libsHandled [name ] != nil {
981
+ lh := pc .libsHandled [name ]
982
+ if lh != nil {
970
983
pc .mtx .Unlock ()
984
+ ls .Lib = & lh .Lib
971
985
prepareLibReencounter (parentNodeName , manifest , pc ,
972
986
& pc .libsHandled [name ].Lib , m )
973
987
return
@@ -989,7 +1003,7 @@ func prepareLib(
989
1003
manifest .BuildVars [haveName ] = "1"
990
1004
manifest .CDefs [haveName ] = "1"
991
1005
992
- lh : = & build.FWAppManifestLibHandled {
1006
+ lh = & build.FWAppManifestLibHandled {
993
1007
Lib : * m ,
994
1008
Path : libLocalDir ,
995
1009
Deps : pc .deps .GetDeps (name ),
@@ -1541,8 +1555,22 @@ func extendManifest(
1541
1555
prependPaths (m2 .BinaryLibs , m2Dir )... ,
1542
1556
)
1543
1557
1544
- // Add modules and libs from lib
1545
- mMain .Modules = append (m1 .Modules , m2 .Modules ... )
1558
+ // Add modules from the lib, dedup and override if necessary.
1559
+ mm := make (map [string ]build.SWModule )
1560
+ for _ , m := range append (m1 .Modules , m2 .Modules ... ) {
1561
+ // Module must already be normalized at this point.
1562
+ if m .Name == "" {
1563
+ return fmt .Errorf ("module not normalized! %+v" , m )
1564
+ }
1565
+ mm [m .Name ] = m
1566
+ }
1567
+ mMain .Modules = nil
1568
+ for _ , m := range mm {
1569
+ mMain .Modules = append (mMain .Modules , m )
1570
+ }
1571
+ sort .Slice (mMain .Modules , func (i , j int ) bool { return mMain .Modules [i ].Name < mMain .Modules [j ].Name })
1572
+
1573
+ // Add modules libs from the lib.
1546
1574
mMain .Libs = append (m1 .Libs , m2 .Libs ... )
1547
1575
mMain .ConfigSchema = append (m1 .ConfigSchema , m2 .ConfigSchema ... )
1548
1576
mMain .CFlags = append (m1 .CFlags , m2 .CFlags ... )
0 commit comments