Skip to content

Commit

Permalink
Added full version strings and associated API functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph M. Wintersteiger committed Jul 28, 2016
1 parent 5f5ef8b commit 3587baa
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 1 deletion.
2 changes: 2 additions & 0 deletions examples/dotnet/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2159,6 +2159,8 @@ static void Main(string[] args)
Console.WriteLine(Microsoft.Z3.Version.Major.ToString());
Console.Write("Z3 Full Version: ");
Console.WriteLine(Microsoft.Z3.Version.ToString());
Console.Write("Z3 Full Version String: ");
Console.WriteLine(Microsoft.Z3.Version.FullVersion);


SimpleExample();
Expand Down
2 changes: 2 additions & 0 deletions examples/java/JavaExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -2291,6 +2291,8 @@ public static void main(String[] args)
System.out.println(Version.getMajor());
System.out.print("Z3 Full Version: ");
System.out.println(Version.getString());
System.out.print("Z3 Full Version String: ");
System.out.println(Version.getFullVersion());

p.simpleExample();

Expand Down
1 change: 1 addition & 0 deletions examples/ml/ml_example.ml
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ let _ =
else
(
Printf.printf "Running Z3 version %s\n" Version.to_string ;
Printf.printf "Z3 full version string: %s\n" Version.full_version ;
let cfg = [("model", "true"); ("proof", "false")] in
let ctx = (mk_context cfg) in
let is = (Symbol.mk_int ctx 42) in
Expand Down
20 changes: 19 additions & 1 deletion scripts/mk_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def getenv(name, default):
VS_PAR_NUM=8
GPROF=False
GIT_HASH=False
GIT_DESCRIBE=False
SLOW_OPTIMIZE=False
USE_OMP=True

Expand Down Expand Up @@ -534,11 +535,14 @@ def find_c_compiler():
raise MKException('C compiler was not found. Try to set the environment variable CC with the C compiler available in your system.')

def set_version(major, minor, build, revision):
global VER_MAJOR, VER_MINOR, VER_BUILD, VER_REVISION
global VER_MAJOR, VER_MINOR, VER_BUILD, VER_REVISION, GIT_DESCRIBE
VER_MAJOR = major
VER_MINOR = minor
VER_BUILD = build
VER_REVISION = revision
if GIT_DESCRIBE:
branch = check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'])
VER_REVISION = int(check_output(['git', 'rev-list', '--count', 'HEAD']))

def get_version():
return (VER_MAJOR, VER_MINOR, VER_BUILD, VER_REVISION)
Expand Down Expand Up @@ -621,6 +625,7 @@ def display_help(exit_code):
print(" --pypkgdir=<dir> Force a particular Python package directory (default %s)" % PYTHON_PACKAGE_DIR)
print(" -b <subdir>, --build=<subdir> subdirectory where Z3 will be built (default: %s)." % BUILD_DIR)
print(" --githash=hash include the given hash in the binaries.")
print(" --git-describe include the output of 'git describe' in the version information.")
print(" -d, --debug compile Z3 in debug mode.")
print(" -t, --trace enable tracing in release mode.")
if IS_WINDOWS:
Expand Down Expand Up @@ -732,6 +737,8 @@ def parse_options():
GPROF = True
elif opt == '--githash':
GIT_HASH=arg
elif opt == '--git-describe':
GIT_DESCRIBE = True
elif opt in ('', '--ml'):
ML_ENABLED = True
elif opt in ('', '--noomp'):
Expand Down Expand Up @@ -2593,6 +2600,16 @@ def update_version():
mk_all_assembly_infos(major, minor, build, revision)
mk_def_files()

def get_full_version_string(major, minor, build, revision):
global GIT_HASH, GIT_DESCRIBE
res = "Z3 %s.%s.%s.%s" % (major, minor, build, revision)
if GIT_HASH:
res += " " + GIT_HASH
if GIT_DESCRIBE:
branch = check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD', '--long'])
res += " master " + check_output(['git', 'describe'])
return '"' + res + '"'

# Update files with the version number
def mk_version_dot_h(major, minor, build, revision):
c = get_component(UTIL_COMPONENT)
Expand All @@ -2606,6 +2623,7 @@ def mk_version_dot_h(major, minor, build, revision):
'Z3_VERSION_MINOR': str(minor),
'Z3_VERSION_PATCH': str(build),
'Z3_VERSION_TWEAK': str(revision),
'Z3_FULL_VERSION': get_full_version_string(major, minor, build, revision)
}
)
if VERBOSE:
Expand Down
5 changes: 5 additions & 0 deletions src/api/api_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,11 @@ extern "C" {
*revision_number = Z3_REVISION_NUMBER;
}

Z3_string Z3_API Z3_get_full_version(void) {
LOG_Z3_get_full_version();
return Z3_FULL_VERSION;
}

void Z3_API Z3_enable_trace(Z3_string tag) {
memory::initialize(UINT_MAX);
LOG_Z3_enable_trace(tag);
Expand Down
11 changes: 11 additions & 0 deletions src/api/dotnet/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ public static uint Revision
}
}

/// <summary>
/// A full version string
/// </summary>
public static string FullVersion
{
get
{
return Native.Z3_get_full_version();
}
}

/// <summary>
/// A string representation of the version information.
/// </summary>
Expand Down
8 changes: 8 additions & 0 deletions src/api/java/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ public static int getRevision()
return revision.value;
}

/**
* A full version string
**/
public static String getFullVersion()
{
return Native.getFullVersion();
}

/**
* A string representation of the version information.
**/
Expand Down
2 changes: 2 additions & 0 deletions src/api/ml/z3.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ module Version =
struct
let (major, minor, build, revision) = Z3native.get_version ()

let full_version : string = Z3native.get_full_version()

let to_string =
string_of_int major ^ "." ^
string_of_int minor ^ "." ^
Expand Down
3 changes: 3 additions & 0 deletions src/api/ml/z3.mli
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ sig
(** The revision. *)
val revision : int

(** A full version string. *)
val full_version : string

(** A string representation of the version information. *)
val to_string : string
end
Expand Down
3 changes: 3 additions & 0 deletions src/api/python/z3.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def get_version():
Z3_get_version(major, minor, build, rev)
return (major.value, minor.value, build.value, rev.value)

def get_full_version():
return Z3_get_full_version()

# We use _z3_assert instead of the assert command because we want to
# produce nice error messages in Z3Py at rise4fun.com
def _z3_assert(cond, msg):
Expand Down
7 changes: 7 additions & 0 deletions src/api/z3_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -5139,6 +5139,13 @@ extern "C" {
*/
void Z3_API Z3_get_version(unsigned * major, unsigned * minor, unsigned * build_number, unsigned * revision_number);

/**
\brief Return a string that fully describes the version of Z3 in use.
def_API('Z3_get_full_version', STRING, ())
*/
Z3_string Z3_API Z3_get_full_version(void);

/**
\brief Enable tracing messages tagged as \c tag when Z3 is compiled in debug mode.
It is a NOOP otherwise
Expand Down
2 changes: 2 additions & 0 deletions src/util/version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
#define Z3_MINOR_VERSION @Z3_VERSION_MINOR@
#define Z3_BUILD_NUMBER @Z3_VERSION_PATCH@
#define Z3_REVISION_NUMBER @Z3_VERSION_TWEAK@

#define Z3_FULL_VERSION @Z3_FULL_VERSION@

0 comments on commit 3587baa

Please sign in to comment.