populate file metadata for onnxruntime.dll (#2978)

This commit is contained in:
Ori Levari 2020-02-07 11:00:28 -08:00 committed by GitHub
parent 4f4f4bcd92
commit 0beb75ce77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 103 additions and 14 deletions

View file

@ -823,7 +823,12 @@ else()
list(APPEND onnxruntime_EXTERNAL_LIBRARIES ${CMAKE_DL_LIBS} Threads::Threads)
endif()
# Default version parts for Windows.AI.MachineLearning.dll and onnxruntime.dll in non-ADO pipeline local builds
set(VERSION_MAJOR_PART 0 CACHE STRING "First part of numeric file/product version.")
set(VERSION_MINOR_PART 0 CACHE STRING "Second part of numeric file/product version.")
set(VERSION_BUILD_PART 0 CACHE STRING "Third part of numeric file/product version.")
set(VERSION_PRIVATE_PART 0 CACHE STRING "Fourth part of numeric file/product version.")
set(VERSION_STRING "Internal Build" CACHE STRING "String representation of file/product version.")
if (onnxruntime_USE_WINML)
# WINML uses and depends on the shared lib. Note: You can build WINML without DML and you will get a

View file

@ -26,7 +26,11 @@ add_custom_command(OUTPUT ${SYMBOL_FILE} ${CMAKE_CURRENT_BINARY_DIR}/generated_s
add_custom_target(onnxruntime_generate_def ALL DEPENDS ${SYMBOL_FILE} ${CMAKE_CURRENT_BINARY_DIR}/generated_source.c)
if(WIN32)
add_library(onnxruntime SHARED ${SYMBOL_FILE} "${ONNXRUNTIME_ROOT}/core/dll/dllmain.cc")
add_library(onnxruntime SHARED
${SYMBOL_FILE}
"${ONNXRUNTIME_ROOT}/core/dll/dllmain.cc"
"${ONNXRUNTIME_ROOT}/core/dll/onnxruntime.rc"
)
else()
add_library(onnxruntime SHARED ${CMAKE_CURRENT_BINARY_DIR}/generated_source.c)
endif()
@ -36,6 +40,12 @@ add_dependencies(onnxruntime onnxruntime_generate_def ${onnxruntime_EXTERNAL_DEP
target_include_directories(onnxruntime PRIVATE ${ONNXRUNTIME_ROOT})
onnxruntime_add_include_to_target(onnxruntime)
target_compile_definitions(onnxruntime PRIVATE VER_MAJOR=${VERSION_MAJOR_PART})
target_compile_definitions(onnxruntime PRIVATE VER_MINOR=${VERSION_MINOR_PART})
target_compile_definitions(onnxruntime PRIVATE VER_BUILD=${VERSION_BUILD_PART})
target_compile_definitions(onnxruntime PRIVATE VER_PRIVATE=${VERSION_PRIVATE_PART})
target_compile_definitions(onnxruntime PRIVATE VER_STRING=\"${VERSION_STRING}\")
if (onnxruntime_USE_CUDA)
target_include_directories(onnxruntime PRIVATE ${onnxruntime_CUDNN_HOME}/include ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
endif()

View file

@ -18,13 +18,6 @@ set(winml_lib_api_ort_dir ${REPO_ROOT}/winml/lib/api.ort)
set(winml_lib_common_dir ${REPO_ROOT}/winml/lib/common)
set(winml_lib_telemetry_dir ${REPO_ROOT}/winml/lib/telemetry)
# Version parts for Windows.AI.MachineLearning.dll.
set(WINML_VERSION_MAJOR_PART 0 CACHE STRING "First part of numeric file/product version.")
set(WINML_VERSION_MINOR_PART 0 CACHE STRING "Second part of numeric file/product version.")
set(WINML_VERSION_BUILD_PART 0 CACHE STRING "Third part of numeric file/product version.")
set(WINML_VERSION_PRIVATE_PART 0 CACHE STRING "Fourth part of numeric file/product version.")
set(WINML_VERSION_STRING "Internal Build" CACHE STRING "String representation of file/product version.")
get_filename_component(exclusions "${winml_api_root}/exclusions.txt" ABSOLUTE)
convert_forward_slashes_to_back(${exclusions} CPPWINRT_COMPONENT_EXCLUSION_LIST)
@ -516,11 +509,11 @@ target_compile_definitions(winml_dll PRIVATE ONNX_ML)
target_compile_definitions(winml_dll PRIVATE LOTUS_LOG_THRESHOLD=2)
target_compile_definitions(winml_dll PRIVATE LOTUS_ENABLE_STDERR_LOGGING)
target_compile_definitions(winml_dll PRIVATE PLATFORM_WINDOWS)
target_compile_definitions(winml_dll PRIVATE VER_MAJOR=${WINML_VERSION_MAJOR_PART})
target_compile_definitions(winml_dll PRIVATE VER_MINOR=${WINML_VERSION_MINOR_PART})
target_compile_definitions(winml_dll PRIVATE VER_BUILD=${WINML_VERSION_BUILD_PART})
target_compile_definitions(winml_dll PRIVATE VER_PRIVATE=${WINML_VERSION_PRIVATE_PART})
target_compile_definitions(winml_dll PRIVATE VER_STRING=\"${WINML_VERSION_STRING}\")
target_compile_definitions(winml_dll PRIVATE VER_MAJOR=${VERSION_MAJOR_PART})
target_compile_definitions(winml_dll PRIVATE VER_MINOR=${VERSION_MINOR_PART})
target_compile_definitions(winml_dll PRIVATE VER_BUILD=${VERSION_BUILD_PART})
target_compile_definitions(winml_dll PRIVATE VER_PRIVATE=${VERSION_PRIVATE_PART})
target_compile_definitions(winml_dll PRIVATE VER_STRING=\"${VERSION_STRING}\")
# Specify the usage of a precompiled header
target_precompiled_header(winml_dll pch.h)

View file

@ -0,0 +1,45 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// This file REQUIRES the following external definitions:
// VER_MAJOR, VER_MINOR, VER_BUILD, VER_PRIVATE, and VER_STRING
#include <Winver.h>
#if defined(DEBUG) || defined(_DEBUG)
#define VER_DEBUG VS_FF_DEBUG
#else
#define VER_DEBUG 0
#endif
// -----------------------------------------------------------------------------
VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_MAJOR, VER_MINOR, VER_BUILD, VER_PRIVATE
PRODUCTVERSION VER_MAJOR, VER_MINOR, VER_BUILD, VER_PRIVATE
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS VER_DEBUG
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", "Microsoft Corporation"
VALUE "FileDescription", "ONNX Runtime"
VALUE "FileVersion", VER_STRING
VALUE "InternalName", "ONNX Runtime"
VALUE "LegalCopyright", "\251 Microsoft Corporation. All rights reserved."
VALUE "OriginalFilename", "onnxruntime.dll"
VALUE "ProductName", "Microsoft\256 Windows\256 Operating System"
VALUE "ProductVersion", VER_STRING
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END

View file

@ -376,6 +376,39 @@ def generate_build_tree(cmake_path, source_dir, build_dir, cuda_home, cudnn_home
if is_windows():
cmake_args += cmake_extra_args
# ADO pipelines will store the pipeline build number (e.g. 191101-2300.1.master) and
# source version in environment variables. If present, use these values to define the
# WinML/ORT DLL versions.
build_number = os.getenv('Build_BuildNumber')
source_version = os.getenv('Build_SourceVersion')
if build_number and source_version:
build_matches = re.match(r"^(\d\d)(\d\d)(\d\d)-(\d\d)(\d\d)\.(\d)\.(\S+)$", build_number)
if build_matches:
YY = build_matches.group(1)
MM = build_matches.group(2)
DD = build_matches.group(3)
HH = build_matches.group(4)
# Get ORT major and minor number
with open(os.path.join(source_dir, 'VERSION_NUMBER')) as f:
first_line = f.readline()
ort_version_matches = re.match(r"(\d+).(\d+)", first_line)
if not ort_version_matches:
raise BuildError("Couldn't read version from VERSION_FILE")
ort_major = ort_version_matches.group(1)
ort_minor = ort_version_matches.group(2)
# Example (BuildNumber: 191101-2300.1.master, SourceVersion: 0bce7ae6755c792eda558e5d27ded701707dc404)
# MajorPart = 1
# MinorPart = 0
# BuildPart = 1911
# PrivatePart = 123
# String = 191101-2300.1.master.0bce7ae
cmake_args += ["-DVERSION_MAJOR_PART={}".format(ort_major),
"-DVERSION_MINOR_PART={}".format(ort_minor),
"-DVERSION_BUILD_PART={}{}".format(YY, MM),
"-DVERSION_PRIVATE_PART={}{}".format(DD, HH),
"-DVERSION_STRING={}.{}.{}.{}".format(ort_major, ort_minor, build_number, source_version[0:7])]
for config in configs:
config_build_dir = get_config_build_dir(build_dir, config)
os.makedirs(config_build_dir, exist_ok=True)

View file

@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// This file REQUIRES the following external definitions:
// VER_MAJOR, VER_MINOR, VER_BUILD, VER_PRIVATE, and VER_STRING