Skip to content

Commit 8844112

Browse files
update header include generation to use relative paths #534
Signed-off-by: Nikolaj Bjorner <[email protected]>
1 parent 4d07fa5 commit 8844112

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

scripts/mk_genfile_common.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,14 @@ def mk_def_file_internal(defname, dll_name, export_header_files):
587587
###############################################################################
588588
# Functions for generating ``gparams_register_modules.cpp``
589589
###############################################################################
590+
591+
def path_after_src(h_file):
592+
h_file = h_file.replace("\\","/")
593+
idx = h_file.index("src/")
594+
if idx == -1:
595+
return h_file
596+
return h_file[idx + 4:]
597+
590598
def mk_gparams_register_modules_internal(h_files_full_path, path):
591599
"""
592600
Generate a ``gparams_register_modules.cpp`` file in the directory ``path``.
@@ -608,7 +616,7 @@ def mk_gparams_register_modules_internal(h_files_full_path, path):
608616
fullname = os.path.join(path, 'gparams_register_modules.cpp')
609617
fout = open(fullname, 'w')
610618
fout.write('// Automatically generated file.\n')
611-
fout.write('#include"gparams.h"\n')
619+
fout.write('#include "util/gparams.h"\n')
612620
reg_pat = re.compile('[ \t]*REG_PARAMS\(\'([^\']*)\'\)')
613621
reg_mod_pat = re.compile('[ \t]*REG_MODULE_PARAMS\(\'([^\']*)\', *\'([^\']*)\'\)')
614622
reg_mod_descr_pat = re.compile('[ \t]*REG_MODULE_DESCRIPTION\(\'([^\']*)\', *\'([^\']*)\'\)')
@@ -620,13 +628,13 @@ def mk_gparams_register_modules_internal(h_files_full_path, path):
620628
if m:
621629
if not added_include:
622630
added_include = True
623-
fout.write('#include"%s"\n' % os.path.basename(h_file))
631+
fout.write('#include "%s"\n' % path_after_src(h_file))
624632
cmds.append((m.group(1)))
625633
m = reg_mod_pat.match(line)
626634
if m:
627635
if not added_include:
628636
added_include = True
629-
fout.write('#include"%s"\n' % os.path.basename(h_file))
637+
fout.write('#include "%s"\n' % path_after_src(h_file))
630638
mod_cmds.append((m.group(1), m.group(2)))
631639
m = reg_mod_descr_pat.match(line)
632640
if m:
@@ -680,9 +688,9 @@ def ADD_PROBE(name, descr, cmd):
680688
fullname = os.path.join(path, 'install_tactic.cpp')
681689
fout = open(fullname, 'w')
682690
fout.write('// Automatically generated file.\n')
683-
fout.write('#include"tactic.h"\n')
684-
fout.write('#include"tactic_cmds.h"\n')
685-
fout.write('#include"cmd_context.h"\n')
691+
fout.write('#include "tactic/tactic.h"\n')
692+
fout.write('#include "cmd_context/tactic_cmds.h"\n')
693+
fout.write('#include "cmd_context/cmd_context.h"\n')
686694
tactic_pat = re.compile('[ \t]*ADD_TACTIC\(.*\)')
687695
probe_pat = re.compile('[ \t]*ADD_PROBE\(.*\)')
688696
for h_file in sorted_headers_by_component(h_files_full_path):
@@ -691,8 +699,8 @@ def ADD_PROBE(name, descr, cmd):
691699
for line in fin:
692700
if tactic_pat.match(line):
693701
if not added_include:
694-
added_include = True
695-
fout.write('#include"%s"\n' % os.path.basename(h_file))
702+
added_include = True
703+
fout.write('#include "%s"\n' % path_after_src(h_file))
696704
try:
697705
eval(line.strip('\n '), eval_globals, None)
698706
except Exception as e:
@@ -702,7 +710,7 @@ def ADD_PROBE(name, descr, cmd):
702710
if probe_pat.match(line):
703711
if not added_include:
704712
added_include = True
705-
fout.write('#include"%s"\n' % os.path.basename(h_file))
713+
fout.write('#include "%s"\n' % path_after_src(h_file))
706714
try:
707715
eval(line.strip('\n '), eval_globals, None)
708716
except Exception as e:
@@ -764,19 +772,19 @@ def mk_mem_initializer_cpp_internal(h_files_full_path, path):
764772
if m:
765773
if not added_include:
766774
added_include = True
767-
fout.write('#include"%s"\n' % os.path.basename(h_file))
775+
fout.write('#include "%s"\n' % path_after_src(h_file))
768776
initializer_cmds.append((m.group(1), 0))
769777
m = initializer_prio_pat.match(line)
770778
if m:
771779
if not added_include:
772780
added_include = True
773-
fout.write('#include"%s"\n' % os.path.basename(h_file))
781+
fout.write('#include "%s"\n' % path_after_src(h_file))
774782
initializer_cmds.append((m.group(1), int(m.group(2))))
775783
m = finalizer_pat.match(line)
776784
if m:
777785
if not added_include:
778786
added_include = True
779-
fout.write('#include"%s"\n' % os.path.basename(h_file))
787+
fout.write('#include "%s"\n' % path_after_src(h_file))
780788
finalizer_cmds.append(m.group(1))
781789
initializer_cmds.sort(key=lambda tup: tup[1])
782790
fout.write('void mem_initialize() {\n')
@@ -881,9 +889,9 @@ def def_module_params(module_name, export, params, class_name=None, description=
881889
out.write('// Automatically generated file\n')
882890
out.write('#ifndef __%s_HPP_\n' % class_name.upper())
883891
out.write('#define __%s_HPP_\n' % class_name.upper())
884-
out.write('#include"params.h"\n')
892+
out.write('#include "util/params.h"\n')
885893
if export:
886-
out.write('#include"gparams.h"\n')
894+
out.write('#include "util/gparams.h"\n')
887895
out.write('struct %s {\n' % class_name)
888896
out.write(' params_ref const & p;\n')
889897
if export:

scripts/update_include.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def find_paths(dir):
4545
for root, dirs, files in os.walk(dir):
4646
root1 = root.replace("\\","/")[4:]
4747
for f in files:
48-
if f.endswith('.h'):
48+
if f.endswith('.h') or f.endswith('.hpp') or f.endswith('.cpp'):
4949
path = "%s/%s" % (root1, f)
5050
paths[f] = path
5151
if f.endswith('.pyg'):

src/ast/ast.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2210,7 +2210,7 @@ app * ast_manager::mk_app(func_decl * decl, unsigned num_args, expr * const * ar
22102210
r = mk_app_core(decl, num_args, args);
22112211
}
22122212
SASSERT(r != 0);
2213-
TRACE("app_ground", tout << "ground: " << r->is_ground() << "\n" << mk_ll_pp(r, *this) << "\n";);
2213+
TRACE("app_ground", tout << "ground: " << r->is_ground() << " id: " << r->get_id() << "\n" << mk_ll_pp(r, *this) << "\n";);
22142214
return r;
22152215
}
22162216

0 commit comments

Comments
 (0)