@@ -1080,8 +1080,11 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger):
1080
1080
1081
1081
1082
1082
def LoadConfigurations ():
1083
+ # open the pico_configs.tsv from the executable's directory
1084
+ this_module_location = os .path .dirname (os .path .realpath (__file__ ))
1085
+ tsv_file = os .path .join (this_module_location , "pico_configs.tsv" )
1083
1086
try :
1084
- with open ("pico_configs.tsv" ) as tsvfile :
1087
+ with open (tsv_file ) as tsvfile :
1085
1088
reader = csv .DictReader (tsvfile , dialect = 'excel-tab' )
1086
1089
for row in reader :
1087
1090
configuration_dictionary .append (row )
@@ -1180,70 +1183,74 @@ def DoEverything(parent, params):
1180
1183
1181
1184
###################################################################################
1182
1185
# main execution starteth here
1186
+ def main ():
1187
+ args = ParseCommandLine ()
1183
1188
1184
- args = ParseCommandLine ()
1185
-
1186
- if args .nouart :
1187
- args .uart = False
1189
+ if args .nouart :
1190
+ args .uart = False
1188
1191
1189
1192
# TODO this could be better, need some constants etc
1190
- if args .debugger > 1 :
1191
- args .debugger = 0
1193
+ if args .debugger > 1 :
1194
+ args .debugger = 0
1192
1195
1193
1196
# Check we have everything we need to compile etc
1194
- c = CheckPrerequisites ()
1197
+ c = CheckPrerequisites ()
1195
1198
1196
1199
## TODO Do both warnings in the same error message so user does have to keep coming back to find still more to do
1197
1200
1198
- if c == None :
1199
- m = 'Unable to find the `' + COMPILER_NAME + '` compiler\n '
1200
- m += 'You will need to install an appropriate compiler to build a Raspberry Pi Pico project\n '
1201
- m += 'See the Raspberry Pi Pico documentation for how to do this on your particular platform\n '
1201
+ if c == None :
1202
+ m = 'Unable to find the `' + COMPILER_NAME + '` compiler\n '
1203
+ m += 'You will need to install an appropriate compiler to build a Raspberry Pi Pico project\n '
1204
+ m += 'See the Raspberry Pi Pico documentation for how to do this on your particular platform\n '
1202
1205
1203
- if (args .gui ):
1204
- RunWarning (m )
1205
- else :
1206
- print (m )
1207
- sys .exit (- 1 )
1206
+ if (args .gui ):
1207
+ RunWarning (m )
1208
+ else :
1209
+ print (m )
1210
+ sys .exit (- 1 )
1208
1211
1209
- if args .name == None and not args .gui and not args .list and not args .configs :
1210
- print ("No project name specfied\n " )
1211
- sys .exit (- 1 )
1212
+ if args .name == None and not args .gui and not args .list and not args .configs :
1213
+ print ("No project name specfied\n " )
1214
+ sys .exit (- 1 )
1212
1215
1213
1216
# load/parse any configuration dictionary we may have
1214
- LoadConfigurations ()
1217
+ LoadConfigurations ()
1215
1218
1216
- p = CheckSDKPath (args .gui )
1219
+ p = CheckSDKPath (args .gui )
1217
1220
1218
- if p == None :
1219
- sys .exit (- 1 )
1221
+ if p == None :
1222
+ sys .exit (- 1 )
1220
1223
1221
- sdkPath = Path (p )
1224
+ sdkPath = Path (p )
1222
1225
1223
- if args .gui :
1224
- RunGUI (sdkPath , args ) # does not return, only exits
1226
+ if args .gui :
1227
+ RunGUI (sdkPath , args ) # does not return, only exits
1225
1228
1226
- projectRoot = Path (os .getcwd ())
1229
+ projectRoot = Path (os .getcwd ())
1227
1230
1228
- if args .list or args .configs :
1229
- if args .list :
1230
- print ("Available project features:\n " )
1231
- for feat in features_list :
1232
- print (feat .ljust (6 ), '\t ' , features_list [feat ][GUI_TEXT ])
1233
- print ('\n ' )
1231
+ if args .list or args .configs :
1232
+ if args .list :
1233
+ print ("Available project features:\n " )
1234
+ for feat in features_list :
1235
+ print (feat .ljust (6 ), '\t ' , features_list [feat ][GUI_TEXT ])
1236
+ print ('\n ' )
1234
1237
1235
- if args .configs :
1236
- print ("Available project configuration items:\n " )
1237
- for conf in configuration_dictionary :
1238
- print (conf ['name' ].ljust (40 ), '\t ' , conf ['description' ])
1239
- print ('\n ' )
1238
+ if args .configs :
1239
+ print ("Available project configuration items:\n " )
1240
+ for conf in configuration_dictionary :
1241
+ print (conf ['name' ].ljust (40 ), '\t ' , conf ['description' ])
1242
+ print ('\n ' )
1243
+
1244
+ sys .exit (0 )
1245
+ else :
1246
+ p = Parameters (sdkPath = sdkPath , projectRoot = projectRoot , projectName = args .name ,
1247
+ gui = False , overwrite = args .overwrite , build = args .build , features = args .feature ,
1248
+ projects = args .project , configs = (), runFromRAM = args .runFromRAM ,
1249
+ examples = args .examples , uart = args .uart , usb = args .usb , cpp = args .cpp , debugger = args .debugger , exceptions = args .cppexceptions , rtti = args .cpprtti )
1250
+
1251
+ DoEverything (None , p )
1240
1252
1241
- sys .exit (0 )
1242
- else :
1243
- p = Parameters (sdkPath = sdkPath , projectRoot = projectRoot , projectName = args .name ,
1244
- gui = False , overwrite = args .overwrite , build = args .build , features = args .feature ,
1245
- projects = args .project , configs = (), runFromRAM = args .runFromRAM ,
1246
- examples = args .examples , uart = args .uart , usb = args .usb , cpp = args .cpp , debugger = args .debugger , exceptions = args .cppexceptions , rtti = args .cpprtti )
1247
1253
1248
- DoEverything (None , p )
1254
+ if __name__ == "__main__" :
1255
+ main ()
1249
1256
0 commit comments