Skip to content

Commit

Permalink
depgen.py: preprocess before line control.
Browse files Browse the repository at this point in the history
  • Loading branch information
skosukhin committed Apr 25, 2024
1 parent 0dca10a commit 30d1dbb
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions mkhelper/depgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,16 +440,16 @@ def default_obj_name(src_name):
def main():
args = parse_args()

lc_files = set()

def lc_callback(filename):
lc_files.add(filename)

included_files = set()

def include_callback(filename):
included_files.add(filename)

lc_files = set()

def lc_callback(filename):
lc_files.add(filename)

provided_modules = set()

def module_start_callback(module):
Expand All @@ -463,26 +463,11 @@ def module_use_callback(module):
def submodule_start_callback(_submodule, _parent, module):
required_modules.add(module)

lc_debug_info = None
pp_debug_info = None
lc_debug_info = None
ftn_debug_info = None

parser = None
if args.lc_enable:
from depgen.line_control import LCProcessor

parser = LCProcessor(include_roots=args.src_roots, subparser=parser)
parser.lc_callback = lc_callback

def debug_callback(line, msg):
lc_debug_info.append(
"# `{0}`:\t{1}\n".format(line.rstrip("\n"), msg)
)

if args.debug:
lc_debug_info = ["#\n# Line control processor:\n"]
parser.debug_callback = debug_callback

if args.pp_enable:
from depgen.preprocessor import Preprocessor

Expand All @@ -508,6 +493,21 @@ def debug_callback(line, msg):
pp_debug_info = ["#\n# Preprocessor:\n"]
parser.debug_callback = debug_callback

if args.lc_enable:
from depgen.line_control import LCProcessor

parser = LCProcessor(include_roots=args.src_roots, subparser=parser)
parser.lc_callback = lc_callback

def debug_callback(line, msg):
lc_debug_info.append(
"# `{0}`:\t{1}\n".format(line.rstrip("\n"), msg)
)

if args.debug:
lc_debug_info = ["#\n# Line control processor:\n"]
parser.debug_callback = debug_callback

if args.fc_enable:
from depgen.fortran_parser import FortranParser

Expand Down Expand Up @@ -581,10 +581,10 @@ def debug_callback(line, msg):
"\n",
]
)
if lc_debug_info is not None:
out_lines.extend(lc_debug_info)
if pp_debug_info is not None:
out_lines.extend(pp_debug_info)
if lc_debug_info is not None:
out_lines.extend(lc_debug_info)
if ftn_debug_info is not None:
out_lines.extend(ftn_debug_info)
out_lines.append("\n")
Expand All @@ -595,8 +595,8 @@ def debug_callback(line, msg):
out_stream.writelines(out_lines)
not out_stream_close or out_stream.close()

lc_files.clear()
included_files.clear()
lc_files.clear()
provided_modules.clear()
required_modules.clear()

Expand Down

0 comments on commit 30d1dbb

Please sign in to comment.