1 // created on 4/3/04 at 6:27 a
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 2 of the License, or
6 // (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU Library General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 using Mfconsulting
.General
.Prj2Make
;
21 namespace Mfconsulting
.General
.Prj2Make
.Cui
25 public string m_AppName
= "prj2make-sharp";
26 public string m_WorkspaceFileName
;
27 public string m_FileNamePath
;
28 public string m_OutputMakefile
;
30 private bool m_IsUnix
= false;
31 private bool m_IsMcs
= true;
33 // Determines the make file type/style
36 get { return m_IsUnix; }
37 set { m_IsUnix = value; }
40 // Determines what compiler to use MCS or CSC
43 get { return m_IsMcs; }
44 set { m_IsMcs = value; }
47 protected void MyInitializeComponents()
51 public MainMod (string inputFileName
)
53 Mfconsulting
.General
.Prj2Make
.Maker mkObj
= null;
55 MyInitializeComponents();
57 if (inputFileName
== null || inputFileName
.Length
< 1)
59 Console
.WriteLine ("No input file has been specified.");
63 if (Path
.GetExtension(inputFileName
).ToUpper().CompareTo(".SLN") == 0)
65 mkObj
= new Mfconsulting
.General
.Prj2Make
.Maker();
66 mkObj
.CreateCombineFromSln(inputFileName
);
70 if (Path
.GetExtension(inputFileName
).ToUpper().CompareTo(".CSPROJ") == 0)
72 mkObj
= new Mfconsulting
.General
.Prj2Make
.Maker();
73 mkObj
.CreatePrjxFromCsproj(inputFileName
);
78 // For command line handling
79 public MainMod (bool isNmake
, bool isCsc
, string WorkspaceFile
)
81 MyInitializeComponents();
82 this.IsMcs
= (isCsc
== true) ? false : true;
83 this.IsUnix
= (isNmake
== true) ? false : true;
84 IniFromCommandLine(WorkspaceFile
);
87 void IniFromCommandLine(string WorkspaceFilename
)
89 m_WorkspaceFileName
= WorkspaceFilename
;
90 m_FileNamePath
= System
.IO
.Path
.GetDirectoryName(m_WorkspaceFileName
);
91 m_OutputMakefile
= System
.IO
.Path
.Combine(m_FileNamePath
, "Makefile");
94 m_OutputMakefile
= System
.IO
.Path
.Combine(m_FileNamePath
, "Makefile");
96 m_OutputMakefile
= System
.IO
.Path
.Combine(m_FileNamePath
, "Makefile.Win32");
98 // Actually follow through and genrate the contents of the Makefile
99 // to be placed on the textview
104 protected void CreateMakefile()
106 Mfconsulting
.General
.Prj2Make
.Maker mkObj
= null;
107 string slnFile
= null;
109 if (this.m_WorkspaceFileName
.Length
< 1) {
110 Console
.WriteLine ("No input file has been specified.");
114 slnFile
= m_WorkspaceFileName
;
116 mkObj
= new Mfconsulting
.General
.Prj2Make
.Maker();
117 SaveMakefileToDisk(mkObj
.MakerMain(IsUnix
, IsMcs
, slnFile
));
120 protected void SaveMakefileToDisk (string MakeFileContents
)
122 FileStream fs
= null;
123 StreamWriter w
= null;
125 if (MakeFileContents
.StartsWith ("Error") || MakeFileContents
.StartsWith ("Notice")) {
126 Console
.WriteLine(MakeFileContents
);
130 if (m_OutputMakefile
!= null && m_OutputMakefile
.Length
> 1) {
131 fs
= new FileStream(m_OutputMakefile
, FileMode
.Create
, FileAccess
.Write
);
132 w
= new StreamWriter(fs
);
136 w
.WriteLine (MakeFileContents
);