mirror of
https://github.com/Z3Prover/z3
synced 2025-04-22 16:45:31 +00:00
[CMake] Fix dependencies for generating install_tactic.cpp
.
Previously CMake was not aware of which headers files the generation of `install_tactic.cpp` depended on. Consequently this could result in broken incremental builds if * Existing headers that declared tactics/probes changed. * New tactics/probes were added to new header files. Now the `z3_add_component()` CMake function has been modifed to take an optional `TACTIC_HEADERS` argument which allows the headers that declare tactics/probes to be explicitly listed. The necessary component declarations have been modified to declare their tactic/probe header files. With this information CMake will now regenerate `install_tactic.cpp` correctly. This required the `mk_install_tactic_cpp_internal()` function to be changed to take a list of header files rather than a list of component source directories. The two consumers (CMake and Python/Makefile build systems) of this function have been modified to work with this change. This partially fixes #1030.
This commit is contained in:
parent
a3ee785923
commit
229fd3dc3e
22 changed files with 171 additions and 32 deletions
|
@ -651,7 +651,7 @@ def mk_gparams_register_modules_internal(component_src_dirs, path):
|
|||
# Functions/data structures for generating ``install_tactics.cpp``
|
||||
###############################################################################
|
||||
|
||||
def mk_install_tactic_cpp_internal(component_src_dirs, path):
|
||||
def mk_install_tactic_cpp_internal(h_files_full_path, path):
|
||||
"""
|
||||
Generate a ``install_tactics.cpp`` file in the directory ``path``.
|
||||
Returns the path the generated file.
|
||||
|
@ -662,9 +662,10 @@ def mk_install_tactic_cpp_internal(component_src_dirs, path):
|
|||
void install_tactics(tactic_manager & ctx)
|
||||
```
|
||||
|
||||
It installs all tactics found in the given component directories
|
||||
``component_src_dirs`` The procedure looks for ``ADD_TACTIC`` commands
|
||||
in the ``.h`` and ``.hpp`` files of these components.
|
||||
It installs all tactics declared in the given header files
|
||||
``h_files_full_path`` The procedure looks for ``ADD_TACTIC`` and
|
||||
``ADD_PROBE``commands in the ``.h`` and ``.hpp`` files of these
|
||||
components.
|
||||
"""
|
||||
ADD_TACTIC_DATA = []
|
||||
ADD_PROBE_DATA = []
|
||||
|
@ -679,7 +680,7 @@ def mk_install_tactic_cpp_internal(component_src_dirs, path):
|
|||
'ADD_PROBE': ADD_PROBE,
|
||||
}
|
||||
|
||||
assert isinstance(component_src_dirs, list)
|
||||
assert isinstance(h_files_full_path, list)
|
||||
assert check_dir_exists(path)
|
||||
fullname = os.path.join(path, 'install_tactic.cpp')
|
||||
fout = open(fullname, 'w')
|
||||
|
@ -689,11 +690,6 @@ def mk_install_tactic_cpp_internal(component_src_dirs, path):
|
|||
fout.write('#include"cmd_context.h"\n')
|
||||
tactic_pat = re.compile('[ \t]*ADD_TACTIC\(.*\)')
|
||||
probe_pat = re.compile('[ \t]*ADD_PROBE\(.*\)')
|
||||
h_files_full_path = []
|
||||
for component_src_dir in sorted(component_src_dirs):
|
||||
h_files = filter(lambda f: f.endswith('.h') or f.endswith('.hpp'), os.listdir(component_src_dir))
|
||||
h_files = list(map(lambda p: os.path.join(component_src_dir, p), h_files))
|
||||
h_files_full_path.extend(h_files)
|
||||
for h_file in sorted_headers_by_component(h_files_full_path):
|
||||
added_include = False
|
||||
with open(h_file, 'r') as fin:
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
"""
|
||||
Determines the available tactics
|
||||
in header files in the list of source directions
|
||||
and generates a ``install_tactic.cpp`` file in
|
||||
the destination directory that defines a function
|
||||
``void install_tactics(tactic_manager& ctx)``.
|
||||
Determines the available tactics from a list of header files and generates a
|
||||
``install_tactic.cpp`` file in the destination directory that defines a
|
||||
function ``void install_tactics(tactic_manager& ctx)``.
|
||||
"""
|
||||
import mk_genfile_common
|
||||
import argparse
|
||||
|
@ -16,19 +14,22 @@ def main(args):
|
|||
logging.basicConfig(level=logging.INFO)
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("destination_dir", help="destination directory")
|
||||
parser.add_argument("source_dirs", nargs="+",
|
||||
help="One or more source directories to search")
|
||||
parser.add_argument("header_files", nargs="+",
|
||||
help="One or more header files to parse")
|
||||
pargs = parser.parse_args(args)
|
||||
|
||||
if not mk_genfile_common.check_dir_exists(pargs.destination_dir):
|
||||
return 1
|
||||
|
||||
for source_dir in pargs.source_dirs:
|
||||
if not mk_genfile_common.check_dir_exists(source_dir):
|
||||
return 1
|
||||
if not mk_genfile_common.check_files_exist(pargs.header_files):
|
||||
return 1
|
||||
|
||||
h_files_full_path = []
|
||||
for header_file in pargs.header_files:
|
||||
h_files_full_path.append(os.path.abspath(header_file))
|
||||
|
||||
output = mk_genfile_common.mk_install_tactic_cpp_internal(
|
||||
pargs.source_dirs,
|
||||
h_files_full_path,
|
||||
pargs.destination_dir
|
||||
)
|
||||
logging.info('Generated "{}"'.format(output))
|
||||
|
|
|
@ -2712,12 +2712,22 @@ def mk_all_assembly_infos(major, minor, build, revision):
|
|||
else:
|
||||
raise MKException("Failed to find assembly template info file '%s'" % assembly_info_template)
|
||||
|
||||
def get_header_files_for_components(component_src_dirs):
|
||||
assert isinstance(component_src_dirs, list)
|
||||
h_files_full_path = []
|
||||
for component_src_dir in sorted(component_src_dirs):
|
||||
h_files = filter(lambda f: f.endswith('.h') or f.endswith('.hpp'), os.listdir(component_src_dir))
|
||||
h_files = list(map(lambda p: os.path.join(component_src_dir, p), h_files))
|
||||
h_files_full_path.extend(h_files)
|
||||
return h_files_full_path
|
||||
|
||||
def mk_install_tactic_cpp(cnames, path):
|
||||
component_src_dirs = []
|
||||
for cname in cnames:
|
||||
c = get_component(cname)
|
||||
component_src_dirs.append(c.src_dir)
|
||||
generated_file = mk_genfile_common.mk_install_tactic_cpp_internal(component_src_dirs, path)
|
||||
h_files_full_path = get_header_files_for_components(component_src_dirs)
|
||||
generated_file = mk_genfile_common.mk_install_tactic_cpp_internal(h_files_full_path, path)
|
||||
if VERBOSE:
|
||||
print("Generated '{}'".format(generated_file))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue