tools/builder/Config.cs
branchrefac-jit
changeset 2168 c24a6fa957db
child 2289 44045ead61cd
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/builder/Config.cs	Sun Jul 06 04:49:55 2008 +0000
     1.3 @@ -0,0 +1,110 @@
     1.4 +using System;
     1.5 +using System.IO;
     1.6 +using System.Text;
     1.7 +
     1.8 +namespace builder
     1.9 +{
    1.10 +	public enum BasePlatform
    1.11 +	{
    1.12 +		Platform_Windows,
    1.13 +		Platform_Linux
    1.14 +	};
    1.15 +
    1.16 +	public class Config
    1.17 +	{
    1.18 +		public string source_path;
    1.19 +		public string pkg_path;
    1.20 +		public string builder_path;
    1.21 +		public string build_options;
    1.22 +		public string pdb_log_file;
    1.23 +		public builder.BasePlatform Platform;
    1.24 +
    1.25 +		public Config()
    1.26 +		{
    1.27 +			if ((int)System.Environment.OSVersion.Platform == 128)
    1.28 +			{
    1.29 +				Platform = BasePlatform.Platform_Linux;
    1.30 +			} 
    1.31 +			else 
    1.32 +			{
    1.33 +				Platform = BasePlatform.Platform_Windows;
    1.34 +			}
    1.35 +		}
    1.36 +
    1.37 +		public static string PathFormat(string format, params string [] args)
    1.38 +		{
    1.39 +			string temp = string.Format(format, args);
    1.40 +			return temp.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
    1.41 +		}
    1.42 +
    1.43 +		public bool ReadFromFile(string file)
    1.44 +		{
    1.45 +			bool read = true;
    1.46 +			StreamReader sr = null;
    1.47 +			try
    1.48 +			{
    1.49 +				sr = new StreamReader(file);
    1.50 +
    1.51 +				string line;
    1.52 +				string delim = "\t \n\r\v";
    1.53 +				string split = "=";
    1.54 +				
    1.55 +				while ( (line = sr.ReadLine()) != null )
    1.56 +				{
    1.57 +					line = line.Trim(delim.ToCharArray());
    1.58 +					if (line.Length < 1 || line[0] == ';')
    1.59 +					{
    1.60 +						continue;
    1.61 +					}
    1.62 +					string [] s = line.Split(split.ToCharArray());
    1.63 +					string key, val = "";
    1.64 +					if (s.GetLength(0) >= 1)
    1.65 +					{
    1.66 +						key = s[0];
    1.67 +						if (s.GetLength(0) >= 2)
    1.68 +						{
    1.69 +							for (int i=1; i<s.GetLength(0); i++)
    1.70 +							{
    1.71 +								val += s[i];
    1.72 +							}
    1.73 +						}
    1.74 +						key = key.Trim(delim.ToCharArray());
    1.75 +						val = val.Trim(delim.ToCharArray());
    1.76 +						if (key.CompareTo("SourceBase") == 0)
    1.77 +						{
    1.78 +							source_path = val;
    1.79 +						} 
    1.80 +						else if (key.CompareTo("OutputBase") == 0) 
    1.81 +						{
    1.82 +							pkg_path = val;
    1.83 +						} 
    1.84 +						else if (key.CompareTo("BuilderPath") == 0) 
    1.85 +						{
    1.86 +							builder_path = val;
    1.87 +						} 
    1.88 +						else if (key.CompareTo("BuildOptions") == 0) 
    1.89 +						{
    1.90 +							build_options = val;
    1.91 +						}
    1.92 +						else if (key.CompareTo("PDBLog") == 0)
    1.93 +						{
    1.94 +							pdb_log_file = val;
    1.95 +						}
    1.96 +					}
    1.97 +				}
    1.98 +			} 
    1.99 +			catch (System.Exception e)
   1.100 +			{
   1.101 +				Console.WriteLine("Unable to read {0:s}: {1:s}", file, e.Message);
   1.102 +				read = false;
   1.103 +			}
   1.104 +
   1.105 +			if (sr != null)
   1.106 +			{
   1.107 +				sr.Close();
   1.108 +			}
   1.109 +
   1.110 +			return read;
   1.111 +		}
   1.112 +	}
   1.113 +}