зеркало из https://github.com/microsoft/SymCrypt.git
Merged PR 10744990: More small build tweaks
- Prepare to support undocked "logical monorepo" by moving version info into `version.json` in repo root and generating `symcrypt_internal_shared.inc` from that - Make `apt update` in pipeline non-fatal in case some repos are unavailable
This commit is contained in:
Родитель
c2cd679a41
Коммит
a090addfb5
|
@ -32,6 +32,7 @@ build/bin/
|
|||
inc/*.dat.h
|
||||
inc/buildInfo.h
|
||||
inc/resource.h
|
||||
inc/symcrypt_internal_shared.inc
|
||||
|
||||
[Pp]ass*-buildfre.dbb
|
||||
[Pp]ass*-buildfre.evt
|
||||
|
|
|
@ -57,6 +57,7 @@ jobs:
|
|||
steps:
|
||||
- script: |
|
||||
apt-get update -y
|
||||
continueOnError: true
|
||||
displayName: 'Update package manager'
|
||||
|
||||
- ${{ if eq(parameters.cc, 'clang') }}:
|
||||
|
|
|
@ -6,6 +6,9 @@ MinimumVisualStudioVersion = 10.0.40219.1
|
|||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "symcrypt.lib", "lib\symcrypt.vcxproj", "{7C3BD5D2-7213-4CFA-B6CB-EB41623601BC}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "symcryptunittest.lib", "unittest\lib\symcryptunittest_lib.vcxproj", "{1146804C-B04F-43F1-83B0-081A5187BA02}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{7C3BD5D2-7213-4CFA-B6CB-EB41623601BC} = {7C3BD5D2-7213-4CFA-B6CB-EB41623601BC}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "symcryptunittest.exe", "unittest\exe_test\symcryptunittest.vcxproj", "{1651C608-DD2F-4D18-8E5B-E3C1D11BD7B9}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
//
|
||||
// symcrypt_internal_shared.inc
|
||||
// Copyright (c) Microsoft Corporation. Licensed under the MIT license.
|
||||
//
|
||||
// This is the file that contains the SymCrypt version information and defines SYMCRYPT_DEBUG.
|
||||
// It is included in both C and ASM such that the values are the same on both sides.
|
||||
// We use the C preprocessor to set ASM constants, as we already need to use the C preprocessor for
|
||||
// symcryptasm processing (see scripts/symcryptasm_processor.py).
|
||||
//
|
||||
// In previous releases we had a numbering system with major/minor version number.
|
||||
// This worked well with the sequential servicing imposed by SourceDepot.
|
||||
// With the switch to Git this no longer works due to having multiple branches.
|
||||
// We move to having the version here only specify the API and minor version number
|
||||
// These will NOT be changed for every build. The API version only changes when there are
|
||||
// breaking changes to the API in symcrypt.h. (Note: symcrypt_low_level.h is not stable and can change
|
||||
// at any time.) The minor version is changed at regular intervals, but not necessarily at
|
||||
// every build of the library.
|
||||
//
|
||||
// Separate from these numbers the build system includes information about the branch,
|
||||
// last commit, build time, etc.
|
||||
//
|
||||
// The API numbering starts at 100 to avoid number conflicts with the old system.
|
||||
//
|
||||
|
||||
#define SYMCRYPT_CODE_VERSION_API 103
|
||||
#define SYMCRYPT_CODE_VERSION_MINOR 4
|
||||
#define SYMCRYPT_CODE_VERSION_PATCH 2
|
||||
|
||||
#if defined(DBG)
|
||||
#define SYMCRYPT_DEBUG 1
|
||||
#else
|
||||
#define SYMCRYPT_DEBUG 0
|
||||
#endif
|
||||
//
|
||||
// symcrypt_internal_shared.inc
|
||||
// Copyright (c) Microsoft Corporation. Licensed under the MIT license.
|
||||
//
|
||||
// This is the file that contains the SymCrypt version information and defines SYMCRYPT_DEBUG.
|
||||
// It is included in both C and ASM such that the values are the same on both sides.
|
||||
// We use the C preprocessor to set ASM constants, as we already need to use the C preprocessor for
|
||||
// symcryptasm processing (see scripts/symcryptasm_processor.py).
|
||||
//
|
||||
// In previous releases we had a numbering system with major/minor version number.
|
||||
// This worked well with the sequential servicing imposed by SourceDepot.
|
||||
// With the switch to Git this no longer works due to having multiple branches.
|
||||
// We move to having the version here only specify the API and minor version number
|
||||
// These will NOT be changed for every build. The API version only changes when there are
|
||||
// breaking changes to the API in symcrypt.h. (Note: symcrypt_low_level.h is not stable and can change
|
||||
// at any time.) The minor version is changed at regular intervals, but not necessarily at
|
||||
// every build of the library.
|
||||
//
|
||||
// Separate from these numbers the build system includes information about the branch,
|
||||
// last commit, build time, etc.
|
||||
//
|
||||
// The API numbering starts at 100 to avoid number conflicts with the old system.
|
||||
//
|
||||
|
||||
#define SYMCRYPT_CODE_VERSION_API @SYMCRYPT_VERSION_MAJOR@
|
||||
#define SYMCRYPT_CODE_VERSION_MINOR @SYMCRYPT_VERSION_MINOR@
|
||||
#define SYMCRYPT_CODE_VERSION_PATCH @SYMCRYPT_VERSION_PATCH@
|
||||
|
||||
#if defined(DBG)
|
||||
#define SYMCRYPT_DEBUG 1
|
||||
#else
|
||||
#define SYMCRYPT_DEBUG 0
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project InitialTargets="GenerateBuildInfo" DefaultTargets="Build" ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{7C3BD5D2-7213-4CFA-B6CB-EB41623601BC}</ProjectGuid>
|
||||
<TemplateGuid>{0a049372-4c4d-4ea0-a64e-dc6ad88ceca1}</TemplateGuid>
|
||||
|
@ -173,8 +173,8 @@
|
|||
<SymCryptAsm Include="arm64\wipe.symcryptasm" Dialect="armasm64" Arch="arm64" Convention="arm64ec" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Generate buildInfo.h -->
|
||||
<Target Name="GenerateBuildInfo" BeforeTargets="ClCompile;ResourceCompile">
|
||||
<!-- Generate buildInfo.h and symcrypt_internal_shared.inc -->
|
||||
<Target Name="GenerateBuildInfo">
|
||||
<Message Importance="high" Text="Generating build info header" />
|
||||
<Exec Command="python ..\scripts\version.py --build-info" />
|
||||
</Target>
|
||||
|
|
|
@ -8,6 +8,7 @@ Copyright (c) Microsoft Corporation. Licensed under the MIT license.
|
|||
|
||||
import argparse
|
||||
import datetime
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
|
@ -18,9 +19,14 @@ from typing import Tuple
|
|||
|
||||
from devops_utils import set_task_variable
|
||||
|
||||
VERSION_INFO_PATH = "version.json"
|
||||
|
||||
SHARED_HEADER_INPUT_PATH = "conf/symcrypt_internal_shared.inc.in"
|
||||
SHARED_HEADER_OUTPUT_PATH = "inc/symcrypt_internal_shared.inc"
|
||||
|
||||
BUILD_INFO_INPUT_PATH = "conf/buildInfo.h.in"
|
||||
BUILD_INFO_OUTPUT_PATH = "inc/buildInfo.h"
|
||||
VERSION_INFO_RELATIVE_PATH = "inc/symcrypt_internal_shared.inc"
|
||||
|
||||
GIT_BRANCH_CMD = "git branch --show"
|
||||
GIT_COMMIT_HASH_CMD = "git log -1 --format=%h"
|
||||
GIT_COMMIT_TIMESTAMP_CMD = "git log -1 --date=iso-strict-local --format=%cd"
|
||||
|
@ -101,25 +107,25 @@ def get_version_info() -> SymCryptVersion:
|
|||
if get_version_info.symcrypt_version is not None:
|
||||
return get_version_info.symcrypt_version
|
||||
|
||||
version_info_absolute_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", VERSION_INFO_RELATIVE_PATH)
|
||||
version_info_absolute_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", VERSION_INFO_PATH)
|
||||
|
||||
# Parse the version information from the SymCrypt headers
|
||||
version_info_contents = open(version_info_absolute_path, "r").read()
|
||||
version_info = json.loads(open(version_info_absolute_path, "r").read())
|
||||
|
||||
version_api_match = re.search(r"#define SYMCRYPT_CODE_VERSION_API\s+(\d+)", version_info_contents)
|
||||
version_minor_match = re.search(r"#define SYMCRYPT_CODE_VERSION_MINOR\s+(\d+)", version_info_contents)
|
||||
version_patch_match = re.search(r"#define SYMCRYPT_CODE_VERSION_PATCH\s+(\d+)", version_info_contents)
|
||||
version_major = version_info.get("major")
|
||||
version_minor = version_info.get("minor")
|
||||
version_patch = version_info.get("patch")
|
||||
|
||||
if not version_api_match or not version_minor_match or not version_patch_match:
|
||||
if type(version_major) is not int or type(version_minor) is not int or type(version_patch) is not int:
|
||||
raise Exception("Could not parse version from version file " + version_info_absolute_path)
|
||||
|
||||
(version_branch, version_commit_hash, version_commit_timestamp) = get_commit_info()
|
||||
|
||||
version_build_timestamp = datetime.datetime.now()
|
||||
get_version_info.symcrypt_version = SymCryptVersion(
|
||||
int(version_api_match.group(1)),
|
||||
int(version_minor_match.group(1)),
|
||||
int(version_patch_match.group(1)),
|
||||
version_major,
|
||||
version_minor,
|
||||
version_patch,
|
||||
version_branch,
|
||||
version_commit_hash,
|
||||
version_commit_timestamp,
|
||||
|
@ -129,10 +135,12 @@ def get_version_info() -> SymCryptVersion:
|
|||
|
||||
def generate_build_info(version_info: SymCryptVersion) -> None:
|
||||
"""
|
||||
Generates buildInfo.h using the given version info.
|
||||
Generates buildInfo.h and symcrypt_internal_shared.inc using the given version info.
|
||||
"""
|
||||
|
||||
# Generate buildInfo.h from template
|
||||
build_info_input_absolute_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", BUILD_INFO_INPUT_PATH)
|
||||
build_info_output_absolute_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", BUILD_INFO_OUTPUT_PATH)
|
||||
|
||||
build_info_template = open(build_info_input_absolute_path, "r").read()
|
||||
|
||||
|
@ -142,11 +150,23 @@ def generate_build_info(version_info: SymCryptVersion) -> None:
|
|||
build_info = build_info.replace("@SYMCRYPT_BUILD_INFO_COMMIT@", commit_string)
|
||||
build_info = build_info.replace("@SYMCRYPT_BUILD_INFO_TIMESTAMP@", version_info.build_timestamp.isoformat(timespec = "seconds"))
|
||||
|
||||
build_info_output_absolute_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", BUILD_INFO_OUTPUT_PATH)
|
||||
# Generate symcrypt_internal_shared.inc from template
|
||||
shared_header_input_absolute_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", SHARED_HEADER_INPUT_PATH)
|
||||
shared_header_output_absolute_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", SHARED_HEADER_OUTPUT_PATH)
|
||||
|
||||
shared_header_template = open(shared_header_input_absolute_path, "r").read()
|
||||
|
||||
shared_header = shared_header_template.replace("@SYMCRYPT_VERSION_MAJOR@", str(version_info.major))
|
||||
shared_header = shared_header.replace("@SYMCRYPT_VERSION_MINOR@", str(version_info.minor))
|
||||
shared_header = shared_header.replace("@SYMCRYPT_VERSION_PATCH@", str(version_info.patch))
|
||||
|
||||
# Write both files to disk
|
||||
with open(build_info_output_absolute_path, 'w', encoding = "utf-8") as build_info_output:
|
||||
build_info_output.write(build_info)
|
||||
|
||||
with open(shared_header_output_absolute_path, 'w', encoding = "utf-8") as shared_header_output:
|
||||
shared_header_output.write(shared_header)
|
||||
|
||||
def print_devops_vars(version_info: SymCryptVersion) -> None:
|
||||
"""
|
||||
Prints the version information in a format suitable for setting Azure DevOps variables.
|
||||
|
|
|
@ -12,6 +12,11 @@
|
|||
<UndockedOut>$(SolutionDir)</UndockedOut>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(UndockedDir)symcrypt.undocked.props" />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\lib\symcrypt.vcxproj">
|
||||
<Project>{7c3bd5d2-7213-4cfa-b6cb-eb41623601bc}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\;..\inc;..\SymCryptDependencies\inc;..\..\inc;..\..\lib;</AdditionalIncludeDirectories>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{ "major": 103, "minor": 4, "patch": 2 }
|
Загрузка…
Ссылка в новой задаче