diff options
author | Adam <Adam@anope.org> | 2010-10-30 19:41:13 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-10-30 19:41:13 -0400 |
commit | fb9f41b3e52cfddada7773a65b9723cd3a96b785 (patch) | |
tree | bd97f21b4a5098d43f2a680ae09136f3e0ef6bb5 /src/win32/Config.cs | |
parent | a7e5d51616363214d391500b2d9d647379fba833 (diff) |
Made gettext work on most OSs. Tested on Debian, FreeBSD, Gentoo, and Windows.
Added a search path option to the Config script for cmake to use when finding libraries for modules or for gettext.
Fixed m_mysql and m_ssl to work under Windows, made the Windows Config
program remember the last used options, and fixed Windows release builds.
Diffstat (limited to 'src/win32/Config.cs')
-rw-r--r-- | src/win32/Config.cs | 100 |
1 files changed, 96 insertions, 4 deletions
diff --git a/src/win32/Config.cs b/src/win32/Config.cs index cdd64a6f1..fd1cbbfda 100644 --- a/src/win32/Config.cs +++ b/src/win32/Config.cs @@ -13,7 +13,7 @@ * Written by Scott <stealtharcher.scott@gmail.com>
* Written by Adam <Adam@anope.org>
*
- * Compile with: csc /out:Config.exe Config.cs
+ * Compile with: csc /out:../../Config.exe /win32icon:anope-icon.ico Config.cs
*
*/
@@ -27,8 +27,8 @@ namespace Config {
class Config
{
- static string InstallDirectory, VSVersion, VSShortVer;
- static bool UseNMake, BuildDebug;
+ static string InstallDirectory, VSVersion, VSShortVer, ExtraArguments;
+ static bool UseNMake = true, BuildDebug = false;
static bool CheckResponse(string InstallerResponse)
{
@@ -36,6 +36,78 @@ namespace Config return true;
return false;
}
+
+ static bool LoadCache()
+ {
+ try
+ {
+ string[] cache = File.ReadAllLines("config.cache");
+ if (cache.Length > 0)
+ Console.WriteLine("Using defaults from config.cache");
+ foreach (string line in cache)
+ {
+ int e = line.IndexOf('=');
+ string name = line.Substring(0, e);
+ string value = line.Substring(e + 1);
+
+ if (name == "INSTDIR")
+ InstallDirectory = value;
+ else if (name == "DEBUG")
+ BuildDebug = CheckResponse(value);
+ else if (name == "USENMAKE")
+ UseNMake = CheckResponse(value);
+ else if (name == "EXTRAARGS")
+ ExtraArguments = value;
+ else if (name == "VSVERSION")
+ VSVersion = value;
+ else if (name == "VSSHORTVER")
+ VSShortVer = value;
+ }
+
+ return true;
+ }
+ catch (Exception) { }
+
+ return false;
+ }
+
+ static void SaveCache()
+ {
+ TextWriter tw = new StreamWriter("config.cache");
+ tw.WriteLine("INSTDIR=" + InstallDirectory);
+ tw.WriteLine("DEBUG=" + (BuildDebug ? "yes" : "no"));
+ tw.WriteLine("USENMAKE=" + (UseNMake ? "yes" : "no"));
+ tw.WriteLine("EXTRAARGS=" + ExtraArguments);
+ tw.WriteLine("VSVERSION=" + VSVersion);
+ tw.WriteLine("VSSHORTVER=" + VSShortVer);
+ tw.Close();
+ }
+
+ static string HandleCache(int i)
+ {
+ switch (i)
+ {
+ case 0:
+ Console.Write("[" + InstallDirectory + "] ");
+ return InstallDirectory;
+ case 1:
+ Console.Write("[" + UseNMake + "] ");
+ return (UseNMake ? "yes" : "no");
+ case 2:
+ Console.Write("[" + VSShortVer + "] ");
+ return VSShortVer;
+ case 3:
+ Console.Write("[" + BuildDebug + "] ");
+ return (BuildDebug ? "yes" : "no");
+ case 4:
+ Console.Write("[" + ExtraArguments + "] ");
+ return ExtraArguments;
+ default:
+ break;
+ }
+
+ return null;
+ }
static string FindAnopeVersion()
{
@@ -126,18 +198,27 @@ namespace Config Console.WriteLine("Press Enter to begin");
Console.WriteLine("");
Console.ReadKey();
+
+ bool UseCache = LoadCache();
Dictionary<int, string> InstallerQuestions = new Dictionary<int, string>();
InstallerQuestions.Add(0, "Where do you want Anope to be installed?");
InstallerQuestions.Add(1, "Would you like to build using NMake instead of using Visual Studio?\r\nNOTE: If you decide to use NMake, you must be in an environment where\r\nNMake can function, such as the Visual Studio command line. If you say\r\nyes to this while not in an environment that can run NMake, it can\r\ncause the CMake configuration to enter an endless loop. [y/n]");
InstallerQuestions.Add(2, "Are you using Visual Studio 2008 or 2010? You can leave this blank\nand have CMake try and auto detect it, but this usually doesn't\nwork correctly. [2008/2010]");
InstallerQuestions.Add(3, "Would you like to build a debug version of Anope? [y/n]");
+ InstallerQuestions.Add(4, "Are there any extra arguments you wish to pass to cmake?\nYou may only need to do this if cmake is unable to locate missing dependencies without hints.\nTo do this, set the variable EXTRA_INCLUDE like this: -DEXTRA_INCLUDE:STRING=c:/some/path/include;c:/some/path/bin;c:/some/path/lib");
for (int i = 0; i < InstallerQuestions.Count; ++i)
{
Console.WriteLine(InstallerQuestions[i]);
+ string CacheResponse = null;
+ if (UseCache)
+ CacheResponse = HandleCache(i);
string InstallerResponse = Console.ReadLine();
Console.WriteLine("");
+
+ if (CacheResponse != null && (InstallerResponse == null || InstallerResponse.Length < 1))
+ InstallerResponse = CacheResponse;
if (InstallerResponse == null || InstallerResponse.Length < 1)
{
@@ -192,6 +273,9 @@ namespace Config case 3:
BuildDebug = CheckResponse(InstallerResponse);
break;
+ case 4:
+ ExtraArguments = InstallerResponse;
+ break;
default:
break;
}
@@ -206,12 +290,20 @@ namespace Config Console.WriteLine("Using Visual Studio: No");
Console.WriteLine("Build debug: {0}", BuildDebug ? "Yes" : "No");
Console.WriteLine("Anope Version: {0}", AnopeVersion); ;
+ if (ExtraArguments != null)
+ Console.WriteLine("Extra Arguments: {0}", ExtraArguments);
Console.WriteLine("Press Enter to continue...");
Console.ReadKey();
+
+ SaveCache();
+
+ if (ExtraArguments != null)
+ ExtraArguments += " ";
+
InstallDirectory = "-DINSTDIR:STRING=\"" + InstallDirectory.Replace('\\', '/') + "\" ";
string NMake = UseNMake ? "-G\"NMake Makefiles\" " : "";
string Debug = BuildDebug ? "-DCMAKE_BUILD_TYPE:STRING=DEBUG " : "-DCMAKE_BUILD_TYPE:STRING=RELEASE ";
- string cMake = InstallDirectory + NMake + Debug + VSVersion + Environment.CurrentDirectory.Replace('\\','/');
+ string cMake = InstallDirectory + NMake + Debug + VSVersion + ExtraArguments + Environment.CurrentDirectory.Replace('\\','/');
RunCMake(cMake);
return 0;
|