Skip to content

Commit b04d804

Browse files
committed
Changes to enable SemVer in binary and NuGet version numbers.
* 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).
1 parent 54dbf5c commit b04d804

File tree

4 files changed

+74
-44
lines changed

4 files changed

+74
-44
lines changed

Build/scripts/init_build.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ $PushDate = Get-Date $BuildPushDate -Format yyMMdd.HHmm
9999

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

102-
$VersionString = "${Env:VERSION_MAJOR}.${Env:VERSION_MINOR}.${buildPushIdString}"
102+
$VersionMajor = UseValueOrDefault "$Env:VERSION_MAJOR" "1"
103+
$VersionMinor = UseValueOrDefault "$Env:VERSION_MINOR" "2"
104+
$VersionPatch = UseValueOrDefault "$Env:VERSION_PATCH" "0"
105+
$VersionQFE = UseValueOrDefault "$Env:VERSION_QFE" "0"
106+
107+
$VersionString = "${VersionMajor}.${VersionMinor}.${VersionPatch}.${VersionQFE}"
103108
$PreviewVersionString = "${VersionString}-preview"
104109

105110
# unless it is a build branch, subdivide the output directory by month

Build/scripts/pre_post_util.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ function WriteCommonArguments() {
1313
}
1414

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

2121
# Get the pushId and push date time to use that for build number and build date time

bin/CoreCommon.ver

Lines changed: 64 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@
44
//-------------------------------------------------------------------------------------------------------
55
#include "CommonDefines.h"
66

7+
/// For version metadata defined in the source, see:
8+
/// core/bin/lib/Common/CommonDefines.h
9+
/// core/bin/lib/Common/ChakraCoreVersion.h
10+
///
11+
/// Build number is defined in the Chakra.Generated.BuildInfo.props file generated by
12+
/// Build/scripts/pre_build.ps1
13+
/// e.g.:
14+
/// <ChakraVersionBuildNumber>1</ChakraVersionBuildNumber>
15+
/// <ChakraVersionBuildQFENumber>23456</ChakraVersionBuildQFENumber>
16+
/// Which are used to define the C++ macros below, respectively:
17+
/// CHAKRA_VERSION_BUILD_NUMBER
18+
/// CHAKRA_VERSION_BUILD_QFE
19+
///
20+
/// Binary version string is composed from the following values:
21+
/// CHAKRA_CORE_MAJOR_VERSION . CHAKRA_CORE_MINOR_VERSION . VER_PRODUCTBUILD . CHAKRA_CORE_VERSION_RELEASE_QFE
22+
/// e.g. 1.2.0.0
23+
/// These fields must be explicitly set in the source.
24+
/// Note: VER_PRODUCTBUILD is always set to 0.
25+
726
#define VER_COMPANYNAME_STR "Microsoft Corporation"
827

928
#define VER_FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
@@ -36,41 +55,68 @@
3655
#define VER_FILEDESCRIPTION_SUFFIX1_STR L"Debug"
3756
#elif defined(ENABLE_DEBUG_CONFIG_OPTIONS)
3857
#define VER_FILEDESCRIPTION_SUFFIX1_STR L"Test"
58+
// else, we don't display a build configuration suffix for Release builds
3959
#endif
4060

4161
#if !CHAKRA_CORE_VERSION_RELEASE
4262
#define VER_FILEDESCRIPTION_SUFFIX2_STR L"Private"
43-
#elif CHAKRA_CORE_VERSION_PRERELEASE
63+
#elif CHAKRA_CORE_VERSION_PRERELEASE // _RELEASE && _PRERELEASE
4464
#define VER_FILEDESCRIPTION_SUFFIX2_STR L"Pre-release"
65+
// else _RELEASE && !_PRERELEASE
66+
// we don't display a suffix because this binary was built to potentially be released
4567
#endif
4668

47-
#if CHAKRA_CORE_VERSION_RELEASE
4869
#define VER_PRODUCTBUILD 0
49-
#elif CHAKRA_VERSION_BUILD_NUMBER
50-
#define VER_PRODUCTBUILD CHAKRA_VERSION_BUILD_NUMBER
51-
#else
52-
#define VER_PRODUCTBUILD 65535
70+
#define VER_PRODUCTBUILD_QFE CHAKRA_CORE_VERSION_RELEASE_QFE
71+
72+
#ifdef CHAKRA_VERSION_BUILD_COMMIT
73+
#define __BUILDMACHINE__ CHAKRA_VERSION_BUILD_COMMIT
5374
#endif
5475

