aspnetcore/makefile.shade

144 lines
4.6 KiB
Plaintext

var PROJECT='AspNet'
var VERSION='0.2.1-dev'
use namespace='System'
use namespace='System.IO'
use namespace='System.Collections.Generic'
use import="BuildEnv"
var repos='${new Dictionary<string,string> {
{"KRuntime", "git@github.com:aspnet/KRuntime.git"},
{"HttpAbstractions", "git@github.com:aspnet/HttpAbstractions.git"},
{"DependencyInjection", "git@github.com:aspnet/DependencyInjection.git"},
{"FileSystem", "git@github.com:aspnet/FileSystem.git"},
{"Logging", "git@github.com:aspnet/Logging.git"},
{"Configuration", "git@github.com:aspnet/Configuration.git"},
{"DataProtection", "git@github.com:aspnet/DataProtection.git"},
{"Identity", "git@github.com:aspnet/Identity.git"},
{"StaticFiles", "git@github.com:aspnet/StaticFiles.git"},
{"Data", "git@github.com:aspnet/Data.git"},
{"Razor", "git@github.com:aspnet/Razor.git"},
{"Routing", "git@github.com:aspnet/Routing.git"},
{"WebFx", "git@github.com:aspnet/WebFx.git"},
{"Hosting", "git@github.com:aspnet/Hosting.git"},
{"Helios", "git@github.com:aspnet/Helios.git"},
{"WebListener", "git@github.com:aspnet/WebListener.git"}
}}'
default BASE_DIR='${Directory.GetCurrentDirectory()}'
default TARGET_DIR='${Path.Combine(BASE_DIR, "artifacts", "build")}'
@{
VERSION += "-" + BuildNumber;
}
#default .compile
#pull
#compile .pull
#install .pull
#pack
directory create='${TARGET_DIR}'
nuget-pack nuspecFile='${Path.Combine(BASE_DIR, "KoreBuild.nuspec")}' packageVersion='${VERSION}' outputDir='${TARGET_DIR}'
#pack-install .pack
nuget-local-publish sourcePackagesDir='${TARGET_DIR}'
#git-pull target='pull'
@{
foreach(var repo in repos)
{
if(Directory.Exists(repo.Key))
{
GitPull(repo.Value, "dev", repo.Key);
}
else
{
GitClone(repo.Value, "dev");
GitConfig("bugtraq.url", "http://github.com/aspnet/" + repo.Key + "/issues/%BUGID%", repo.Key);
GitConfig("bugtraq.logregex", @"#(\d+)", repo.Key);
}
}
}
#init
@{
var templatePath = Path.Combine(BASE_DIR, "build-template");
var templateFiles = Files.Include(templatePath + Path.DirectorySeparatorChar + "*.*").Select(Path.GetFileName).ToList();
foreach(var repo in repos)
{
foreach (string fileName in templateFiles)
{
var targetFile = Path.Combine(Directory.GetCurrentDirectory(), repo.Key, fileName);
var sourceFile = Path.Combine(Directory.GetCurrentDirectory(), templatePath, fileName);
// Don't update the makefile
if(fileName.Equals("makefile.shake", StringComparison.OrdinalIgnoreCase) && File.Exists(targetFile))
{
continue;
}
if(!File.Exists(sourceFile) ||
(File.ReadAllText(sourceFile) != File.ReadAllText(targetFile)))
{
Log.Info("Updating " + fileName + " to " + repo.Key);
File.Copy(sourceFile, targetFile, true);
}
}
}
}
#only-compile target='compile'
@{
var failed = new Dictionary<string, Exception>();
foreach(var repo in repos)
{
try
{
Log.Info(string.Format("Building {0}", repo.Key));
Exec("build.cmd", "compile", repo.Key);
Log.Info(string.Format("Build {0} succeeded", repo.Key));
}
catch(Exception ex)
{
Log.Warn(string.Format("Build {0} failed: {1}", repo.Key, ex.Message));
failed[repo.Key] = ex;
}
}
foreach(var repo in repos)
{
Exception ex;
if (failed.TryGetValue(repo.Key, out ex))
{
Log.Warn(string.Format("Build {0} failed: {1}", repo.Key, ex.Message));
}
else
{
Log.Info(string.Format("Build {0} succeeded", repo.Key));
}
}
}
#only-install target='install'
@{
foreach(var repo in repos)
{
Exec("build.cmd", "install", repo.Key);
}
}
macro name='GitPull' gitUri='string' gitBranch='string' gitFolder='string'
git-pull
macro name='GitClone' gitUri='string' gitBranch='string'
git-clone
macro name='GitConfig' gitOptionName='string' gitOptionValue='string' gitFolder='string'
git-config
macro name='Exec' program='string' commandline='string' workingdir='string'
exec