-
-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
299 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System.Text.RegularExpressions; | ||
|
||
namespace CKAN | ||
{ | ||
public static class Meta | ||
{ | ||
public readonly static string Development = "development"; | ||
|
||
// Do *not* change the following line, BUILD_VERSION is | ||
// replaced by our build system with our actual version. | ||
|
||
private readonly static string BUILD_VERSION = <%version%>; | ||
|
||
/// <summary> | ||
/// Returns the version of the CKAN.dll used, complete with git info | ||
/// and other decorations as filled in by our build system. | ||
/// Eg: v1.3.5-12-g055d7c3 (beta) or "development (unstable)" | ||
/// </summary> | ||
public static string Version() | ||
{ | ||
string version = BuildVersion(); | ||
|
||
#if (STABLE) | ||
version += " (stable)"; | ||
#else | ||
version += " (beta)"; | ||
#endif | ||
|
||
return version; | ||
} | ||
|
||
/// <summary> | ||
/// Returns only the build info, with no decorations, or "development" if | ||
/// unknown. | ||
/// </summary> | ||
public static string BuildVersion() | ||
{ | ||
return BUILD_VERSION ?? Development; | ||
} | ||
|
||
/// <summary> | ||
/// Returns just our release number (eg: 1.0.3), or null for a dev build. | ||
/// </summary> | ||
public static Version ReleaseNumber() | ||
{ | ||
string build_version = BuildVersion(); | ||
|
||
if (build_version == Development) | ||
{ | ||
return null; | ||
} | ||
|
||
string short_version = Regex.Match(build_version, @"^(.*)-\d+-.*$").Result("$1"); | ||
|
||
return new Version(short_version); | ||
} | ||
|
||
/// <summary> | ||
/// Returns true if this is a 'stable' build, false otherwise. | ||
/// </summary> | ||
public static bool IsStable() | ||
{ | ||
#if (STABLE) | ||
return true; | ||
#else | ||
return false; | ||
#endif | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
arg0="" | ||
remainingArgs="" | ||
|
||
if [ $# -gt 0 ]; then | ||
arg0="$1" | ||
fi | ||
|
||
if [ $# -gt 1 ]; then | ||
skippedFirst=false | ||
for i in "$@"; do | ||
if $skippedFirst; then | ||
remainingArgs="$remainingArgs $i" | ||
else | ||
skippedFirst=true | ||
fi | ||
done | ||
fi | ||
|
||
nugetVersion="3.4.3" | ||
useExperimental=false | ||
rootDir=$(dirname $0) | ||
buildDir="$rootDir/.build" | ||
toolsDir="$buildDir/tools" | ||
packagesDir="$buildDir/lib/nuget" | ||
nugetExe="$toolsDir/nuget/$nugetVersion/NuGet.exe" | ||
packagesConfigFile="$rootDir/packages.config" | ||
cakeVersion="$(sed -nE "s|\s*<package\s+id=\"Cake\"\s+version=\"(.+)\"\s*/>\s*|\1|p" $packagesConfigFile)" | ||
cakeExe="$packagesDir/Cake.$cakeVersion/Cake.exe" | ||
|
||
nugetDir="$(dirname $nugetExe)" | ||
if [ ! -d "$nugetDir" ]; then | ||
mkdir -p "$nugetDir" | ||
fi | ||
|
||
if [ ! -f "$nugetExe" ]; then | ||
curl -L "https://dist.nuget.org/win-x86-commandline/v${nugetVersion}/nuget.exe" --output "$nugetExe" | ||
fi | ||
|
||
mono "$nugetExe" install "$packagesConfigFile" -OutputDirectory "$packagesDir" | ||
|
||
cakeArgs="" | ||
|
||
if [ -n "$arg0" ]; then | ||
case $arg0 in | ||
-*) | ||
cakeArgs="$cakeArgs $arg0" | ||
;; | ||
*) | ||
cakeArgs="$cakeArgs --target=$arg0" | ||
;; | ||
esac | ||
fi | ||
|
||
if $useExperimental; then | ||
cakeArgs="$cakeArgs --experimental" | ||
fi | ||
|
||
echo "CAKE: mono $cakeExe $cakeArgs $remainingArgs" | ||
|
||
mono "$cakeExe" $cakeArgs $remainingArgs | ||
exit $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#tool nuget:?package=ILRepack&version=2.0.10 | ||
|
||
using System.Text.RegularExpressions; | ||
|
||
var target = Argument<string>("target", "Build"); | ||
var configuration = Argument<string>("configuration", "Debug"); | ||
var solution = Argument<string>("solution", "CKAN.sln"); | ||
|
||
Task("BuildDotNet") | ||
.Does(() => | ||
{ | ||
var version = GetGitVersion(); | ||
var metaFileContents = TransformTextFile("Core/Meta.cs.in") | ||
.WithToken("version", version == null ? "null" : string.Format(@"""{0}""", version)) | ||
.ToString(); | ||
System.IO.File.WriteAllText("Core/Meta.cs", metaFileContents); | ||
DotNetBuild(solution, settings => | ||
{ | ||
settings.Properties["win32icon"] = new List<string> { MakeAbsolute(File("GUI/assets/ckan.ico")).FullPath }; | ||
if (IsStable()) | ||
{ | ||
settings.Properties["DefineConstants"] = new List<string> { "STABLE" }; | ||
} | ||
}); | ||
}); | ||
|
||
Task("BuildCkan") | ||
.IsDependentOn("BuildDotNet") | ||
.Does(() => | ||
{ | ||
var assemblyPaths = GetFiles(string.Format("Cmdline/bin/{0}/*.dll", configuration)); | ||
assemblyPaths.Add(string.Format("Cmdline/bin/{0}/CKAN-GUI.exe", configuration)); | ||
ILRepack("ckan.exe", string.Format("Cmdline/bin/{0}/CmdLine.exe", configuration), assemblyPaths, | ||
new ILRepackSettings | ||
{ | ||
Libs = new List<FilePath> { string.Format("Cmdline/bin/{0}", configuration) }, | ||
// TODO: Cannot use the "TargetPlaform" | ||
// Must wait until https://github.com/cake-build/cake/pull/692 is released. | ||
ArgumentCustomization = builder => { | ||
builder.Append("/targetplatform:v4"); | ||
return builder; | ||
} | ||
} | ||
); | ||
}); | ||
|
||
Task("BuildNetkan") | ||
.IsDependentOn("BuildDotNet") | ||
.Does(() => | ||
{ | ||
ILRepack( | ||
"netkan.exe", | ||
string.Format("Netkan/bin/{0}/NetKAN.exe", configuration), | ||
GetFiles(string.Format("Netkan/bin/{0}/*.dll", configuration)), | ||
new ILRepackSettings | ||
{ | ||
Libs = new List<FilePath> { string.Format("Netkan/bin/{0}", configuration) } | ||
} | ||
); | ||
}); | ||
|
||
Task("Build") | ||
.IsDependentOn("BuildCkan") | ||
.IsDependentOn("BuildNetkan"); | ||
|
||
RunTarget(target); | ||
|
||
private bool IsStable() | ||
{ | ||
var processSettings = new ProcessSettings | ||
{ | ||
Arguments = "rev-parse --abbrev-ref HEAD", | ||
RedirectStandardOutput = true | ||
}; | ||
|
||
IEnumerable<string> output; | ||
if (StartProcess("git", processSettings, out output) == 0) | ||
{ | ||
var branch = output.Single(); | ||
return Regex.IsMatch(branch, @"(\b|_)stable(\b|_)") || Regex.IsMatch(branch, @"v\d+\.\d*[02468]$"); | ||
} | ||
else | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
private string GetGitVersion() | ||
{ | ||
var processSettings = new ProcessSettings | ||
{ | ||
Arguments = "describe --tags --long", | ||
RedirectStandardOutput = true | ||
}; | ||
|
||
IEnumerable<string> output; | ||
if (StartProcess("git", processSettings, out output) == 0) | ||
return output.Single(); | ||
else | ||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
Param ( | ||
[Parameter(Position = 0)] | ||
[string]$Arg0, | ||
|
||
[Parameter(ValueFromRemainingArguments = $true)] | ||
[Object[]]$RemainingArgs | ||
) | ||
|
||
# Globals | ||
$NugetVersion = "3.4.3" | ||
$UseExperimental = $false | ||
$RootDir = "${PSScriptRoot}" | ||
$BuildDir = "${RootDir}/.build" | ||
$ToolsDir = "${BuildDir}/tools" | ||
$PackagesDir = "${BuildDir}/lib/nuget" | ||
$NugetExe = "${ToolsDir}/nuget/${NugetVersion}/NuGet.exe" | ||
$PackagesConfigFile = "${RootDir}/packages.config" | ||
$CakeVersion = (Select-Xml -Xml ([xml](Get-Content $PackagesConfigFile)) -XPath "//package[@id='Cake'][1]/@version").Node.Value | ||
$CakeExe = "${PackagesDir}/Cake.${CakeVersion}/Cake.exe" | ||
|
||
# Download NuGet | ||
$nugetDir = Split-Path $NugetExe -Parent | ||
if (!(Test-Path $nugetDir)) { | ||
mkdir $nugetDir > $null | ||
} | ||
|
||
if (!(Test-Path $NugetExe)) { | ||
(New-Object System.Net.WebClient).DownloadFile("https://dist.nuget.org/win-x86-commandline/v${NugetVersion}/nuget.exe", $NugetExe) | ||
} | ||
|
||
# Install build packages | ||
iex "${NugetExe} install `"${PackagesConfigFile}`" -OutputDirectory `"${PackagesDir}`"" | ||
|
||
# Build args | ||
$cakeArgs = @() | ||
|
||
if ($Arg0) { | ||
if ($Arg0[0] -eq "-") { | ||
$cakeArgs += "${Arg0}" | ||
} else { | ||
$cakeArgs += "--target=${Arg0}" | ||
} | ||
} | ||
|
||
if ($UseExperimental) { | ||
$cakeArgs += "--experimental" | ||
} | ||
|
||
# Run Cake | ||
iex "${CakeExe} ${cakeArgs} ${RemainingArgs}" | ||
exit $LASTEXITCODE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Cake" version="0.11.0" /> | ||
</packages> |