mirror of
https://github.com/Z3Prover/z3
synced 2025-04-22 16:45:31 +00:00
merge with master
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
commit
c513f3ca09
883 changed files with 13979 additions and 16480 deletions
|
@ -72,7 +72,7 @@ def main(args):
|
|||
|
||||
if count == 0:
|
||||
logging.info('No files generated. You need to specific an output directory'
|
||||
' for the relevant langauge bindings')
|
||||
' for the relevant language bindings')
|
||||
# TODO: Add support for other bindings
|
||||
return 0
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ from mk_util import *
|
|||
|
||||
# Z3 Project definition
|
||||
def init_project_def():
|
||||
set_version(4, 5, 1, 0)
|
||||
set_version(4, 6, 2, 0)
|
||||
add_lib('util', [])
|
||||
add_lib('polynomial', ['util'], 'math/polynomial')
|
||||
add_lib('sat', ['util'])
|
||||
|
@ -74,10 +74,9 @@ def init_project_def():
|
|||
add_lib('smtlogic_tactics', ['ackermannization', 'sat_solver', 'arith_tactics', 'bv_tactics', 'nlsat_tactic', 'smt_tactic', 'aig_tactic', 'fp', 'muz','qe'], 'tactic/smtlogics')
|
||||
add_lib('fpa_tactics', ['fpa', 'core_tactics', 'bv_tactics', 'sat_tactic', 'smt_tactic', 'arith_tactics', 'smtlogic_tactics'], 'tactic/fpa')
|
||||
add_lib('portfolio', ['smtlogic_tactics', 'sat_solver', 'ufbv_tactic', 'fpa_tactics', 'aig_tactic', 'fp', 'qe','sls_tactic', 'subpaving_tactic'], 'tactic/portfolio')
|
||||
add_lib('smtparser', ['portfolio'], 'parsers/smt')
|
||||
add_lib('opt', ['smt', 'smtlogic_tactics', 'sls_tactic', 'sat_solver'], 'opt')
|
||||
API_files = ['z3_api.h', 'z3_ast_containers.h', 'z3_algebraic.h', 'z3_polynomial.h', 'z3_rcf.h', 'z3_fixedpoint.h', 'z3_optimization.h', 'z3_interp.h', 'z3_fpa.h', 'z3_spacer.h']
|
||||
add_lib('api', ['portfolio', 'smtparser', 'realclosure', 'interp', 'opt'],
|
||||
add_lib('api', ['portfolio', 'realclosure', 'interp', 'opt'],
|
||||
includes2install=['z3.h', 'z3_v1.h', 'z3_macros.h'] + API_files)
|
||||
add_exe('shell', ['api', 'sat', 'extra_cmds','opt'], exe_name='z3')
|
||||
add_exe('test', ['api', 'fuzzing', 'simplex'], exe_name='test-z3', install=False)
|
||||
|
|
|
@ -69,6 +69,7 @@ IS_WINDOWS=False
|
|||
IS_LINUX=False
|
||||
IS_OSX=False
|
||||
IS_FREEBSD=False
|
||||
IS_NETBSD=False
|
||||
IS_OPENBSD=False
|
||||
IS_CYGWIN=False
|
||||
IS_CYGWIN_MINGW=False
|
||||
|
@ -141,6 +142,9 @@ def is_linux():
|
|||
def is_freebsd():
|
||||
return IS_FREEBSD
|
||||
|
||||
def is_netbsd():
|
||||
return IS_NETBSD
|
||||
|
||||
def is_openbsd():
|
||||
return IS_OPENBSD
|
||||
|
||||
|
@ -604,13 +608,15 @@ elif os.name == 'posix':
|
|||
IS_LINUX=True
|
||||
elif os.uname()[0] == 'FreeBSD':
|
||||
IS_FREEBSD=True
|
||||
elif os.uname()[0] == 'NetBSD':
|
||||
IS_NETBSD=True
|
||||
elif os.uname()[0] == 'OpenBSD':
|
||||
IS_OPENBSD=True
|
||||
elif os.uname()[0][:6] == 'CYGWIN':
|
||||
IS_CYGWIN=True
|
||||
if (CC != None and "mingw" in CC):
|
||||
IS_CYGWIN_MINGW=True
|
||||
elif os.uname()[0].startswith('MSYS_NT'):
|
||||
elif os.uname()[0].startswith('MSYS_NT') or os.uname()[0].startswith('MINGW'):
|
||||
IS_MSYS2=True
|
||||
if os.uname()[4] == 'x86_64':
|
||||
LINUX_X64=True
|
||||
|
@ -889,8 +895,13 @@ def is_CXX_gpp():
|
|||
return is_compiler(CXX, 'g++')
|
||||
|
||||
def is_clang_in_gpp_form(cc):
|
||||
version_string = check_output([cc, '--version']).encode('utf-8').decode('utf-8')
|
||||
return version_string.find('clang') != -1
|
||||
str = check_output([cc, '--version'])
|
||||
try:
|
||||
version_string = str.encode('utf-8')
|
||||
except:
|
||||
version_string = str
|
||||
clang = 'clang'.encode('utf-8')
|
||||
return version_string.find(clang) != -1
|
||||
|
||||
def is_CXX_clangpp():
|
||||
if is_compiler(CXX, 'g++'):
|
||||
|
@ -1240,9 +1251,9 @@ def get_so_ext():
|
|||
sysname = os.uname()[0]
|
||||
if sysname == 'Darwin':
|
||||
return 'dylib'
|
||||
elif sysname == 'Linux' or sysname == 'FreeBSD' or sysname == 'OpenBSD' or sysname.startswith('MSYS_NT'):
|
||||
elif sysname == 'Linux' or sysname == 'FreeBSD' or sysname == 'NetBSD' or sysname == 'OpenBSD':
|
||||
return 'so'
|
||||
elif sysname == 'CYGWIN':
|
||||
elif sysname == 'CYGWIN' or sysname.startswith('MSYS_NT') or sysname.startswith('MINGW'):
|
||||
return 'dll'
|
||||
else:
|
||||
assert(False)
|
||||
|
@ -1790,6 +1801,8 @@ class JavaDLLComponent(Component):
|
|||
t = t.replace('PLATFORM', 'linux')
|
||||
elif IS_FREEBSD:
|
||||
t = t.replace('PLATFORM', 'freebsd')
|
||||
elif IS_NETBSD:
|
||||
t = t.replace('PLATFORM', 'netbsd')
|
||||
elif IS_OPENBSD:
|
||||
t = t.replace('PLATFORM', 'openbsd')
|
||||
elif IS_CYGWIN:
|
||||
|
@ -1888,7 +1901,6 @@ class MLComponent(Component):
|
|||
def _init_ocamlfind_paths(self):
|
||||
"""
|
||||
Initialises self.destdir and self.ldconf
|
||||
|
||||
Do not call this from the MLComponent constructor because OCAMLFIND
|
||||
has not been checked at that point
|
||||
"""
|
||||
|
@ -1991,7 +2003,7 @@ class MLComponent(Component):
|
|||
out.write('%s.cmxa: %s %s %s %s.cma\n' % (z3mls, cmxs, stubso, z3dllso, z3mls))
|
||||
out.write('\t%s -o %s -I %s %s %s %s\n' % (OCAMLMKLIB, z3mls, self.sub_dir, stubso, cmxs, LIBZ3))
|
||||
out.write('%s.cmxs: %s.cmxa\n' % (z3mls, z3mls))
|
||||
out.write('\t%s -shared -o %s.cmxs -I %s %s.cmxa\n' % (OCAMLOPTF, z3mls, self.sub_dir, z3mls))
|
||||
out.write('\t%s -linkall -shared -o %s.cmxs -I %s %s.cmxa\n' % (OCAMLOPTF, z3mls, self.sub_dir, z3mls))
|
||||
|
||||
out.write('\n')
|
||||
out.write('ml: %s.cma %s.cmxa %s.cmxs\n' % (z3mls, z3mls, z3mls))
|
||||
|
@ -2073,7 +2085,6 @@ class ExampleComponent(Component):
|
|||
def is_example(self):
|
||||
return True
|
||||
|
||||
|
||||
class CppExampleComponent(ExampleComponent):
|
||||
def __init__(self, name, path):
|
||||
ExampleComponent.__init__(self, name, path)
|
||||
|
@ -2120,6 +2131,30 @@ class CExampleComponent(CppExampleComponent):
|
|||
def src_files(self):
|
||||
return get_c_files(self.ex_dir)
|
||||
|
||||
def mk_makefile(self, out):
|
||||
dll_name = get_component(Z3_DLL_COMPONENT).dll_name
|
||||
dll = '%s$(SO_EXT)' % dll_name
|
||||
|
||||
objfiles = ''
|
||||
for cfile in self.src_files():
|
||||
objfile = '%s$(OBJ_EXT)' % (cfile[:cfile.rfind('.')])
|
||||
objfiles = objfiles + ('%s ' % objfile)
|
||||
out.write('%s: %s\n' % (objfile, os.path.join(self.to_ex_dir, cfile)));
|
||||
out.write('\t%s $(CFLAGS) $(OS_DEFINES) $(EXAMP_DEBUG_FLAG) $(C_OUT_FLAG)%s $(LINK_FLAGS)' % (self.compiler(), objfile))
|
||||
out.write(' -I%s' % get_component(API_COMPONENT).to_src_dir)
|
||||
out.write(' %s' % os.path.join(self.to_ex_dir, cfile))
|
||||
out.write('\n')
|
||||
|
||||
exefile = '%s$(EXE_EXT)' % self.name
|
||||
out.write('%s: %s %s\n' % (exefile, dll, objfiles))
|
||||
out.write('\t$(LINK) $(LINK_OUT_FLAG)%s $(LINK_FLAGS) %s ' % (exefile, objfiles))
|
||||
if IS_WINDOWS:
|
||||
out.write('%s.lib' % dll_name)
|
||||
else:
|
||||
out.write(dll)
|
||||
out.write(' $(LINK_EXTRA_FLAGS)\n')
|
||||
out.write('_ex_%s: %s\n\n' % (self.name, exefile))
|
||||
|
||||
class DotNetExampleComponent(ExampleComponent):
|
||||
def __init__(self, name, path):
|
||||
ExampleComponent.__init__(self, name, path)
|
||||
|
@ -2321,6 +2356,7 @@ def mk_config():
|
|||
'CC=cl\n'
|
||||
'CXX=cl\n'
|
||||
'CXX_OUT_FLAG=/Fo\n'
|
||||
'C_OUT_FLAG=/Fo\n'
|
||||
'OBJ_EXT=.obj\n'
|
||||
'LIB_EXT=.lib\n'
|
||||
'AR=lib\n'
|
||||
|
@ -2398,7 +2434,7 @@ def mk_config():
|
|||
'LINK_EXTRA_FLAGS=/link%s /DEBUG /MACHINE:X86 /SUBSYSTEM:CONSOLE /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE /NXCOMPAT %s\n'
|
||||
'SLINK_EXTRA_FLAGS=/link%s /DEBUG /MACHINE:X86 /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 %s %s\n' % (LTCG, link_extra_opt, LTCG, maybe_disable_dynamic_base, link_extra_opt))
|
||||
|
||||
|
||||
config.write('CFLAGS=$(CXXFLAGS)\n')
|
||||
|
||||
# End of Windows VS config.mk
|
||||
if is_verbose():
|
||||
|
@ -2419,6 +2455,8 @@ def mk_config():
|
|||
CXX = find_cxx_compiler()
|
||||
CC = find_c_compiler()
|
||||
SLIBEXTRAFLAGS = ''
|
||||
EXE_EXT = ''
|
||||
LIB_EXT = '.a'
|
||||
if GPROF:
|
||||
CXXFLAGS = '%s -pg' % CXXFLAGS
|
||||
LDFLAGS = '%s -pg' % LDFLAGS
|
||||
|
@ -2448,18 +2486,19 @@ def mk_config():
|
|||
if DEBUG_MODE:
|
||||
CXXFLAGS = '%s -g -Wall' % CXXFLAGS
|
||||
EXAMP_DEBUG_FLAG = '-g'
|
||||
CPPFLAGS = '%s -DZ3DEBUG -D_DEBUG' % CPPFLAGS
|
||||
else:
|
||||
CXXFLAGS = '%s -O3' % CXXFLAGS
|
||||
if GPROF:
|
||||
CXXFLAGS = '%s -O3 -D _EXTERNAL_RELEASE' % CXXFLAGS
|
||||
else:
|
||||
CXXFLAGS = '%s -O3 -D _EXTERNAL_RELEASE -fomit-frame-pointer' % CXXFLAGS
|
||||
CXXFLAGS += '-fomit-frame-pointer'
|
||||
CPPFLAGS = '%s -DNDEBUG -D_EXTERNAL_RELEASE' % CPPFLAGS
|
||||
if is_CXX_clangpp():
|
||||
CXXFLAGS = '%s -Wno-unknown-pragmas -Wno-overloaded-virtual -Wno-unused-value' % CXXFLAGS
|
||||
sysname, _, _, _, machine = os.uname()
|
||||
if sysname == 'Darwin':
|
||||
SO_EXT = '.dylib'
|
||||
SLIBFLAGS = '-dynamiclib'
|
||||
elif sysname == 'Linux' or sysname.startswith('MSYS_NT'):
|
||||
elif sysname == 'Linux':
|
||||
CXXFLAGS = '%s -D_LINUX_' % CXXFLAGS
|
||||
OS_DEFINES = '-D_LINUX_'
|
||||
SO_EXT = '.so'
|
||||
|
@ -2473,20 +2512,34 @@ def mk_config():
|
|||
LDFLAGS = '%s -lrt' % LDFLAGS
|
||||
SLIBFLAGS = '-shared'
|
||||
SLIBEXTRAFLAGS = '%s -lrt' % SLIBEXTRAFLAGS
|
||||
elif sysname == 'NetBSD':
|
||||
CXXFLAGS = '%s -D_NETBSD_' % CXXFLAGS
|
||||
OS_DEFINES = '-D_NETBSD_'
|
||||
SO_EXT = '.so'
|
||||
LDFLAGS = '%s -lrt' % LDFLAGS
|
||||
SLIBFLAGS = '-shared'
|
||||
SLIBEXTRAFLAGS = '%s -lrt' % SLIBEXTRAFLAGS
|
||||
elif sysname == 'OpenBSD':
|
||||
CXXFLAGS = '%s -D_OPENBSD_' % CXXFLAGS
|
||||
OS_DEFINES = '-D_OPENBSD_'
|
||||
SO_EXT = '.so'
|
||||
SLIBFLAGS = '-shared'
|
||||
elif sysname[:6] == 'CYGWIN':
|
||||
elif sysname.startswith('CYGWIN'):
|
||||
CXXFLAGS = '%s -D_CYGWIN' % CXXFLAGS
|
||||
OS_DEFINES = '-D_CYGWIN'
|
||||
SO_EXT = '.dll'
|
||||
SLIBFLAGS = '-shared'
|
||||
elif sysname.startswith('MSYS_NT') or sysname.startswith('MINGW'):
|
||||
CXXFLAGS = '%s -D_MINGW' % CXXFLAGS
|
||||
OS_DEFINES = '-D_MINGW'
|
||||
SO_EXT = '.dll'
|
||||
SLIBFLAGS = '-shared'
|
||||
EXE_EXT = '.exe'
|
||||
LIB_EXT = '.lib'
|
||||
else:
|
||||
raise MKException('Unsupported platform: %s' % sysname)
|
||||
if is64():
|
||||
if sysname[:6] != 'CYGWIN':
|
||||
if not sysname.startswith('CYGWIN') and not sysname.startswith('MSYS') and not sysname.startswith('MINGW'):
|
||||
CXXFLAGS = '%s -fPIC' % CXXFLAGS
|
||||
CPPFLAGS = '%s -D_AMD64_' % CPPFLAGS
|
||||
if sysname == 'Linux':
|
||||
|
@ -2495,10 +2548,6 @@ def mk_config():
|
|||
CXXFLAGS = '%s -m32' % CXXFLAGS
|
||||
LDFLAGS = '%s -m32' % LDFLAGS
|
||||
SLIBFLAGS = '%s -m32' % SLIBFLAGS
|
||||
if DEBUG_MODE:
|
||||
CPPFLAGS = '%s -DZ3DEBUG -D_DEBUG' % CPPFLAGS
|
||||
else:
|
||||
CPPFLAGS = '%s -DNDEBUG -D_EXTERNAL_RELEASE' % CPPFLAGS
|
||||
if TRACE or DEBUG_MODE:
|
||||
CPPFLAGS = '%s -D_TRACE' % CPPFLAGS
|
||||
if is_cygwin_mingw():
|
||||
|
@ -2513,14 +2562,16 @@ def mk_config():
|
|||
config.write('CC=%s\n' % CC)
|
||||
config.write('CXX=%s\n' % CXX)
|
||||
config.write('CXXFLAGS=%s %s\n' % (CPPFLAGS, CXXFLAGS))
|
||||
config.write('CFLAGS=%s %s\n' % (CPPFLAGS, CXXFLAGS.replace('-std=c++11', '')))
|
||||
config.write('EXAMP_DEBUG_FLAG=%s\n' % EXAMP_DEBUG_FLAG)
|
||||
config.write('CXX_OUT_FLAG=-o \n')
|
||||
config.write('C_OUT_FLAG=-o \n')
|
||||
config.write('OBJ_EXT=.o\n')
|
||||
config.write('LIB_EXT=.a\n')
|
||||
config.write('LIB_EXT=%s\n' % LIB_EXT)
|
||||
config.write('AR=%s\n' % AR)
|
||||
config.write('AR_FLAGS=rcs\n')
|
||||
config.write('AR_OUTFLAG=\n')
|
||||
config.write('EXE_EXT=\n')
|
||||
config.write('EXE_EXT=%s\n' % EXE_EXT)
|
||||
config.write('LINK=%s\n' % CXX)
|
||||
config.write('LINK_FLAGS=\n')
|
||||
config.write('LINK_OUT_FLAG=-o \n')
|
||||
|
@ -3174,7 +3225,6 @@ class MakeRuleCmd(object):
|
|||
"""
|
||||
These class methods provide a convenient way to emit frequently
|
||||
needed commands used in Makefile rules
|
||||
|
||||
Note that several of the method are meant for use during ``make
|
||||
install`` and ``make uninstall``. These methods correctly use
|
||||
``$(PREFIX)`` and ``$(DESTDIR)`` and therefore are preferrable
|
||||
|
@ -3350,10 +3400,8 @@ def configure_file(template_file_path, output_file_path, substitutions):
|
|||
Read a template file ``template_file_path``, perform substitutions
|
||||
found in the ``substitutions`` dictionary and write the result to
|
||||
the output file ``output_file_path``.
|
||||
|
||||
The template file should contain zero or more template strings of the
|
||||
form ``@NAME@``.
|
||||
|
||||
The substitutions dictionary maps old strings (without the ``@``
|
||||
symbols) to their replacements.
|
||||
"""
|
||||
|
|
|
@ -240,7 +240,7 @@ def param2javaw(p):
|
|||
if k == OUT:
|
||||
return "jobject"
|
||||
elif k == IN_ARRAY or k == INOUT_ARRAY or k == OUT_ARRAY:
|
||||
if param_type(p) == INT or param_type(p) == UINT:
|
||||
if param_type(p) == INT or param_type(p) == UINT or param_type(p) == BOOL:
|
||||
return "jintArray"
|
||||
else:
|
||||
return "jlongArray"
|
||||
|
@ -258,7 +258,7 @@ def param2pystr(p):
|
|||
def param2ml(p):
|
||||
k = param_kind(p)
|
||||
if k == OUT:
|
||||
if param_type(p) == INT or param_type(p) == UINT or param_type(p) == INT64 or param_type(p) == UINT64:
|
||||
if param_type(p) == INT or param_type(p) == UINT or param_type(p) == BOOL or param_type(p) == INT64 or param_type(p) == UINT64:
|
||||
return "int"
|
||||
elif param_type(p) == STRING:
|
||||
return "string"
|
||||
|
@ -279,8 +279,8 @@ def mk_py_binding(name, result, params):
|
|||
global _API2PY
|
||||
_API2PY.append((name, result, params))
|
||||
if result != VOID:
|
||||
core_py.write(" _lib.%s.restype = %s\n" % (name, type2pystr(result)))
|
||||
core_py.write(" _lib.%s.argtypes = [" % name)
|
||||
core_py.write("_lib.%s.restype = %s\n" % (name, type2pystr(result)))
|
||||
core_py.write("_lib.%s.argtypes = [" % name)
|
||||
first = True
|
||||
for p in params:
|
||||
if first:
|
||||
|
@ -311,8 +311,32 @@ def display_args_to_z3(params):
|
|||
core_py.write("a%s" % i)
|
||||
i = i + 1
|
||||
|
||||
NULLWrapped = [ 'Z3_mk_context', 'Z3_mk_context_rc', 'Z3_mk_interpolation_context' ]
|
||||
Unwrapped = [ 'Z3_del_context', 'Z3_get_error_code' ]
|
||||
|
||||
def mk_py_wrappers():
|
||||
core_py.write("\n")
|
||||
core_py.write("""
|
||||
class Elementaries:
|
||||
def __init__(self, f):
|
||||
self.f = f
|
||||
self.get_error_code = _lib.Z3_get_error_code
|
||||
self.get_error_message = _lib.Z3_get_error_msg
|
||||
self.OK = Z3_OK
|
||||
self.Exception = Z3Exception
|
||||
|
||||
def Check(self, ctx):
|
||||
err = self.get_error_code(ctx)
|
||||
if err != self.OK:
|
||||
raise self.Exception(self.get_error_message(ctx, err))
|
||||
|
||||
def Z3_set_error_handler(ctx, hndlr, _elems=Elementaries(_lib.Z3_set_error_handler)):
|
||||
ceh = _error_handler_type(hndlr)
|
||||
_elems.f(ctx, ceh)
|
||||
_elems.Check(ctx)
|
||||
return ceh
|
||||
|
||||
""")
|
||||
|
||||
for sig in _API2PY:
|
||||
name = sig[0]
|
||||
result = sig[1]
|
||||
|
@ -320,25 +344,20 @@ def mk_py_wrappers():
|
|||
num = len(params)
|
||||
core_py.write("def %s(" % name)
|
||||
display_args(num)
|
||||
core_py.write("):\n")
|
||||
core_py.write(" _lib = lib()\n")
|
||||
core_py.write(" if _lib is None or _lib.%s is None:\n" % name)
|
||||
core_py.write(" return\n")
|
||||
if result != VOID:
|
||||
core_py.write(" r = _lib.%s(" % name)
|
||||
else:
|
||||
core_py.write(" _lib.%s(" % name)
|
||||
comma = ", " if num != 0 else ""
|
||||
core_py.write("%s_elems=Elementaries(_lib.%s)):\n" % (comma, name))
|
||||
lval = "r = " if result != VOID else ""
|
||||
core_py.write(" %s_elems.f(" % lval)
|
||||
display_args_to_z3(params)
|
||||
core_py.write(")\n")
|
||||
if len(params) > 0 and param_type(params[0]) == CONTEXT:
|
||||
core_py.write(" err = _lib.Z3_get_error_code(a0)\n")
|
||||
core_py.write(" if err != Z3_OK:\n")
|
||||
core_py.write(" raise Z3Exception(_lib.Z3_get_error_msg(a0, err))\n")
|
||||
if len(params) > 0 and param_type(params[0]) == CONTEXT and not name in Unwrapped:
|
||||
core_py.write(" _elems.Check(a0)\n")
|
||||
if result == STRING:
|
||||
core_py.write(" return _to_pystr(r)\n")
|
||||
elif result != VOID:
|
||||
core_py.write(" return r\n")
|
||||
core_py.write("\n")
|
||||
core_py
|
||||
|
||||
|
||||
## .NET API native interface
|
||||
|
@ -391,10 +410,6 @@ def mk_dotnet(dotnet):
|
|||
dotnet.write(');\n\n')
|
||||
dotnet.write(' }\n')
|
||||
|
||||
|
||||
NULLWrapped = [ 'Z3_mk_context', 'Z3_mk_context_rc', 'Z3_mk_interpolation_context' ]
|
||||
Unwrapped = [ 'Z3_del_context', 'Z3_get_error_code' ]
|
||||
|
||||
def mk_dotnet_wrappers(dotnet):
|
||||
global Type2Str
|
||||
dotnet.write("\n")
|
||||
|
@ -476,7 +491,7 @@ def java_method_name(name):
|
|||
|
||||
# Return the type of the java array elements
|
||||
def java_array_element_type(p):
|
||||
if param_type(p) == INT or param_type(p) == UINT:
|
||||
if param_type(p) == INT or param_type(p) == UINT or param_type(p) == BOOL:
|
||||
return 'jint'
|
||||
else:
|
||||
return 'jlong'
|
||||
|
@ -638,7 +653,7 @@ def mk_java(java_dir, package_name):
|
|||
if k == OUT or k == INOUT:
|
||||
java_wrapper.write(' %s _a%s;\n' % (type2str(param_type(param)), i))
|
||||
elif k == IN_ARRAY or k == INOUT_ARRAY:
|
||||
if param_type(param) == INT or param_type(param) == UINT:
|
||||
if param_type(param) == INT or param_type(param) == UINT or param_type(param) == BOOL:
|
||||
java_wrapper.write(' %s * _a%s = (%s*) jenv->GetIntArrayElements(a%s, NULL);\n' % (type2str(param_type(param)), i, type2str(param_type(param)), i))
|
||||
else:
|
||||
java_wrapper.write(' GETLONGAELEMS(%s, a%s, _a%s);\n' % (type2str(param_type(param)), i, i))
|
||||
|
@ -648,7 +663,7 @@ def mk_java(java_dir, package_name):
|
|||
type2str(param_type(param)),
|
||||
param_array_capacity_pos(param),
|
||||
type2str(param_type(param))))
|
||||
if param_type(param) == INT or param_type(param) == UINT:
|
||||
if param_type(param) == INT or param_type(param) == UINT or param_type(param) == BOOL:
|
||||
java_wrapper.write(' jenv->GetIntArrayRegion(a%s, 0, (jsize)a%s, (jint*)_a%s);\n' % (i, param_array_capacity_pos(param), i))
|
||||
else:
|
||||
java_wrapper.write(' GETLONGAREGION(%s, a%s, 0, a%s, _a%s);\n' % (type2str(param_type(param)), i, param_array_capacity_pos(param), i))
|
||||
|
@ -687,19 +702,19 @@ def mk_java(java_dir, package_name):
|
|||
for param in params:
|
||||
k = param_kind(param)
|
||||
if k == OUT_ARRAY:
|
||||
if param_type(param) == INT or param_type(param) == UINT:
|
||||
if param_type(param) == INT or param_type(param) == UINT or param_type(param) == BOOL:
|
||||
java_wrapper.write(' jenv->SetIntArrayRegion(a%s, 0, (jsize)a%s, (jint*)_a%s);\n' % (i, param_array_capacity_pos(param), i))
|
||||
else:
|
||||
java_wrapper.write(' SETLONGAREGION(a%s, 0, a%s, _a%s);\n' % (i, param_array_capacity_pos(param), i))
|
||||
java_wrapper.write(' free(_a%s);\n' % i)
|
||||
elif k == IN_ARRAY or k == OUT_ARRAY:
|
||||
if param_type(param) == INT or param_type(param) == UINT:
|
||||
if param_type(param) == INT or param_type(param) == UINT or param_type(param) == BOOL:
|
||||
java_wrapper.write(' jenv->ReleaseIntArrayElements(a%s, (jint*)_a%s, JNI_ABORT);\n' % (i, i))
|
||||
else:
|
||||
java_wrapper.write(' RELEASELONGAELEMS(a%s, _a%s);\n' % (i, i))
|
||||
|
||||
elif k == OUT or k == INOUT:
|
||||
if param_type(param) == INT or param_type(param) == UINT:
|
||||
if param_type(param) == INT or param_type(param) == UINT or param_type(param) == BOOL:
|
||||
java_wrapper.write(' {\n')
|
||||
java_wrapper.write(' jclass mc = jenv->GetObjectClass(a%s);\n' % i)
|
||||
java_wrapper.write(' jfieldID fid = jenv->GetFieldID(mc, "value", "I");\n')
|
||||
|
@ -942,7 +957,7 @@ def def_API(name, result, params):
|
|||
log_c.write(" }\n")
|
||||
log_c.write(" Au(a%s);\n" % sz)
|
||||
exe_c.write("in.get_uint_array(%s)" % i)
|
||||
elif ty == INT:
|
||||
elif ty == INT or ty == BOOL:
|
||||
log_c.write("U(a%s[i]);" % i)
|
||||
log_c.write(" }\n")
|
||||
log_c.write(" Au(a%s);\n" % sz)
|
||||
|
@ -1605,39 +1620,87 @@ def write_exe_c_preamble(exe_c):
|
|||
|
||||
def write_core_py_post(core_py):
|
||||
core_py.write("""
|
||||
|
||||
# Clean up
|
||||
del _lib
|
||||
del _default_dirs
|
||||
del _all_dirs
|
||||
del _ext
|
||||
""")
|
||||
|
||||
def write_core_py_preamble(core_py):
|
||||
core_py.write('# Automatically generated file\n')
|
||||
core_py.write('import sys, os\n')
|
||||
core_py.write('import ctypes\n')
|
||||
core_py.write('import pkg_resources\n')
|
||||
core_py.write('from .z3types import *\n')
|
||||
core_py.write('from .z3consts import *\n')
|
||||
core_py.write(
|
||||
"""
|
||||
# Automatically generated file
|
||||
import sys, os
|
||||
import ctypes
|
||||
import pkg_resources
|
||||
from .z3types import *
|
||||
from .z3consts import *
|
||||
|
||||
_ext = 'dll' if sys.platform in ('win32', 'cygwin') else 'dylib' if sys.platform == 'darwin' else 'so'
|
||||
|
||||
_lib = None
|
||||
_default_dirs = ['.',
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
pkg_resources.resource_filename('z3', 'lib'),
|
||||
os.path.join(sys.prefix, 'lib'),
|
||||
None]
|
||||
_all_dirs = []
|
||||
|
||||
def lib():
|
||||
global _lib
|
||||
if _lib is None:
|
||||
_dirs = ['.', os.path.dirname(os.path.abspath(__file__)), pkg_resources.resource_filename('z3', 'lib'), os.path.join(sys.prefix, 'lib'), None]
|
||||
for _dir in _dirs:
|
||||
try:
|
||||
init(_dir)
|
||||
break
|
||||
except:
|
||||
pass
|
||||
if _lib is None:
|
||||
raise Z3Exception("init(Z3_LIBRARY_PATH) must be invoked before using Z3-python")
|
||||
return _lib
|
||||
if sys.version < '3':
|
||||
import __builtin__
|
||||
if hasattr(__builtin__, "Z3_LIB_DIRS"):
|
||||
_all_dirs = __builtin__.Z3_LIB_DIRS
|
||||
else:
|
||||
import builtins
|
||||
if hasattr(builtins, "Z3_LIB_DIRS"):
|
||||
_all_dirs = builtins.Z3_LIB_DIRS
|
||||
|
||||
for v in ('Z3_LIBRARY_PATH', 'PATH'):
|
||||
if v in os.environ:
|
||||
lp = os.environ[v];
|
||||
lds = lp.split(';') if sys.platform in ('win32') else lp.split(':')
|
||||
_all_dirs.extend(lds)
|
||||
|
||||
_all_dirs.extend(_default_dirs)
|
||||
|
||||
for d in _all_dirs:
|
||||
try:
|
||||
d = os.path.realpath(d)
|
||||
if os.path.isdir(d):
|
||||
d = os.path.join(d, 'libz3.%s' % _ext)
|
||||
if os.path.isfile(d):
|
||||
_lib = ctypes.CDLL(d)
|
||||
break
|
||||
except:
|
||||
pass
|
||||
|
||||
if _lib is None:
|
||||
# If all else failed, ask the system to find it.
|
||||
try:
|
||||
_lib = ctypes.CDLL('libz3.%s' % _ext)
|
||||
except:
|
||||
pass
|
||||
|
||||
if _lib is None:
|
||||
print("Could not find libz3.%s; consider adding the directory containing it to" % _ext)
|
||||
print(" - your system's PATH environment variable,")
|
||||
print(" - the Z3_LIBRARY_PATH environment variable, or ")
|
||||
print(" - to the custom Z3_LIBRARY_DIRS Python-builtin before importing the z3 module, e.g. via")
|
||||
if sys.version < '3':
|
||||
print(" import __builtin__")
|
||||
print(" __builtin__.Z3_LIB_DIRS = [ '/path/to/libz3.%s' ] " % _ext)
|
||||
else:
|
||||
print(" import builtins")
|
||||
print(" builtins.Z3_LIB_DIRS = [ '/path/to/libz3.%s' ] " % _ext)
|
||||
raise Z3Exception("libz3.%s not found." % _ext)
|
||||
|
||||
def _to_ascii(s):
|
||||
if isinstance(s, str):
|
||||
return s.encode('ascii')
|
||||
try:
|
||||
return s.encode('ascii')
|
||||
except:
|
||||
# kick the bucket down the road. :-J
|
||||
return s
|
||||
else:
|
||||
return s
|
||||
|
||||
|
@ -1653,16 +1716,11 @@ else:
|
|||
else:
|
||||
return ""
|
||||
|
||||
def init(PATH):
|
||||
if PATH:
|
||||
PATH = os.path.realpath(PATH)
|
||||
if os.path.isdir(PATH):
|
||||
PATH = os.path.join(PATH, 'libz3.%s' % _ext)
|
||||
else:
|
||||
PATH = 'libz3.%s' % _ext
|
||||
_error_handler_type = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_uint)
|
||||
|
||||
_lib.Z3_set_error_handler.restype = None
|
||||
_lib.Z3_set_error_handler.argtypes = [ContextObj, _error_handler_type]
|
||||
|
||||
global _lib
|
||||
_lib = ctypes.CDLL(PATH)
|
||||
"""
|
||||
)
|
||||
|
||||
|
|
49
scripts/vsts-vs2013.cmd
Normal file
49
scripts/vsts-vs2013.cmd
Normal file
|
@ -0,0 +1,49 @@
|
|||
|
||||
set
|
||||
echo "Build"
|
||||
md build
|
||||
cd build
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" amd64
|
||||
cmake -DBUILD_DOTNET_BINDINGS=True -DBUILD_JAVA_BINDINGS=True -DBUILD_PYTHON_BINDINGS=True -G "NMake Makefiles" ../
|
||||
nmake
|
||||
if ERRORLEVEL 1 exit 1
|
||||
|
||||
rem echo "Test python bindings"
|
||||
rem pushd python
|
||||
rem python z3test.py z3
|
||||
rem if ERRORLEVEL 1 exit 1
|
||||
rem python z3test.py z3num
|
||||
rem if ERRORLEVEL 1 exit 1
|
||||
rem popd
|
||||
|
||||
echo "Build and run examples"
|
||||
nmake cpp_example
|
||||
examples\cpp_example_build_dir\cpp_example.exe
|
||||
if ERRORLEVEL 1 exit 1
|
||||
|
||||
nmake c_example
|
||||
examples\c_example_build_dir\c_example.exe
|
||||
if ERRORLEVEL 1 exit 1
|
||||
|
||||
rem nmake java_example
|
||||
rem java_example.exe
|
||||
if ERRORLEVEL 1 exit 1
|
||||
|
||||
rem nmake dotnet_example
|
||||
rem dotnet_example.exe
|
||||
if ERRORLEVEL 1 exit 1
|
||||
|
||||
echo "Build and run unit tests"
|
||||
nmake test-z3
|
||||
rem TBD: test error level
|
||||
rem test-z3.exe -a
|
||||
|
||||
|
||||
cd ..
|
||||
echo "Run regression tests"
|
||||
git clone https://github.com/z3prover/z3test z3test
|
||||
echo "test-benchmarks"
|
||||
python z3test\scripts\test_benchmarks.py build\z3.exe z3test\regressions\smt2
|
||||
if ERRORLEVEL 1 exit 1
|
||||
echo "benchmarks tested"
|
||||
|
51
scripts/vsts-vs2017.cmd
Normal file
51
scripts/vsts-vs2017.cmd
Normal file
|
@ -0,0 +1,51 @@
|
|||
rem Supply argument x64 or x86
|
||||
|
||||
echo "Build"
|
||||
md build
|
||||
cd build
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" %1
|
||||
cmake -DBUILD_DOTNET_BINDINGS=True -DBUILD_JAVA_BINDINGS=True -DBUILD_PYTHON_BINDINGS=True -G "NMake Makefiles" ../
|
||||
nmake
|
||||
if ERRORLEVEL 1 exit 1
|
||||
|
||||
if %1 == "x86" goto :BUILD_EXAMPLES
|
||||
echo "Test python bindings"
|
||||
pushd python
|
||||
python z3test.py z3
|
||||
if ERRORLEVEL 1 exit 1
|
||||
python z3test.py z3num
|
||||
if ERRORLEVEL 1 exit 1
|
||||
popd
|
||||
|
||||
:BUILD_EXAMPLES
|
||||
echo "Build and run examples"
|
||||
nmake cpp_example
|
||||
examples\cpp_example_build_dir\cpp_example.exe
|
||||
if ERRORLEVEL 1 exit 1
|
||||
|
||||
nmake c_example
|
||||
examples\c_example_build_dir\c_example.exe
|
||||
if ERRORLEVEL 1 exit 1
|
||||
|
||||
rem nmake java_example
|
||||
rem java_example.exe
|
||||
if ERRORLEVEL 1 exit 1
|
||||
|
||||
rem nmake dotnet_example
|
||||
rem dotnet_example.exe
|
||||
if ERRORLEVEL 1 exit 1
|
||||
|
||||
echo "Build and run unit tests"
|
||||
nmake test-z3
|
||||
rem TBD: test error level
|
||||
rem test-z3.exe -a
|
||||
|
||||
|
||||
cd ..
|
||||
echo "Run regression tests"
|
||||
git clone https://github.com/z3prover/z3test z3test
|
||||
echo "test-benchmarks"
|
||||
python z3test\scripts\test_benchmarks.py build\z3.exe z3test\regressions\smt2
|
||||
if ERRORLEVEL 1 exit 1
|
||||
echo "benchmarks tested"
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue