178 строки
7.7 KiB
C#
178 строки
7.7 KiB
C#
///////////////////////////////////////////////////////////////////////////////
|
|
// USINGS
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// ARGUMENTS
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
var target = Argument("target", "Default");
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// SETTINGS
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
var platforms = new [] { "Win32", "x64" }.ToList();
|
|
var configurations = new [] { "Debug", "Release" }.ToList();
|
|
var solution = "./BatchEncoder.sln";
|
|
var versionHeaderPath = (FilePath)File("./src/version.h");
|
|
var installerScript = MakeAbsolute((FilePath)File("./setup/setup.iss"));
|
|
var iscc = @"C:/Program Files (x86)/Inno Setup 5/ISCC.exe";
|
|
var artifactsDir = (DirectoryPath)Directory("./artifacts");
|
|
var binDir = (DirectoryPath)Directory("./src/bin");
|
|
var objDir = (DirectoryPath)Directory("./src/obj");
|
|
|
|
var platformsEditor = new [] { "AnyCPU", "x64", "x86" }.ToList();
|
|
var configurationsEditor = new [] { "Debug", "Release" }.ToList();
|
|
var solutionEditor = "./editor/LanguageEditor.sln";
|
|
var binDirEditor = (DirectoryPath)Directory("./editor/bin");
|
|
var objDirEditor = (DirectoryPath)Directory("./editor/obj");
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// RELEASE
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
var isAppVeyorBuild = AppVeyor.IsRunningOnAppVeyor;
|
|
var isLocalBuild = BuildSystem.IsLocalBuild;
|
|
var isPullRequest = BuildSystem.AppVeyor.Environment.PullRequest.IsPullRequest;
|
|
var isMainRepo = StringComparer.OrdinalIgnoreCase.Equals("wieslawsoltes/BatchEncoder", BuildSystem.AppVeyor.Environment.Repository.Name);
|
|
var isMasterBranch = StringComparer.OrdinalIgnoreCase.Equals("master", BuildSystem.AppVeyor.Environment.Repository.Branch);
|
|
var isTagged = BuildSystem.AppVeyor.Environment.Repository.Tag.IsTag
|
|
&& !string.IsNullOrWhiteSpace(BuildSystem.AppVeyor.Environment.Repository.Tag.Name);
|
|
var isRelease = !isLocalBuild && !isPullRequest && isMainRepo && isMasterBranch && isTagged;
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// VERSION
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
var text = System.IO.File.ReadAllText(versionHeaderPath.FullPath);
|
|
var split = text.Split(new char [] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
|
|
var major = split[0].Split(new char [] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[2];
|
|
var minor = split[1].Split(new char [] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[2];
|
|
var revision = split[2].Split(new char [] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[2];
|
|
var build = split[3].Split(new char [] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[2];
|
|
var version = major + "." + minor;
|
|
var suffix = (isRelease || !isAppVeyorBuild) ? "" : "-build" + EnvironmentVariable("APPVEYOR_BUILD_NUMBER") + "-alpha";
|
|
|
|
Information("Defined Version: {0}.{1}.{2}.{3}", major, minor, revision, build);
|
|
Information("Release Version: {0}", version + suffix);
|
|
|
|
var versionEditor = ParseAssemblyInfo(File("./editor/Properties/AssemblyInfo.cs")).AssemblyVersion;
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// ACTIONS
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
var buildSolutionAction = new Action<string,string,string> ((solution, configuration, platform) =>
|
|
{
|
|
Information("Building: {0}, {1} / {2}", solution, configuration, platform);
|
|
MSBuild(solution, settings => {
|
|
settings.SetConfiguration(configuration);
|
|
settings.WithProperty("Platform", "\"" + platform + "\"");
|
|
settings.SetVerbosity(Verbosity.Minimal); });
|
|
});
|
|
|
|
var packageBinariesAction = new Action<string,string> ((configuration, platform) =>
|
|
{
|
|
var path = "./src/bin/" + configuration + "/" + platform + "/";
|
|
var output = "BatchEncoder-" + version + suffix + "-" + platform + (configuration == "Release" ? "" : ("-(" + configuration + ")"));
|
|
var outputDir = artifactsDir.Combine(output);
|
|
var outputZip = artifactsDir.CombineWithFilePath(output + ".zip");
|
|
var exeFile = File(path + "BatchEncoder.exe");
|
|
CleanDirectory(outputDir);
|
|
CopyFileToDirectory(File("README.md"), outputDir);
|
|
CopyFileToDirectory(File("LICENSE.TXT"), outputDir);
|
|
CopyFileToDirectory(exeFile, outputDir);
|
|
CopyFiles("./config/*.options", outputDir);
|
|
CopyFiles("./config/*.formats", outputDir);
|
|
CopyFiles("./config/*.items", outputDir);
|
|
CopyFiles("./formats/encoder/*.format", outputDir);
|
|
CopyFiles("./formats/decoder/*.format", outputDir);
|
|
CopyFiles("./progress/*.progress", outputDir);
|
|
CopyFiles("./lang/*.language", outputDir);
|
|
CopyFiles("./scripts/*.ps1", outputDir);
|
|
Zip(outputDir, outputZip);
|
|
});
|
|
|
|
var packageBinariesEditorAction = new Action<string,string> ((configuration, platform) =>
|
|
{
|
|
var path = "./editor/bin/" + platform + "/" + configuration + "/";
|
|
var output = "LanguageEditor-" + versionEditor + suffix + "-" + platform + (configuration == "Release" ? "" : ("-(" + configuration + ")"));
|
|
var outputDir = artifactsDir.Combine(output);
|
|
var outputZip = artifactsDir.CombineWithFilePath(output + ".zip");
|
|
var exeFile = File(path + "LanguageEditor.exe");
|
|
CleanDirectory(outputDir);
|
|
CopyFileToDirectory(exeFile, outputDir);
|
|
Zip(outputDir, outputZip);
|
|
});
|
|
|
|
var packageInstallersAction = new Action<string,string> ((configuration, platform) =>
|
|
{
|
|
StartProcess(iscc, new ProcessSettings {
|
|
Arguments =
|
|
"\"" + installerScript.FullPath + "\""
|
|
+ " /DCONFIGURATION=" + configuration
|
|
+ " /DBUILD=" + platform
|
|
+ " /DVERSION=" + version
|
|
+ " /DSUFFIX=" + suffix,
|
|
WorkingDirectory = MakeAbsolute(artifactsDir) });
|
|
});
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// TASKS
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
Task("Clean")
|
|
.Does(() =>
|
|
{
|
|
CleanDirectory(artifactsDir);
|
|
CleanDirectory(binDir);
|
|
CleanDirectory(objDir);
|
|
CleanDirectory(binDirEditor);
|
|
CleanDirectory(objDirEditor);
|
|
});
|
|
|
|
Task("Build")
|
|
.IsDependentOn("Clean")
|
|
.Does(() =>
|
|
{
|
|
configurations.ForEach(configuration => platforms.ForEach(platform => buildSolutionAction(solution, configuration, platform)));
|
|
configurationsEditor.ForEach(configuration => platformsEditor.ForEach(platform => buildSolutionAction(solutionEditor, configuration, platform)));
|
|
});
|
|
|
|
Task("Package-Binaries")
|
|
.IsDependentOn("Build")
|
|
.Does(() =>
|
|
{
|
|
configurations.ForEach(configuration => platforms.ForEach(platform => packageBinariesAction(configuration, platform)));
|
|
configurationsEditor.ForEach(configuration => platformsEditor.ForEach(platform => packageBinariesEditorAction(configuration, platform)));
|
|
});
|
|
|
|
Task("Package-Installers")
|
|
.IsDependentOn("Build")
|
|
.Does(() =>
|
|
{
|
|
configurations.ForEach(configuration => platforms.ForEach(platform => packageInstallersAction(configuration, platform)));
|
|
});
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// TARGETS
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
Task("Package")
|
|
.IsDependentOn("Package-Binaries")
|
|
.IsDependentOn("Package-Installers");
|
|
|
|
Task("Default")
|
|
.IsDependentOn("Build");
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// EXECUTE
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
RunTarget(target);
|