DrNim (Nim compiler with Z3 integration) (#13743)

* code cleanups and feature additions
* added basic test and koch/CI integration
* make it build on Unix
* DrNim: now buildable on Unix, only takes 10 minutes, enjoy
* added basic documentation for DrNim which can also be seen as the RFC we're following
* drnim: change the build setup so that drnim.exe ends up in bin/
* makes simple floating point ranges work
* added basic float range check
* drnim: teach Z3 about Nim's range types plus code refactoring
* drnim: make unsigned numbers work
* added and fixed index checking under setLen
* first implementation of .ensures, .invariant and .assume (.requires still missing and so is proc type compatibility checking
* drnim: .requires checking implemented
* drnim: implemented .ensures properly
* more impressive test involving min()
* drnim: check for proc type compatibility and base method compatibility wrt .requires and .ensures
* testament: support for 'pattern <directory>
* koch: uses new <directory> feature of testament
* drnim: added tiny musings about 'old'
* Make testament work with old SSL versions
* koch: add support for 'koch drnim -d:release'
* drnim: preparations for the param.old notation
This commit is contained in:
Andreas Rumpf 2020-03-31 22:54:48 +02:00 • committed by GitHub
commit 9ffec79300
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 1242 additions and 35 deletions

View file

@ -12,6 +12,10 @@
const
NimbleStableCommit = "4007b2a778429a978e12307bf13a038029b4c4d9" # master
when not defined(windows):
const
Z3StableCommit = "65de3f748a6812eecd7db7c478d5fc54424d368b" # the version of Z3 that DrNim uses
when defined(gcc) and defined(windows):
when defined(x86):
{.link: "icons/koch.res".}
@ -473,6 +477,29 @@ proc xtemp(cmd: string) =
finally:
copyExe(d / "bin" / "nim_backup".exe, d / "bin" / "nim".exe)
proc buildDrNim(args: string) =
if not dirExists("dist/nimz3"):
exec("git clone https://github.com/zevv/nimz3.git dist/nimz3")
when defined(windows):
if not dirExists("dist/dlls"):
exec("git clone -q https://github.com/nim-lang/dlls.git dist/dlls")
copyExe("dist/dlls/libz3.dll", "bin/libz3.dll")
execFold("build drnim", "nim c -o:$1 $2 drnim/drnim" % ["bin/drnim".exe, args])
else:
if not dirExists("dist/z3"):
exec("git clone -q https://github.com/Z3Prover/z3.git dist/z3")
withDir("dist/z3"):
exec("git fetch")
exec("git checkout " & Z3StableCommit)
createDir("build")
withDir("build"):
exec("""cmake -DZ3_BUILD_LIBZ3_SHARED=FALSE -G "Unix Makefiles" ../""")
exec("make -j4")
execFold("build drnim", "nim cpp --dynlibOverride=libz3 -o:$1 $2 drnim/drnim" % ["bin/drnim".exe, args])
# always run the tests for now:
exec("testament/testament".exe & " --nim:" & "drnim".exe & " pat drnim/tests")
proc hostInfo(): string =
"hostOS: $1, hostCPU: $2, int: $3, float: $4, cpuEndian: $5, cwd: $6" %
[hostOS, hostCPU, $int.sizeof, $float.sizeof, $cpuEndian, getCurrentDir()]
@ -636,6 +663,7 @@ when isMainModule:
of "pushcsource", "pushcsources": pushCsources()
of "valgrind": valgrind(op.cmdLineRest)
of "c2nim": bundleC2nim(op.cmdLineRest)
of "drnim": buildDrNim(op.cmdLineRest)
else: showHelp()
break
of cmdEnd: break