mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 20:18:18 +00:00
Move `mk_pat_db_internal()
from
mk_util.py
` to
``mk_genfile_common.py`` and adapt ``mk_util.py`` and ``mk_pat_db.py`` to use the code at its new location. Whilst I'm here reindent ``mk_mem_initializer_cpp.py``. The purpose of this change is to have Python code common to the Python and CMake build systems separate from Python code that is only used for the Python build system.
This commit is contained in:
parent
114e165fad
commit
8840e5a00f
|
@ -376,3 +376,18 @@ def mk_mem_initializer_cpp_internal(component_src_dirs, path):
|
||||||
fout.write('}\n')
|
fout.write('}\n')
|
||||||
fout.close()
|
fout.close()
|
||||||
return fullname
|
return fullname
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Functions for generating ``database.h``
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
def mk_pat_db_internal(inputFilePath, outputFilePath):
|
||||||
|
"""
|
||||||
|
Generate ``g_pattern_database[]`` declaration header file.
|
||||||
|
"""
|
||||||
|
with open(inputFilePath, 'r') as fin:
|
||||||
|
with open(outputFilePath, 'w') as fout:
|
||||||
|
fout.write('static char const g_pattern_database[] =\n')
|
||||||
|
for line in fin:
|
||||||
|
fout.write('"%s\\n"\n' % line.strip('\n'))
|
||||||
|
fout.write(';\n')
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Reads a pattern database and generates the corresponding
|
Reads a pattern database and generates the corresponding
|
||||||
header file.
|
header file.
|
||||||
"""
|
"""
|
||||||
import mk_util
|
import mk_genfile_common
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
@ -20,13 +20,8 @@ def main(args):
|
||||||
logging.error('"{}" does not exist'.format(pargs.db_file))
|
logging.error('"{}" does not exist'.format(pargs.db_file))
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if (os.path.exists(pargs.output_file) and
|
mk_genfile_common.mk_pat_db_internal(pargs.db_file, pargs.output_file)
|
||||||
not os.path.isfile(pargs.output_file)):
|
logging.info('Generated "{}"'.format(pargs.output_file))
|
||||||
logging.error('Refusing to overwrite "{}"'.format(
|
|
||||||
pargs.output_file))
|
|
||||||
return 1
|
|
||||||
|
|
||||||
mk_util.mk_pat_db_internal(pargs.db_file, pargs.output_file)
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -2621,17 +2621,9 @@ def mk_pat_db():
|
||||||
c = get_component(PATTERN_COMPONENT)
|
c = get_component(PATTERN_COMPONENT)
|
||||||
fin = os.path.join(c.src_dir, 'database.smt2')
|
fin = os.path.join(c.src_dir, 'database.smt2')
|
||||||
fout = os.path.join(c.src_dir, 'database.h')
|
fout = os.path.join(c.src_dir, 'database.h')
|
||||||
mk_pat_db_internal(fin, fout)
|
mk_genfile_common.mk_pat_db_internal(fin, fout)
|
||||||
|
|
||||||
def mk_pat_db_internal(inputFilePath, outputFilePath):
|
|
||||||
with open(inputFilePath, 'r') as fin:
|
|
||||||
with open(outputFilePath, 'w') as fout:
|
|
||||||
fout.write('static char const g_pattern_database[] =\n')
|
|
||||||
for line in fin:
|
|
||||||
fout.write('"%s\\n"\n' % line.strip('\n'))
|
|
||||||
fout.write(';\n')
|
|
||||||
if VERBOSE:
|
if VERBOSE:
|
||||||
print("Generated '%s'" % outputFilePath)
|
print("Generated '{}'".format(fout))
|
||||||
|
|
||||||
# Update version numbers
|
# Update version numbers
|
||||||
def update_version():
|
def update_version():
|
||||||
|
|
Loading…
Reference in a new issue