55-
#if CHAKRA_CORE_VERSION_RELEASE
56-
#define VER_PRODUCTBUILD_QFE CHAKRA_CORE_VERSION_RELEASE_QFE
57-
#elif CHAKRA_VERSION_BUILD_QFE
58-
#define VER_PRODUCTBUILD_QFE CHAKRA_VERSION_BUILD_QFE
76+
#if defined(CHAKRA_VERSION_BUILD_NUMBER) && defined(CHAKRA_VERSION_BUILD_QFE)
77+
78+
#if (CHAKRA_VERSION_BUILD_NUMBER < 10)
79+
#define CHAKRA_VERSION_BUILD_NUMBER_PADDING 0000
80+
#elif (CHAKRA_VERSION_BUILD_NUMBER < 100)
81+
#define CHAKRA_VERSION_BUILD_NUMBER_PADDING 000
82+
#elif (CHAKRA_VERSION_BUILD_NUMBER < 1000)
83+
#define CHAKRA_VERSION_BUILD_NUMBER_PADDING 00
84+
#elif (CHAKRA_VERSION_BUILD_NUMBER < 10000)
85+
#define CHAKRA_VERSION_BUILD_NUMBER_PADDING 0
5986
#else
60-
#define VER_PRODUCTBUILD_QFE 65535
87+
#define CHAKRA_VERSION_BUILD_NUMBER_PADDING CHAKRA_VERSION_BUILD_NUMBER
6188
#endif
6289

63-
#ifdef CHAKRA_VERSION_BUILD_COMMIT
64-
#define __BUILDMACHINE__ CHAKRA_VERSION_BUILD_COMMIT
90+
#if (CHAKRA_VERSION_BUILD_QFE < 10)
91+
#define CHAKRA_VERSION_BUILD_QFE_PADDING 0000
92+
#elif (CHAKRA_VERSION_BUILD_QFE < 100)
93+
#define CHAKRA_VERSION_BUILD_QFE_PADDING 000
94+
#elif (CHAKRA_VERSION_BUILD_QFE < 1000)
95+
#define CHAKRA_VERSION_BUILD_QFE_PADDING 00
96+
#elif (CHAKRA_VERSION_BUILD_QFE < 10000)
97+
#define CHAKRA_VERSION_BUILD_QFE_PADDING 0
98+
#else
99+
#define CHAKRA_VERSION_BUILD_QFE_PADDING CHAKRA_VERSION_BUILD_QFE
65100
#endif
66101

102+
#define CONCAT_PADDING_(padding,value) padding ## value
103+
#define CONCAT_PADDING(padding,value) CONCAT_PADDING_(padding,value)
104+
#define PADDED_CHAKRA_VERSION_BUILD_NUMBER CONCAT_PADDING(CHAKRA_VERSION_BUILD_NUMBER_PADDING,CHAKRA_VERSION_BUILD_NUMBER)
105+
#define PADDED_CHAKRA_VERSION_BUILD_QFE CONCAT_PADDING(CHAKRA_VERSION_BUILD_QFE_PADDING,CHAKRA_VERSION_BUILD_QFE)
106+
67107
#ifdef CHAKRA_VERSION_BUILD_DATE
68-
#if defined(CHAKRA_VERSION_BUILD_NUMBER) && defined(CHAKRA_VERSION_BUILD_QFE)
69-
#define __BUILDDATE__ CHAKRA_VERSION_BUILD_NUMBER.CHAKRA_VERSION_BUILD_QFE.CHAKRA_VERSION_BUILD_DATE
108+
#define __BUILDDATE__ PADDED_CHAKRA_VERSION_BUILD_NUMBER.PADDED_CHAKRA_VERSION_BUILD_QFE.CHAKRA_VERSION_BUILD_DATE
70109
#else
110+
#define __BUILDDATE__ PADDED_CHAKRA_VERSION_BUILD_NUMBER.PADDED_CHAKRA_VERSION_BUILD_QFE
111+
#endif
112+
113+
#else // defined(CHAKRA_VERSION_BUILD_NUMBER) && defined(CHAKRA_VERSION_BUILD_QFE)
114+
115+
#ifdef CHAKRA_VERSION_BUILD_DATE
71116
#define __BUILDDATE__ CHAKRA_VERSION_BUILD_DATE
72117
#endif
73-
#endif // CHAKRA_VERSION_BUILD_DATE
118+
119+
#endif // defined(CHAKRA_VERSION_BUILD_NUMBER) && defined(CHAKRA_VERSION_BUILD_QFE)
74120

