mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 09:05:31 +00:00
Merge branch 'master' into polysat
This commit is contained in:
commit
e5e79c1d4b
398 changed files with 24548 additions and 4983 deletions
|
@ -8,7 +8,7 @@
|
|||
from mk_util import *
|
||||
|
||||
def init_version():
|
||||
set_version(4, 8, 16, 0)
|
||||
set_version(4, 8, 18, 0)
|
||||
|
||||
# Z3 Project definition
|
||||
def init_project_def():
|
||||
|
|
|
@ -28,6 +28,7 @@ JAVA_ENABLED=True
|
|||
GIT_HASH=False
|
||||
PYTHON_ENABLED=True
|
||||
MAKEJOBS=getenv("MAKEJOBS", '8')
|
||||
OS_NAME=None
|
||||
|
||||
def set_verbose(flag):
|
||||
global VERBOSE
|
||||
|
@ -58,13 +59,14 @@ def display_help():
|
|||
print(" --dotnet-key=<file> sign the .NET assembly with the private key in <file>.")
|
||||
print(" --arch=<arch> set architecture (to arm64) to force arm64 build")
|
||||
print(" --nojava do not include Java bindings in the binary distribution files.")
|
||||
print(" --os=<os> set OS version.")
|
||||
print(" --nopython do not include Python bindings in the binary distribution files.")
|
||||
print(" --githash include git hash in the Zip file.")
|
||||
exit(0)
|
||||
|
||||
# Parse configuration option for mk_make script
|
||||
def parse_options():
|
||||
global FORCE_MK, JAVA_ENABLED, GIT_HASH, DOTNET_CORE_ENABLED, DOTNET_KEY_FILE
|
||||
global FORCE_MK, JAVA_ENABLED, GIT_HASH, DOTNET_CORE_ENABLED, DOTNET_KEY_FILE, OS_NAME
|
||||
path = BUILD_DIR
|
||||
options, remainder = getopt.gnu_getopt(sys.argv[1:], 'b:hsf', ['build=',
|
||||
'help',
|
||||
|
@ -74,6 +76,7 @@ def parse_options():
|
|||
'nodotnet',
|
||||
'dotnet-key=',
|
||||
'arch=',
|
||||
'os=',
|
||||
'githash',
|
||||
'nopython'
|
||||
])
|
||||
|
@ -103,6 +106,8 @@ def parse_options():
|
|||
mk_util.IS_ARCH_ARM64 = True
|
||||
else:
|
||||
raise MKException("Invalid architecture directive '%s'. Legal directives: arm64" % arg)
|
||||
elif opt == '--os':
|
||||
OS_NAME = arg
|
||||
else:
|
||||
raise MKException("Invalid command line option '%s'" % opt)
|
||||
set_build_dir(path)
|
||||
|
@ -154,6 +159,8 @@ def mk_z3():
|
|||
return 1
|
||||
|
||||
def get_os_name():
|
||||
if OS_NAME is not None:
|
||||
return OS_NAME
|
||||
import platform
|
||||
basic = os.uname()[0].lower()
|
||||
if basic == 'linux':
|
||||
|
|
|
@ -246,10 +246,13 @@ def rmf(fname):
|
|||
|
||||
def exec_compiler_cmd(cmd):
|
||||
r = exec_cmd(cmd)
|
||||
if is_windows() or is_cygwin_mingw() or is_cygwin() or is_msys2():
|
||||
rmf('a.exe')
|
||||
else:
|
||||
rmf('a.out')
|
||||
# Windows
|
||||
rmf('a.exe')
|
||||
# Unix
|
||||
rmf('a.out')
|
||||
# Emscripten
|
||||
rmf('a.wasm')
|
||||
rmf('a.worker.js')
|
||||
return r
|
||||
|
||||
def test_cxx_compiler(cc):
|
||||
|
@ -293,6 +296,10 @@ def test_fpmath(cc):
|
|||
t.commit()
|
||||
# -Werror is needed because some versions of clang warn about unrecognized
|
||||
# -m flags.
|
||||
# TODO(ritave): Safari doesn't allow SIMD WebAssembly extension, add a flag to build script
|
||||
if exec_compiler_cmd([cc, CPPFLAGS, '-Werror', 'tstsse.cpp', LDFLAGS, '-msse -msse2 -msimd128']) == 0:
|
||||
FPMATH_FLAGS='-msse -msse2 -msimd128'
|
||||
return 'SSE2-EMSCRIPTEN'
|
||||
if exec_compiler_cmd([cc, CPPFLAGS, '-Werror', 'tstsse.cpp', LDFLAGS, '-mfpmath=sse -msse -msse2']) == 0:
|
||||
FPMATH_FLAGS="-mfpmath=sse -msse -msse2"
|
||||
return "SSE2-GCC"
|
||||
|
@ -499,7 +506,7 @@ def find_ml_lib():
|
|||
|
||||
def is64():
|
||||
global LINUX_X64
|
||||
if is_sunos() and sys.version_info.major < 3:
|
||||
if is_sunos() and sys.version_info.major < 3:
|
||||
return LINUX_X64
|
||||
else:
|
||||
return LINUX_X64 and sys.maxsize >= 2**32
|
||||
|
@ -625,11 +632,11 @@ elif os.name == 'posix':
|
|||
else:
|
||||
LINUX_X64=False
|
||||
|
||||
|
||||
|
||||
if os.name == 'posix' and os.uname()[4] == 'arm64':
|
||||
IS_ARCH_ARM64 = True
|
||||
|
||||
|
||||
|
||||
def display_help(exit_code):
|
||||
print("mk_make.py: Z3 Makefile generator\n")
|
||||
print("This script generates the Makefile for the Z3 theorem prover.")
|
||||
|
@ -792,7 +799,7 @@ def extract_c_includes(fname):
|
|||
linenum = 1
|
||||
for line in f:
|
||||
m1 = std_inc_pat.match(line)
|
||||
if m1:
|
||||
if m1:
|
||||
root_file_name = m1.group(1)
|
||||
slash_pos = root_file_name.rfind('/')
|
||||
if slash_pos >= 0 and root_file_name.find("..") < 0 : #it is a hack for lp include files that behave as continued from "src"
|
||||
|
@ -1650,7 +1657,7 @@ def set_key_file(self):
|
|||
else:
|
||||
print("Keyfile '%s' could not be found; %s.dll will be unsigned." % (self.key_file, self.dll_name))
|
||||
self.key_file = None
|
||||
|
||||
|
||||
|
||||
# build for dotnet core
|
||||
class DotNetDLLComponent(Component):
|
||||
|
@ -1664,7 +1671,7 @@ class DotNetDLLComponent(Component):
|
|||
self.assembly_info_dir = assembly_info_dir
|
||||
self.key_file = default_key_file
|
||||
|
||||
|
||||
|
||||
def mk_makefile(self, out):
|
||||
if not is_dotnet_core_enabled():
|
||||
return
|
||||
|
@ -1680,7 +1687,7 @@ class DotNetDLLComponent(Component):
|
|||
out.write(' ')
|
||||
out.write(cs_file)
|
||||
out.write('\n')
|
||||
|
||||
|
||||
set_key_file(self)
|
||||
key = ""
|
||||
if not self.key_file is None:
|
||||
|
@ -1724,7 +1731,7 @@ class DotNetDLLComponent(Component):
|
|||
ous.write(core_csproj_str)
|
||||
|
||||
dotnetCmdLine = [DOTNET, "build", csproj]
|
||||
|
||||
|
||||
dotnetCmdLine.extend(['-c'])
|
||||
if DEBUG_MODE:
|
||||
dotnetCmdLine.extend(['Debug'])
|
||||
|
@ -1733,19 +1740,19 @@ class DotNetDLLComponent(Component):
|
|||
|
||||
path = os.path.join(os.path.abspath(BUILD_DIR), ".")
|
||||
dotnetCmdLine.extend(['-o', "\"%s\"" % path])
|
||||
|
||||
|
||||
MakeRuleCmd.write_cmd(out, ' '.join(dotnetCmdLine))
|
||||
out.write('\n')
|
||||
out.write('\n')
|
||||
out.write('%s: %s\n\n' % (self.name, dllfile))
|
||||
|
||||
def main_component(self):
|
||||
return is_dotnet_core_enabled()
|
||||
|
||||
|
||||
def has_assembly_info(self):
|
||||
# TBD: is this required for dotnet core given that version numbers are in z3.csproj file?
|
||||
return False
|
||||
|
||||
|
||||
|
||||
def mk_win_dist(self, build_path, dist_path):
|
||||
if is_dotnet_core_enabled():
|
||||
mk_dir(os.path.join(dist_path, INSTALL_BIN_DIR))
|
||||
|
@ -2038,7 +2045,7 @@ class MLComponent(Component):
|
|||
out.write('ml: %s.cma %s.cmxa %s.cmxs\n' % (z3mls, z3mls, z3mls))
|
||||
if IS_OSX:
|
||||
out.write('\tinstall_name_tool -id %s/libz3.dylib libz3.dylib\n' % (stubs_install_path))
|
||||
out.write('\tinstall_name_tool -change libz3.dylib %s/libz3.dylib api/ml/dllz3ml.so\n' % (stubs_install_path))
|
||||
out.write('\tinstall_name_tool -change libz3.dylib %s/libz3.dylib api/ml/dllz3ml.so\n' % (stubs_install_path))
|
||||
out.write('\n')
|
||||
|
||||
if IS_WINDOWS:
|
||||
|
@ -2599,6 +2606,7 @@ def mk_config():
|
|||
OS_DEFINES = '-D_FREEBSD_'
|
||||
SO_EXT = '.so'
|
||||
SLIBFLAGS = '-shared'
|
||||
SLIBEXTRAFLAGS = '%s -Wl,-soname,libz3.so' % SLIBEXTRAFLAGS
|
||||
elif sysname == 'NetBSD':
|
||||
CXXFLAGS = '%s -D_NETBSD_' % CXXFLAGS
|
||||
OS_DEFINES = '-D_NETBSD_'
|
||||
|
@ -2632,7 +2640,7 @@ def mk_config():
|
|||
if is64():
|
||||
if not sysname.startswith('CYGWIN') and not sysname.startswith('MSYS') and not sysname.startswith('MINGW'):
|
||||
CXXFLAGS = '%s -fPIC' % CXXFLAGS
|
||||
if sysname == 'Linux':
|
||||
if sysname == 'Linux' or sysname == 'FreeBSD':
|
||||
CPPFLAGS = '%s -D_USE_THREAD_LOCAL' % CPPFLAGS
|
||||
elif not LINUX_X64:
|
||||
CXXFLAGS = '%s -m32' % CXXFLAGS
|
||||
|
@ -3019,10 +3027,12 @@ def mk_bindings(api_files):
|
|||
if is_dotnet_core_enabled():
|
||||
dotnet_output_dir = os.path.join(BUILD_DIR, 'dotnet')
|
||||
mk_dir(dotnet_output_dir)
|
||||
java_input_dir = None
|
||||
java_output_dir = None
|
||||
java_package_name = None
|
||||
if is_java_enabled():
|
||||
java_output_dir = get_component('java').src_dir
|
||||
java_input_dir = get_component('java').src_dir
|
||||
java_package_name = get_component('java').package_name
|
||||
ml_output_dir = None
|
||||
if is_ml_enabled():
|
||||
|
@ -3033,7 +3043,8 @@ def mk_bindings(api_files):
|
|||
api_output_dir=get_component('api').src_dir,
|
||||
z3py_output_dir=get_z3py_dir(),
|
||||
dotnet_output_dir=dotnet_output_dir,
|
||||
java_output_dir=java_output_dir,
|
||||
java_input_dir=java_input_dir,
|
||||
java_output_dir=java_output_dir,
|
||||
java_package_name=java_package_name,
|
||||
ml_output_dir=ml_output_dir,
|
||||
ml_src_dir=ml_output_dir
|
||||
|
@ -3116,7 +3127,7 @@ def get_platform_toolset_str():
|
|||
if len(tokens) < 2:
|
||||
return default
|
||||
else:
|
||||
if tokens[0] == "15":
|
||||
if tokens[0] == "15":
|
||||
# Visual Studio 2017 reports 15.* but the PlatformToolsetVersion is 141
|
||||
return "v141"
|
||||
else:
|
||||
|
|
|
@ -2,7 +2,7 @@ variables:
|
|||
|
||||
Major: '4'
|
||||
Minor: '8'
|
||||
Patch: '16'
|
||||
Patch: '18'
|
||||
NightlyVersion: $(Major).$(Minor).$(Patch).$(Build.BuildId)-$(Build.DefinitionName)
|
||||
|
||||
stages:
|
||||
|
@ -29,7 +29,7 @@ stages:
|
|||
pool:
|
||||
vmImage: "macOS-latest"
|
||||
steps:
|
||||
- script: python scripts/mk_unix_dist.py --dotnet-key=$(Build.SourcesDirectory)/resources/z3.snk --arch=arm64
|
||||
- script: python scripts/mk_unix_dist.py --dotnet-key=$(Build.SourcesDirectory)/resources/z3.snk --arch=arm64 --os=osx-11.0
|
||||
- script: git clone https://github.com/z3prover/z3test z3test
|
||||
- script: cp dist/*.zip $(Build.ArtifactStagingDirectory)/.
|
||||
- task: PublishPipelineArtifact@1
|
||||
|
@ -86,13 +86,14 @@ stages:
|
|||
artifactName: 'UbuntuDoc'
|
||||
targetPath: $(Build.ArtifactStagingDirectory)
|
||||
|
||||
- job: Manylinux
|
||||
displayName: "Manylinux build"
|
||||
- job: ManyLinuxBuild
|
||||
variables:
|
||||
python: "/opt/python/cp37-cp37m/bin/python"
|
||||
name: ManyLinux
|
||||
displayName: "ManyLinux build"
|
||||
pool:
|
||||
vmImage: "Ubuntu-18.04"
|
||||
container: "quay.io/pypa/manylinux2010_x86_64:latest"
|
||||
variables:
|
||||
python: "/opt/python/cp37-cp37m/bin/python"
|
||||
steps:
|
||||
- script: $(python) scripts/mk_unix_dist.py --nodotnet --nojava
|
||||
- script: git clone https://github.com/z3prover/z3test z3test
|
||||
|
@ -100,9 +101,29 @@ stages:
|
|||
- script: cp dist/*.zip $(Build.ArtifactStagingDirectory)/
|
||||
- task: PublishPipelineArtifact@0
|
||||
inputs:
|
||||
artifactName: 'Manylinux'
|
||||
artifactName: '$(name)Build'
|
||||
targetPath: $(Build.ArtifactStagingDirectory)
|
||||
|
||||
# - job: MuslLinuxBuild
|
||||
# condition: eq(0,1)
|
||||
# variables:
|
||||
# python: "/opt/python/cp310-cp310/bin/python"
|
||||
# name: MuslLinux
|
||||
# displayName: "MuslLinux build"
|
||||
# pool:
|
||||
# vmImage: "Ubuntu-18.04"
|
||||
# container: "quay.io/pypa/musllinux_1_1_x86_64:latest"
|
||||
# steps:
|
||||
# - script: $(python) scripts/mk_unix_dist.py --nodotnet --nojava
|
||||
# - script: git clone https://github.com/z3prover/z3test z3test
|
||||
# - script: $(python) z3test/scripts/test_benchmarks.py build-dist/z3 z3test/regressions/smt2
|
||||
# - script: cp dist/*.zip $(Build.ArtifactStagingDirectory)/
|
||||
# - task: PublishPipelineArtifact@0
|
||||
# inputs:
|
||||
# artifactName: '$(name)Build'
|
||||
# targetPath: $(Build.ArtifactStagingDirectory)
|
||||
|
||||
|
||||
- job: Windows32
|
||||
displayName: "Windows 32-bit build"
|
||||
pool:
|
||||
|
@ -393,8 +414,13 @@ stages:
|
|||
targetPath: $(Agent.TempDirectory)
|
||||
- task: DownloadPipelineArtifact@2
|
||||
inputs:
|
||||
artifactName: 'Manylinux'
|
||||
artifactName: 'ManyLinuxBuild'
|
||||
targetPath: $(Agent.TempDirectory)
|
||||
# - task: DownloadPipelineArtifact@2
|
||||
# displayName: 'Download MuslLinux Build'
|
||||
# inputs:
|
||||
# artifact: 'MuslLinuxBuild'
|
||||
# path: $(Agent.TempDirectory)
|
||||
- task: DownloadPipelineArtifact@2
|
||||
inputs:
|
||||
artifactName: 'Mac'
|
||||
|
@ -405,13 +431,15 @@ stages:
|
|||
targetPath: $(Agent.TempDirectory)
|
||||
- script: cd $(Agent.TempDirectory); mkdir osx-x64-bin; cd osx-x64-bin; unzip ../*x64-osx*.zip
|
||||
- script: cd $(Agent.TempDirectory); mkdir osx-arm64-bin; cd osx-arm64-bin; unzip ../*arm64-osx*.zip
|
||||
- script: cd $(Agent.TempDirectory); mkdir linux-bin; cd linux-bin; unzip ../*glibc*.zip
|
||||
- script: cd $(Agent.TempDirectory); mkdir libc-bin; cd libc-bin; unzip ../*glibc*.zip
|
||||
# - script: cd $(Agent.TempDirectory); mkdir musl-bin; cd musl-bin; unzip ../*-linux.zip
|
||||
- script: cd $(Agent.TempDirectory); mkdir win32-bin; cd win32-bin; unzip ../*x86-win*.zip
|
||||
- script: cd $(Agent.TempDirectory); mkdir win64-bin; cd win64-bin; unzip ../*x64-win*.zip
|
||||
- script: python3 -m pip install --user -U setuptools wheel
|
||||
- script: cd src/api/python; python3 setup.py sdist
|
||||
# take a look at this PREMIUM HACK I came up with to get around the fact that the azure variable syntax overloads the bash syntax for subshells
|
||||
- script: cd src/api/python; echo $(Agent.TempDirectory)/linux-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python3 setup.py bdist_wheel
|
||||
- script: cd src/api/python; echo $(Agent.TempDirectory)/libc-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python3 setup.py bdist_wheel
|
||||
# - script: cd src/api/python; echo $(Agent.TempDirectory)/musl-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python3 setup.py bdist_wheel
|
||||
- script: cd src/api/python; echo $(Agent.TempDirectory)/win32-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python3 setup.py bdist_wheel
|
||||
- script: cd src/api/python; echo $(Agent.TempDirectory)/win64-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python3 setup.py bdist_wheel
|
||||
- script: cd src/api/python; echo $(Agent.TempDirectory)/osx-x64-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python3 setup.py bdist_wheel
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
trigger: none
|
||||
|
||||
variables:
|
||||
ReleaseVersion: '4.8.16'
|
||||
ReleaseVersion: '4.8.18'
|
||||
|
||||
stages:
|
||||
|
||||
|
@ -43,6 +43,28 @@ stages:
|
|||
artifactName: 'macOSBuild'
|
||||
targetPath: $(Build.ArtifactStagingDirectory)
|
||||
|
||||
- job: MacBuildArm64
|
||||
displayName: "macOS Build"
|
||||
pool:
|
||||
vmImage: "macOS-latest"
|
||||
steps:
|
||||
- task: PythonScript@0
|
||||
displayName: Build
|
||||
inputs:
|
||||
scriptSource: 'filepath'
|
||||
scriptPath: scripts/mk_unix_dist.py
|
||||
arguments: --dotnet-key=$(Build.SourcesDirectory)/resources/z3.snk --nojava --arch=arm64 --os=osx-11.0
|
||||
- task: CopyFiles@2
|
||||
inputs:
|
||||
sourceFolder: dist
|
||||
contents: '*.zip'
|
||||
targetFolder: $(Build.ArtifactStagingDirectory)
|
||||
- task: PublishPipelineArtifact@0
|
||||
inputs:
|
||||
artifactName: 'macOSBuildArm64'
|
||||
targetPath: $(Build.ArtifactStagingDirectory)
|
||||
|
||||
|
||||
- job: UbuntuBuild
|
||||
displayName: "Ubuntu build"
|
||||
pool:
|
||||
|
@ -107,13 +129,23 @@ stages:
|
|||
artifactName: 'UbuntuDoc'
|
||||
targetPath: $(Build.ArtifactStagingDirectory)
|
||||
|
||||
- job: ManyLinuxBuild
|
||||
displayName: "ManyLinux build"
|
||||
- job: LinuxBuilds
|
||||
strategy:
|
||||
matrix:
|
||||
manyLinux:
|
||||
name: ManyLinux
|
||||
image: "quay.io/pypa/manylinux2010_x86_64:latest"
|
||||
python: "/opt/python/cp37-cp37m/bin/python"
|
||||
muslLinux:
|
||||
name: MuslLinux
|
||||
image: "quay.io/pypa/musllinux_1_1_x86_64:latest"
|
||||
python: "/opt/python/cp310-cp310/bin/python"
|
||||
displayName: "$(name) build"
|
||||
pool:
|
||||
vmImage: "ubuntu-latest"
|
||||
container: "quay.io/pypa/manylinux2010_x86_64:latest"
|
||||
container: $(image)
|
||||
variables:
|
||||
python: "/opt/python/cp37-cp37m/bin/python"
|
||||
python: $(python)
|
||||
steps:
|
||||
- task: PythonScript@0
|
||||
displayName: Build
|
||||
|
@ -138,7 +170,7 @@ stages:
|
|||
targetFolder: $(Build.ArtifactStagingDirectory)
|
||||
- task: PublishPipelineArtifact@0
|
||||
inputs:
|
||||
artifactName: 'ManyLinuxBuild'
|
||||
artifactName: '$(name)Build'
|
||||
targetPath: $(Build.ArtifactStagingDirectory)
|
||||
|
||||
- template: build-win-signed.yml
|
||||
|
@ -378,6 +410,11 @@ stages:
|
|||
inputs:
|
||||
artifact: 'ManyLinuxBuild'
|
||||
path: $(Agent.TempDirectory)
|
||||
- task: DownloadPipelineArtifact@2
|
||||
displayName: 'Download MuslLinux Build'
|
||||
inputs:
|
||||
artifact: 'MuslLinuxBuild'
|
||||
path: $(Agent.TempDirectory)
|
||||
- task: DownloadPipelineArtifact@2
|
||||
displayName: 'Download Win32 Build'
|
||||
inputs:
|
||||
|
@ -389,14 +426,18 @@ stages:
|
|||
artifact: 'WindowsBuild-x64'
|
||||
path: $(Agent.TempDirectory)
|
||||
- script: cd $(Agent.TempDirectory); mkdir osx-bin; cd osx-bin; unzip ../*osx*.zip
|
||||
- script: cd $(Agent.TempDirectory); mkdir linux-bin; cd linux-bin; unzip ../*glibc*.zip
|
||||
- script: cd $(Agent.TempDirectory); mkdir osx-arm64-bin; cd osx-arm64-bin; unzip ../*arm64-osx*.zip
|
||||
- script: cd $(Agent.TempDirectory); mkdir libc-bin; cd libc-bin; unzip ../*glibc*.zip
|
||||
- script: cd $(Agent.TempDirectory); mkdir musl-bin; cd musl-bin; unzip ../*-linux.zip
|
||||
- script: cd $(Agent.TempDirectory); mkdir win32-bin; cd win32-bin; unzip ../*x86-win*.zip
|
||||
- script: cd $(Agent.TempDirectory); mkdir win64-bin; cd win64-bin; unzip ../*x64-win*.zip
|
||||
- script: python3 -m pip install --user -U setuptools wheel
|
||||
- script: cd src/api/python; python3 setup.py sdist
|
||||
# take a look at this PREMIUM HACK I came up with to get around the fact that the azure variable syntax overloads the bash syntax for subshells
|
||||
- script: cd src/api/python; echo $(Agent.TempDirectory)/osx-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python3 setup.py bdist_wheel
|
||||
- script: cd src/api/python; echo $(Agent.TempDirectory)/linux-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python3 setup.py bdist_wheel
|
||||
- script: cd src/api/python; echo $(Agent.TempDirectory)/osx-arm64-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python3 setup.py bdist_wheel
|
||||
- script: cd src/api/python; echo $(Agent.TempDirectory)/libc-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python3 setup.py bdist_wheel
|
||||
- script: cd src/api/python; echo $(Agent.TempDirectory)/musl-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python3 setup.py bdist_wheel
|
||||
- script: cd src/api/python; echo $(Agent.TempDirectory)/win32-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python3 setup.py bdist_wheel
|
||||
- script: cd src/api/python; echo $(Agent.TempDirectory)/win64-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python3 setup.py bdist_wheel
|
||||
- task: PublishPipelineArtifact@0
|
||||
|
@ -429,6 +470,11 @@ stages:
|
|||
inputs:
|
||||
artifact: 'macOSBuild'
|
||||
path: $(Agent.TempDirectory)
|
||||
- task: DownloadPipelineArtifact@2
|
||||
displayName: 'Download macOSArm64 Build'
|
||||
inputs:
|
||||
artifact: 'macOSBuildArm64'
|
||||
path: $(Agent.TempDirectory)
|
||||
- task: DownloadPipelineArtifact@2
|
||||
displayName: 'Download Win32 Build'
|
||||
inputs:
|
||||
|
@ -507,4 +553,4 @@ stages:
|
|||
secureFile: 'pypircs'
|
||||
- script: python3 -m pip install --upgrade pip
|
||||
- script: python3 -m pip install --user -U setuptools importlib_metadata wheel twine
|
||||
- script: python3 -m twine upload --config-file $(pypircs.secureFilePath) -r $(pypiReleaseServer) dist/*
|
||||
- script: python3 -m twine upload --config-file $(pypircs.secureFilePath) -r $(pypiReleaseServer) dist/*
|
||||
|
|
|
@ -42,6 +42,7 @@ IN_ARRAY = 3
|
|||
OUT_ARRAY = 4
|
||||
INOUT_ARRAY = 5
|
||||
OUT_MANAGED_ARRAY = 6
|
||||
FN_PTR = 7
|
||||
|
||||
# Primitive Types
|
||||
VOID = 0
|
||||
|
@ -60,37 +61,46 @@ DOUBLE = 12
|
|||
FLOAT = 13
|
||||
CHAR = 14
|
||||
CHAR_PTR = 15
|
||||
LBOOL = 16
|
||||
|
||||
FIRST_FN_ID = 50
|
||||
|
||||
FIRST_OBJ_ID = 100
|
||||
|
||||
def is_obj(ty):
|
||||
return ty >= FIRST_OBJ_ID
|
||||
|
||||
def is_fn(ty):
|
||||
return FIRST_FN_ID <= ty and ty < FIRST_OBJ_ID
|
||||
|
||||
Type2Str = { VOID : 'void', VOID_PTR : 'void*', INT : 'int', UINT : 'unsigned', INT64 : 'int64_t', UINT64 : 'uint64_t', DOUBLE : 'double',
|
||||
FLOAT : 'float', STRING : 'Z3_string', STRING_PTR : 'Z3_string_ptr', BOOL : 'bool', SYMBOL : 'Z3_symbol',
|
||||
PRINT_MODE : 'Z3_ast_print_mode', ERROR_CODE : 'Z3_error_code', CHAR: 'char', CHAR_PTR: 'Z3_char_ptr'
|
||||
PRINT_MODE : 'Z3_ast_print_mode', ERROR_CODE : 'Z3_error_code', CHAR: 'char', CHAR_PTR: 'Z3_char_ptr', LBOOL : 'Z3_lbool'
|
||||
}
|
||||
|
||||
Type2PyStr = { VOID_PTR : 'ctypes.c_void_p', INT : 'ctypes.c_int', UINT : 'ctypes.c_uint', INT64 : 'ctypes.c_longlong',
|
||||
UINT64 : 'ctypes.c_ulonglong', DOUBLE : 'ctypes.c_double', FLOAT : 'ctypes.c_float',
|
||||
STRING : 'ctypes.c_char_p', STRING_PTR : 'ctypes.POINTER(ctypes.c_char_p)', BOOL : 'ctypes.c_bool', SYMBOL : 'Symbol',
|
||||
PRINT_MODE : 'ctypes.c_uint', ERROR_CODE : 'ctypes.c_uint', CHAR : 'ctypes.c_char', CHAR_PTR: 'ctypes.POINTER(ctypes.c_char)'
|
||||
PRINT_MODE : 'ctypes.c_uint', ERROR_CODE : 'ctypes.c_uint', CHAR : 'ctypes.c_char', CHAR_PTR: 'ctypes.POINTER(ctypes.c_char)', LBOOL : 'ctypes.c_int'
|
||||
}
|
||||
|
||||
# Mapping to .NET types
|
||||
Type2Dotnet = { VOID : 'void', VOID_PTR : 'IntPtr', INT : 'int', UINT : 'uint', INT64 : 'Int64', UINT64 : 'UInt64', DOUBLE : 'double',
|
||||
FLOAT : 'float', STRING : 'string', STRING_PTR : 'byte**', BOOL : 'byte', SYMBOL : 'IntPtr',
|
||||
PRINT_MODE : 'uint', ERROR_CODE : 'uint', CHAR : 'char', CHAR_PTR : 'IntPtr' }
|
||||
PRINT_MODE : 'uint', ERROR_CODE : 'uint', CHAR : 'char', CHAR_PTR : 'IntPtr', LBOOL : 'int' }
|
||||
|
||||
|
||||
# Mapping to ML types
|
||||
Type2ML = { VOID : 'unit', VOID_PTR : 'VOIDP', INT : 'int', UINT : 'int', INT64 : 'int', UINT64 : 'int', DOUBLE : 'float',
|
||||
Type2ML = { VOID : 'unit', VOID_PTR : 'ptr', INT : 'int', UINT : 'int', INT64 : 'int', UINT64 : 'int', DOUBLE : 'float',
|
||||
FLOAT : 'float', STRING : 'string', STRING_PTR : 'char**',
|
||||
BOOL : 'bool', SYMBOL : 'z3_symbol', PRINT_MODE : 'int', ERROR_CODE : 'int', CHAR : 'char', CHAR_PTR : 'string' }
|
||||
BOOL : 'bool', SYMBOL : 'z3_symbol', PRINT_MODE : 'int', ERROR_CODE : 'int', CHAR : 'char', CHAR_PTR : 'string', LBOOL : 'int' }
|
||||
|
||||
Closures = []
|
||||
|
||||
class APITypes:
|
||||
def __init__(self):
|
||||
self.next_type_id = FIRST_OBJ_ID
|
||||
self.next_fntype_id = FIRST_FN_ID
|
||||
|
||||
def def_Type(self, var, c_type, py_type):
|
||||
"""Process type definitions of the form def_Type(var, c_type, py_type)
|
||||
|
@ -103,24 +113,42 @@ class APITypes:
|
|||
Type2Str[id] = c_type
|
||||
Type2PyStr[id] = py_type
|
||||
self.next_type_id += 1
|
||||
|
||||
|
||||
def def_Types(self, api_files):
|
||||
global Closures
|
||||
pat1 = re.compile(" *def_Type\(\'(.*)\',[^\']*\'(.*)\',[^\']*\'(.*)\'\)[ \t]*")
|
||||
pat2 = re.compile("Z3_DECLARE_CLOSURE\((.*),(.*), \((.*)\)\)")
|
||||
for api_file in api_files:
|
||||
with open(api_file, 'r') as api:
|
||||
for line in api:
|
||||
m = pat1.match(line)
|
||||
if m:
|
||||
self.def_Type(m.group(1), m.group(2), m.group(3))
|
||||
continue
|
||||
m = pat2.match(line)
|
||||
if m:
|
||||
self.fun_Type(m.group(1))
|
||||
Closures += [(m.group(1), m.group(2), m.group(3))]
|
||||
continue
|
||||
#
|
||||
# Populate object type entries in dotnet and ML bindings.
|
||||
#
|
||||
for k in Type2Str:
|
||||
v = Type2Str[k]
|
||||
if is_obj(k):
|
||||
if is_obj(k) or is_fn(k):
|
||||
Type2Dotnet[k] = v
|
||||
Type2ML[k] = v.lower()
|
||||
|
||||
def fun_Type(self, var):
|
||||
"""Process function type definitions"""
|
||||
id = self.next_fntype_id
|
||||
exec('%s = %s' % (var, id), globals())
|
||||
Type2Str[id] = var
|
||||
Type2PyStr[id] = var
|
||||
self.next_fntype_id += 1
|
||||
|
||||
|
||||
def type2str(ty):
|
||||
global Type2Str
|
||||
return Type2Str[ty]
|
||||
|
@ -147,6 +175,9 @@ def _in(ty):
|
|||
def _in_array(sz, ty):
|
||||
return (IN_ARRAY, ty, sz)
|
||||
|
||||
def _fnptr(ty):
|
||||
return (FN_PTR, ty)
|
||||
|
||||
def _out(ty):
|
||||
return (OUT, ty)
|
||||
|
||||
|
@ -179,11 +210,13 @@ def param_array_size_pos(p):
|
|||
|
||||
def param2str(p):
|
||||
if param_kind(p) == IN_ARRAY:
|
||||
return "%s const *" % type2str(param_type(p))
|
||||
return "%s const *" % (type2str(param_type(p)))
|
||||
elif param_kind(p) == OUT_ARRAY or param_kind(p) == IN_ARRAY or param_kind(p) == INOUT_ARRAY:
|
||||
return "%s*" % type2str(param_type(p))
|
||||
return "%s*" % (type2str(param_type(p)))
|
||||
elif param_kind(p) == OUT:
|
||||
return "%s*" % type2str(param_type(p))
|
||||
return "%s*" % (type2str(param_type(p)))
|
||||
elif param_kind(p) == FN_PTR:
|
||||
return "%s*" % (type2str(param_type(p)))
|
||||
else:
|
||||
return type2str(param_type(p))
|
||||
|
||||
|
@ -276,6 +309,13 @@ def display_args_to_z3(params):
|
|||
|
||||
NULLWrapped = [ 'Z3_mk_context', 'Z3_mk_context_rc' ]
|
||||
Unwrapped = [ 'Z3_del_context', 'Z3_get_error_code' ]
|
||||
Unchecked = frozenset([ 'Z3_dec_ref', 'Z3_params_dec_ref', 'Z3_model_dec_ref',
|
||||
'Z3_func_interp_dec_ref', 'Z3_func_entry_dec_ref',
|
||||
'Z3_goal_dec_ref', 'Z3_tactic_dec_ref', 'Z3_probe_dec_ref',
|
||||
'Z3_fixedpoint_dec_ref', 'Z3_param_descrs_dec_ref',
|
||||
'Z3_ast_vector_dec_ref', 'Z3_ast_map_dec_ref',
|
||||
'Z3_apply_result_dec_ref', 'Z3_solver_dec_ref',
|
||||
'Z3_stats_dec_ref', 'Z3_optimize_dec_ref'])
|
||||
|
||||
def mk_py_wrappers():
|
||||
core_py.write("""
|
||||
|
@ -345,7 +385,7 @@ def mk_py_wrapper_single(sig, decode_string=True):
|
|||
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 and not name in Unwrapped:
|
||||
if len(params) > 0 and param_type(params[0]) == CONTEXT and not name in Unwrapped and not name in Unchecked:
|
||||
core_py.write(" _elems.Check(a0)\n")
|
||||
if result == STRING and decode_string:
|
||||
core_py.write(" return _to_pystr(r)\n")
|
||||
|
@ -374,11 +414,21 @@ def mk_dotnet(dotnet):
|
|||
v = Type2Str[k]
|
||||
if is_obj(k):
|
||||
dotnet.write(' using %s = System.IntPtr;\n' % v)
|
||||
|
||||
dotnet.write(' using voidp = System.IntPtr;\n')
|
||||
dotnet.write('\n')
|
||||
dotnet.write(' public class Native\n')
|
||||
dotnet.write(' {\n\n')
|
||||
dotnet.write(' [UnmanagedFunctionPointer(CallingConvention.Cdecl)]\n')
|
||||
dotnet.write(' public delegate void Z3_error_handler(Z3_context c, Z3_error_code e);\n\n')
|
||||
|
||||
for name, ret, sig in Closures:
|
||||
sig = sig.replace("void*","voidp").replace("unsigned","uint")
|
||||
sig = sig.replace("Z3_ast*","ref IntPtr").replace("uint*","ref uint").replace("Z3_lbool*","ref int")
|
||||
ret = ret.replace("void*","voidp").replace("unsigned","uint")
|
||||
if "*" in sig or "*" in ret:
|
||||
continue
|
||||
dotnet.write(' [UnmanagedFunctionPointer(CallingConvention.Cdecl)]\n')
|
||||
dotnet.write(' public delegate %s %s(%s);\n' % (ret,name,sig))
|
||||
|
||||
dotnet.write(' public class LIB\n')
|
||||
dotnet.write(' {\n')
|
||||
dotnet.write(' const string Z3_DLL_NAME = \"libz3\";\n'
|
||||
|
@ -456,7 +506,7 @@ def mk_dotnet_wrappers(dotnet):
|
|||
dotnet.write(" if (r == IntPtr.Zero)\n")
|
||||
dotnet.write(" throw new Z3Exception(\"Object allocation failed.\");\n")
|
||||
else:
|
||||
if len(params) > 0 and param_type(params[0]) == CONTEXT:
|
||||
if len(params) > 0 and param_type(params[0]) == CONTEXT and name not in Unchecked:
|
||||
dotnet.write(" Z3_error_code err = (Z3_error_code)LIB.Z3_get_error_code(a0);\n")
|
||||
dotnet.write(" if (err != Z3_error_code.Z3_OK)\n")
|
||||
dotnet.write(" throw new Z3Exception(Marshal.PtrToStringAnsi(LIB.Z3_get_error_msg(a0, (uint)err)));\n")
|
||||
|
@ -473,22 +523,22 @@ def mk_dotnet_wrappers(dotnet):
|
|||
|
||||
Type2Java = { VOID : 'void', VOID_PTR : 'long', INT : 'int', UINT : 'int', INT64 : 'long', UINT64 : 'long', DOUBLE : 'double',
|
||||
FLOAT : 'float', STRING : 'String', STRING_PTR : 'StringPtr',
|
||||
BOOL : 'boolean', SYMBOL : 'long', PRINT_MODE : 'int', ERROR_CODE : 'int', CHAR : 'char', CHAR_PTR : 'long' }
|
||||
BOOL : 'boolean', SYMBOL : 'long', PRINT_MODE : 'int', ERROR_CODE : 'int', CHAR : 'char', CHAR_PTR : 'long', LBOOL : 'int' }
|
||||
|
||||
Type2JavaW = { VOID : 'void', VOID_PTR : 'jlong', INT : 'jint', UINT : 'jint', INT64 : 'jlong', UINT64 : 'jlong', DOUBLE : 'jdouble',
|
||||
FLOAT : 'jfloat', STRING : 'jstring', STRING_PTR : 'jobject',
|
||||
BOOL : 'jboolean', SYMBOL : 'jlong', PRINT_MODE : 'jint', ERROR_CODE : 'jint', CHAR : 'jchar', CHAR_PTR : 'jlong'}
|
||||
BOOL : 'jboolean', SYMBOL : 'jlong', PRINT_MODE : 'jint', ERROR_CODE : 'jint', CHAR : 'jchar', CHAR_PTR : 'jlong', LBOOL : 'jint'}
|
||||
|
||||
def type2java(ty):
|
||||
global Type2Java
|
||||
if (ty >= FIRST_OBJ_ID):
|
||||
if (ty >= FIRST_FN_ID):
|
||||
return 'long'
|
||||
else:
|
||||
return Type2Java[ty]
|
||||
|
||||
def type2javaw(ty):
|
||||
global Type2JavaW
|
||||
if (ty >= FIRST_OBJ_ID):
|
||||
if (ty >= FIRST_FN_ID):
|
||||
return 'jlong'
|
||||
else:
|
||||
return Type2JavaW[ty]
|
||||
|
@ -513,6 +563,8 @@ def param2java(p):
|
|||
return "UIntArrayPtr"
|
||||
else:
|
||||
return "ObjArrayPtr"
|
||||
elif k == FN_PTR:
|
||||
return "LongPtr"
|
||||
else:
|
||||
return type2java(param_type(p))
|
||||
|
||||
|
@ -552,7 +604,7 @@ def java_array_element_type(p):
|
|||
else:
|
||||
return 'jlong'
|
||||
|
||||
def mk_java(java_dir, package_name):
|
||||
def mk_java(java_src, java_dir, package_name):
|
||||
java_nativef = os.path.join(java_dir, 'Native.java')
|
||||
java_wrapperf = os.path.join(java_dir, 'Native.cpp')
|
||||
java_native = open(java_nativef, 'w')
|
||||
|
@ -627,7 +679,7 @@ def mk_java(java_dir, package_name):
|
|||
java_native.write(" if (res == 0)\n")
|
||||
java_native.write(" throw new Z3Exception(\"Object allocation failed.\");\n")
|
||||
else:
|
||||
if len(params) > 0 and param_type(params[0]) == CONTEXT:
|
||||
if len(params) > 0 and param_type(params[0]) == CONTEXT and name not in Unchecked:
|
||||
java_native.write(' Z3_error_code err = Z3_error_code.fromInt(INTERNALgetErrorCode(a0));\n')
|
||||
java_native.write(' if (err != Z3_error_code.Z3_OK)\n')
|
||||
java_native.write(' throw new Z3Exception(INTERNALgetErrorMsg(a0, err.toInt()));\n')
|
||||
|
@ -637,65 +689,9 @@ def mk_java(java_dir, package_name):
|
|||
java_native.write('}\n')
|
||||
java_wrapper = open(java_wrapperf, 'w')
|
||||
pkg_str = package_name.replace('.', '_')
|
||||
java_wrapper.write('// Automatically generated file\n')
|
||||
java_wrapper.write('#include<jni.h>\n')
|
||||
java_wrapper.write('#include<stdlib.h>\n')
|
||||
java_wrapper.write('#include"z3.h"\n')
|
||||
java_wrapper.write('#ifdef __cplusplus\n')
|
||||
java_wrapper.write('extern "C" {\n')
|
||||
java_wrapper.write('#endif\n\n')
|
||||
java_wrapper.write('#ifdef __GNUC__\n#if __GNUC__ >= 4\n#define DLL_VIS __attribute__ ((visibility ("default")))\n#else\n#define DLL_VIS\n#endif\n#else\n#define DLL_VIS\n#endif\n\n')
|
||||
java_wrapper.write('#if defined(__LP64__) || defined(_WIN64)\n\n')
|
||||
java_wrapper.write('#define GETLONGAELEMS(T,OLD,NEW) \\\n')
|
||||
java_wrapper.write(' T * NEW = (OLD == 0) ? 0 : (T*) jenv->GetLongArrayElements(OLD, NULL);\n')
|
||||
java_wrapper.write('#define RELEASELONGAELEMS(OLD,NEW) \\\n')
|
||||
java_wrapper.write(' if (OLD != 0) jenv->ReleaseLongArrayElements(OLD, (jlong *) NEW, JNI_ABORT); \n\n')
|
||||
java_wrapper.write('#define GETLONGAREGION(T,OLD,Z,SZ,NEW) \\\n')
|
||||
java_wrapper.write(' jenv->GetLongArrayRegion(OLD,Z,(jsize)SZ,(jlong*)NEW); \n')
|
||||
java_wrapper.write('#define SETLONGAREGION(OLD,Z,SZ,NEW) \\\n')
|
||||
java_wrapper.write(' jenv->SetLongArrayRegion(OLD,Z,(jsize)SZ,(jlong*)NEW) \n\n')
|
||||
java_wrapper.write('#else\n\n')
|
||||
java_wrapper.write('#define GETLONGAELEMS(T,OLD,NEW) \\\n')
|
||||
java_wrapper.write(' T * NEW = 0; { \\\n')
|
||||
java_wrapper.write(' jlong * temp = (OLD == 0) ? 0 : jenv->GetLongArrayElements(OLD, NULL); \\\n')
|
||||
java_wrapper.write(' unsigned int size = (OLD == 0) ? 0 :jenv->GetArrayLength(OLD); \\\n')
|
||||
java_wrapper.write(' if (OLD != 0) { \\\n')
|
||||
java_wrapper.write(' NEW = (T*) (new int[size]); \\\n')
|
||||
java_wrapper.write(' for (unsigned i=0; i < size; i++) \\\n')
|
||||
java_wrapper.write(' NEW[i] = reinterpret_cast<T>(temp[i]); \\\n')
|
||||
java_wrapper.write(' jenv->ReleaseLongArrayElements(OLD, temp, JNI_ABORT); \\\n')
|
||||
java_wrapper.write(' } \\\n')
|
||||
java_wrapper.write(' } \n\n')
|
||||
java_wrapper.write('#define RELEASELONGAELEMS(OLD,NEW) \\\n')
|
||||
java_wrapper.write(' delete [] NEW; \n\n')
|
||||
java_wrapper.write('#define GETLONGAREGION(T,OLD,Z,SZ,NEW) \\\n')
|
||||
java_wrapper.write(' { \\\n')
|
||||
java_wrapper.write(' jlong * temp = new jlong[SZ]; \\\n')
|
||||
java_wrapper.write(' jenv->GetLongArrayRegion(OLD,Z,(jsize)SZ,(jlong*)temp); \\\n')
|
||||
java_wrapper.write(' for (int i = 0; i < (SZ); i++) \\\n')
|
||||
java_wrapper.write(' NEW[i] = reinterpret_cast<T>(temp[i]); \\\n')
|
||||
java_wrapper.write(' delete [] temp; \\\n')
|
||||
java_wrapper.write(' }\n\n')
|
||||
java_wrapper.write('#define SETLONGAREGION(OLD,Z,SZ,NEW) \\\n')
|
||||
java_wrapper.write(' { \\\n')
|
||||
java_wrapper.write(' jlong * temp = new jlong[SZ]; \\\n')
|
||||
java_wrapper.write(' for (int i = 0; i < (SZ); i++) \\\n')
|
||||
java_wrapper.write(' temp[i] = reinterpret_cast<jlong>(NEW[i]); \\\n')
|
||||
java_wrapper.write(' jenv->SetLongArrayRegion(OLD,Z,(jsize)SZ,temp); \\\n')
|
||||
java_wrapper.write(' delete [] temp; \\\n')
|
||||
java_wrapper.write(' }\n\n')
|
||||
java_wrapper.write('#endif\n\n')
|
||||
java_wrapper.write('void Z3JavaErrorHandler(Z3_context c, Z3_error_code e)\n')
|
||||
java_wrapper.write('{\n')
|
||||
java_wrapper.write(' // Internal do-nothing error handler. This is required to avoid that Z3 calls exit()\n')
|
||||
java_wrapper.write(' // upon errors, but the actual error handling is done by throwing exceptions in the\n')
|
||||
java_wrapper.write(' // wrappers below.\n')
|
||||
java_wrapper.write('}\n\n')
|
||||
java_wrapper.write('DLL_VIS JNIEXPORT void JNICALL Java_%s_Native_setInternalErrorHandler(JNIEnv * jenv, jclass cls, jlong a0)\n' % pkg_str)
|
||||
java_wrapper.write('{\n')
|
||||
java_wrapper.write(' Z3_set_error_handler((Z3_context)a0, Z3JavaErrorHandler);\n')
|
||||
java_wrapper.write('}\n\n')
|
||||
java_wrapper.write('')
|
||||
with open(java_src + "/NativeStatic.txt") as ins:
|
||||
for line in ins:
|
||||
java_wrapper.write(line)
|
||||
for name, result, params in _dotnet_decls:
|
||||
java_wrapper.write('DLL_VIS JNIEXPORT %s JNICALL Java_%s_Native_INTERNAL%s(JNIEnv * jenv, jclass cls' % (type2javaw(result), pkg_str, java_method_name(name)))
|
||||
i = 0
|
||||
|
@ -973,6 +969,9 @@ def def_API(name, result, params):
|
|||
elif ty == VOID_PTR:
|
||||
log_c.write(" P(0);\n")
|
||||
exe_c.write("in.get_obj_addr(%s)" % i)
|
||||
elif ty == LBOOL:
|
||||
log_c.write(" I(static_cast<signed>(a%s));\n" % i)
|
||||
exe_c.write("static_cast<%s>(in.get_int(%s))" % (type2str(ty), i))
|
||||
elif ty == PRINT_MODE or ty == ERROR_CODE:
|
||||
log_c.write(" U(static_cast<unsigned>(a%s));\n" % i)
|
||||
exe_c.write("static_cast<%s>(in.get_uint(%s))" % (type2str(ty), i))
|
||||
|
@ -1070,6 +1069,9 @@ def def_API(name, result, params):
|
|||
log_c.write(" }\n")
|
||||
log_c.write(" Ap(%s);\n" % sz_e)
|
||||
exe_c.write("reinterpret_cast<%s**>(in.get_obj_array(%s))" % (tstr, i))
|
||||
elif kind == FN_PTR:
|
||||
log_c.write("// P(a%s);\n" % i)
|
||||
exe_c.write("reinterpret_cast<%s>(in.get_obj(%s))" % (param2str(p), i))
|
||||
else:
|
||||
error ("unsupported parameter for %s, %s" % (name, p))
|
||||
i = i + 1
|
||||
|
@ -1244,7 +1246,7 @@ def ml_unwrap(t, ts, s):
|
|||
return '(' + ts + ') String_val(' + s + ')'
|
||||
elif t == BOOL or (type2str(t) == 'bool'):
|
||||
return '(' + ts + ') Bool_val(' + s + ')'
|
||||
elif t == INT or t == PRINT_MODE or t == ERROR_CODE:
|
||||
elif t == INT or t == PRINT_MODE or t == ERROR_CODE or t == LBOOL:
|
||||
return '(' + ts + ') Int_val(' + s + ')'
|
||||
elif t == UINT:
|
||||
return '(' + ts + ') Unsigned_int_val(' + s + ')'
|
||||
|
@ -1265,7 +1267,7 @@ def ml_set_wrap(t, d, n):
|
|||
return d + ' = Val_unit;'
|
||||
elif t == BOOL or (type2str(t) == 'bool'):
|
||||
return d + ' = Val_bool(' + n + ');'
|
||||
elif t == INT or t == UINT or t == PRINT_MODE or t == ERROR_CODE:
|
||||
elif t == INT or t == UINT or t == PRINT_MODE or t == ERROR_CODE or t == LBOOL:
|
||||
return d + ' = Val_int(' + n + ');'
|
||||
elif t == INT64 or t == UINT64:
|
||||
return d + ' = Val_long(' + n + ');'
|
||||
|
@ -1278,7 +1280,7 @@ def ml_set_wrap(t, d, n):
|
|||
return '*(' + pts + '*)Data_custom_val(' + d + ') = ' + n + ';'
|
||||
|
||||
def ml_alloc_and_store(t, lhs, rhs):
|
||||
if t == VOID or t == BOOL or t == INT or t == UINT or t == PRINT_MODE or t == ERROR_CODE or t == INT64 or t == UINT64 or t == DOUBLE or t == STRING or (type2str(t) == 'bool'):
|
||||
if t == VOID or t == BOOL or t == INT or t == UINT or t == PRINT_MODE or t == ERROR_CODE or t == INT64 or t == UINT64 or t == DOUBLE or t == STRING or t == LBOOL or (type2str(t) == 'bool'):
|
||||
return ml_set_wrap(t, lhs, rhs)
|
||||
else:
|
||||
pts = ml_plus_type(type2str(t))
|
||||
|
@ -1286,6 +1288,27 @@ def ml_alloc_and_store(t, lhs, rhs):
|
|||
alloc_str = '%s = caml_alloc_custom(&%s, sizeof(%s), 0, 1); ' % (lhs, pops, pts)
|
||||
return alloc_str + ml_set_wrap(t, lhs, rhs)
|
||||
|
||||
|
||||
z3_long_funs = frozenset([
|
||||
'Z3_solver_check',
|
||||
'Z3_solver_check_assumptions',
|
||||
'Z3_simplify',
|
||||
'Z3_simplify_ex',
|
||||
])
|
||||
|
||||
z3_ml_overrides = frozenset([
|
||||
'Z3_mk_config'])
|
||||
|
||||
z3_ml_callbacks = frozenset([
|
||||
'Z3_solver_propagate_init',
|
||||
'Z3_solver_propagate_fixed',
|
||||
'Z3_solver_propagate_final',
|
||||
'Z3_solver_propagate_eq',
|
||||
'Z3_solver_propagate_diseq',
|
||||
'Z3_solver_propagate_created',
|
||||
'Z3_solver_propagate_decide'
|
||||
])
|
||||
|
||||
def mk_ml(ml_src_dir, ml_output_dir):
|
||||
global Type2Str
|
||||
ml_nativef = os.path.join(ml_output_dir, 'z3native.ml')
|
||||
|
@ -1299,6 +1322,8 @@ def mk_ml(ml_src_dir, ml_output_dir):
|
|||
|
||||
ml_native.write('\n')
|
||||
for name, result, params in _dotnet_decls:
|
||||
if name in z3_ml_callbacks:
|
||||
continue
|
||||
ml_native.write('external %s : ' % ml_method_name(name))
|
||||
ip = inparams(params)
|
||||
op = outparams(params)
|
||||
|
@ -1343,17 +1368,6 @@ def mk_ml(ml_src_dir, ml_output_dir):
|
|||
|
||||
mk_z3native_stubs_c(ml_src_dir, ml_output_dir)
|
||||
|
||||
z3_long_funs = frozenset([
|
||||
'Z3_solver_check',
|
||||
'Z3_solver_check_assumptions',
|
||||
'Z3_simplify',
|
||||
'Z3_simplify_ex',
|
||||
])
|
||||
|
||||
z3_ml_overrides = frozenset([
|
||||
'Z3_mk_config'
|
||||
])
|
||||
|
||||
def mk_z3native_stubs_c(ml_src_dir, ml_output_dir): # C interface
|
||||
ml_wrapperf = os.path.join(ml_output_dir, 'z3native_stubs.c')
|
||||
ml_wrapper = open(ml_wrapperf, 'w')
|
||||
|
@ -1368,6 +1382,8 @@ def mk_z3native_stubs_c(ml_src_dir, ml_output_dir): # C interface
|
|||
|
||||
if name in z3_ml_overrides:
|
||||
continue
|
||||
if name in z3_ml_callbacks:
|
||||
continue
|
||||
|
||||
ip = inparams(params)
|
||||
op = outparams(params)
|
||||
|
@ -1433,7 +1449,7 @@ def mk_z3native_stubs_c(ml_src_dir, ml_output_dir): # C interface
|
|||
# determine if the function has a context as parameter.
|
||||
have_context = (len(params) > 0) and (param_type(params[0]) == CONTEXT)
|
||||
|
||||
if have_context and name not in Unwrapped:
|
||||
if have_context and name not in Unwrapped and name not in Unchecked:
|
||||
ml_wrapper.write(' Z3_error_code ec;\n')
|
||||
|
||||
if result != VOID:
|
||||
|
@ -1559,7 +1575,7 @@ def mk_z3native_stubs_c(ml_src_dir, ml_output_dir): # C interface
|
|||
if release_caml_gc:
|
||||
ml_wrapper.write('\n caml_acquire_runtime_system();\n')
|
||||
|
||||
if have_context and name not in Unwrapped:
|
||||
if have_context and name not in Unwrapped and name not in Unchecked:
|
||||
ml_wrapper.write(' ec = Z3_get_error_code(ctx_p->ctx);\n')
|
||||
ml_wrapper.write(' if (ec != Z3_OK) {\n')
|
||||
ml_wrapper.write(' const char * msg = Z3_get_error_msg(ctx_p->ctx, ec);\n')
|
||||
|
@ -1703,7 +1719,6 @@ def write_log_h_preamble(log_h):
|
|||
|
||||
def write_log_c_preamble(log_c):
|
||||
log_c.write('// Automatically generated file\n')
|
||||
log_c.write('#include<iostream>\n')
|
||||
log_c.write('#include\"api/z3.h\"\n')
|
||||
log_c.write('#include\"api/api_log_macros.h\"\n')
|
||||
log_c.write('#include\"api/z3_logger.h\"\n')
|
||||
|
@ -1820,28 +1835,22 @@ _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]
|
||||
|
||||
push_eh_type = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_void_p)
|
||||
pop_eh_type = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_uint)
|
||||
fresh_eh_type = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)
|
||||
Z3_push_eh = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_void_p)
|
||||
Z3_pop_eh = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_uint)
|
||||
Z3_fresh_eh = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)
|
||||
|
||||
fixed_eh_type = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)
|
||||
final_eh_type = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_void_p)
|
||||
eq_eh_type = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)
|
||||
Z3_fixed_eh = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)
|
||||
Z3_final_eh = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_void_p)
|
||||
Z3_eq_eh = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)
|
||||
|
||||
Z3_created_eh = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)
|
||||
Z3_decide_eh = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)
|
||||
|
||||
_lib.Z3_solver_propagate_init.restype = None
|
||||
_lib.Z3_solver_propagate_init.argtypes = [ContextObj, SolverObj, ctypes.c_void_p, push_eh_type, pop_eh_type, fresh_eh_type]
|
||||
|
||||
_lib.Z3_solver_propagate_final.restype = None
|
||||
_lib.Z3_solver_propagate_final.argtypes = [ContextObj, SolverObj, final_eh_type]
|
||||
|
||||
_lib.Z3_solver_propagate_fixed.restype = None
|
||||
_lib.Z3_solver_propagate_fixed.argtypes = [ContextObj, SolverObj, fixed_eh_type]
|
||||
|
||||
_lib.Z3_solver_propagate_eq.restype = None
|
||||
_lib.Z3_solver_propagate_eq.argtypes = [ContextObj, SolverObj, eq_eh_type]
|
||||
|
||||
_lib.Z3_solver_propagate_diseq.restype = None
|
||||
_lib.Z3_solver_propagate_diseq.argtypes = [ContextObj, SolverObj, eq_eh_type]
|
||||
|
||||
on_model_eh_type = ctypes.CFUNCTYPE(None, ctypes.c_void_p)
|
||||
_lib.Z3_optimize_register_model_eh.restype = None
|
||||
|
@ -1861,6 +1870,7 @@ def generate_files(api_files,
|
|||
api_output_dir=None,
|
||||
z3py_output_dir=None,
|
||||
dotnet_output_dir=None,
|
||||
java_input_dir=None,
|
||||
java_output_dir=None,
|
||||
java_package_name=None,
|
||||
ml_output_dir=None,
|
||||
|
@ -1938,7 +1948,7 @@ def generate_files(api_files,
|
|||
print("Generated '{}'".format(dotnet_file.name))
|
||||
|
||||
if java_output_dir:
|
||||
mk_java(java_output_dir, java_package_name)
|
||||
mk_java(java_input_dir, java_output_dir, java_package_name)
|
||||
|
||||
if ml_output_dir:
|
||||
assert not ml_src_dir is None
|
||||
|
@ -1962,6 +1972,10 @@ def main(args):
|
|||
dest="dotnet_output_dir",
|
||||
default=None,
|
||||
help="Directory to emit dotnet files. If not specified no files are emitted.")
|
||||
parser.add_argument("--java-input-dir",
|
||||
dest="java_input_dir",
|
||||
default=None,
|
||||
help="Directory where Java sources reside.")
|
||||
parser.add_argument("--java-output-dir",
|
||||
dest="java_output_dir",
|
||||
default=None,
|
||||
|
@ -1984,6 +1998,9 @@ def main(args):
|
|||
if pargs.java_package_name == None:
|
||||
logging.error('--java-package-name must be specified')
|
||||
return 1
|
||||
if pargs.java_input_dir is None:
|
||||
logging.error('--java-input-dir must be specified')
|
||||
return 1
|
||||
|
||||
if pargs.ml_output_dir:
|
||||
if pargs.ml_src_dir is None:
|
||||
|
@ -1999,6 +2016,7 @@ def main(args):
|
|||
api_output_dir=pargs.api_output_dir,
|
||||
z3py_output_dir=pargs.z3py_output_dir,
|
||||
dotnet_output_dir=pargs.dotnet_output_dir,
|
||||
java_input_dir=pargs.java_input_dir,
|
||||
java_output_dir=pargs.java_output_dir,
|
||||
java_package_name=pargs.java_package_name,
|
||||
ml_output_dir=pargs.ml_output_dir,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue