Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/py_modules/code_projects/extract_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def expand_source_files():
if block.manual_chop:
source_files = manual_chop(split)
else:
source_files = real_gnatchop(split)
source_files = real_gnatchop(split, block.compiler_switches)

if len(source_files) == 0:
print_error(loc, "Failed to chop example, skipping\n")
Expand Down
14 changes: 11 additions & 3 deletions frontend/sphinx/widget/chop.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import shutil
import subprocess
import tempfile
from typing import List
from typing import List, Optional

from .resource import Resource

Expand Down Expand Up @@ -93,7 +93,7 @@ def to_base_filename(g):
return results


def real_gnatchop(lines: List[str]) -> List[Resource]:
def real_gnatchop(lines: List[str], compiler_switches: Optional[dict] = None) -> List[Resource]:
"""Uses gnatchop to chop the text into files

Args:
Expand All @@ -114,7 +114,15 @@ def real_gnatchop(lines: List[str]) -> List[Resource]:
f.write('\n'.join(lines))

# run gnatchop on temp file
cmd = ['gnatchop', gnatchop_file]
if compiler_switches is None:
cmd = ['gnatchop', gnatchop_file]
else:
cmd = ['gnatchop']
for sw in compiler_switches:
# gnatchop only accepts `-gnatXXX` switches
if "gnat" in sw:
cmd.append(sw)
cmd.append(gnatchop_file)
output = subprocess.check_output(cmd, cwd=wd)
files = [os.path.join(wd, f.decode("utf-8").strip()) for f in output.splitlines()
if not f.startswith(b'splitting ')]
Expand Down
4 changes: 2 additions & 2 deletions frontend/sphinx/widget/widget.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from itertools import count
import re
from typing import List, Match, Dict
from typing import List, Match, Dict, Optional

from .button import Button
from .chop import manual_chop, cheapo_gnatchop, real_gnatchop, ChopStrategy
Expand Down Expand Up @@ -381,7 +381,7 @@ def parseContent(self, content: List[str]):
elif self.__chop_strategy is ChopStrategy.CHEAPO:
self.__files = cheapo_gnatchop(content)
elif self.__chop_strategy is ChopStrategy.REAL:
self.__files = real_gnatchop(content)
self.__files = real_gnatchop(content, self.switches['Compiler'])
else:
raise ChopException('No chop strategy defined')

Expand Down
Loading