From 9f78eaecda3b2adf6bb5b4559dbbc74e15881de3 Mon Sep 17 00:00:00 2001 From: jofleish Date: Mon, 22 Aug 2022 12:46:45 -0400 Subject: [PATCH] WiP: test build specific version number --- scripts/mk_project.py | 2 +- scripts/mk_util.py | 29 ++++++++++++++++++++++++----- scripts/mk_win_dist.py | 9 ++++++++- scripts/nightly.yaml | 8 +++++--- 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/scripts/mk_project.py b/scripts/mk_project.py index 849d271ac..055a5ce7d 100644 --- a/scripts/mk_project.py +++ b/scripts/mk_project.py @@ -8,7 +8,7 @@ from mk_util import * def init_version(): - set_version(4, 11, 1, 0) + set_version(4, 11, 1, 0) # express a default build version or pick up ci build version # Z3 Project definition def init_project_def(): diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 02a1a1fbf..ac08796c9 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -91,6 +91,7 @@ TRACE = False PYTHON_ENABLED=False DOTNET_CORE_ENABLED=False DOTNET_KEY_FILE=getenv("Z3_DOTNET_KEY_FILE", None) +ASSEMBLY_VERSION=getenv("Z2_ASSEMBLY_VERSION", None) JAVA_ENABLED=False ML_ENABLED=False PYTHON_INSTALL_ENABLED=False @@ -540,15 +541,30 @@ 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_TWEAK, GIT_DESCRIBE + global ASSEMBLY_VERSION,VER_MAJOR, VER_MINOR, VER_BUILD, VER_TWEAK, GIT_DESCRIBE + + # We need to give the assembly a build specific version + # global version overrides local default expression + if not ASSEMBLY_VERSION is None: + versionSplits = ASSEMBLY_VERSION.split('.') + if len(versionSplits) > 3: + VER_MAJOR = versionSplits[0] + VER_MINOR = versionSplits[1] + VER_BUILD = versionSplits[2] + VER_TWEAK = versionSplits[3] + return + + # use parameters to set up version if not provided by script args VER_MAJOR = major VER_MINOR = minor VER_BUILD = build VER_TWEAK = revision + + # update VER_TWEAK base on github if GIT_DESCRIBE: branch = check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']) VER_TWEAK = int(check_output(['git', 'rev-list', '--count', 'HEAD'])) - + def get_version(): return (VER_MAJOR, VER_MINOR, VER_BUILD, VER_TWEAK) @@ -666,6 +682,7 @@ def display_help(exit_code): print(" --optimize generate optimized code during linking.") print(" --dotnet generate .NET platform bindings.") print(" --dotnet-key= sign the .NET assembly using the private key in .") + print(" --assembly-version= provide version number for build") print(" --java generate Java bindings.") print(" --ml generate OCaml bindings.") print(" --js generate JScript bindings.") @@ -700,14 +717,14 @@ def display_help(exit_code): # Parse configuration option for mk_make script def parse_options(): global VERBOSE, DEBUG_MODE, IS_WINDOWS, VS_X64, ONLY_MAKEFILES, SHOW_CPPS, VS_PROJ, TRACE, VS_PAR, VS_PAR_NUM - global DOTNET_CORE_ENABLED, DOTNET_KEY_FILE, JAVA_ENABLED, ML_ENABLED, STATIC_LIB, STATIC_BIN, PREFIX, GMP, PYTHON_PACKAGE_DIR, GPROF, GIT_HASH, GIT_DESCRIBE, PYTHON_INSTALL_ENABLED, PYTHON_ENABLED + global DOTNET_CORE_ENABLED, DOTNET_KEY_FILE, ASSEMBLY_VERSION, JAVA_ENABLED, ML_ENABLED, STATIC_LIB, STATIC_BIN, PREFIX, GMP, PYTHON_PACKAGE_DIR, GPROF, GIT_HASH, GIT_DESCRIBE, PYTHON_INSTALL_ENABLED, PYTHON_ENABLED global LINUX_X64, SLOW_OPTIMIZE, LOG_SYNC, SINGLE_THREADED global GUARD_CF, ALWAYS_DYNAMIC_BASE, IS_ARCH_ARM64 try: options, remainder = getopt.gnu_getopt(sys.argv[1:], 'b:df:sxa:hmcvtnp:gj', ['build=', 'debug', 'silent', 'x64', 'arm64=', 'help', 'makefiles', 'showcpp', 'vsproj', 'guardcf', - 'trace', 'dotnet', 'dotnet-key=', 'staticlib', 'prefix=', 'gmp', 'java', 'parallel=', 'gprof', 'js', + 'trace', 'dotnet', 'dotnet-key=', 'assembly-version=', 'staticlib', 'prefix=', 'gmp', 'java', 'parallel=', 'gprof', 'js', 'githash=', 'git-describe', 'x86', 'ml', 'optimize', 'pypkgdir=', 'python', 'staticbin', 'log-sync', 'single-threaded']) except: print("ERROR: Invalid command line option") @@ -745,6 +762,8 @@ def parse_options(): DOTNET_CORE_ENABLED = True elif opt in ('--dotnet-key'): DOTNET_KEY_FILE = arg + elif opt in ('--assembly-version'): + ASSEMBLY_VERSION = arg elif opt in ('--staticlib'): STATIC_LIB = True elif opt in ('--staticbin'): @@ -1694,7 +1713,7 @@ class DotNetDLLComponent(Component): key = "%s" % self.key_file key += "\ntrue" - version = get_version_string(3) + version = get_version_string(4) core_csproj_str = """ diff --git a/scripts/mk_win_dist.py b/scripts/mk_win_dist.py index 8f00b2755..95400bf03 100644 --- a/scripts/mk_win_dist.py +++ b/scripts/mk_win_dist.py @@ -24,6 +24,7 @@ BUILD_X86_DIR=os.path.join('build-dist', 'x86') VERBOSE=True DIST_DIR='dist' FORCE_MK=False +ASSEMBLY_VERSION=None DOTNET_CORE_ENABLED=True DOTNET_KEY_FILE=None JAVA_ENABLED=True @@ -62,6 +63,7 @@ def display_help(): print(" -s, --silent do not print verbose messages.") print(" -b , --build= subdirectory where x86 and x64 Z3 versions will be built (default: build-dist).") print(" -f, --force force script to regenerate Makefiles.") + print(" --assembly-version assembly version for dll") print(" --nodotnet do not include .NET bindings in the binary distribution files.") print(" --dotnet-key= strongname sign the .NET assembly with the private key in .") print(" --nojava do not include Java bindings in the binary distribution files.") @@ -102,6 +104,8 @@ def parse_options(): FORCE_MK = True elif opt == '--nodotnet': DOTNET_CORE_ENABLED = False + elif opt == '--assemblyVersion': + ASSEMBLY_VERSION = arg elif opt == '--nopython': PYTHON_ENABLED = False elif opt == '--dotnet-key': @@ -133,6 +137,8 @@ def mk_build_dir(path, x64): opts.append('--dotnet') if not DOTNET_KEY_FILE is None: opts.append('--dotnet-key=' + DOTNET_KEY_FILE) + if not ASSEMBLY_VERSION is None: + opts.append('--assembly-version='+ASSEMBLY_VERSION) if JAVA_ENABLED: opts.append('--java') if x64: @@ -299,9 +305,10 @@ def cp_licenses(): cp_license(False) def init_flags(): - global DOTNET_KEY_FILE, JAVA_ENABLED, PYTHON_ENABLED + global DOTNET_KEY_FILE, JAVA_ENABLED, PYTHON_ENABLED, ASSEMBLY_VERSION mk_util.DOTNET_CORE_ENABLED = True mk_util.DOTNET_KEY_FILE = DOTNET_KEY_FILE + mk_util.ASSEMBLY_VERSION = ASSEMBLY_VERSION mk_util.JAVA_ENABLED = JAVA_ENABLED mk_util.PYTHON_ENABLED = PYTHON_ENABLED mk_util.ALWAYS_DYNAMIC_BASE = True diff --git a/scripts/nightly.yaml b/scripts/nightly.yaml index cd885bb06..5cc4c2daa 100644 --- a/scripts/nightly.yaml +++ b/scripts/nightly.yaml @@ -1,14 +1,14 @@ variables: - Major: '4' Minor: '11' Patch: '1' - NightlyVersion: $(Major).$(Minor).$(Patch).$(Build.BuildId)-$(Build.DefinitionName) + AssemblyVersion: $(Major).$(Minor).$(Patch).$(Build.BuildId) + NightlyVersion: $(AssemblyVersion)-$(Build.DefinitionName) stages: - stage: Build jobs: - + - job: Mac displayName: "Mac Build" pool: @@ -135,6 +135,7 @@ stages: script: call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x86 & python scripts\mk_win_dist.py + --assembly-version=$(AssemblyVersion) --x86-only --dotnet-key=$(Build.SourcesDirectory)/resources/z3.snk --zip @@ -174,6 +175,7 @@ stages: script: call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 & python scripts\mk_win_dist.py + --assembly-version=$(AssemblyVersion) --x64-only --dotnet-key=$(Build.SourcesDirectory)/resources/z3.snk --zip