Skip to content

Commit

Permalink
[MERGE #1480 @dilijev] Changes to enable SemVer in binary and NuGet v…
Browse files Browse the repository at this point in the history
…ersion numbers.

Merge pull request #1480 from dilijev:nuget

* Provide the ability to specify all four fields of the NuGet package version (by defining environment variables in the build environment with defaults specified in init_build.ps1).
* No longer pad binary version number segments.
* No longer use build number in the product version number (include that information in the file version string, along with branch, commit, and build date).
  • Loading branch information
dilijev committed Aug 24, 2016
2 parents 54dbf5c + b04d804 commit 687dd4b
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 44 deletions.
7 changes: 6 additions & 1 deletion Build/scripts/init_build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ $PushDate = Get-Date $BuildPushDate -Format yyMMdd.HHmm

$buildPushId, $buildPushIdPart1, $buildPushIdPart2, $buildPushIdString = GetBuildPushId $info

$VersionString = "${Env:VERSION_MAJOR}.${Env:VERSION_MINOR}.${buildPushIdString}"
$VersionMajor = UseValueOrDefault "$Env:VERSION_MAJOR" "1"
$VersionMinor = UseValueOrDefault "$Env:VERSION_MINOR" "2"
$VersionPatch = UseValueOrDefault "$Env:VERSION_PATCH" "0"
$VersionQFE = UseValueOrDefault "$Env:VERSION_QFE" "0"

$VersionString = "${VersionMajor}.${VersionMinor}.${VersionPatch}.${VersionQFE}"
$PreviewVersionString = "${VersionString}-preview"

# unless it is a build branch, subdivide the output directory by month
Expand Down
4 changes: 2 additions & 2 deletions Build/scripts/pre_post_util.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ function WriteCommonArguments() {
}

function GetBuildInfo($oauth, $commitHash) {
# Get the git remote path and construct the rest API URI
# Get the git remote path and construct the REST API URI
$gitExe = GetGitPath
$remote = (iex "$gitExe remote -v")[0].split()[1].replace("_git", "_apis/git/repositories")
$remote = (iex "$gitExe remote -v" | ? { $_.contains("_git") })[0].split()[1].replace("_git", "_apis/git/repositories")
$remote = $remote.replace("mshttps", "https")

# Get the pushId and push date time to use that for build number and build date time
Expand Down
103 changes: 64 additions & 39 deletions bin/CoreCommon.ver
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@
//-------------------------------------------------------------------------------------------------------
#include "CommonDefines.h"

/// For version metadata defined in the source, see:
/// core/bin/lib/Common/CommonDefines.h
/// core/bin/lib/Common/ChakraCoreVersion.h
///
/// Build number is defined in the Chakra.Generated.BuildInfo.props file generated by
/// Build/scripts/pre_build.ps1
/// e.g.:
/// <ChakraVersionBuildNumber>1</ChakraVersionBuildNumber>
/// <ChakraVersionBuildQFENumber>23456</ChakraVersionBuildQFENumber>
/// Which are used to define the C++ macros below, respectively:
/// CHAKRA_VERSION_BUILD_NUMBER
/// CHAKRA_VERSION_BUILD_QFE
///
/// Binary version string is composed from the following values:
/// CHAKRA_CORE_MAJOR_VERSION . CHAKRA_CORE_MINOR_VERSION . VER_PRODUCTBUILD . CHAKRA_CORE_VERSION_RELEASE_QFE
/// e.g. 1.2.0.0
/// These fields must be explicitly set in the source.
/// Note: VER_PRODUCTBUILD is always set to 0.

#define VER_COMPANYNAME_STR "Microsoft Corporation"

#define VER_FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
Expand Down Expand Up @@ -36,41 +55,68 @@
#define VER_FILEDESCRIPTION_SUFFIX1_STR L"Debug"
#elif defined(ENABLE_DEBUG_CONFIG_OPTIONS)
#define VER_FILEDESCRIPTION_SUFFIX1_STR L"Test"
// else, we don't display a build configuration suffix for Release builds
#endif

#if !CHAKRA_CORE_VERSION_RELEASE
#define VER_FILEDESCRIPTION_SUFFIX2_STR L"Private"
#elif CHAKRA_CORE_VERSION_PRERELEASE
#elif CHAKRA_CORE_VERSION_PRERELEASE // _RELEASE && _PRERELEASE
#define VER_FILEDESCRIPTION_SUFFIX2_STR L"Pre-release"
// else _RELEASE && !_PRERELEASE
// we don't display a suffix because this binary was built to potentially be released
#endif

#if CHAKRA_CORE_VERSION_RELEASE
#define VER_PRODUCTBUILD 0
#elif CHAKRA_VERSION_BUILD_NUMBER
#define VER_PRODUCTBUILD CHAKRA_VERSION_BUILD_NUMBER
#else
#define VER_PRODUCTBUILD 65535
#define VER_PRODUCTBUILD_QFE CHAKRA_CORE_VERSION_RELEASE_QFE

#ifdef CHAKRA_VERSION_BUILD_COMMIT
#define __BUILDMACHINE__ CHAKRA_VERSION_BUILD_COMMIT
#endif

#if CHAKRA_CORE_VERSION_RELEASE
#define VER_PRODUCTBUILD_QFE CHAKRA_CORE_VERSION_RELEASE_QFE
#elif CHAKRA_VERSION_BUILD_QFE
#define VER_PRODUCTBUILD_QFE CHAKRA_VERSION_BUILD_QFE
#if defined(CHAKRA_VERSION_BUILD_NUMBER) && defined(CHAKRA_VERSION_BUILD_QFE)

#if (CHAKRA_VERSION_BUILD_NUMBER < 10)
#define CHAKRA_VERSION_BUILD_NUMBER_PADDING 0000
#elif (CHAKRA_VERSION_BUILD_NUMBER < 100)
#define CHAKRA_VERSION_BUILD_NUMBER_PADDING 000
#elif (CHAKRA_VERSION_BUILD_NUMBER < 1000)
#define CHAKRA_VERSION_BUILD_NUMBER_PADDING 00
#elif (CHAKRA_VERSION_BUILD_NUMBER < 10000)
#define CHAKRA_VERSION_BUILD_NUMBER_PADDING 0
#else
#define VER_PRODUCTBUILD_QFE 65535
#define CHAKRA_VERSION_BUILD_NUMBER_PADDING CHAKRA_VERSION_BUILD_NUMBER
#endif

#ifdef CHAKRA_VERSION_BUILD_COMMIT
#define __BUILDMACHINE__ CHAKRA_VERSION_BUILD_COMMIT
#if (CHAKRA_VERSION_BUILD_QFE < 10)
#define CHAKRA_VERSION_BUILD_QFE_PADDING 0000
#elif (CHAKRA_VERSION_BUILD_QFE < 100)
#define CHAKRA_VERSION_BUILD_QFE_PADDING 000
#elif (CHAKRA_VERSION_BUILD_QFE < 1000)
#define CHAKRA_VERSION_BUILD_QFE_PADDING 00
#elif (CHAKRA_VERSION_BUILD_QFE < 10000)
#define CHAKRA_VERSION_BUILD_QFE_PADDING 0
#else
#define CHAKRA_VERSION_BUILD_QFE_PADDING CHAKRA_VERSION_BUILD_QFE
#endif

#define CONCAT_PADDING_(padding,value) padding ## value
#define CONCAT_PADDING(padding,value) CONCAT_PADDING_(padding,value)
#define PADDED_CHAKRA_VERSION_BUILD_NUMBER CONCAT_PADDING(CHAKRA_VERSION_BUILD_NUMBER_PADDING,CHAKRA_VERSION_BUILD_NUMBER)
#define PADDED_CHAKRA_VERSION_BUILD_QFE CONCAT_PADDING(CHAKRA_VERSION_BUILD_QFE_PADDING,CHAKRA_VERSION_BUILD_QFE)

#ifdef CHAKRA_VERSION_BUILD_DATE
#if defined(CHAKRA_VERSION_BUILD_NUMBER) && defined(CHAKRA_VERSION_BUILD_QFE)
#define __BUILDDATE__ CHAKRA_VERSION_BUILD_NUMBER.CHAKRA_VERSION_BUILD_QFE.CHAKRA_VERSION_BUILD_DATE
#define __BUILDDATE__ PADDED_CHAKRA_VERSION_BUILD_NUMBER.PADDED_CHAKRA_VERSION_BUILD_QFE.CHAKRA_VERSION_BUILD_DATE
#else
#define __BUILDDATE__ PADDED_CHAKRA_VERSION_BUILD_NUMBER.PADDED_CHAKRA_VERSION_BUILD_QFE
#endif

#else // defined(CHAKRA_VERSION_BUILD_NUMBER) && defined(CHAKRA_VERSION_BUILD_QFE)

#ifdef CHAKRA_VERSION_BUILD_DATE
#define __BUILDDATE__ CHAKRA_VERSION_BUILD_DATE
#endif
#endif // CHAKRA_VERSION_BUILD_DATE

#endif // defined(CHAKRA_VERSION_BUILD_NUMBER) && defined(CHAKRA_VERSION_BUILD_QFE)

#define VER_FILEFLAGS (VER_DEBUG|VER_PRIVATE|VER_PRERELEASE)

Expand All @@ -80,29 +126,9 @@
#define VER_PRODUCTVERSION_MAJORMINOR1(x,y) VER_PRODUCTVERSION_MAJORMINOR2(x, y)
#define VER_PRODUCTVERSION_STRING VER_PRODUCTVERSION_MAJORMINOR1(VER_PRODUCTMAJORVERSION, VER_PRODUCTMINORVERSION)

#if (VER_PRODUCTBUILD < 10)
#define VER_BPAD "000"
#elif (VER_PRODUCTBUILD < 100)
#define VER_BPAD "00"
#elif (VER_PRODUCTBUILD < 1000)
#define VER_BPAD "0"
#else
#define VER_BPAD
#endif

#if (VER_PRODUCTBUILD < 10)
#define LVER_BPAD L"000"
#elif (VER_PRODUCTBUILD < 100)
#define LVER_BPAD L"00"
#elif (VER_PRODUCTBUILD < 1000)
#define LVER_BPAD L"0"
#else
#define LVER_BPAD
#endif

#define VER_PRODUCTVERSION_STR4(x) VER_PRODUCTVERSION_STRING "." VER_BPAD #x
#define VER_PRODUCTVERSION_STR4(x) VER_PRODUCTVERSION_STRING "." #x
#define VER_PRODUCTVERSION_STR3(x) VER_PRODUCTVERSION_STR4(x)
#define VER_PRODUCTVERSION_STR2(x,y) VER_PRODUCTVERSION_STRING "." VER_BPAD #x "." #y
#define VER_PRODUCTVERSION_STR2(x,y) VER_PRODUCTVERSION_STRING "." #x "." #y
#define VER_PRODUCTVERSION_STR1(x,y) VER_PRODUCTVERSION_STR2(x, y)
#define VER_PRODUCTVERSION_STR VER_PRODUCTVERSION_STR1(VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE)

Expand All @@ -121,4 +147,3 @@
#define VER_PRODUCTNAME_STR VER_PRODUCTNAME L"\0"
#define VER_FILEDESCRIPTION_STR VER_PRODUCTNAME VER_FILEDESCRIPTION_SUFFIX_STR L"\0"
#include "common.ver"

4 changes: 2 additions & 2 deletions lib/Common/CommonDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@

// GC features
#define ENABLE_CONCURRENT_GC 1
#define ENABLE_PARTIAL_GC 1
#define ENABLE_PARTIAL_GC 1
#define BUCKETIZE_MEDIUM_ALLOCATIONS 1 // *** TODO: Won't build if disabled currently
#define SMALLBLOCK_MEDIUM_ALLOC 1 // *** TODO: Won't build if disabled currently
#define LARGEHEAPBLOCK_ENCODING 1 // Large heap block metadata encoding
Expand All @@ -114,7 +114,7 @@
#define ENABLE_NATIVE_CODEGEN 0
#define ENABLE_PROFILE_INFO 0
#define ENABLE_BACKGROUND_PARSING 0 // Disable background parsing in this mode
// We need to decouple the Jobs infrastructure out of
// We need to decouple the Jobs infrastructure out of
// Backend to make background parsing work with JIT disabled
#define DYNAMIC_INTERPRETER_THUNK 0
#define DISABLE_DYNAMIC_PROFILE_DEFER_PARSE
Expand Down

0 comments on commit 687dd4b

Please sign in to comment.