Add commit hash to dotnet
This commit is contained in:
parent
6cd56257fc
commit
9f05d51ddb
6 changed files with 37 additions and 11 deletions
|
@ -165,6 +165,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
// Run the build
|
||||
string rid = GetRuntimeId();
|
||||
string corehostSrcDir = Path.Combine(c.BuildContext.BuildDirectory, "src", "corehost");
|
||||
string commitHash = c.BuildContext.Get<string>("CommitHash");
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
|
@ -177,6 +178,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
var baseSupportedRid = $"win7-{arch}";
|
||||
var cmakeHostPolicyVer = $"-DCLI_CMAKE_HOST_POLICY_VER:STRING={buildVersion.LatestHostPolicyVersion}";
|
||||
var cmakeBaseRid = $"-DCLI_CMAKE_PKG_RID:STRING={baseSupportedRid}";
|
||||
var cmakeCommitHash = $"-DCLI_CMAKE_COMMIT_HASH:STRING={commitHash}";
|
||||
|
||||
ExecIn(cmakeOut, "cmake",
|
||||
corehostSrcDir,
|
||||
|
@ -184,6 +186,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
ridMacro,
|
||||
cmakeHostPolicyVer,
|
||||
cmakeBaseRid,
|
||||
cmakeCommitHash,
|
||||
"-G",
|
||||
visualStudio);
|
||||
|
||||
|
@ -217,7 +220,9 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
"--policyver",
|
||||
buildVersion.LatestHostPolicyVersion,
|
||||
"--rid",
|
||||
rid);
|
||||
rid,
|
||||
"--commithash",
|
||||
commitHash);
|
||||
|
||||
// Copy the output out
|
||||
File.Copy(Path.Combine(cmakeOut, "cli", "dotnet"), Path.Combine(Dirs.CorehostLatest, "dotnet"), overwrite: true);
|
||||
|
|
|
@ -27,12 +27,13 @@ init_distro_name_and_rid()
|
|||
|
||||
usage()
|
||||
{
|
||||
echo "Usage: $0 --arch <Architecture> --rid <Runtime Identifier> --policyver <HostPolicy library version> [--xcompiler <Cross C++ Compiler>]"
|
||||
echo "Usage: $0 --arch <Architecture> --rid <Runtime Identifier> --policyver <HostPolicy library version> --commithash <Git commit hash> [--xcompiler <Cross C++ Compiler>]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --arch <Architecture> Target Architecture (amd64, x86, arm)"
|
||||
echo " --rid <Runtime Identifier> Target Runtime Identifier"
|
||||
echo " --policyver <HostPolicy version> Version of the hostpolicy library"
|
||||
echo " --commithash <Git commit hash> Current commit hash of the repo at build time"
|
||||
echo " --xcompiler <Cross C++ Compiler> Cross Compiler when the target is arm"
|
||||
echo " e.g.) /usr/bin/arm-linux-gnueabi-g++-4.7"
|
||||
|
||||
|
@ -53,6 +54,7 @@ __build_arch=
|
|||
__runtime_id=
|
||||
__policy_ver=
|
||||
__CrossBuild=0
|
||||
__commit_hash=
|
||||
|
||||
while [ "$1" != "" ]; do
|
||||
lowerI="$(echo $1 | awk '{print tolower($0)}')"
|
||||
|
@ -73,6 +75,10 @@ while [ "$1" != "" ]; do
|
|||
shift
|
||||
__policy_ver=$1
|
||||
;;
|
||||
--commithash)
|
||||
shift
|
||||
__commit_hash=$1
|
||||
;;
|
||||
--xcompiler)
|
||||
shift
|
||||
__CrossCompiler="$1"
|
||||
|
@ -116,15 +122,20 @@ if [ -z $__rid_plat ]; then
|
|||
exit -1
|
||||
fi
|
||||
|
||||
if [-z $__commit_hash ]; then
|
||||
echo "Commit hash was not specified"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
__build_arch_lowcase=$(echo "$__build_arch" | tr '[:upper:]' '[:lower:]')
|
||||
__base_rid=$__rid_plat-$__build_arch_lowcase
|
||||
|
||||
echo "Building Corehost from $DIR to $(pwd)"
|
||||
set -x # turn on trace
|
||||
if [ $__CrossBuild == 1 ]; then
|
||||
cmake "$DIR" -G "Unix Makefiles" $__cmake_defines -DCLI_CMAKE_RUNTIME_ID:STRING=$__runtime_id -DCLI_CMAKE_HOST_POLICY_VER:STRING=$__policy_ver -DCMAKE_CXX_COMPILER="$__CrossCompiler" -DCLI_CMAKE_PKG_RID:STRING=$__base_rid
|
||||
cmake "$DIR" -G "Unix Makefiles" $__cmake_defines -DCLI_CMAKE_RUNTIME_ID:STRING=$__runtime_id -DCLI_CMAKE_HOST_POLICY_VER:STRING=$__policy_ver -DCMAKE_CXX_COMPILER="$__CrossCompiler" -DCLI_CMAKE_PKG_RID:STRING=$__base_rid -DCLI_CMAKE_COMMIT_HASH:STRING=$__commit_hash
|
||||
else
|
||||
cmake "$DIR" -G "Unix Makefiles" $__cmake_defines -DCLI_CMAKE_RUNTIME_ID:STRING=$__runtime_id -DCLI_CMAKE_HOST_POLICY_VER:STRING=$__policy_ver -DCLI_CMAKE_PKG_RID:STRING=$__base_rid
|
||||
cmake "$DIR" -G "Unix Makefiles" $__cmake_defines -DCLI_CMAKE_RUNTIME_ID:STRING=$__runtime_id -DCLI_CMAKE_HOST_POLICY_VER:STRING=$__policy_ver -DCLI_CMAKE_PKG_RID:STRING=$__base_rid -DCLI_CMAKE_COMMIT_HASH:STRING=$__commit_hash
|
||||
fi
|
||||
set +x # turn off trace
|
||||
make
|
||||
|
|
|
@ -148,6 +148,8 @@ SHARED_API int hostfxr_main(const int argc, const pal::char_t* argv[])
|
|||
{
|
||||
trace::setup();
|
||||
|
||||
trace::info(_X("--- Invoked hostfxr [commit hash: %s] main"), _STRINGIFY(REPO_COMMIT_HASH));
|
||||
|
||||
fx_muxer_t muxer;
|
||||
return muxer.execute(argc, argv);
|
||||
}
|
||||
|
|
|
@ -226,7 +226,8 @@ SHARED_API int corehost_main(const int argc, const pal::char_t* argv[])
|
|||
{
|
||||
if (trace::is_enabled())
|
||||
{
|
||||
trace::info(_X("--- Invoked policy [%s,%s,%s][%s] main = {"),
|
||||
trace::info(_X("--- Invoked hostpolicy [commit hash: %s] [%s,%s,%s][%s] main = {"),
|
||||
_STRINGIFY(REPO_COMMIT_HASH),
|
||||
_STRINGIFY(HOST_POLICY_PKG_NAME),
|
||||
_STRINGIFY(HOST_POLICY_PKG_VER),
|
||||
_STRINGIFY(HOST_POLICY_PKG_REL_DIR),
|
||||
|
|
|
@ -55,21 +55,28 @@ else()
|
|||
message(FATAL_ERROR "Unknown target architecture")
|
||||
endif()
|
||||
|
||||
if(${CLI_CMAKE_RUNTIME_ID} STREQUAL "")
|
||||
if("${CLI_CMAKE_RUNTIME_ID}" STREQUAL "")
|
||||
message(FATAL_ERROR "Runtime ID not specified")
|
||||
else()
|
||||
add_definitions(-DTARGET_RUNTIME_ID="${CLI_CMAKE_RUNTIME_ID}")
|
||||
endif()
|
||||
|
||||
if(${CLI_CMAKE_HOST_POLICY_VER} STREQUAL "")
|
||||
if("${CLI_CMAKE_HOST_POLICY_VER}" STREQUAL "")
|
||||
message(FATAL_ERROR "Host policy version is not specified")
|
||||
else()
|
||||
add_definitions(-DHOST_POLICY_PKG_VER="${CLI_CMAKE_HOST_POLICY_VER}")
|
||||
endif()
|
||||
|
||||
if(${CLI_CMAKE_PKG_RID} STREQUAL "")
|
||||
if("${CLI_CMAKE_PKG_RID}" STREQUAL "")
|
||||
message(FATAL_ERROR "A minimum supported package rid is not specified (ex: win7-x86 or ubuntu.14.04-x64, osx.10.10-x64, rhel.7-x64)")
|
||||
else()
|
||||
add_definitions(-DHOST_POLICY_PKG_NAME="runtime.${CLI_CMAKE_PKG_RID}.Microsoft.NETCore.DotNetHostPolicy")
|
||||
add_definitions(-DHOST_POLICY_PKG_REL_DIR="runtimes/${CLI_CMAKE_PKG_RID}/native")
|
||||
endif()
|
||||
|
||||
if("${CLI_CMAKE_COMMIT_HASH}" STREQUAL "")
|
||||
message(FATAL_ERROR "Commit hash needs to be specified to build the host")
|
||||
else()
|
||||
add_definitions(-DREPO_COMMIT_HASH="${CLI_CMAKE_COMMIT_HASH}")
|
||||
endif()
|
||||
|
||||
add_definitions(-DHOST_POLICY_PKG_NAME="runtime.${CLI_CMAKE_PKG_RID}.Microsoft.NETCore.DotNetHostPolicy")
|
||||
add_definitions(-DHOST_POLICY_PKG_REL_DIR="runtimes/${CLI_CMAKE_PKG_RID}/native")
|
||||
|
|
|
@ -96,7 +96,7 @@ int main(const int argc, const pal::char_t* argv[])
|
|||
|
||||
if (trace::is_enabled())
|
||||
{
|
||||
trace::info(_X("--- Invoked host main = {"));
|
||||
trace::info(_X("--- Invoked dotnet [commit hash: %s] main = {"), _STRINGIFY(REPO_COMMIT_HASH));
|
||||
for (int i = 0; i < argc; ++i)
|
||||
{
|
||||
trace::info(_X("%s"), argv[i]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue