@@ -115,6 +115,10 @@ func Debug(ctx context.Context, req *dbg.DebugConfigReq, inStream io.Reader, out
115
115
116
116
// getCommandLine compose a debug command represented by a core recipe
117
117
func getCommandLine (req * dbg.DebugConfigReq , pm * packagemanager.PackageManager ) ([]string , error ) {
118
+ if req .GetImportFile () != "" {
119
+ return nil , errors .New ("the ImportFile parameter has been deprecated, use ImportDir instead" )
120
+ }
121
+
118
122
// TODO: make a generic function to extract sketch from request
119
123
// and remove duplication in commands/compile.go
120
124
if req .GetSketchPath () == "" {
@@ -185,40 +189,24 @@ func getCommandLine(req *dbg.DebugConfigReq, pm *packagemanager.PackageManager)
185
189
}
186
190
}
187
191
188
- // Set path to compiled binary
189
- // Make the filename without the FQBN configs part
190
- fqbn .Configs = properties .NewMap ()
191
- fqbnSuffix := strings .Replace (fqbn .String (), ":" , "." , - 1 )
192
-
193
192
var importPath * paths.Path
194
- var importFile string
195
- if req .GetImportFile () == "" {
196
- importPath = sketch .FullPath
197
- importFile = sketch .Name + "." + fqbnSuffix
193
+ if importDir := req .GetImportDir (); importDir != "" {
194
+ importPath = paths .New (importDir )
198
195
} else {
199
- importPath = paths .New (req .GetImportFile ()).Parent ()
200
- importFile = paths .New (req .GetImportFile ()).Base ()
196
+ // TODO: Create a function to obtain importPath from sketch
197
+ importPath = sketch .FullPath
198
+ // Add FQBN (without configs part) to export path
199
+ fqbnSuffix := strings .Replace (fqbn .StringWithoutConfig (), ":" , "." , - 1 )
200
+ importPath = importPath .Join ("build" ).Join (fqbnSuffix )
201
201
}
202
-
203
- outputTmpFile , ok := toolProperties .GetOk ("recipe.output.tmp_file" )
204
- outputTmpFile = toolProperties .ExpandPropsInString (outputTmpFile )
205
- if ! ok {
206
- return nil , fmt .Errorf ("property 'recipe.output.tmp_file' not defined" )
202
+ if ! importPath .Exist () {
203
+ return nil , fmt .Errorf ("compiled sketch not found in %s" , importPath )
207
204
}
208
- ext := filepath .Ext (outputTmpFile )
209
- if strings .HasSuffix (importFile , ext ) {
210
- importFile = importFile [:len (importFile )- len (ext )]
205
+ if ! importPath .IsDir () {
206
+ return nil , fmt .Errorf ("expected compiled sketch in directory %s, but is a file instead" , importPath )
211
207
}
212
-
213
208
toolProperties .SetPath ("build.path" , importPath )
214
- toolProperties .Set ("build.project_name" , importFile )
215
- uploadFile := importPath .Join (importFile + ext )
216
- if _ , err := uploadFile .Stat (); err != nil {
217
- if os .IsNotExist (err ) {
218
- return nil , fmt .Errorf ("compiled sketch %s not found" , uploadFile .String ())
219
- }
220
- return nil , errors .Wrap (err , "cannot open sketch" )
221
- }
209
+ toolProperties .Set ("build.project_name" , sketch .Name + ".ino" )
222
210
223
211
// Set debug port property
224
212
port := req .GetPort ()
0 commit comments