Skip to content

Commit

Permalink
Moved versioning to a T4 template
Browse files Browse the repository at this point in the history
This allows the correct build sequence number, unlike my last attempt.
  • Loading branch information
kf6kjg committed Aug 10, 2018
1 parent dc933ba commit 8f3a96c
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ after_build:
- ps: |
If (Test-Path "bin/OpenSim.Framework.Servers.dll") {
$halcyon_version = (Get-ChildItem -Path bin/OpenSim.Framework.Servers.dll | % versioninfo).ProductVersion
Update-AppveyorBuild -Version "0.$($halcyon_version.Substring(0, $halcyon_version.lastIndexOf('.')))-$env:APPVEYOR_BUILD_NUMBER"
Update-AppveyorBuild -Version "$halcyon_version-$env:APPVEYOR_BUILD_NUMBER"
}
- ps: Rename-Item -Path bin -NewName halcyon

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,5 @@ bin4
bin/blacklist.old
bin/blacklist.txt
*.pid

OpenSim/Framework/Servers/VersionInfo\.cs
28 changes: 20 additions & 8 deletions OpenSim/Framework/Servers/OpenSim.Framework.Servers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<OutputPath>../../../bin/</OutputPath>
<OutputType>Library</OutputType>
Expand All @@ -22,6 +21,7 @@
<StartArguments></StartArguments>
<FileUpgradeFlags>
</FileUpgradeFlags>
<PreBuildEventUseInBuild>true</PreBuildEventUseInBuild>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
Expand All @@ -42,6 +42,7 @@
<NoStdLib>False</NoStdLib>
<NoWarn></NoWarn>
<PlatformTarget>x64</PlatformTarget>
<PreBuildEventUseInBuild>true</PreBuildEventUseInBuild>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
Expand All @@ -62,41 +63,46 @@
<NoStdLib>False</NoStdLib>
<NoWarn></NoWarn>
<PlatformTarget>x64</PlatformTarget>
<PreBuildEventUseInBuild>true</PreBuildEventUseInBuild>
</PropertyGroup>
<ItemGroup>
<Reference Include="LibreMetaverse.StructuredData" >
<Reference Include="LibreMetaverse.StructuredData">
<Name>LibreMetaverse.StructuredData</Name>
<HintPath>..\..\..\bin\LibreMetaverse.StructuredData.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="LibreMetaverse.Types" >
<Reference Include="LibreMetaverse.Types">
<Name>LibreMetaverse.Types</Name>
<HintPath>..\..\..\bin\LibreMetaverse.Types.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="log4net" >
<Reference Include="log4net">
<Name>log4net</Name>
<HintPath>..\..\..\bin\log4net.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Nini" >
<Reference Include="Nini">
<Name>Nini</Name>
<HintPath>..\..\..\bin\Nini.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" >
<Reference Include="System">
<Name>System</Name>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml" >
<Reference Include="System.Xml">
<Name>System.Xml</Name>
<Private>False</Private>
</Reference>
<Reference Include="XmlRpcCS" >
<Reference Include="XmlRpcCS">
<Name>XmlRpcCS</Name>
<HintPath>..\..\..\bin\XmlRpcCS.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Mono.TextTemplating">
<!-- If this gets updated, be sure to update the PreBuildEvent. -->
<HintPath>..\..\..\packages\Mono.TextTemplating.1.3.1\lib\net45\Mono.TextTemplating.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Data\OpenSim.Data.csproj">
Expand Down Expand Up @@ -144,9 +150,15 @@
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="VersionInfo.tt" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<!-- MS's T4 template engine requires copying around some DLLS. Meh, I'll just import the Mono based unit - I know it works on Linux. -->
<PreBuildEvent>
$(SolutionDir)packages\Mono.TextTemplating.1.3.1\tools\TextTransform.exe -o $(ProjectDir)VersionInfo.cs $(ProjectDir)VersionInfo.tt
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<#@ output extension=".cs" #>
<#@ template language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
/*
* Copyright (c) InWorldz Halcyon Developers
* Copyright (c) Contributors, http://opensimulator.org/
Expand Down Expand Up @@ -25,12 +31,14 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

// THIS CS FILE IS AUTO GENERATED FROM A T4 TEMPLATE. MODIFY THE TEMPLATE, NOT THE CS FILE!

using System.Reflection;

// Using a * for the third number means auto-fill with the # days since 2000. Good for us here.
// That only leaves us with two in front, so we'll divide the first number by 10.
// i.e. 9.18.R in the assembly is presented as 0.9.18.R
[assembly: AssemblyVersion("9.40.*")]
// Version format is Major.Minor.Patch.Revision
// Using the "build" number, the 3rd value, as patch is a bit non-standard from MS's perspective. However this is what https://semver.org/ uses it as.
// Using day since 2000 is good for us here as we've always historically used the revision field as a unique ID value. Originally it was the SVN revision number, but since the switch to git that went away.
[assembly: AssemblyVersion("0.9.40.<#= (int)DateTimeOffset.UtcNow.Subtract(new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.Zero)).TotalDays #>")]
// Do not provide AssemblyFileVersion and it will be kept in sync.

namespace OpenSim
Expand All @@ -56,12 +64,27 @@ private static string _Initialize()
if (_revision == null)
{
Version ver = typeof(VersionInfo).Assembly.GetName().Version;
_version = String.Format("{0}.{1}.{2}", ver.Major/10, ver.Major % 10, ver.Minor);
_version = String.Format("{0}.{1}.{2}", ver.Major, ver.Minor, ver.Build);
_revision = ver.Build.ToString();
}
return _revision;
}

/// <value>
/// This is the external interface version. It is separate from the externally-visible version info.
///
/// This version number should be increased by 1 every time a code change makes the previous revision incompatible
/// with the new revision. This will usually be due to interregion or grid facing interface changes.
///
/// Changes which are compatible with an older revision (e.g. older revisions experience degraded functionality
/// but not outright failure) do not need a version number increment.
///
/// Having this version number allows the grid service to reject connections from regions running a version
/// of the code that is too old.
///
/// </value>
public readonly static int MajorInterfaceVersion = 4;


public static string Revision
{
Expand Down Expand Up @@ -107,20 +130,5 @@ public static string Version
return _version + "." + Revision;
}
}

/// <value>
/// This is the external interface version. It is separate from the externally-visible version info.
///
/// This version number should be increased by 1 every time a code change makes the previous revision incompatible
/// with the new revision. This will usually be due to interregion or grid facing interface changes.
///
/// Changes which are compatible with an older revision (e.g. older revisions experience degraded functionality
/// but not outright failure) do not need a version number increment.
///
/// Having this version number allows the grid service to reject connections from regions running a version
/// of the code that is too old.
///
/// </value>
public readonly static int MajorInterfaceVersion = 4;
}
}
4 changes: 4 additions & 0 deletions OpenSim/Framework/Servers/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Mono.TextTemplating" version="1.3.1" targetFramework="net45" />
</packages>

0 comments on commit 8f3a96c

Please sign in to comment.