mirror of
https://github.com/Z3Prover/z3
synced 2025-06-06 14:13:23 +00:00
Refactor `mk_mem_initializer_cpp()
` so that it is usable externally via a new
function ``mk_mem_initializer_cpp_internal()`` which is called by a new ``mk_mem_initializer_cpp.py`` script. This will allow other build systems to generate the ``mem_initializer.cpp`` files.
This commit is contained in:
parent
a13438818f
commit
2f7f022605
2 changed files with 58 additions and 4 deletions
48
scripts/mk_mem_initializer_cpp.py
Executable file
48
scripts/mk_mem_initializer_cpp.py
Executable file
|
@ -0,0 +1,48 @@
|
|||
#!/usr/bin/env python
|
||||
"""
|
||||
Scans the source directories for
|
||||
memory initializers and finalizers and
|
||||
emits and implementation of
|
||||
``void mem_initialize()`` and
|
||||
``void mem_finalize()`` into ``mem_initializer.cpp``
|
||||
in the destination directory.
|
||||
"""
|
||||
import mk_util
|
||||
import argparse
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
def check_dir(path):
|
||||
if not os.path.exists(path):
|
||||
logging.error('"{}" does not exist'.format(path))
|
||||
return 1
|
||||
|
||||
if not os.path.isdir(path):
|
||||
logging.error('"{}" is not a directory'.format(path))
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
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")
|
||||
pargs = parser.parse_args(args)
|
||||
|
||||
if check_dir(pargs.destination_dir) != 0:
|
||||
return 1
|
||||
|
||||
for source_dir in pargs.source_dirs:
|
||||
if check_dir(source_dir) != 0:
|
||||
return 1
|
||||
|
||||
mk_util.mk_mem_initializer_cpp_internal(pargs.source_dirs, pargs.destination_dir)
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue