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