-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathProgram.cs
More file actions
76 lines (74 loc) · 2.4 KB
/
Copy pathProgram.cs
File metadata and controls
76 lines (74 loc) · 2.4 KB
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
/*
* Created by SharpDevelop.
* User: elijah
* Date: 12/29/2011
* Time: 5:00 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.CodeDom.Compiler;
using System.IO;
namespace SharpLua.Compiler
{
class Program
{
public static int Main(string[] args)
{
string inFile = null, outFile = null;
Compiler.OutputType ot = Compiler.OutputType.Exe;
if (args.Length > 1)
{
foreach (string a in args)
{
if (a.ToLower().StartsWith("-ot:"))
{
string b = a.Substring("-ot:".Length);
if (b.ToLower() == "winexe")
ot = Compiler.OutputType.WinFormsExe;
else
ot = Compiler.OutputType.Exe;
}
if (a.ToLower().StartsWith("-out:"))
{
string b = a.Substring("-out:".Length);
outFile = b;
}
else
{
inFile = a;
}
}
if (inFile == null)
{
Console.WriteLine("Error: Input file not specified!");
return 1;
}
if (outFile == null)
outFile = Path.GetDirectoryName(inFile) + "\\" + Path.GetFileNameWithoutExtension(inFile) + ".exe";
}
else
{
inFile = args[0];
outFile = Path.GetDirectoryName(inFile) + "\\" + Path.GetFileNameWithoutExtension(inFile) + ".exe";
ot = Compiler.OutputType.Exe;
}
Console.WriteLine("Compiling '" + inFile + "'...");
// compile
CompilerResults cr = Compiler.Compile(new string[] { inFile }, ot, outFile);
// display errors
if (cr.Errors.Count > 0)
{
foreach (CompilerError err in cr.Errors)
Console.WriteLine("Compile Error: " + err);
return 1;
}
else
{
Console.WriteLine("Compiled to '" + outFile + "'!");
}
// return
return 0;
}
}
}