mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 04:03:39 +00:00
Refactor `mk_def_file()
` so that it is usable externally via a new
function ``mk_def_file_internal()`` which is called by a new ``mk_def_file.py`` script. This will allow other build systems to generate the ``api_dll.def`` file.
This commit is contained in:
parent
ce54f6d957
commit
46ac368f86
36
scripts/mk_def_file.py
Executable file
36
scripts/mk_def_file.py
Executable file
|
@ -0,0 +1,36 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
"""
|
||||||
|
Reads a list of Z3 API header files and
|
||||||
|
generate a ``.def`` file to define the
|
||||||
|
exported symbols of a dll. This file
|
||||||
|
can be passed to the ``/DEF`` to the
|
||||||
|
linker used by MSVC.
|
||||||
|
"""
|
||||||
|
import mk_util
|
||||||
|
import argparse
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def main(args):
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
parser.add_argument("output_file", help="output def file path")
|
||||||
|
parser.add_argument("dllname", help="dllname to use in def file")
|
||||||
|
parser.add_argument("api_files", nargs="+")
|
||||||
|
pargs = parser.parse_args(args)
|
||||||
|
|
||||||
|
for api_file in pargs.api_files:
|
||||||
|
if not os.path.exists(api_file):
|
||||||
|
logging.error('"{}" does not exist'.format(api_file))
|
||||||
|
return 1
|
||||||
|
|
||||||
|
mk_util.mk_def_file_internal(
|
||||||
|
pargs.output_file,
|
||||||
|
pargs.dllname,
|
||||||
|
pargs.api_files)
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.exit(main(sys.argv[1:]))
|
||||||
|
|
|
@ -2884,14 +2884,22 @@ def mk_all_gparams_register_modules():
|
||||||
|
|
||||||
# Generate a .def based on the files at c.export_files slot.
|
# Generate a .def based on the files at c.export_files slot.
|
||||||
def mk_def_file(c):
|
def mk_def_file(c):
|
||||||
pat1 = re.compile(".*Z3_API.*")
|
|
||||||
defname = '%s.def' % os.path.join(c.src_dir, c.name)
|
defname = '%s.def' % os.path.join(c.src_dir, c.name)
|
||||||
fout = open(defname, 'w')
|
dll_name = c.dll_name
|
||||||
fout.write('LIBRARY "%s"\nEXPORTS\n' % c.dll_name)
|
export_header_files = []
|
||||||
num = 1
|
|
||||||
for dot_h in c.export_files:
|
for dot_h in c.export_files:
|
||||||
dot_h_c = c.find_file(dot_h, c.name)
|
dot_h_c = c.find_file(dot_h, c.name)
|
||||||
api = open(os.path.join(dot_h_c.src_dir, dot_h), 'r')
|
api = os.path.join(dot_h_c.src_dir, dot_h)
|
||||||
|
export_header_files.append(api)
|
||||||
|
mk_def_file_internal(defname, dll_name, export_header_files)
|
||||||
|
|
||||||
|
def mk_def_file_internal(defname, dll_name, export_header_files):
|
||||||
|
pat1 = re.compile(".*Z3_API.*")
|
||||||
|
fout = open(defname, 'w')
|
||||||
|
fout.write('LIBRARY "%s"\nEXPORTS\n' % dll_name)
|
||||||
|
num = 1
|
||||||
|
for export_header_file in export_header_files:
|
||||||
|
api = open(export_header_file, 'r')
|
||||||
for line in api:
|
for line in api:
|
||||||
m = pat1.match(line)
|
m = pat1.match(line)
|
||||||
if m:
|
if m:
|
||||||
|
|
Loading…
Reference in a new issue