@@ -227,99 +227,99 @@ func (pm *Builder) loadPlatform(targetPackage *cores.Package, architecture strin
227
227
return nil
228
228
}
229
229
230
- func (pm * Builder ) loadPlatformRelease (platform * cores.PlatformRelease , path * paths.Path ) error {
230
+ func (pm * Builder ) loadPlatformRelease (platformRelease * cores.PlatformRelease , platformPath * paths.Path ) error {
231
231
// If the installed.json file is found load it, this is done to handle the
232
232
// case in which the platform's index and its url have been deleted locally,
233
233
// if we don't load it some information about the platform is lost
234
- installedJSONPath := path .Join ("installed.json" )
234
+ installedJSONPath := platformPath .Join ("installed.json" )
235
235
if installedJSONPath .Exist () {
236
236
if _ , err := pm .LoadPackageIndexFromFile (installedJSONPath ); err != nil {
237
237
return errors .New (i18n .Tr ("loading %[1]s: %[2]s" , installedJSONPath , err ))
238
238
}
239
239
}
240
240
241
- platform .InstallDir = path
242
- platform .Timestamps .AddFile (installedJSONPath )
243
- platform .Properties = platform .Properties .Clone () // TODO: why CLONE?
241
+ platformRelease .InstallDir = platformPath
242
+ platformRelease .Timestamps .AddFile (installedJSONPath )
243
+ platformRelease .Properties = platformRelease .Properties .Clone () // TODO: why CLONE?
244
244
245
245
// Create platform properties
246
- platformTxtPath := path .Join ("platform.txt" )
247
- platform .Timestamps .AddFile (platformTxtPath )
246
+ platformTxtPath := platformPath .Join ("platform.txt" )
247
+ platformRelease .Timestamps .AddFile (platformTxtPath )
248
248
if p , err := properties .SafeLoadFromPath (platformTxtPath ); err == nil {
249
- platform .Properties .Merge (p )
249
+ platformRelease .Properties .Merge (p )
250
250
} else {
251
251
return errors .New (i18n .Tr ("loading %[1]s: %[2]s" , platformTxtPath , err ))
252
252
}
253
253
254
- platformTxtLocalPath := path .Join ("platform.local.txt" )
255
- platform .Timestamps .AddFile (platformTxtLocalPath )
254
+ platformTxtLocalPath := platformPath .Join ("platform.local.txt" )
255
+ platformRelease .Timestamps .AddFile (platformTxtLocalPath )
256
256
if p , err := properties .SafeLoadFromPath (platformTxtLocalPath ); err == nil {
257
- platform .Properties .Merge (p )
257
+ platformRelease .Properties .Merge (p )
258
258
} else {
259
259
return errors .New (i18n .Tr ("loading %[1]s: %[2]s" , platformTxtLocalPath , err ))
260
260
}
261
261
262
- if platform .Properties .SubTree ("pluggable_discovery" ).Size () > 0 || platform .Properties .SubTree ("pluggable_monitor" ).Size () > 0 {
263
- platform .PluggableDiscoveryAware = true
262
+ if platformRelease .Properties .SubTree ("pluggable_discovery" ).Size () > 0 || platformRelease .Properties .SubTree ("pluggable_monitor" ).Size () > 0 {
263
+ platformRelease .PluggableDiscoveryAware = true
264
264
} else {
265
- platform .Properties .Set ("pluggable_discovery.required.0" , "builtin:serial-discovery" )
266
- platform .Properties .Set ("pluggable_discovery.required.1" , "builtin:mdns-discovery" )
267
- platform .Properties .Set ("pluggable_monitor.required.serial" , "builtin:serial-monitor" )
265
+ platformRelease .Properties .Set ("pluggable_discovery.required.0" , "builtin:serial-discovery" )
266
+ platformRelease .Properties .Set ("pluggable_discovery.required.1" , "builtin:mdns-discovery" )
267
+ platformRelease .Properties .Set ("pluggable_monitor.required.serial" , "builtin:serial-monitor" )
268
268
}
269
269
270
- if platform .Name == "" {
271
- if name , ok := platform .Properties .GetOk ("name" ); ok {
272
- platform .Name = name
270
+ if platformRelease .Name == "" {
271
+ if name , ok := platformRelease .Properties .GetOk ("name" ); ok {
272
+ platformRelease .Name = name
273
273
} else {
274
274
// If the platform.txt file doesn't exist for this platform and it's not in any
275
275
// package index there is no way of retrieving its name, so we build one using
276
276
// the available information, that is the packager name and the architecture.
277
- platform .Name = fmt .Sprintf ("%s-%s" , platform .Platform .Package .Name , platform .Platform .Architecture )
277
+ platformRelease .Name = fmt .Sprintf ("%s-%s" , platformRelease .Platform .Package .Name , platformRelease .Platform .Architecture )
278
278
}
279
279
}
280
280
281
281
// Create programmers properties
282
- programmersTxtPath := path .Join ("programmers.txt" )
283
- platform .Timestamps .AddFile (programmersTxtPath )
282
+ programmersTxtPath := platformPath .Join ("programmers.txt" )
283
+ platformRelease .Timestamps .AddFile (programmersTxtPath )
284
284
if programmersProperties , err := properties .SafeLoadFromPath (programmersTxtPath ); err == nil {
285
285
for programmerID , programmerProps := range programmersProperties .FirstLevelOf () {
286
- if ! platform .PluggableDiscoveryAware {
286
+ if ! platformRelease .PluggableDiscoveryAware {
287
287
convertUploadToolsToPluggableDiscovery (programmerProps )
288
288
}
289
- platform .Programmers [programmerID ] = pm .loadProgrammer (programmerProps )
290
- platform .Programmers [programmerID ].PlatformRelease = platform
289
+ platformRelease .Programmers [programmerID ] = pm .loadProgrammer (programmerProps )
290
+ platformRelease .Programmers [programmerID ].PlatformRelease = platformRelease
291
291
}
292
292
} else {
293
293
return err
294
294
}
295
295
296
- if err := pm .loadBoards (platform ); err != nil {
296
+ if err := pm .loadBoards (platformRelease ); err != nil {
297
297
return errors .New (i18n .Tr ("loading boards: %s" , err ))
298
298
}
299
299
300
- if ! platform .PluggableDiscoveryAware {
301
- convertLegacyPlatformToPluggableDiscovery (platform )
300
+ if ! platformRelease .PluggableDiscoveryAware {
301
+ convertLegacyPlatformToPluggableDiscovery (platformRelease )
302
302
}
303
303
304
304
// Build pluggable monitor references
305
- platform .Monitors = map [string ]* cores.MonitorDependency {}
306
- for protocol , ref := range platform .Properties .SubTree ("pluggable_monitor.required" ).AsMap () {
305
+ platformRelease .Monitors = map [string ]* cores.MonitorDependency {}
306
+ for protocol , ref := range platformRelease .Properties .SubTree ("pluggable_monitor.required" ).AsMap () {
307
307
split := strings .Split (ref , ":" )
308
308
if len (split ) != 2 {
309
309
return errors .New (i18n .Tr ("invalid pluggable monitor reference: %s" , ref ))
310
310
}
311
311
pm .log .WithField ("protocol" , protocol ).WithField ("tool" , ref ).Info ("Adding monitor tool" )
312
- platform .Monitors [protocol ] = & cores.MonitorDependency {
312
+ platformRelease .Monitors [protocol ] = & cores.MonitorDependency {
313
313
Packager : split [0 ],
314
314
Name : split [1 ],
315
315
}
316
316
}
317
317
318
318
// Support for pluggable monitors in debugging/development environments
319
- platform .MonitorsDevRecipes = map [string ]string {}
320
- for protocol , recipe := range platform .Properties .SubTree ("pluggable_monitor.pattern" ).AsMap () {
319
+ platformRelease .MonitorsDevRecipes = map [string ]string {}
320
+ for protocol , recipe := range platformRelease .Properties .SubTree ("pluggable_monitor.pattern" ).AsMap () {
321
321
pm .log .WithField ("protocol" , protocol ).WithField ("recipe" , recipe ).Info ("Adding monitor recipe" )
322
- platform .MonitorsDevRecipes [protocol ] = recipe
322
+ platformRelease .MonitorsDevRecipes [protocol ] = recipe
323
323
}
324
324
325
325
return nil
0 commit comments