75121
#define VER_FILEFLAGS (VER_DEBUG|VER_PRIVATE|VER_PRERELEASE)
76122

@@ -80,29 +126,9 @@
80126
#define VER_PRODUCTVERSION_MAJORMINOR1(x,y) VER_PRODUCTVERSION_MAJORMINOR2(x, y)
81127
#define VER_PRODUCTVERSION_STRING VER_PRODUCTVERSION_MAJORMINOR1(VER_PRODUCTMAJORVERSION, VER_PRODUCTMINORVERSION)
82128

83-
#if (VER_PRODUCTBUILD < 10)
84-
#define VER_BPAD "000"
85-
#elif (VER_PRODUCTBUILD < 100)
86-
#define VER_BPAD "00"
87-
#elif (VER_PRODUCTBUILD < 1000)
88-
#define VER_BPAD "0"
89-
#else
90-
#define VER_BPAD
91-
#endif
92-
93-
#if (VER_PRODUCTBUILD < 10)
94-
#define LVER_BPAD L"000"
95-
#elif (VER_PRODUCTBUILD < 100)
96-
#define LVER_BPAD L"00"
97-
#elif (VER_PRODUCTBUILD < 1000)
98-
#define LVER_BPAD L"0"
99-
#else
100-
#define LVER_BPAD
101-
#endif
102-
103-
#define VER_PRODUCTVERSION_STR4(x) VER_PRODUCTVERSION_STRING "." VER_BPAD #x
129+
#define VER_PRODUCTVERSION_STR4(x) VER_PRODUCTVERSION_STRING "." #x
104130
#define VER_PRODUCTVERSION_STR3(x) VER_PRODUCTVERSION_STR4(x)
105-
#define VER_PRODUCTVERSION_STR2(x,y) VER_PRODUCTVERSION_STRING "." VER_BPAD #x "." #y
131+
#define VER_PRODUCTVERSION_STR2(x,y) VER_PRODUCTVERSION_STRING "." #x "." #y
106132
#define VER_PRODUCTVERSION_STR1(x,y) VER_PRODUCTVERSION_STR2(x, y)
107133
#define VER_PRODUCTVERSION_STR VER_PRODUCTVERSION_STR1(VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE)
108134

@@ -121,4 +147,3 @@
121147
#define VER_PRODUCTNAME_STR VER_PRODUCTNAME L"\0"
122148
#define VER_FILEDESCRIPTION_STR VER_PRODUCTNAME VER_FILEDESCRIPTION_SUFFIX_STR L"\0"
123149
#include "common.ver"
124-

lib/Common/CommonDefines.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100

101101
// GC features
102102
#define ENABLE_CONCURRENT_GC 1
103-
#define ENABLE_PARTIAL_GC 1
103+
#define ENABLE_PARTIAL_GC 1
104104
#define BUCKETIZE_MEDIUM_ALLOCATIONS 1 // *** TODO: Won't build if disabled currently
105105
#define SMALLBLOCK_MEDIUM_ALLOC 1 // *** TODO: Won't build if disabled currently
106106
#define LARGEHEAPBLOCK_ENCODING 1 // Large heap block metadata encoding
@@ -114,7 +114,7 @@
114114
#define ENABLE_NATIVE_CODEGEN 0
115115
#define ENABLE_PROFILE_INFO 0
116116
#define ENABLE_BACKGROUND_PARSING 0 // Disable background parsing in this mode
117-
// We need to decouple the Jobs infrastructure out of
117+
// We need to decouple the Jobs infrastructure out of
118118
// Backend to make background parsing work with JIT disabled
119119
#define DYNAMIC_INTERPRETER_THUNK 0
120120
#define DISABLE_DYNAMIC_PROFILE_DEFER_PARSE

0 commit comments

Comments
 (0)