/
PackageBuilderOptions.cs
99 lines (87 loc) · 3.8 KB
/
PackageBuilderOptions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Copyright (c) Xenko contributors (https://xenko.com) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
using System;
using System.Collections.Generic;
using System.IO;
using Xenko.Core;
using Xenko.Core.Diagnostics;
namespace Xenko.Core.Assets.CompilerApp
{
public class PackageBuilderOptions
{
public readonly LoggerResult Logger;
public bool Verbose = false;
public bool Debug = false;
// This should not be a list
public bool DisableAutoCompileProjects { get; set; }
public string ProjectConfiguration { get; set; }
public string OutputDirectory { get; set; }
public string BuildDirectory { get; set; }
public string SolutionFile { get; set; }
public Guid PackageId { get; set; }
public PlatformType Platform { get; set; }
public string PackageFile { get; set; }
public List<string> LogPipeNames = new List<string>();
public List<string> MonitorPipeNames = new List<string>();
public bool EnableFileLogging;
public string CustomLogFileName;
public string SlavePipe;
public Dictionary<string, string> Properties = new Dictionary<string, string>();
public Dictionary<string, string> ExtraCompileProperties;
public int ThreadCount = Environment.ProcessorCount;
public string TestName;
public PackageBuilderOptions(LoggerResult logger)
{
if (logger == null) throw new ArgumentNullException("logger");
Logger = logger;
}
/// <summary>
/// Gets the logger messages type depending on the current options
/// </summary>
public LogMessageType LoggerType
{
get { return Debug ? LogMessageType.Debug : (Verbose ? LogMessageType.Verbose : LogMessageType.Info); }
}
/// <summary>
/// This function indicate if the current builder options mean to execute a slave session
/// </summary>
/// <returns>true if the options mean to execute a slave session</returns>
public bool IsValidForSlave()
{
return !string.IsNullOrEmpty(SlavePipe) && !string.IsNullOrEmpty(BuildDirectory);
}
/// <summary>
/// Ensure every parameter is correct for a master execution. Throw an OptionException if a parameter is wrong
/// </summary>
/// <exception cref="Mono.Options.OptionException">This tool requires one input file.;filename
/// or
/// The given working directory \ + workingDir + \ does not exist.;workingdir</exception>
public void ValidateOptions()
{
if (string.IsNullOrWhiteSpace(BuildDirectory))
throw new ArgumentException("This tool requires a build path.", "build-path");
try
{
BuildDirectory = Path.GetFullPath(BuildDirectory);
}
catch (Exception)
{
throw new ArgumentException("The provided path is not a valid path name.", "build-path");
}
if (SlavePipe == null)
{
if (string.IsNullOrWhiteSpace(PackageFile))
{
if (string.IsNullOrWhiteSpace(SolutionFile) || PackageId == Guid.Empty)
{
throw new ArgumentException("This tool requires either a --package-file, or a --solution-file and --package-id.", "inputPackageFile");
}
}
else if (!File.Exists(PackageFile))
{
throw new ArgumentException("Package file [{0}] doesn't exist".ToFormat(PackageFile), "inputPackageFile");
}
}
}
}
}