--- /dev/null
+<UserSettings>\r
+ <ApplicationIdentity version="11.0"/>\r
+ <ToolsOptions>\r
+ <ToolsOptionsCategory name="TextEditor" RegisteredName="TextEditor">\r
+ <ToolsOptionsSubCategory name="CSharp" RegisteredName="CSharp" PackageName="Text Management Package">\r
+ <PropertyValue name="TabSize">8</PropertyValue>\r
+ <PropertyValue name="AutoListMembers">false</PropertyValue>\r
+ <PropertyValue name="IndentStyle">2</PropertyValue>\r
+ <PropertyValue name="HideAdvancedMembers">true</PropertyValue>\r
+ <PropertyValue name="ShowNavigationBar">true</PropertyValue>\r
+ <PropertyValue name="VirtualSpace">false</PropertyValue>\r
+ <PropertyValue name="InsertTabs">true</PropertyValue>\r
+ <PropertyValue name="WordWrapGlyphs">true</PropertyValue>\r
+ <PropertyValue name="EnableLeftClickForURLs">true</PropertyValue>\r
+ <PropertyValue name="ShowLineNumbers">false</PropertyValue>\r
+ <PropertyValue name="WordWrap">false</PropertyValue>\r
+ <PropertyValue name="IndentSize">8</PropertyValue>\r
+ <PropertyValue name="CutCopyBlankLines">true</PropertyValue>\r
+ <PropertyValue name="AutoListParams">false</PropertyValue>\r
+ </ToolsOptionsSubCategory>\r
+ <ToolsOptionsSubCategory name="CSharp-Specific" RegisteredName="CSharp-Specific" PackageName="Visual C# Language Service Package">\r
+ <PropertyValue name="NewLines_QueryExpression_EachClause">1</PropertyValue>\r
+ <PropertyValue name="Space_Normalize">0</PropertyValue>\r
+ <PropertyValue name="Space_AroundBinaryOperator">1</PropertyValue>\r
+ <PropertyValue name="Formatting_TriggerOnPaste">1</PropertyValue>\r
+ <PropertyValue name="UnboundItem_ExactMatches">5</PropertyValue>\r
+ <PropertyValue name="GenerateConstructorSmartTagEnabled">1</PropertyValue>\r
+ <PropertyValue name="CompleteOnSpace">1</PropertyValue>\r
+ <PropertyValue name="WarnWhenMembersCauseCompilerGeneratedReferences">1</PropertyValue>\r
+ <PropertyValue name="CollapseInactiveBlocksOnOpen">1</PropertyValue>\r
+ <PropertyValue name="Watson_MaxExceptionsToReport">1</PropertyValue>\r
+ <PropertyValue name="EditAndContinueReportEnterBreakStateFailure">1</PropertyValue>\r
+ <PropertyValue name="TrackMostRecentlyUsed">1</PropertyValue>\r
+ <PropertyValue name="FilterKeywordsContextually">1</PropertyValue>\r
+ <PropertyValue name="BringUpOnSpace">1</PropertyValue>\r
+ <PropertyValue name="Rename_Preview">1</PropertyValue>\r
+ <PropertyValue name="EncapsulateField_PreviewReferenceChanges">1</PropertyValue>\r
+ <PropertyValue name="DelayBeforeShowingErrors">1500</PropertyValue>\r
+ <PropertyValue name="CollapseRegionBlocksOnOpen">1</PropertyValue>\r
+ <PropertyValue name="NewLines_Braces_Method">1</PropertyValue>\r
+ <PropertyValue name="HighlightReferences">1</PropertyValue>\r
+ <PropertyValue name="RefactorNotifyRenameEnabled">1</PropertyValue>\r
+ <PropertyValue name="OnlyScanFirstTypeInFileForDesignerAttribute">0</PropertyValue>\r
+ <PropertyValue name="Indent_CaseLabels">0</PropertyValue>\r
+ <PropertyValue name="Formatting_TriggerOnBlockCompletion">1</PropertyValue>\r
+ <PropertyValue name="CompletionCommitCharacters">{}[]().,:;+-*/%&|^!~=<>?@#'"\</PropertyValue>\r
+ <PropertyValue name="EditAndContinueEnabled">1</PropertyValue>\r
+ <PropertyValue name="InsertNewlineOnEnterWithWholeWord">0</PropertyValue>\r
+ <PropertyValue name="BringUpOnOverride">1</PropertyValue>\r
+ <PropertyValue name="CodeDefinitionWindow_DocumentationComment_IndentOffset">2</PropertyValue>\r
+ <PropertyValue name="Rename_Comments">0</PropertyValue>\r
+ <PropertyValue name="Squiggles_SemanticAnalysis">0</PropertyValue>\r
+ <PropertyValue name="NewLines_Braces_ControlFlow">0</PropertyValue>\r
+ <PropertyValue name="NewLines_Braces_AnonymousMethod">0</PropertyValue>\r
+ <PropertyValue name="Space_WithinOtherParentheses">0</PropertyValue>\r
+ <PropertyValue name="BringUpOnIdentifier">1</PropertyValue>\r
+ <PropertyValue name="RemoveParameters_PreviewReferenceChanges">1</PropertyValue>\r
+ <PropertyValue name="Wrapping_KeepStatementsOnSingleLine">1</PropertyValue>\r
+ <PropertyValue name="Space_AfterBasesColon">1</PropertyValue>\r
+ <PropertyValue name="Indent_Braces">0</PropertyValue>\r
+ <PropertyValue name="CompleteOnNewline">1</PropertyValue>\r
+ <PropertyValue name="EncapsulateField_UpdateAllReferences">0</PropertyValue>\r
+ <PropertyValue name="Wrapping_IgnoreSpacesAroundVariableDeclaration">0</PropertyValue>\r
+ <PropertyValue name="Space_WithinMethodCallParentheses">0</PropertyValue>\r
+ <PropertyValue name="Space_AfterCast">0</PropertyValue>\r
+ <PropertyValue name="Colorize">1</PropertyValue>\r
+ <PropertyValue name="EditAndContinueReportOpenScopeFailure">0</PropertyValue>\r
+ <PropertyValue name="FilterToAllowableTypes">1</PropertyValue>\r
+ <PropertyValue name="WarnOnBuildErrors">1</PropertyValue>\r
+ <PropertyValue name="SortUsings_PlaceSystemFirst">1</PropertyValue>\r
+ <PropertyValue name="NewLines_Braces_CollectionInitializer">0</PropertyValue>\r
+ <PropertyValue name="Watson_DeferSendingUntilLater">0</PropertyValue>\r
+ <PropertyValue name="ShowKeywords">1</PropertyValue>\r
+ <PropertyValue name="ShowSnippets">1</PropertyValue>\r
+ <PropertyValue name="BraceMatchingRectangle">1</PropertyValue>\r
+ <PropertyValue name="NewLines_AnonymousTypeInitializer_EachMember">1</PropertyValue>\r
+ <PropertyValue name="NewLines_Keywords_Catch">0</PropertyValue>\r
+ <PropertyValue name="NewLines_Braces_ObjectInitializer">1</PropertyValue>\r
+ <PropertyValue name="NewLines_Braces_ArrayInitializer">0</PropertyValue>\r
+ <PropertyValue name="Space_WithinExpressionParentheses">0</PropertyValue>\r
+ <PropertyValue name="Space_InControlFlowConstruct">1</PropertyValue>\r
+ <PropertyValue name="Formatting_TriggerOnStatementCompletion">1</PropertyValue>\r
+ <PropertyValue name="CodeDefinitionWindow_DocumentationComment_WrapLength">80</PropertyValue>\r
+ <PropertyValue name="NewLines_Keywords_Finally">0</PropertyValue>\r
+ <PropertyValue name="Space_BetweenEmptyMethodDeclarationParentheses">0</PropertyValue>\r
+ <PropertyValue name="Indent_UnindentLabels">1</PropertyValue>\r
+ <PropertyValue name="SmartTagEnabled">1</PropertyValue>\r
+ <PropertyValue name="SortUsings">1</PropertyValue>\r
+ <PropertyValue name="Rename_Strings">0</PropertyValue>\r
+ <PropertyValue name="NewLines_ObjectInitializer_EachMember">1</PropertyValue>\r
+ <PropertyValue name="NewLines_Keywords_Else">0</PropertyValue>\r
+ <PropertyValue name="EnableProgressDialogOnWaitForBackground">1</PropertyValue>\r
+ <PropertyValue name="Space_WithinMethodDeclarationParentheses">0</PropertyValue>\r
+ <PropertyValue name="Space_BetweenEmptyMethodCallParentheses">0</PropertyValue>\r
+ <PropertyValue name="Space_BeforeSemicolonsInForStatement">0</PropertyValue>\r
+ <PropertyValue name="Space_BeforeComma">0</PropertyValue>\r
+ <PropertyValue name="Space_AfterMethodCallName">1</PropertyValue>\r
+ <PropertyValue name="Space_AfterComma">1</PropertyValue>\r
+ <PropertyValue name="ExtractInterface_SelectAll">0</PropertyValue>\r
+ <PropertyValue name="ReorderParameters_PreviewReferenceChanges">1</PropertyValue>\r
+ <PropertyValue name="Wrapping_IgnoreSpacesAroundBinaryOperators">0</PropertyValue>\r
+ <PropertyValue name="Space_BeforeBasesColon">1</PropertyValue>\r
+ <PropertyValue name="Space_AfterMethodDeclarationName">1</PropertyValue>\r
+ <PropertyValue name="Space_AfterDot">0</PropertyValue>\r
+ <PropertyValue name="UnboundItemSmartTagEnabled">1</PropertyValue>\r
+ <PropertyValue name="AutoComment">1</PropertyValue>\r
+ <PropertyValue name="NewLines_Braces_Type">0</PropertyValue>\r
+ <PropertyValue name="Space_AfterLambdaArrow">1</PropertyValue>\r
+ <PropertyValue name="ImplementInterfaceSmartTagEnabled">1</PropertyValue>\r
+ <PropertyValue name="BringUpOnPartial">1</PropertyValue>\r
+ <PropertyValue name="CodeDefinitionWindow_DocumentationComment_IndentBase">1</PropertyValue>\r
+ <PropertyValue name="EncapsulateField_SearchInStrings">0</PropertyValue>\r
+ <PropertyValue name="EnterOutliningModeOnOpen">1</PropertyValue>\r
+ <PropertyValue name="NewLines_Braces_LambdaExpressionBody">0</PropertyValue>\r
+ <PropertyValue name="Space_WithinSquares">0</PropertyValue>\r
+ <PropertyValue name="Space_BeforeLambdaArrow">1</PropertyValue>\r
+ <PropertyValue name="ShowHiddenItems">0</PropertyValue>\r
+ <PropertyValue name="Squiggles">0</PropertyValue>\r
+ <PropertyValue name="NewLines_Braces_AnonymousTypeInitializer">0</PropertyValue>\r
+ <PropertyValue name="Space_WithinCastParentheses">0</PropertyValue>\r
+ <PropertyValue name="Space_AfterSemicolonsInForStatement">1</PropertyValue>\r
+ <PropertyValue name="Indent_CaseContents">1</PropertyValue>\r
+ <PropertyValue name="Indent_FlushLabelsLeft">0</PropertyValue>\r
+ <PropertyValue name="Watson_ReportExceptions">1</PropertyValue>\r
+ <PropertyValue name="GenerateStubSmartTagEnabled">1</PropertyValue>\r
+ <PropertyValue name="BringUpOnEventHookup">1</PropertyValue>\r
+ <PropertyValue name="ImplementInterface_InsertRegionTags">0</PropertyValue>\r
+ <PropertyValue name="Wrapping_PreserveSingleLine">1</PropertyValue>\r
+ <PropertyValue name="Space_BetweenEmptySquares">0</PropertyValue>\r
+ <PropertyValue name="Space_BeforeOpenSquare">1</PropertyValue>\r
+ <PropertyValue name="Space_BeforeDot">0</PropertyValue>\r
+ <PropertyValue name="Indent_BlockContents">1</PropertyValue>\r
+ <PropertyValue name="RenameSmartTagEnabled">1</PropertyValue>\r
+ <PropertyValue name="ColorizeBoundTypes">1</PropertyValue>\r
+ <PropertyValue name="RemoveUnusedUsings">1</PropertyValue>\r
+ <PropertyValue name="Rename_Overloads">0</PropertyValue>\r
+ <PropertyValue name="EncapsulateField_SearchInComments">0</PropertyValue>\r
+ <PropertyValue name="Refactoring_Verification_Enabled">0</PropertyValue>\r
+ <PropertyValue name="ProgressDialogDelaySeconds">2</PropertyValue>\r
+ </ToolsOptionsSubCategory>\r
+ </ToolsOptionsCategory>\r
+ </ToolsOptions>\r
+</UserSettings>\r
Library, Exe, Module, WinExe
}
-public enum LanguageVersion
-{
- ISO_1 = 1,
- Default_MCS = 2,
- ISO_2 = 3,
- LINQ = 4,
- Future = 5,
- Default = LINQ
+public enum LanguageVersion {
+ ISO_1 = 1,
+ Default_MCS = 2,
+ ISO_2 = 3,
+ LINQ = 4,
+ Future = 5,
+ Default = LINQ
}
class SlnGenerator {
{
try {
libraries.Add (library, Guid.NewGuid ().ToString ().ToUpper ());
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
Console.WriteLine (ex);
}
}
sln.WriteLine ("\t\tDebug|Any CPU = Debug|Any CPU");
sln.WriteLine ("\t\tRelease|Any CPU = Release|Any CPU");
sln.WriteLine ("\tEndGlobalSection");
-
+
sln.WriteLine ("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution");
foreach (var library in libraries) {
sln.WriteLine ("\t\t{{{0}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU", library.Value);
sln.WriteLine ("\t\t{{{0}}}.Release|Any CPU.Build.0 = Release|Any CPU", library.Value);
}
sln.WriteLine ("\tEndGlobalSection");
-
+
sln.WriteLine ("\tGlobalSection(SolutionProperties) = preSolution");
sln.WriteLine ("\t\tHideSolutionNode = FALSE");
sln.WriteLine ("\tEndGlobalSection");
sln.WriteLine ("EndGlobal");
}
}
+
+ internal bool ContainsKey (string csprojFilename)
+ {
+ return libraries.ContainsKey (csprojFilename);
+ }
+
+ public int Count { get { return libraries.Count; } }
}
class MsbuildGenerator {
static string template;
static MsbuildGenerator ()
{
- using (var input = new StreamReader ("csproj.tmpl")){
+ using (var input = new StreamReader ("csproj.tmpl")) {
template = input.ReadToEnd ();
}
}
// Class directory, relative to
string class_dir;
-
+
public MsbuildGenerator (string dir)
{
this.dir = dir;
-
- if (dir == "mcs"){
+
+ if (dir == "mcs") {
mcs_topdir = "..\\";
class_dir = "..\\class\\";
base_dir = "..\\..\\mcs\\mcs";
} else {
mcs_topdir = "..\\";
-
- foreach (char c in dir){
+
+ foreach (char c in dir) {
if (c == '/')
mcs_topdir = "..//" + mcs_topdir;
}
class_dir = mcs_topdir.Substring (3);
-
+
base_dir = Path.Combine ("..", "..", "mcs", dir);
}
}
-
+
// Currently used
bool Unsafe = false;
StringBuilder defines = new StringBuilder ();
bool want_debugging_support = false;
bool Checked = false;
bool WarningsAreErrors;
- Dictionary<string,string> embedded_resources = new Dictionary<string,string> ();
+ Dictionary<string, string> embedded_resources = new Dictionary<string, string> ();
List<string> references = new List<string> ();
List<string> libs = new List<string> ();
List<string> reference_aliases = new List<string> ();
LanguageVersion Version = LanguageVersion.Default;
string CodePage;
- readonly char[] argument_value_separator = new char [] { ';', ',' };
+ readonly char [] argument_value_separator = new char [] { ';', ',' };
//
// This parses the -arg and /arg options to the compiler, even if the strings
int idx = option.IndexOf (':');
string arg, value;
- if (idx == -1){
+ if (idx == -1) {
arg = option;
value = "";
} else {
value = option.Substring (idx + 1);
}
- switch (arg.ToLower (CultureInfo.InvariantCulture)){
+ switch (arg.ToLower (CultureInfo.InvariantCulture)) {
case "/nologo":
return true;
case "/t":
case "/target":
- switch (value){
+ switch (value) {
case "exe":
Target = Target.Exe;
break;
return true;
case "/out":
- if (value.Length == 0){
+ if (value.Length == 0) {
Usage ();
Environment.Exit (1);
}
case "/d":
case "/define": {
- if (value.Length == 0){
- Usage ();
- Environment.Exit (1);
- }
+ if (value.Length == 0) {
+ Usage ();
+ Environment.Exit (1);
+ }
- foreach (string d in value.Split (argument_value_separator)){
- if (defines.Length != 0)
- defines.Append (";");
- defines.Append (d);
- }
+ foreach (string d in value.Split (argument_value_separator)) {
+ if (defines.Length != 0)
+ defines.Append (";");
+ defines.Append (d);
+ }
- return true;
- }
+ return true;
+ }
case "/bugreport":
//
case "/res":
case "/resource":
bool embeded = arg [1] == 'r' || arg [1] == 'R';
- string[] s = value.Split (argument_value_separator);
+ string [] s = value.Split (argument_value_separator);
switch (s.Length) {
case 1:
- if (s[0].Length == 0)
+ if (s [0].Length == 0)
goto default;
- embedded_resources [s[0]] = Path.GetFileName (s[0]);
+ embedded_resources [s [0]] = Path.GetFileName (s [0]);
break;
case 2:
embedded_resources [s [0]] = s [1];
Console.WriteLine ("Wrong number of arguments for option `{0}'", option);
Environment.Exit (1);
break;
-
+
}
return true;
-
+
case "/recurse":
Console.WriteLine ("/recurse not supported");
Environment.Exit (1);
case "/r":
case "/reference": {
- if (value.Length == 0){
- Console.WriteLine ("-reference requires an argument");
- Environment.Exit (1);
- }
-
- string[] refs = value.Split (argument_value_separator);
- foreach (string r in refs){
- string val = r;
- int index = val.IndexOf ('=');
- if (index > -1) {
- reference_aliases.Add (r);
- continue;
+ if (value.Length == 0) {
+ Console.WriteLine ("-reference requires an argument");
+ Environment.Exit (1);
}
- if (val.Length != 0)
- references.Add (val);
+ string [] refs = value.Split (argument_value_separator);
+ foreach (string r in refs) {
+ string val = r;
+ int index = val.IndexOf ('=');
+ if (index > -1) {
+ reference_aliases.Add (r);
+ continue;
+ }
+
+ if (val.Length != 0)
+ references.Add (val);
+ }
+ return true;
}
- return true;
- }
case "/main":
case "/m":
- case "/addmodule":
+ case "/addmodule":
case "/win32res":
- case "/doc":
- {
- Console.WriteLine ("{0} = not supported", arg);
- throw new Exception ();
- }
- case "/lib":
- {
- libs.Add (value);
- return true;
- }
+ case "/doc": {
+ Console.WriteLine ("{0} = not supported", arg);
+ return true; // throwing an exception was a showstopper, so far as I can see.
+ }
+ case "/lib": {
+ libs.Add (value);
+ return true;
+ }
case "/win32icon": {
- win32IconFile = value;
- return true;
- }
+ win32IconFile = value;
+ return true;
+ }
case "/debug-":
want_debugging_support = false;
return true;
-
+
case "/debug":
case "/debug+":
want_debugging_support = true;
case "/-runtime":
Console.WriteLine ("Warning ignoring /runtime:v4");
return true;
-
+
case "/warnaserror-":
if (value.Length == 0) {
WarningsAreErrors = false;
return true;
case "/nowarn": {
- string [] warns;
+ string [] warns;
- if (value.Length == 0){
- Console.WriteLine ("/nowarn requires an argument");
- Environment.Exit (1);
- }
-
- warns = value.Split (argument_value_separator);
- foreach (string wc in warns){
- try {
- if (wc.Trim ().Length == 0)
- continue;
+ if (value.Length == 0) {
+ Console.WriteLine ("/nowarn requires an argument");
+ Environment.Exit (1);
+ }
- int warn = Int32.Parse (wc);
- if (warn < 1) {
- throw new ArgumentOutOfRangeException("warn");
+ warns = value.Split (argument_value_separator);
+ foreach (string wc in warns) {
+ try {
+ if (wc.Trim ().Length == 0)
+ continue;
+
+ int warn = Int32.Parse (wc);
+ if (warn < 1) {
+ throw new ArgumentOutOfRangeException ("warn");
+ }
+ ignore_warning.Add (warn);
+ } catch {
+ Console.WriteLine (String.Format ("`{0}' is not a valid warning number", wc));
+ Environment.Exit (1);
}
- ignore_warning.Add (warn);
- } catch {
- Console.WriteLine (String.Format("`{0}' is not a valid warning number", wc));
- Environment.Exit (1);
}
+ return true;
}
- return true;
- }
case "/noconfig":
load_default_config = false;
case "iso-1":
Version = LanguageVersion.ISO_1;
return true;
-
+
case "default":
Version = LanguageVersion.Default;
return true;
Console.WriteLine ("Invalid option `{0}' for /langversion. It must be either `ISO-1', `ISO-2' or `Default'", value);
Environment.Exit (1);
return true;
-
+
case "/codepage":
CodePage = value;
return true;
} catch {
return null;
}
-
+
StringBuilder sb = new StringBuilder ();
-
- while ((line = f.ReadLine ()) != null){
+
+ while ((line = f.ReadLine ()) != null) {
int t = line.Length;
-
- for (int i = 0; i < t; i++){
+
+ for (int i = 0; i < t; i++) {
char c = line [i];
-
- if (c == '"' || c == '\''){
+
+ if (c == '"' || c == '\'') {
char end = c;
-
- for (i++; i < t; i++){
+
+ for (i++; i < t; i++) {
c = line [i];
-
+
if (c == end)
break;
sb.Append (c);
}
- } else if (c == ' '){
- if (sb.Length > 0){
+ } else if (c == ' ') {
+ if (sb.Length > 0) {
args.Add (sb.ToString ());
sb.Length = 0;
}
} else
sb.Append (c);
}
- if (sb.Length > 0){
+ if (sb.Length > 0) {
args.Add (sb.ToString ());
sb.Length = 0;
}
}
-
+
string [] ret_value = new string [args.Count];
args.CopyTo (ret_value, 0);
-
+
return ret_value;
}
static string Load (string f)
{
var native = NativeName (f);
-
- if (File.Exists (native)){
- using (var sr = new StreamReader (native)){
+
+ if (File.Exists (native)) {
+ using (var sr = new StreamReader (native)) {
return sr.ReadToEnd ();
}
} else
else
return path.Replace ("/", "\\");
}
-
- public string Generate (XElement xproject)
+
+ public class VsCsproj {
+ public string projectGuid;
+ public string output;
+ public string csprojFileName;
+ public string library_output;
+ public double fx_version;
+ public List<VsCsproj> projReferences = new List<VsCsproj> ();
+ public string library;
+ }
+
+ public VsCsproj Generate (XElement xproject, List<MsbuildGenerator.VsCsproj> projects)
{
+
+ var result = new VsCsproj ();
string library = xproject.Attribute ("library").Value;
- string boot, mcs, flags, output_name, built_sources, library_output, response, fx_version;
+ string boot, mcs, flags, output_name, built_sources, library_output, response, fx_version, profile;
- boot = xproject.Element ("boot").Value;
- mcs = xproject.Element ("mcs").Value;
+ boot = xproject.Element ("boot").Value;
+ mcs = xproject.Element ("mcs").Value;
flags = xproject.Element ("flags").Value;
- output_name =xproject.Element ("output").Value;
+ output_name = xproject.Element ("output").Value;
built_sources = xproject.Element ("built_sources").Value;
library_output = xproject.Element ("library_output").Value;
response = xproject.Element ("response").Value;
fx_version = xproject.Element ("fx_version").Value;
-
+ //if (library.EndsWith("-build")) fx_version = "2.0"; // otherwise problem if .NET4.5 is installed, seems. (https://github.com/nikhilk/scriptsharp/issues/156)
+ profile = xproject.Element ("profile").Value;
+ if (string.IsNullOrEmpty (response)) {
+ // Address the issue where entries are missing the fx_version
+ // Should be fixed in the Makefile or elsewhere; this is a workaround
+ //<fx_version>basic</fx_version>
+ //<profile>./../build/deps/mcs.exe.sources.response</profile>
+ //<response></response>
+ response = profile;
+ profile = fx_version;
+ if (response.Contains ("build") || response.Contains ("basic") || response.Contains ("_2_0")) {
+ fx_version = "2.0";
+ if (response.Contains ("_2_0")) profile = "net_2_0";
+ } if (response.Contains ("build") || response.Contains ("basic") || response.Contains ("_2_0")) {
+ fx_version = "2.0";
+ } else if (response.Contains ("_3_5")) {
+ fx_version = "3.5";
+ profile = "net_3_5";
+ } else if (response.Contains ("_4_0")) {
+ fx_version = "4.0";
+ profile = "net_4_0";
+ } else if (response.Contains ("_4_5")) {
+ fx_version = "4.5";
+ profile = "net_4_5";
+ }
+ }
//
// Prebuild code, might be in inputs, check:
// inputs/LIBRARY-PROFILE.pre
int q = library.IndexOf ("-");
if (q != -1)
prebuild = prebuild + Load (library.Substring (0, q) + ".pre");
-
+
var all_args = new Queue<string []> ();
all_args.Enqueue (flags.Split ());
- while (all_args.Count > 0){
+ while (all_args.Count > 0) {
string [] f = all_args.Dequeue ();
-
- for (int i = 0; i < f.Length; i++){
- if (f [i][0] == '-')
+
+ for (int i = 0; i < f.Length; i++) {
+ if (f [i] [0] == '-')
f [i] = "/" + f [i].Substring (1);
-
- if (f [i][0] == '@') {
+
+ if (f [i] [0] == '@') {
string [] extra_args;
string response_file = f [i].Substring (1);
-
+
var resp_file_full = Path.Combine (base_dir, response_file);
extra_args = LoadArgs (resp_file_full);
if (extra_args == null) {
all_args.Enqueue (extra_args);
continue;
}
-
+
if (CSCParseOption (f [i], ref f))
continue;
Console.WriteLine ("Failure with {0}", f [i]);
Environment.Exit (1);
}
}
-
+
string [] source_files;
- Console.WriteLine ("Base: {0} res: {1}", base_dir, response);
- using (var reader = new StreamReader (NativeName (base_dir + "\\" + response))){
- source_files = reader.ReadToEnd ().Split ();
+ //Console.WriteLine ("Base: {0} res: {1}", base_dir, response);
+ using (var reader = new StreamReader (NativeName (base_dir + "\\" + response))) {
+ source_files = reader.ReadToEnd ().Split ();
}
StringBuilder sources = new StringBuilder ();
- foreach (string s in source_files){
+ foreach (string s in source_files) {
if (s.Length == 0)
continue;
-
+
string src = s.Replace ("/", "\\");
if (src.StartsWith (@"Test\..\"))
src = src.Substring (8, src.Length - 8);
-
+
sources.Append (String.Format (" <Compile Include=\"{0}\" />\n", src));
}
- foreach (string s in built_sources.Split ()){
+ foreach (string s in built_sources.Split ()) {
if (s.Length == 0)
continue;
-
+
string src = s.Replace ("/", "\\");
if (src.StartsWith (@"Test\..\"))
src = src.Substring (8, src.Length - 8);
sources.Append (String.Format (" <Compile Include=\"{0}\" />\n", src));
}
-
- var mono_paths = mcs.Substring (0, mcs.IndexOf (' ')).Split (new char [] {':'});
- for (int i = 0; i < mono_paths.Length; i++){
- int p = mono_paths [i].LastIndexOf ('/');
- if (p != -1)
- mono_paths [i] = mono_paths [i].Substring (p + 1);
- }
-
- var encoded_mono_paths = string.Join ("-", mono_paths).Replace ("--", "-");
-
+
+ //if (library == "corlib-build") // otherwise, does not compile on fx_version == 4.0
+ //{
+ // references.Add("System.dll");
+ // references.Add("System.Xml.dll");
+ //}
+
+ //if (library == "System.Core-build") // otherwise, slow compile. May be a transient need.
+ //{
+ // this.ignore_warning.Add(1685);
+ // this.ignore_warning.Add(0436);
+ //}
+
+ result.library = library;
+ result.csprojFileName = ("..\\..\\mcs\\" + dir + "\\" + library + ".csproj").Replace ('/', '\\');
+ var csprojDir = Path.GetDirectoryName(result.csprojFileName);
+
var refs = new StringBuilder ();
-
- if (references.Count > 0 || reference_aliases.Count > 0){
- string last = mono_paths [0].Substring (mono_paths [0].LastIndexOf ('/') + 1);
-
- string hint_path = class_dir + "\\lib\\" + last;
-
- foreach (string r in references){
- refs.Append (" <Reference Include=\"" + r + "\">\n");
- refs.Append (" <SpecificVersion>False</SpecificVersion>\n");
- refs.Append (" <HintPath>" + r + "</HintPath>\n");
- refs.Append (" </Reference>\n");
+
+ bool is_test = response.Contains ("_test_");
+ if (is_test) {
+ // F:\src\mono\mcs\class\lib\net_2_0\nunit.framework.dll
+ // F:\src\mono\mcs\class\SomeProject\SomeProject_test_-net_2_0.csproj
+ var nunitLibPath = Path.Combine (@"..\lib", profile, "nunit.framework.dll");
+ refs.Append (string.Format (" <Reference Include=\"{0}\" />\n", nunitLibPath));
+ }
+
+ var resources = new StringBuilder ();
+ if (embedded_resources.Count > 0) {
+ resources.AppendFormat (" <ItemGroup>\n");
+ foreach (var dk in embedded_resources) {
+ resources.AppendFormat (" <EmbeddedResource Include=\"{0}\">\n", dk.Key);
+ resources.AppendFormat (" <LogicalName>{0}</LogicalName>\n", dk.Value);
+ resources.AppendFormat (" </EmbeddedResource>\n");
+ }
+ resources.AppendFormat (" </ItemGroup>\n");
+ }
+ if (references.Count > 0 || reference_aliases.Count > 0) {
+ // -r:mscorlib.dll -r:System.dll
+ //<ProjectReference Include="..\corlib\corlib-basic.csproj">
+ // <Project>{155aef28-c81f-405d-9072-9d52780e3e70}</Project>
+ // <Name>corlib-basic</Name>
+ //</ProjectReference>
+ //<ProjectReference Include="..\System\System-basic.csproj">
+ // <Project>{2094e859-db2f-481f-9630-f89d31d9ed48}</Project>
+ // <Name>System-basic</Name>
+ //</ProjectReference>
+ var refdistinct = references.Distinct();
+ foreach (string r in refdistinct) {
+ VsCsproj lastMatching = getMatchingCsproj (Path.GetFileName (r), double.Parse (fx_version), projects);
+ if (lastMatching == null) {
+ refs.Append (" <Reference Include=\"" + r + "\">\n");
+ refs.Append (" <SpecificVersion>False</SpecificVersion>\n");
+ refs.Append (" <HintPath>" + r + "</HintPath>\n");
+ refs.Append (" <Private>False</Private>");
+ refs.Append (" </Reference>\n");
+ } else {
+ //refs.Append (" <ProjectReference Include=\"" + getRelativePath (result.csprojFileName, lastMatching.csprojFileName) + "\">" + Environment.NewLine);
+ refs.Append (" <ProjectReference Include=\"" + lastMatching.csprojFileName + "\">" + Environment.NewLine);
+ refs.Append (" <Project>" + lastMatching.projectGuid + "</Project>" + Environment.NewLine);
+ refs.Append (" <Name>" + Path.GetFileNameWithoutExtension (lastMatching.csprojFileName) + "</Name>" + Environment.NewLine);
+ refs.Append (" <Private>False</Private>");
+ refs.Append (" </ProjectReference>" + Environment.NewLine);
+ if (result.projReferences.Contains (lastMatching) == false)
+ result.projReferences.Add (lastMatching);
+ }
}
- foreach (string r in reference_aliases){
+ foreach (string r in reference_aliases) {
int index = r.IndexOf ('=');
string alias = r.Substring (0, index);
string assembly = r.Substring (index + 1);
refs.Append (" </Reference>\n");
}
}
-
- bool is_test = response.Contains ("_test_");
- if (is_test) {
- refs.Append (" <Reference Include=\"nunit.framework\" />\n");
- }
- var resources = new StringBuilder ();
- if (embedded_resources.Count > 0){
- resources.AppendFormat (" <ItemGroup>\n");
- foreach (var dk in embedded_resources){
- resources.AppendFormat (" <EmbeddedResource Include=\"{0}\">\n", dk.Key);
- resources.AppendFormat (" <LogicalName>{0}</LogicalName>\n", dk.Value);
- resources.AppendFormat (" </EmbeddedResource>\n");
- }
- resources.AppendFormat (" </ItemGroup>\n");
- }
-
+ string library_output_dir = string.Empty;
try {
- library_output = Path.GetDirectoryName (library_output);
- if (string.IsNullOrEmpty (library_output))
- library_output = @".\";
+ // ../class/lib/build/tmp/System.Xml.dll
+ // /class/lib/basic/System.Core.dll
+ // <library_output>mcs.exe</library_output>
+ bool has_tmp = library_output.Contains ("/tmp/");
+ string p = library_output.Replace ("/tmp/", "/").Replace ("/", @"\");
+ string profile_dir = Path.GetDirectoryName (p);
+ string d = has_tmp ? Path.Combine (profile_dir, library) : profile_dir;
+ library_output_dir = d;
+ if (string.IsNullOrEmpty (library_output_dir))
+ library_output_dir = @".\";
+ library_output = Path.Combine (library_output_dir, output_name).Replace (@"\", "/");
} catch {
- Console.WriteLine ("Error in path: {0} while processing {1}", library_output, library);
+ Console.WriteLine ("Error in path: {0} while processing {1}", library_output_dir, library);
}
-
+
+
+ string postbuild = string.Empty;
+ //postbuild = string.Format (
+ // //"if not \"$(OutDir)\" == \"..\\lib\\{0}\" xcopy $(OutDir)$(TargetName).* ..\\lib\\{0}\\ /Y /R /D",
+ // "xcopy $(TargetName).* $(ProjectDir)..\\lib\\{0}\\ /Y /R /D",
+ // profile);
+
+ bool basic_or_build = (library.Contains ("-basic") || library.Contains ("-build"));
+
//
// Replace the template values
//
- string output = template.
+ result.projectGuid = "{" + Guid.NewGuid ().ToString () + "}";
+ result.library_output = library_output;
+ result.fx_version = double.Parse (fx_version);
+ result.output = template.
+ Replace ("@PROJECTGUID@", result.projectGuid).
Replace ("@DEFINES@", defines.ToString ()).
Replace ("@DISABLEDWARNINGS@", string.Join (",", (from i in ignore_warning select i.ToString ()).ToArray ())).
- Replace ("@NOSTDLIB@", StdLib ? "" : "<NoStdLib>true</NoStdLib>").
+ //Replace("@NOSTDLIB@", (basic_or_build || (!StdLib)) ? "<NoStdLib>true</NoStdLib>" : string.Empty).
+ Replace ("@NOSTDLIB@", "<NoStdLib>" + (!StdLib).ToString () + "</NoStdLib>").
+ Replace ("@NOCONFIG@", "<NoConfig>" + (!load_default_config).ToString () + "</NoConfig>").
Replace ("@ALLOWUNSAFE@", Unsafe ? "<AllowUnsafeBlocks>true</AllowUnsafeBlocks>" : "").
Replace ("@FX_VERSION", fx_version).
Replace ("@ASSEMBLYNAME@", Path.GetFileNameWithoutExtension (output_name)).
- Replace ("@OUTPUTDIR@", library_output).
+ Replace ("@OUTPUTDIR@", library_output_dir).
Replace ("@DEFINECONSTANTS@", defines.ToString ()).
Replace ("@DEBUG@", want_debugging_support ? "true" : "false").
Replace ("@DEBUGTYPE@", want_debugging_support ? "full" : "pdbonly").
Replace ("@REFERENCES@", refs.ToString ()).
Replace ("@PREBUILD@", prebuild).
+ Replace ("@POSTBUILD@", postbuild).
Replace ("@ADDITIONALLIBPATHS@", String.Format ("<AdditionalLibPaths>{0}</AdditionalLibPaths>", string.Join (",", libs.ToArray ()))).
Replace ("@RESOURCES@", resources.ToString ()).
Replace ("@OPTIMIZE@", Optimize ? "true" : "false").
Replace ("@SOURCES@", sources.ToString ());
-
- string ofile = "..\\..\\mcs\\" + dir + "\\" + library + ".csproj";
- ofile = ofile.Replace ('\\', '/');
//Console.WriteLine ("Generated {0}", ofile.Replace ("\\", "/"));
- using (var o = new StreamWriter (ofile)){
- o.WriteLine (output);
+ using (var o = new StreamWriter (result.csprojFileName)) {
+ o.WriteLine (result.output);
}
- return ofile;
+ return result;
+ }
+
+ private string getRelativePath (string p1, string p2)
+ {
+ throw new NotImplementedException ();
+ }
+
+ private VsCsproj getMatchingCsproj (string dllReferenceName, double fx_version, List<VsCsproj> projects)
+ {
+ return projects.LastOrDefault ((x => x.library_output.EndsWith (dllReferenceName) && (x.fx_version <= fx_version)));
}
-
+
}
public class Driver {
-
+
static void Main (string [] args)
{
- if (!File.Exists ("genproj.cs")){
- Console.WriteLine ("This command should be ran from mono/msvc/scripts");
+ if (!File.Exists ("genproj.cs")) {
+ Console.WriteLine ("This command must be executed from mono/msvc/scripts");
Environment.Exit (1);
}
var sln_gen = new SlnGenerator ();
+ var small_full_sln_gen = new SlnGenerator ();
+ var basic_sln_gen = new SlnGenerator ();
+ var build_sln_gen = new SlnGenerator ();
+ var two_sln_gen = new SlnGenerator ();
+ var four_sln_gen = new SlnGenerator ();
+ var three_five_sln_gen = new SlnGenerator ();
+ var four_five_sln_gen = new SlnGenerator ();
+ var projects = new List<MsbuildGenerator.VsCsproj> ();
+
XDocument doc = XDocument.Load ("order.xml");
- foreach (XElement project in doc.Root.Elements ()){
+ var duplicates = new List<string> ();
+ foreach (XElement project in doc.Root.Elements ()) {
string dir = project.Attribute ("dir").Value;
string library = project.Attribute ("library").Value;
//
// Do only class libraries for now
//
- if (!(dir.StartsWith ("class") || dir.StartsWith ("mcs")))
+ if (!(dir.StartsWith ("class") || dir.StartsWith ("mcs") || dir.StartsWith ("basic")))
continue;
//
// Do not do 2.1, it is not working yet
// Do not do basic, as there is no point (requires a system mcs to be installed).
//
- if (library.Contains ("moonlight") || library.Contains ("-basic") || library.EndsWith ("bootstrap"))
+ //if (library.Contains ("moonlight") || library.Contains ("-basic") || library.EndsWith ("bootstrap"))
+ if (library.Contains ("moonlight") || library.EndsWith ("bootstrap"))
continue;
-
+
var gen = new MsbuildGenerator (dir);
try {
- //sln_gen.Add (gen.Generate (project));
- gen.Generate (project);
+ var csproj = gen.Generate (project, projects);
+ projects.Add (csproj);
+ var csprojFilename = csproj.csprojFileName;
+ if (!sln_gen.ContainsKey (csprojFilename)) {
+ sln_gen.Add (csprojFilename);
+ } else {
+ duplicates.Add (csprojFilename);
+ }
+
} catch (Exception e) {
Console.WriteLine ("Error in {0}\n{1}", dir, e);
}
}
- sln_gen.Write ("mcs_full.sln");
- }
-}
+
+ //{
+ //try {
+ fillSolution (two_sln_gen, "_2_0", projects, isCommonLibrary);
+ fillSolution (four_five_sln_gen, "_4_5", projects);
+ fillSolution (four_sln_gen, "_4_0", projects);
+ fillSolution (three_five_sln_gen, "_3_5", projects);
+ // var csproj = gen.Generate (project, projects);
+ // projects.Add (csproj);
+ // if (!sln_gen.ContainsKey (csprojFilename)) {
+ // sln_gen.Add (csprojFilename);
+ // if (library.Contains ("-basic")) {
+ // basic_sln_gen.Add (csprojFilename);
+ // build_sln_gen.Add (csprojFilename);
+ // two_sln_gen.Add (csprojFilename);
+ // } else if (library.Contains ("-build"))
+ // build_sln_gen.Add (csprojFilename);
+ // else if (library.Contains ("_2_0"))
+ // two_sln_gen.Add (csprojFilename);
+ // else if (library.Contains ("_3_5"))
+ // three_five_sln_gen.Add (csprojFilename);
+ // else if (library.Contains ("_4_0"))
+ // four_sln_gen.Add (csprojFilename);
+ // else if (library.Contains ("_4_5"))
+ // four_five_sln_gen.Add (csprojFilename);
+ // else
+ // Console.WriteLine ("Don't know in which solution to put {0}; undetected profile", csprojFilename);
+ // if (isCommonLibrary (library)) {
+ // small_full_sln_gen.Add (csprojFilename);
+ // }
+ // } catch (Exception e) {
+ // Console.WriteLine ("Error in {0}\n{1}", dir, e);
+ // }
+
+ StringBuilder sb = new StringBuilder ();
+ sb.AppendLine ("WARNING: Skipped the following project references, apparent duplicates in order.xml:");
+ foreach (var item in duplicates) {
+ sb.AppendLine (item);
+ }
+ Console.WriteLine (sb.ToString ());
+
+ writeSolution (two_sln_gen, "net_2_0.sln");
+ writeSolution (three_five_sln_gen, "net_3_5.sln");
+ writeSolution (four_sln_gen, "net_4_0.sln");
+ writeSolution (four_five_sln_gen, "net_4_5.sln");
+ // A few other optional solutions
+ // Solutions with 'everything' and the most common libraries used in development may be of interest
+ //writeSolution (sln_gen, "mcs_full.sln");
+ //writeSolution (small_full_sln_gen, "small_full.sln");
+ // The following may be useful if lacking visual studio or MonoDevelop, to bootstrap mono compiler self-hosting
+ //writeSolution (basic_sln_gen, "mcs_basic.sln");
+ //writeSolution (build_sln_gen, "mcs_build.sln");
+ }
+
+ private static void fillSolution (SlnGenerator solution, string profileString, List<MsbuildGenerator.VsCsproj> projects, Func<MsbuildGenerator.VsCsproj, bool> additionalFilter = null)
+ {
+ foreach (var vsCsproj in projects) {
+ if (!vsCsproj.library.Contains (profileString))
+ continue;
+ if (additionalFilter != null && !additionalFilter (vsCsproj))
+ continue;
+ var csprojFilename = vsCsproj.csprojFileName;
+ if (!solution.ContainsKey (csprojFilename)) {
+ solution.Add (csprojFilename);
+ recursiveAddProj (solution, vsCsproj);
+ }
+ }
+ }
+
+ private static void recursiveAddProj (SlnGenerator solution, MsbuildGenerator.VsCsproj vsCsproj, int recursiveDepth = 1)
+ {
+ const int max_recursive = 10;
+ if (recursiveDepth > max_recursive) throw new Exception (string.Format ("Reached {0} levels of project dependency", max_recursive));
+ foreach (var projRef in vsCsproj.projReferences) {
+ if (!solution.ContainsKey (projRef.csprojFileName)) {
+ solution.Add (projRef.csprojFileName);
+ recursiveAddProj (solution, projRef, recursiveDepth + 1);
+ }
+ }
+ }
+
+ private static void writeSolution (SlnGenerator sln_gen, string slnfilename)
+ {
+ Console.WriteLine (String.Format ("Writing solution {1}, with {0} projects", sln_gen.Count, slnfilename));
+ sln_gen.Write (slnfilename);
+ }
+
+ private static bool isCommonLibrary (MsbuildGenerator.VsCsproj proj)
+ {
+ var library = proj.library;
+ //if (library.Contains ("-basic"))
+ // return true;
+ //if (library.Contains ("-build"))
+ // return true;
+ //if (library.StartsWith ("corlib"))
+ // return true;
+ if (library.StartsWith ("System-"))
+ return true;
+ if (library.StartsWith ("System.Xml"))
+ return true;
+ if (library.StartsWith ("System.Secu"))
+ return true;
+ if (library.StartsWith ("System.Configuration"))
+ return true;
+ if (library.StartsWith ("System.Core"))
+ return true;
+ //if (library.StartsWith ("Mono."))
+ // return true;
+
+ return false;
+ }
+}
\ No newline at end of file