File tree Expand file tree Collapse file tree 3 files changed +14
-6
lines changed Expand file tree Collapse file tree 3 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -270,7 +270,7 @@ def expand_source_files():
270270 if block .manual_chop :
271271 source_files = manual_chop (split )
272272 else :
273- source_files = real_gnatchop (split )
273+ source_files = real_gnatchop (split , block . compiler_switches )
274274
275275 if len (source_files ) == 0 :
276276 print_error (loc , "Failed to chop example, skipping\n " )
Original file line number Diff line number Diff line change 55import shutil
66import subprocess
77import tempfile
8- from typing import List
8+ from typing import List , Optional
99
1010from .resource import Resource
1111
@@ -93,7 +93,7 @@ def to_base_filename(g):
9393 return results
9494
9595
96- def real_gnatchop (lines : List [str ]) -> List [Resource ]:
96+ def real_gnatchop (lines : List [str ], compiler_switches : Optional [ dict ] = None ) -> List [Resource ]:
9797 """Uses gnatchop to chop the text into files
9898
9999 Args:
@@ -114,7 +114,15 @@ def real_gnatchop(lines: List[str]) -> List[Resource]:
114114 f .write ('\n ' .join (lines ))
115115
116116 # run gnatchop on temp file
117- cmd = ['gnatchop' , gnatchop_file ]
117+ if compiler_switches is None :
118+ cmd = ['gnatchop' , gnatchop_file ]
119+ else :
120+ cmd = ['gnatchop' ]
121+ for sw in compiler_switches :
122+ # gnatchop only accepts `-gnatXXX` switches
123+ if "gnat" in sw :
124+ cmd .append (sw )
125+ cmd .append (gnatchop_file )
118126 output = subprocess .check_output (cmd , cwd = wd )
119127 files = [os .path .join (wd , f .decode ("utf-8" ).strip ()) for f in output .splitlines ()
120128 if not f .startswith (b'splitting ' )]
Original file line number Diff line number Diff line change 11from itertools import count
22import re
3- from typing import List , Match , Dict
3+ from typing import List , Match , Dict , Optional
44
55from .button import Button
66from .chop import manual_chop , cheapo_gnatchop , real_gnatchop , ChopStrategy
@@ -381,7 +381,7 @@ def parseContent(self, content: List[str]):
381381 elif self .__chop_strategy is ChopStrategy .CHEAPO :
382382 self .__files = cheapo_gnatchop (content )
383383 elif self .__chop_strategy is ChopStrategy .REAL :
384- self .__files = real_gnatchop (content )
384+ self .__files = real_gnatchop (content , self . switches [ 'Compiler' ] )
385385 else :
386386 raise ChopException ('No chop strategy defined' )
387387
You can’t perform that action at this time.
0 commit comments