@@ -112,43 +112,30 @@ func run(command *cobra.Command, args []string) {
112
112
}
113
113
114
114
// Load programmer tool
115
- uploadToolID , have := boardProperties .GetOk ("upload.tool" )
116
- if ! have || uploadToolID == "" {
117
- formatter .PrintErrorMessage ("The board defines an invalid 'upload.tool': " + uploadToolID )
115
+ uploadToolPattern , have := boardProperties .GetOk ("upload.tool" )
116
+ if ! have || uploadToolPattern == "" {
117
+ formatter .PrintErrorMessage ("The board does not define an 'upload.tool' property." )
118
118
os .Exit (commands .ErrGeneric )
119
119
}
120
120
121
- var referencedPackage * cores.Package
122
- var referencedPlatform * cores.Platform
123
121
var referencedPlatformRelease * cores.PlatformRelease
124
- var uploadTool * cores. Tool
125
- if split := strings . Split ( uploadToolID , ":" ); len ( split ) == 1 {
126
- uploadTool = board . PlatformRelease . Platform . Package . Tools [ uploadToolID ]
122
+ if split := strings . Split ( uploadToolPattern , ":" ); len ( split ) > 2 {
123
+ formatter . PrintErrorMessage ( "The board defines an invalid 'upload.tool' property: " + uploadToolPattern )
124
+ os . Exit ( commands . ErrGeneric )
127
125
} else if len (split ) == 2 {
128
- referencedPackage = pm .GetPackages ().Packages [split [0 ]]
129
- if referencedPackage == nil {
130
- formatter .PrintErrorMessage ("The board requires a tool from package '" + split [0 ] + "' that is not installed: " + uploadToolID )
131
- os .Exit (commands .ErrGeneric )
132
- }
133
- uploadTool = referencedPackage .Tools [split [1 ]]
126
+ referencedPackageName := split [0 ]
127
+ uploadToolPattern = split [1 ]
128
+ architecture := board .PlatformRelease .Platform .Architecture
134
129
135
- referencedPlatform = referencedPackage .Platforms [board .PlatformRelease .Platform .Architecture ]
136
- if referencedPlatform != nil {
130
+ if referencedPackage := pm .GetPackages ().Packages [referencedPackageName ]; referencedPackage == nil {
131
+ formatter .PrintErrorMessage ("The board requires platform '" + referencedPackageName + ":" + architecture + "' that is not installed." )
132
+ os .Exit (commands .ErrGeneric )
133
+ } else if referencedPlatform := referencedPackage .Platforms [architecture ]; referencedPlatform == nil {
134
+ formatter .PrintErrorMessage ("The board requires platform '" + referencedPackageName + ":" + architecture + "' that is not installed." )
135
+ os .Exit (commands .ErrGeneric )
136
+ } else {
137
137
referencedPlatformRelease = pm .GetInstalledPlatformRelease (referencedPlatform )
138
138
}
139
- } else {
140
- formatter .PrintErrorMessage ("The board defines an invalid 'upload.tool': " + uploadToolID )
141
- os .Exit (commands .ErrGeneric )
142
- }
143
- if uploadTool == nil {
144
- formatter .PrintErrorMessage ("Upload tool '" + uploadToolID + "' not found." )
145
- os .Exit (commands .ErrGeneric )
146
- }
147
- // FIXME: Look into index if the platform requires a specific version
148
- uploadToolRelease := uploadTool .GetLatestInstalled ()
149
- if uploadToolRelease == nil {
150
- formatter .PrintErrorMessage ("Upload tool '" + uploadToolID + "' not installed." )
151
- os .Exit (commands .ErrGeneric )
152
139
}
153
140
154
141
// Build configuration for upload
@@ -160,7 +147,7 @@ func run(command *cobra.Command, args []string) {
160
147
uploadProperties .Merge (board .PlatformRelease .RuntimeProperties ())
161
148
uploadProperties .Merge (boardProperties )
162
149
163
- uploadToolProperties := uploadProperties .SubTree ("tools." + uploadTool . Name )
150
+ uploadToolProperties := uploadProperties .SubTree ("tools." + uploadToolPattern )
164
151
uploadProperties .Merge (uploadToolProperties )
165
152
166
153
if requiredTools , err := pm .FindToolsRequiredForBoard (board ); err == nil {
0 commit comments