cmake: versioning is now a part of the build pipeline

This commit is contained in:
Yatao Li 2018-09-06 15:34:43 +08:00
Родитель 89247e4163
Коммит 13205d86ea
3 изменённых файлов: 52 добавлений и 2 удалений

Просмотреть файл

@ -4,8 +4,13 @@ LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
FIND_PACKAGE(Dotnet 2.0 REQUIRED)
INCLUDE(PostBuild)
PROJECT(GraphEngine VERSION 2.0.9328 LANGUAGES CXX)
SET(TRINITY_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
EXECUTE_PROCESS(
COMMAND ${DOTNET_EXE} run -p ${CMAKE_CURRENT_LIST_DIR}/tools/versioning/versioning.csproj
OUTPUT_VARIABLE TRINITY_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
SET(TRINITY_VERSION "2.0.${TRINITY_VERSION}")
MESSAGE("GraphEngine version is now ${TRINITY_VERSION}")
PROJECT(GraphEngine VERSION ${TRINITY_VERSION} LANGUAGES CXX)
SET(CMAKE_CXX_STANDARD 14)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)

Просмотреть файл

@ -0,0 +1,37 @@
using System;
public class Versioning
{
public static void Main(string[] args)
{
System.Console.WriteLine(GetFileBuildNumber());
}
/// <summary>
/// 16 bit build number: [year: 7 bits][month: 4 bits][day: 5 bits]
/// </summary>
public static string GetFileBuildNumber()
{
DateTime dt = DateTime.Now;
uint year = (uint)(dt.Year - 2000);
year = year << 9;
uint month = (uint)dt.Month;
month = month << 5;
uint day = (uint)dt.Day;
uint time = year | month | day;
return time.ToString();
}
public static string BuildNumber2Date(string build)
{
uint time = uint.Parse(build);
uint day = time & 0x1f;
uint month = (time >> 5) & 0xf;
uint year = (time >> 9) & 0x7f;
return string.Format("20{0}-{1}-{2}", year, month, day);
}
}

Просмотреть файл

@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
</Project>