202
202
isWindows = False
203
203
204
204
class Parameters ():
205
- def __init__ (self , sdkPath , projectRoot , projectName , gui , overwrite , build , features , projects , configs , runFromRAM , examples , uart , usb ):
205
+ def __init__ (self , sdkPath , projectRoot , projectName , gui , overwrite , build , features , projects , configs , runFromRAM , examples , uart , usb , cpp ):
206
206
self .sdkPath = sdkPath
207
207
self .projectRoot = projectRoot
208
208
self .projectName = projectName
@@ -216,6 +216,7 @@ def __init__(self, sdkPath, projectRoot, projectName, gui, overwrite, build, fea
216
216
self .wantExamples = examples
217
217
self .wantUART = uart
218
218
self .wantUSB = usb
219
+ self .wantCPP = cpp
219
220
220
221
def GetBackground ():
221
222
return 'white'
@@ -652,6 +653,10 @@ def init_window(self, args):
652
653
self .wantRunFromRAM .set (args .runFromRAM )
653
654
ttk .Checkbutton (coptionsSubframe , text = "Run from RAM" , variable = self .wantRunFromRAM ).grid (row = 0 , column = 1 , padx = 4 , sticky = tk .W )
654
655
656
+ self .wantCPP = tk .IntVar ()
657
+ self .wantCPP .set (args .cpp )
658
+ ttk .Checkbutton (coptionsSubframe , text = "Generate C++" , variable = self .wantCPP ).grid (row = 0 , column = 3 , padx = 4 , sticky = tk .W )
659
+
655
660
ttk .Button (coptionsSubframe , text = "Advanced..." , command = self .config ).grid (row = 0 , column = 4 , sticky = tk .E )
656
661
657
662
optionsRow += 2
@@ -712,7 +717,7 @@ def OK(self):
712
717
p = Parameters (sdkPath = self .sdkpath , projectRoot = Path (projectPath ), projectName = self .projectName .get (),
713
718
gui = True , overwrite = self .wantOverwrite .get (), build = self .wantBuild .get (),
714
719
features = features , projects = projects , configs = self .configs , runFromRAM = self .wantRunFromRAM .get (),
715
- examples = self .wantExamples .get (), uart = self .wantUART .get (), usb = self .wantUSB .get ())
720
+ examples = self .wantExamples .get (), uart = self .wantUART .get (), usb = self .wantUSB .get (), cpp = self . wantCPP . get () )
716
721
717
722
DoEverything (self , p )
718
723
@@ -773,14 +778,19 @@ def ParseCommandLine():
773
778
parser .add_argument ("-p" , "--project" , action = 'append' , help = "Generate projects files for IDE. Options are: vscode" )
774
779
parser .add_argument ("-r" , "--runFromRAM" , action = 'store_true' , help = "Run the program from RAM rather than flash" )
775
780
parser .add_argument ("-uart" , "--uart" , action = 'store_true' , default = 1 , help = "Console output to UART (default)" )
781
+ parser .add_argument ("-nouart" , "--nouart" , action = 'store_true' , default = 0 , help = "Disable console output to UART" )
776
782
parser .add_argument ("-usb" , "--usb" , action = 'store_true' , help = "Console output to USB (disables other USB functionality" )
783
+ parser .add_argument ("-cpp" , "--cpp" , action = 'store_true' , default = 0 , help = "Generate C++ code" )
777
784
778
785
return parser .parse_args ()
779
786
780
787
781
- def GenerateMain (folder , projectName , features ):
788
+ def GenerateMain (folder , projectName , features , cpp ):
782
789
783
- filename = Path (folder ) / (projectName + '.c' )
790
+ if cpp :
791
+ filename = Path (folder ) / (projectName + '.cpp' )
792
+ else :
793
+ filename = Path (folder ) / (projectName + '.c' )
784
794
785
795
file = open (filename , 'w' )
786
796
@@ -885,7 +895,11 @@ def GenerateCMake(folder, params):
885
895
# No GUI/command line to set a different executable name at this stage
886
896
executableName = params .projectName
887
897
888
- file .write ('add_executable(' + params .projectName + ' ' + params .projectName + '.c )\n \n ' )
898
+ if params .wantCPP :
899
+ file .write ('add_executable(' + params .projectName + ' ' + params .projectName + '.cpp )\n \n ' )
900
+ else :
901
+ file .write ('add_executable(' + params .projectName + ' ' + params .projectName + '.c )\n \n ' )
902
+
889
903
file .write ('pico_set_program_name(' + params .projectName + ' "' + executableName + '")\n ' )
890
904
file .write ('pico_set_program_version(' + params .projectName + ' "0.1")\n \n ' )
891
905
@@ -1077,7 +1091,7 @@ def DoEverything(parent, params):
1077
1091
if params .wantExamples :
1078
1092
features_and_examples = list (stdlib_examples_list .keys ()) + features_and_examples
1079
1093
1080
- GenerateMain ('.' , params .projectName , features_and_examples )
1094
+ GenerateMain ('.' , params .projectName , features_and_examples , params . wantCPP )
1081
1095
1082
1096
GenerateCMake ('.' , params )
1083
1097
@@ -1121,6 +1135,8 @@ def DoEverything(parent, params):
1121
1135
1122
1136
args = ParseCommandLine ()
1123
1137
1138
+ if args .nouart :
1139
+ args .uart = False
1124
1140
1125
1141
# Check we have everything we need to compile etc
1126
1142
c = CheckPrerequisites ()
@@ -1175,7 +1191,7 @@ def DoEverything(parent, params):
1175
1191
p = Parameters (sdkPath = sdkPath , projectRoot = projectRoot , projectName = args .name ,
1176
1192
gui = False , overwrite = args .overwrite , build = args .build , features = args .feature ,
1177
1193
projects = args .project , configs = (), runFromRAM = args .runFromRAM ,
1178
- examples = args .examples , uart = args .uart , usb = args .usb )
1194
+ examples = args .examples , uart = args .uart , usb = args .usb , cpp = args . cpp )
1179
1195
1180
1196
DoEverything (None , p )
1181
1197
0 commit comments