Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.build/
/Library/
/Output/
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: csharp

script:
- ./build
2 changes: 1 addition & 1 deletion Apokee.Artwork.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<licenseUrl>https://raw.githubusercontent.com/Apokee/Artwork/master/LICENSE.md</licenseUrl>
</metadata>
<files>
<file src="Output\Build\*.png" target="Content" />
<file src=".build\out\Build\*.png" target="Content" />
<file src="LICENSE.md" target="Content" />
</files>
</package>
File renamed without changes.
12 changes: 6 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ before_build:
build_script:
ps: |
if ($env:BUILD_RELEASE -eq "True") {
./build -release=true
./build --release=true
} else {
./build
}

after_build:
ps: |
$env:BUILD_VERSION = (cat Output/VERSION)
$env:BUILD_PRELEASE = (cat Output/PRELEASE)
$env:BUILD_CHANGELOG = [System.String]::Join("\n", (cat Output/CHANGELOG))
$env:BUILD_VERSION = (cat .build/out/VERSION)
$env:BUILD_PRELEASE = (cat .build/out/PRELEASE)
$env:BUILD_CHANGELOG = [System.String]::Join("\n", (cat .build/out/CHANGELOG))

$versionMessage = "Version: $env:BUILD_VERSION"

Expand All @@ -44,10 +44,10 @@ after_build:
test: off

artifacts:
- path: 'Output\Package\*.nupkg'
- path: '.build\out\package\*.nupkg'
name: NuGetPackage

- path: 'Output\Package\*.zip'
- path: '.build\out\package\*.zip'
name: ZipPackage

deploy:
Expand Down
64 changes: 64 additions & 0 deletions build
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="4.1.0"
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 $?
67 changes: 46 additions & 21 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,36 +1,54 @@
#l "build-extra.cake"
#l "cake/build-extra.cake"

var target = Argument<string>("target", "Package");
var release = Argument<bool>("release", false);

var buildConfig = GetBuildConfiguration<BuildConfig>();
public sealed class Globals
{
public string Target { get; set; }
public bool Release { get; set; }
public BuildConfig BuildConfig { get; set; }
public string OutputDir { get; set; }
public string OutputBuildDir { get; set; }
public string OutputPackageDir { get; set; }
}

var outputDir = System.IO.Path.Combine("Output");
var outputBuildDir = System.IO.Path.Combine(outputDir, "Build");
var outputPackageDir = System.IO.Path.Combine(outputDir, "Package");
private Globals GetGlobals()
{
var globals = new Globals();
globals.Target = Argument<string>("target", "Package");
globals.Release = Argument<bool>("release", false);
globals.BuildConfig = GetBuildConfiguration<BuildConfig>();
globals.OutputDir = System.IO.Path.Combine(".build/out");
globals.OutputBuildDir = System.IO.Path.Combine(globals.OutputDir, "build");
globals.OutputPackageDir = System.IO.Path.Combine(globals.OutputDir, "package");

return globals;
}

Task("CleanBuild")
.Does(() =>
{
CleanDirectories(new DirectoryPath[] { outputBuildDir });
var globals = GetGlobals();
CleanDirectories(new DirectoryPath[] { globals.OutputBuildDir });
});

Task("CleanPackage")
.Does(() =>
{
CleanDirectories(new DirectoryPath[] { outputPackageDir });
var globals = GetGlobals();
CleanDirectories(new DirectoryPath[] { globals.OutputPackageDir });
});

