forked from MonoGame/MonoGame
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
82 lines (69 loc) · 2.74 KB
/
Copy pathProgram.cs
File metadata and controls
82 lines (69 loc) · 2.74 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
77
78
79
80
81
82
// MonoGame - Copyright (C) The MonoGame Team
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
using System;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
namespace MGCB
{
class Program
{
#if WINDOWS
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern bool SetDllDirectory(string lpPathName);
#endif
static int Main(string[] args)
{
#if WINDOWS
// Set the correct directory for our dependency files.
var is32Bit = IntPtr.Size == 4;
var directory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
string.Format("Dependencies{0}{1}", Path.DirectorySeparatorChar, is32Bit ? "x32" : "x64"));
SetDllDirectory(directory);
#endif
var content = new BuildContent();
// Parse the command line.
var parser = new CommandLineParser(content)
{
Title = "MonoGame Content Builder\n" +
"Builds optimized game content for MonoGame projects."
};
if (!parser.ParseCommandLine(args))
return -1;
// Process all resoponse files.
foreach (var r in content.ResponseFiles)
{
// Read in all the lines, trim whitespace, and remove empty or comment lines.
var commands = File.ReadAllLines(r).
Select(x => x.Trim()).
Where(x => !string.IsNullOrEmpty(x) && !x.StartsWith("#")).
ToArray();
// Parse the commands like they came from the command line.
if (!parser.ParseCommandLine(commands))
return -1;
}
// Do we have anything to do?
if (!content.HasWork)
{
parser.ShowUsage();
return 0;
}
// Print a startup message.
var buildStarted = DateTime.Now;
if (!content.Quiet)
Console.WriteLine("Build started {0}\n", buildStarted);
// Let the content build.
int successCount, errorCount;
content.Build(out successCount, out errorCount);
// Print the finishing info.
if (!content.Quiet)
{
Console.WriteLine("\nBuild {0} succeeded, {1} failed.\n", successCount, errorCount);
Console.WriteLine("Time elapsed {0:hh\\:mm\\:ss\\.ff}.", DateTime.Now - buildStarted);
}
// Return the error count.
return errorCount;
}
}
}