205
205
isWindows = False
206
206
207
207
class Parameters ():
208
- def __init__ (self , sdkPath , projectRoot , projectName , gui , overwrite , build , features , projects , configs , runFromRAM , examples , uart , usb , cpp , debugger ):
208
+ def __init__ (self , sdkPath , projectRoot , projectName , gui , overwrite , build , features , projects ,
209
+ configs , runFromRAM , examples , uart , usb , cpp , debugger , exceptions , rtti ):
209
210
self .sdkPath = sdkPath
210
211
self .projectRoot = projectRoot
211
212
self .projectName = projectName
@@ -221,6 +222,8 @@ def __init__(self, sdkPath, projectRoot, projectName, gui, overwrite, build, fea
221
222
self .wantUSB = usb
222
223
self .wantCPP = cpp
223
224
self .debugger = debugger
225
+ self .exceptions = exceptions
226
+ self .rtti = rtti
224
227
225
228
def GetBackground ():
226
229
return 'white'
@@ -649,7 +652,7 @@ def init_window(self, args):
649
652
650
653
# Code options section
651
654
coptionsSubframe = ttk .LabelFrame (mainFrame , relief = tk .RIDGE , borderwidth = 2 , text = "Code Options" )
652
- coptionsSubframe .grid (row = optionsRow , column = 0 , columnspan = 5 , rowspan = 2 , padx = 5 , pady = 5 , ipadx = 5 , ipady = 3 , sticky = tk .E + tk .W )
655
+ coptionsSubframe .grid (row = optionsRow , column = 0 , columnspan = 5 , rowspan = 3 , padx = 5 , pady = 5 , ipadx = 5 , ipady = 3 , sticky = tk .E + tk .W )
653
656
654
657
self .wantExamples = tk .IntVar ()
655
658
self .wantExamples .set (args .examples )
@@ -665,7 +668,15 @@ def init_window(self, args):
665
668
666
669
ttk .Button (coptionsSubframe , text = "Advanced..." , command = self .config ).grid (row = 0 , column = 4 , sticky = tk .E )
667
670
668
- optionsRow += 2
671
+ self .wantCPPExceptions = tk .IntVar ()
672
+ self .wantCPPExceptions .set (args .cppexceptions )
673
+ ttk .Checkbutton (coptionsSubframe , text = "Enable C++ exceptions" , variable = self .wantCPPExceptions ).grid (row = 1 , column = 0 , padx = 4 , sticky = tk .W )
674
+
675
+ self .wantCPPRTTI = tk .IntVar ()
676
+ self .wantCPPRTTI .set (args .cpprtti )
677
+ ttk .Checkbutton (coptionsSubframe , text = "Enable C++ RTTI" , variable = self .wantCPPRTTI ).grid (row = 1 , column = 1 , padx = 4 , sticky = tk .W )
678
+
679
+ optionsRow += 3
669
680
670
681
# Build Options section
671
682
@@ -735,7 +746,7 @@ def OK(self):
735
746
gui = True , overwrite = self .wantOverwrite .get (), build = self .wantBuild .get (),
736
747
features = features , projects = projects , configs = self .configs , runFromRAM = self .wantRunFromRAM .get (),
737
748
examples = self .wantExamples .get (), uart = self .wantUART .get (), usb = self .wantUSB .get (), cpp = self .wantCPP .get (),
738
- debugger = self .debugger .current ())
749
+ debugger = self .debugger .current (), exceptions = self . wantCPPExceptions , rtti = self . wantCPPRTTI )
739
750
740
751
DoEverything (self , p )
741
752
@@ -799,6 +810,8 @@ def ParseCommandLine():
799
810
parser .add_argument ("-nouart" , "--nouart" , action = 'store_true' , default = 0 , help = "Disable console output to UART" )
800
811
parser .add_argument ("-usb" , "--usb" , action = 'store_true' , help = "Console output to USB (disables other USB functionality" )
801
812
parser .add_argument ("-cpp" , "--cpp" , action = 'store_true' , default = 0 , help = "Generate C++ code" )
813
+ parser .add_argument ("-cpprtti" , "--cpprtti" , action = 'store_true' , default = 0 , help = "Enable C++ RTTI (Uses more memory)" )
814
+ parser .add_argument ("-cppex" , "--cppexceptions" , action = 'store_true' , default = 0 , help = "Enable C++ exceptions (Uses more memory)" )
802
815
parser .add_argument ("-d" , "--debugger" , type = int , help = "Select debugger (0 = SWD, 1 = PicoProbe)" , default = 0 )
803
816
804
817
return parser .parse_args ()
@@ -881,7 +894,7 @@ def GenerateCMake(folder, params):
881
894
)
882
895
883
896
cmake_header3 = (
884
- "# Initialise the Pico SDK\n "
897
+ "\n # Initialise the Pico SDK\n "
885
898
"pico_sdk_init()\n \n "
886
899
"# Add executable. Default name is the project name, version 0.1\n \n "
887
900
)
@@ -901,7 +914,14 @@ def GenerateCMake(folder, params):
901
914
902
915
file .write ('set(PICO_SDK_PATH ' + p + ')\n \n ' )
903
916
file .write (cmake_header2 )
904
- file .write ('project(' + params .projectName + ' C CXX ASM)\n \n ' )
917
+ file .write ('project(' + params .projectName + ' C CXX ASM)\n ' )
918
+
919
+ if params .exceptions :
920
+ file .write ("\n set(PICO_CXX_ENABLE_EXCEPTIONS 1)\n " )
921
+
922
+ if params .rtti :
923
+ file .write ("\n set(PICO_CXX_ENABLE_RTTI 1)\n " )
924
+
905
925
file .write (cmake_header3 )
906
926
907
927
# add the preprocessor defines for overall configuration
@@ -1223,7 +1243,7 @@ def DoEverything(parent, params):
1223
1243
p = Parameters (sdkPath = sdkPath , projectRoot = projectRoot , projectName = args .name ,
1224
1244
gui = False , overwrite = args .overwrite , build = args .build , features = args .feature ,
1225
1245
projects = args .project , configs = (), runFromRAM = args .runFromRAM ,
1226
- examples = args .examples , uart = args .uart , usb = args .usb , cpp = args .cpp , debugger = args .debugger )
1246
+ examples = args .examples , uart = args .uart , usb = args .usb , cpp = args .cpp , debugger = args .debugger , exceptions = args . cppexceptions , rtti = args . cpprtti )
1227
1247
1228
1248
DoEverything (None , p )
1229
1249
0 commit comments