Skip to content

Commit 5d2af92

Browse files
committed
Log more information from build script
1 parent 2becab2 commit 5d2af92

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

test-project/Assets/Editor/Builder.cs

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@
88

99
static class Builder
1010
{
11+
private static string EOL = Environment.NewLine;
12+
1113
private static void ParseCommandLineArguments(out Dictionary<string, string> providedArguments)
1214
{
1315
providedArguments = new Dictionary<string, string>();
1416
string[] args = Environment.GetCommandLineArgs();
1517

16-
// Output args in console
17-
Debug.Log("Arguments given: ");
18-
foreach (string arg in args) {
19-
Debug.Log(arg);
20-
}
18+
Console.WriteLine(
19+
$"{EOL}" +
20+
$"###########################{EOL}" +
21+
$"# Parsing settings #{EOL}" +
22+
$"###########################{EOL}" +
23+
$"{EOL}"
24+
);
2125

2226
// Extract flags with optional values
2327
for (int current = 0, next = 1; current < args.Length; current++, next++) {
@@ -27,10 +31,11 @@ private static void ParseCommandLineArguments(out Dictionary<string, string> pro
2731
string flag = args[current].TrimStart('-');
2832

2933
// Parse optional value
30-
bool flagHasValue = next >= args.Length || !args[next].StartsWith("-");
34+
bool flagHasValue = next < args.Length && !args[next].StartsWith("-");
3135
string value = flagHasValue ? args[next].TrimStart('-') : "";
3236

3337
// Assign
38+
Console.WriteLine($"Found flag \"{flag}\" with value \"{value}\".");
3439
providedArguments.Add(flag, value);
3540
}
3641
}
@@ -40,12 +45,12 @@ private static Dictionary<string, string> GetValidatedOptions()
4045
ParseCommandLineArguments(out var validatedOptions);
4146

4247
if (!validatedOptions.TryGetValue("projectPath", out var projectPath)) {
43-
Debug.Log("Missing argument -projectPath");
48+
Console.WriteLine("Missing argument -projectPath");
4449
EditorApplication.Exit(110);
4550
}
4651

4752
if (!validatedOptions.TryGetValue("buildTarget", out var buildTarget)) {
48-
Debug.Log("Missing argument -buildTarget");
53+
Console.WriteLine("Missing argument -buildTarget");
4954
EditorApplication.Exit(120);
5055
}
5156

@@ -54,17 +59,17 @@ private static Dictionary<string, string> GetValidatedOptions()
5459
}
5560

5661
if (!validatedOptions.TryGetValue("customBuildPath", out var customBuildPath)) {
57-
Debug.Log("Missing argument -customBuildPath");
62+
Console.WriteLine("Missing argument -customBuildPath");
5863
EditorApplication.Exit(130);
5964
}
6065

6166
string defaultCustomBuildName = "TestBuild";
6267
if (!validatedOptions.TryGetValue("customBuildName", out var customBuildName)) {
63-
Debug.Log($"Missing argument -customBuildName, defaulting to {defaultCustomBuildName}.");
68+
Console.WriteLine($"Missing argument -customBuildName, defaulting to {defaultCustomBuildName}.");
6469
validatedOptions.Add("customBuildName", defaultCustomBuildName);
6570
}
6671
else if (customBuildName == "") {
67-
Debug.Log($"Invalid argument -customBuildName, defaulting to {defaultCustomBuildName}.");
72+
Console.WriteLine($"Invalid argument -customBuildName, defaulting to {defaultCustomBuildName}.");
6873
validatedOptions.Add("customBuildName", defaultCustomBuildName);
6974
}
7075

@@ -100,8 +105,7 @@ public static void BuildProject()
100105

101106
private static void ReportSummary(BuildSummary summary)
102107
{
103-
var EOL = Environment.NewLine;
104-
Debug.Log(
108+
Console.WriteLine(
105109
$"{EOL}" +
106110
$"###########################{EOL}" +
107111
$"# Build results #{EOL}" +
@@ -118,22 +122,22 @@ private static void ReportSummary(BuildSummary summary)
118122
private static void ExitWithResult(BuildResult result)
119123
{
120124
if (result == BuildResult.Succeeded) {
121-
Debug.Log("Build succeeded!");
125+
Console.WriteLine("Build succeeded!");
122126
EditorApplication.Exit(0);
123127
}
124128

125129
if (result == BuildResult.Failed) {
126-
Debug.Log("Build failed!");
130+
Console.WriteLine("Build failed!");
127131
EditorApplication.Exit(101);
128132
}
129133

130134
if (result == BuildResult.Cancelled) {
131-
Debug.Log("Build cancelled!");
135+
Console.WriteLine("Build cancelled!");
132136
EditorApplication.Exit(102);
133137
}
134138

135139
if (result == BuildResult.Unknown) {
136-
Debug.Log("Build result is unknown!");
140+
Console.WriteLine("Build result is unknown!");
137141
EditorApplication.Exit(103);
138142
}
139143
}

0 commit comments

Comments
 (0)