Task("BuildVersionInfo")
.Does(() =>
{
var globals = GetGlobals();

SemVer buildVersion;

var changeLog = GetChangeLog();
var version = changeLog.LatestVersion;
var rev = GetGitRevision(useShort: true);

if (rev != null && !release)
if (rev != null && !globals.Release)
{
if (version.Build == null)
{
Expand All @@ -46,28 +64,32 @@ Task("BuildVersionInfo")
buildVersion = version;
}

System.IO.File.WriteAllText("Output/VERSION", buildVersion);
System.IO.File.WriteAllText("Output/PRELEASE", (buildVersion.Pre != null).ToString().ToLower());
System.IO.File.WriteAllText("Output/CHANGELOG", changeLog.LatestChanges);
System.IO.File.WriteAllText(System.IO.Path.Combine(globals.OutputDir, "VERSION"), buildVersion);
System.IO.File.WriteAllText(System.IO.Path.Combine(globals.OutputDir, "PRELEASE"), (buildVersion.Pre != null).ToString().ToLower());
System.IO.File.WriteAllText(System.IO.Path.Combine(globals.OutputDir, "CHANGELOG"), changeLog.LatestChanges);
});

Task("Build")
.IsDependentOn("CleanBuild")
.IsDependentOn("BuildVersionInfo")
.Does(() =>
{
Convert(buildConfig);
CopyFile("LICENSE.md", System.IO.Path.Combine(outputBuildDir, "LICENSE.md"));
var globals = GetGlobals();

Convert(globals.BuildConfig);
CopyFile("LICENSE.md", System.IO.Path.Combine(globals.OutputBuildDir, "LICENSE.md"));
});

Task("NugetPackage")
.IsDependentOn("CleanPackage")
.IsDependentOn("Build")
.Does(() =>
{
var globals = GetGlobals();

NuGetPack("Apokee.Artwork.nuspec", new NuGetPackSettings {
Version = GetVersion().ToString(),
OutputDirectory = outputPackageDir,
OutputDirectory = globals.OutputPackageDir,
});
});

Expand All @@ -76,9 +98,11 @@ Task("ZipPackage")
.IsDependentOn("Build")
.Does(() =>
{
var packageFile = System.IO.Path.Combine(outputPackageDir, String.Format("Apokee.Artwork-{0}.zip", GetBuildVersion()));
var globals = GetGlobals();

var packageFile = System.IO.Path.Combine(globals.OutputPackageDir, String.Format("Apokee.Artwork-{0}.zip", GetBuildVersion()));

Zip(outputBuildDir, packageFile);
Zip(globals.OutputBuildDir, packageFile);
});

Task("Package")
Expand All @@ -88,9 +112,10 @@ Task("Package")
{
});

RunTarget(target);
RunTarget(GetGlobals().Target);

private SemVer GetBuildVersion()
{
return new SemVer(System.IO.File.ReadAllText("Output/VERSION"));
var globals = GetGlobals();
return new SemVer(System.IO.File.ReadAllText(System.IO.Path.Combine(globals.OutputDir, "VERSION")));
}
92 changes: 51 additions & 41 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,41 +1,51 @@
Param (
[Parameter(Position = 0)]
[string]$Arg0,

[Parameter(ValueFromRemainingArguments = $true)]
[Object[]]$RemainingArgs
)

# Globals
# TODO: The experimental flag is necessary after upgrading to VS2015 until the final version of Roslyn is available
# This should presumably occur once VS2015 is final
$UseExperimental = $true
$RootDir = "$PSScriptRoot"
$PackagesConfigFile = "$RootDir/packages.config"
$PackagesDir = "$RootDir/Library/NuGet"
$CakeVersionXPath = "//package[@id='Cake'][1]/@version"
$CakeVersion = (Select-Xml -Xml ([xml](Get-Content $PackagesConfigFile)) -XPath $CakeVersionXPath).Node.Value
$CakeExe = "$PackagesDir/Cake.$CakeVersion/Cake.exe"

# Install build packages
iex "NuGet install `"$PackagesConfigFile`" -OutputDirectory `"$PackagesDir`"" |
Select-String -NotMatch -Pattern "All packages listed in packages.config are already installed."

# 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
Param (
[Parameter(Position = 0)]
[string]$Arg0,

[Parameter(ValueFromRemainingArguments = $true)]
[Object[]]$RemainingArgs
)

# Globals
$NugetVersion = "4.1.0"
$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
4 changes: 2 additions & 2 deletions build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
input_dir: "Source"
output_dir: "Output/Build"
input_dir: "src"
output_dir: ".build/out/build"

conversions:
- input: Airplane.svg
Expand Down
4 changes: 4 additions & 0 deletions cake.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[Paths]
Tools=./.build/tools
Addins=./.build/cake/addins
Modules=./.build/cake/modules
Loading