8
8
9
9
static class Builder
10
10
{
11
+ private static string EOL = Environment . NewLine ;
12
+
11
13
private static void ParseCommandLineArguments ( out Dictionary < string , string > providedArguments )
12
14
{
13
15
providedArguments = new Dictionary < string , string > ( ) ;
14
16
string [ ] args = Environment . GetCommandLineArgs ( ) ;
15
17
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
+ ) ;
21
25
22
26
// Extract flags with optional values
23
27
for ( int current = 0 , next = 1 ; current < args . Length ; current ++ , next ++ ) {
@@ -27,10 +31,11 @@ private static void ParseCommandLineArguments(out Dictionary<string, string> pro
27
31
string flag = args [ current ] . TrimStart ( '-' ) ;
28
32
29
33
// Parse optional value
30
- bool flagHasValue = next >= args . Length || ! args [ next ] . StartsWith ( "-" ) ;
34
+ bool flagHasValue = next < args . Length && ! args [ next ] . StartsWith ( "-" ) ;
31
35
string value = flagHasValue ? args [ next ] . TrimStart ( '-' ) : "" ;
32
36
33
37
// Assign
38
+ Console . WriteLine ( $ "Found flag \" { flag } \" with value \" { value } \" .") ;
34
39
providedArguments . Add ( flag , value ) ;
35
40
}
36
41
}
@@ -40,12 +45,12 @@ private static Dictionary<string, string> GetValidatedOptions()
40
45
ParseCommandLineArguments ( out var validatedOptions ) ;
41
46
42
47
if ( ! validatedOptions . TryGetValue ( "projectPath" , out var projectPath ) ) {
43
- Debug . Log ( "Missing argument -projectPath" ) ;
48
+ Console . WriteLine ( "Missing argument -projectPath" ) ;
44
49
EditorApplication . Exit ( 110 ) ;
45
50
}
46
51
47
52
if ( ! validatedOptions . TryGetValue ( "buildTarget" , out var buildTarget ) ) {
48
- Debug . Log ( "Missing argument -buildTarget" ) ;
53
+ Console . WriteLine ( "Missing argument -buildTarget" ) ;
49
54
EditorApplication . Exit ( 120 ) ;
50
55
}
51
56
@@ -54,17 +59,17 @@ private static Dictionary<string, string> GetValidatedOptions()
54
59
}
55
60
56
61
if ( ! validatedOptions . TryGetValue ( "customBuildPath" , out var customBuildPath ) ) {
57
- Debug . Log ( "Missing argument -customBuildPath" ) ;
62
+ Console . WriteLine ( "Missing argument -customBuildPath" ) ;
58
63
EditorApplication . Exit ( 130 ) ;
59
64
}
60
65
61
66
string defaultCustomBuildName = "TestBuild" ;
62
67
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 } .") ;
64
69
validatedOptions . Add ( "customBuildName" , defaultCustomBuildName ) ;
65
70
}
66
71
else if ( customBuildName == "" ) {
67
- Debug . Log ( $ "Invalid argument -customBuildName, defaulting to { defaultCustomBuildName } .") ;
72
+ Console . WriteLine ( $ "Invalid argument -customBuildName, defaulting to { defaultCustomBuildName } .") ;
68
73
validatedOptions . Add ( "customBuildName" , defaultCustomBuildName ) ;
69
74
}
70
75
@@ -100,8 +105,7 @@ public static void BuildProject()
100
105
101
106
private static void ReportSummary ( BuildSummary summary )
102
107
{
103
- var EOL = Environment . NewLine ;
104
- Debug . Log (
108
+ Console . WriteLine (
105
109
$ "{ EOL } " +
106
110
$ "###########################{ EOL } " +
107
111
$ "# Build results #{ EOL } " +
@@ -118,22 +122,22 @@ private static void ReportSummary(BuildSummary summary)
118
122
private static void ExitWithResult ( BuildResult result )
119
123
{
120
124
if ( result == BuildResult . Succeeded ) {
121
- Debug . Log ( "Build succeeded!" ) ;
125
+ Console . WriteLine ( "Build succeeded!" ) ;
122
126
EditorApplication . Exit ( 0 ) ;
123
127
}
124
128
125
129
if ( result == BuildResult . Failed ) {
126
- Debug . Log ( "Build failed!" ) ;
130
+ Console . WriteLine ( "Build failed!" ) ;
127
131
EditorApplication . Exit ( 101 ) ;
128
132
}
129
133
130
134
if ( result == BuildResult . Cancelled ) {
131
- Debug . Log ( "Build cancelled!" ) ;
135
+ Console . WriteLine ( "Build cancelled!" ) ;
132
136
EditorApplication . Exit ( 102 ) ;
133
137
}
134
138
135
139
if ( result == BuildResult . Unknown ) {
136
- Debug . Log ( "Build result is unknown!" ) ;
140
+ Console . WriteLine ( "Build result is unknown!" ) ;
137
141
EditorApplication . Exit ( 103 ) ;
138
142
}
139
143
}
0 commit comments