[Monodevelop-patches-list] r1759 - trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Mon Jun 14 11:25:53 EDT 2004
Author: paco
Date: 2004-06-14 11:25:53 -0400 (Mon, 14 Jun 2004)
New Revision: 1759
Added:
trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/pkgconfiginvoker.cs
Modified:
trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/Makefile.am
trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/MdPrjHelper.cs
trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/MsPrjHelper.cs
trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/Prj2MakeSharp.prjx
trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/PrjxInfo.cs
Log:
Corrections to the way references of GAC type are generated when reading
a MS VS csproj file
Modified: trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/Makefile.am
===================================================================
--- trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/Makefile.am 2004-06-13 20:04:28 UTC (rev 1758)
+++ trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/Makefile.am 2004-06-14 15:25:53 UTC (rev 1759)
@@ -15,6 +15,7 @@
MdPrjHelper.cs \
CsprojInfo.cs \
PrjxInfo.cs \
+pkgconfiginvoker.cs \
sharp_d_cmbx.cs \
sharp_d_prjx.cs \
csproj_ver2003.cs \
Modified: trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/MdPrjHelper.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/MdPrjHelper.cs 2004-06-13 20:04:28 UTC (rev 1758)
+++ trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/MdPrjHelper.cs 2004-06-14 15:25:53 UTC (rev 1759)
@@ -17,7 +17,17 @@
private MonoDevelop.Prj2Make.Schema.Cmbx.Combine m_cmbObject;
private bool m_bIsUnix;
private bool m_bIsMcs;
+ private bool m_bIsUsingLib;
+
+ // Flag use to determine if the LIB variable will be used in
+ // the Makefile that prj2make generates
+ public bool IsUsingLib
+ {
+ get{ return m_bIsUsingLib; }
+ set{ m_bIsUsingLib = value; }
+ }
+
// Determines if the makefile is intended for nmake or gmake for urposes of path separator character
public bool IsUnix
{
@@ -40,6 +50,7 @@
{
m_bIsUnix = false;
m_bIsMcs = false;
+ m_bIsUsingLib = false;
}
// Combine desirialization
@@ -105,10 +116,17 @@
bool noProjectTargets = false;
bool noFlags = false;
StringBuilder MakefileBuilder = new StringBuilder();
+ int nPos = -1;
- m_bIsUnix = isUnixMode;
- m_bIsMcs = isMcsMode;
+ m_bIsUnix = isUnixMode;
+ m_bIsMcs = isMcsMode;
+
+ if(m_bIsUnix == true && m_bIsMcs == true)
+ {
+ m_bIsUsingLib = true;
+ }
+
if (m_bIsUnix)
{
slash = "/";
@@ -162,6 +180,20 @@
MakefileBuilder.Append("ifndef (RELEASE)\n");
MakefileBuilder.Append("\tMCSFLAGS=-debug --stacktrace\n");
MakefileBuilder.Append("endif\n");
+ // Define and add the information used in the -lib: arguments passed to the
+ // compiler to assist in finding non-fullyqualified assembly references.
+ if(m_bIsUsingLib == true)
+ {
+ string strlibDir = PkgConfigInvoker.GetPkgVariableValue("mono", "libdir");
+
+ if (strlibDir != null)
+ {
+ MakefileBuilder.AppendFormat("\nLIBS=-lib:{0} -lib:{1}\n\n",
+ Path.Combine(strlibDir.TrimEnd(), "mono/1.0"),
+ Path.Combine(strlibDir.TrimEnd(), "mono/gtk-sharp")
+ );
+ }
+ }
}
}
else // nmake
@@ -227,11 +259,25 @@
assemblyName = "System.Xml";
}
- if (System.IO.Path.GetExtension(assemblyName).ToUpper().CompareTo(".DLL") == 0) {
- refs += "-r:" + assemblyName;
- } else {
- refs += "-r:" + assemblyName + ".dll";
- }
+ // Check to see if there is a coma in the
+ // reference. This could indicate a GAC
+ // style reference
+ nPos = assemblyName.IndexOf(',');
+ if(nPos == -1)
+ {
+ if (System.IO.Path.GetExtension(assemblyName).ToUpper().CompareTo(".DLL") == 0)
+ {
+ refs += "-r:" + assemblyName;
+ }
+ else
+ {
+ refs += "-r:" + assemblyName + ".dll";
+ }
+ }
+ else
+ {
+ refs += "-r:" + assemblyName.Substring(0, nPos) + ".dll";
+ }
}
MakefileBuilder.AppendFormat("$({0}): $({1}_SRC) {2}\n", pi.makename_ext, pi.makename, deps);
@@ -245,8 +291,22 @@
MakefileBuilder.Append("\t-md $(TARGET)\n");
}
- MakefileBuilder.AppendFormat("\t$(MCS) $(MCSFLAGS) {2}{3} -out:$({0}) $({1}_RES) $({1}_SRC)\n", pi.makename_ext, pi.makename, refs, pi.switches);
- MakefileBuilder.Append("\n");
+ MakefileBuilder.Append("\t$(MCS) $(MCSFLAGS)");
+
+ // Test to see if any configuratino has the Allow unsafe blocks on
+ if(pi.AllowUnsafeCode == true ) {
+ MakefileBuilder.Append(" -unsafe");
+ }
+
+ // Test for LIBS usage
+ if(m_bIsUsingLib == true) {
+ MakefileBuilder.Append(" $(LIBS)");
+ }
+
+ MakefileBuilder.AppendFormat(" {2}{3} -out:$({0}) $({1}_RES) $({1}_SRC)\n",
+ pi.makename_ext, pi.makename, refs, pi.switches);
+
+ MakefileBuilder.Append("\n");
}
if (!noCommonTargets)
Modified: trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/MsPrjHelper.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/MsPrjHelper.cs 2004-06-13 20:04:28 UTC (rev 1758)
+++ trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/MsPrjHelper.cs 2004-06-14 15:25:53 UTC (rev 1759)
@@ -15,13 +15,23 @@
public static string slash;
static Hashtable projNameInfo = new Hashtable();
static Hashtable projGuidInfo = new Hashtable();
- private bool m_bIsUnix;
- private bool m_bIsMcs;
private string prjxFileName;
private string cmbxFileName;
private string m_strSlnVer;
private string m_strCsprojVer;
+ private bool m_bIsUnix;
+ private bool m_bIsMcs;
+ private bool m_bIsUsingLib;
+
+ // Flag use to determine if the LIB variable will be used in
+ // the Makefile that prj2make generates
+ public bool IsUsingLib
+ {
+ get{ return m_bIsUsingLib; }
+ set{ m_bIsUsingLib = value; }
+ }
+
// Determines if the makefile is intended for nmake or gmake for urposes of path separator character
public bool IsUnix
{
@@ -66,6 +76,7 @@
{
m_bIsUnix = false;
m_bIsMcs = false;
+ m_bIsUsingLib = false;
}
// Utility function to determine the sln file version
@@ -163,6 +174,11 @@
m_bIsUnix = isUnixMode;
m_bIsMcs = isMcsMode;
+ if(m_bIsUnix == true && m_bIsMcs == true)
+ {
+ m_bIsUsingLib = true;
+ }
+
if (m_bIsUnix)
{
slash = "/";
@@ -223,6 +239,21 @@
MakefileBuilder.Append("ifndef (RELEASE)\n");
MakefileBuilder.Append("\tMCSFLAGS=-debug --stacktrace\n");
MakefileBuilder.Append("endif\n");
+ // Define and add the information used in the -lib: arguments passed to the
+ // compiler to assist in finding non-fullyqualified assembly references.
+ if(m_bIsMcs == true)
+ {
+ MonoDevelop.Core // SystemAssemblyService
+ string strlibDir = PkgConfigInvoker.GetPkgVariableValue("mono", "libdir");
+
+ if (strlibDir != null)
+ {
+ MakefileBuilder.AppendFormat("LIBS=-lib:{0} -lib:{1}\n\n",
+ Path.Combine(strlibDir.TrimEnd(), "mono/1.0"),
+ Path.Combine(strlibDir.TrimEnd(), "mono/gtk-sharp")
+ );
+ }
+ }
}
}
else // nmake
@@ -333,15 +364,18 @@
}
// Test to see if any configuratino has the Allow unsafe blocks on
- if(pi.AllowUnsafeCode == true )
- {
- MakefileBuilder.AppendFormat("\t$(MCS) $(MCSFLAGS) -unsafe {2}{3} -out:$({0}) $({1}_RES) $({1}_SRC)\n", pi.makename_ext, pi.makename, refs, pi.switches);
+ if(pi.AllowUnsafeCode == true ) {
+ MakefileBuilder.Append(" -unsafe");
}
- else
- {
- MakefileBuilder.AppendFormat("\t$(MCS) $(MCSFLAGS) {2}{3} -out:$({0}) $({1}_RES) $({1}_SRC)\n", pi.makename_ext, pi.makename, refs, pi.switches);
+
+ // Test for LIBS usage
+ if(m_bIsUsingLib == true) {
+ MakefileBuilder.Append(" $(LIBS)");
}
-
+
+ MakefileBuilder.AppendFormat(" {2}{3} -out:$({0}) $({1}_RES) $({1}_SRC)\n",
+ pi.makename_ext, pi.makename, refs, pi.switches);
+
MakefileBuilder.Append("\n");
}
@@ -589,6 +623,19 @@
MonoDevelop.Prj2Make.Schema.Prjx.Reference[] theReferences = null;
int i = 0;
+ // Get the GAC path
+ string strBasePathMono1_0 = Path.Combine(
+ MonoDevelop.Prj2Make.PkgConfigInvoker.GetPkgVariableValue("mono", "libdir").TrimEnd(),
+ "mono/1.0");
+
+ string strBasePathMono2_0 = Path.Combine(
+ MonoDevelop.Prj2Make.PkgConfigInvoker.GetPkgVariableValue("mono", "libdir").TrimEnd(),
+ "mono/2.0");
+
+ string strBasePathGtkSharp = Path.Combine(
+ MonoDevelop.Prj2Make.PkgConfigInvoker.GetPkgVariableValue("mono", "libdir").TrimEnd(),
+ "mono/gtk-sharp");
+
if(References != null && References.Length > 0)
{
theReferences = new MonoDevelop.Prj2Make.Schema.Prjx.Reference[References.Length];
@@ -602,22 +649,105 @@
foreach(MonoDevelop.Prj2Make.Schema.Csproj.Reference rf in References)
{
MonoDevelop.Prj2Make.Schema.Prjx.Reference rfOut = new MonoDevelop.Prj2Make.Schema.Prjx.Reference();
+ string strRefFileName;
if(rf.Package == null || rf.Package.CompareTo("") == 0)
{
- rfOut.type = MonoDevelop.Prj2Make.Schema.Prjx.ReferenceType.Gac;
+ bool bIsWhereExpected = false;
// HACK - under Unix filenames are case sensitive
// Under Windows there's no agreement on Xml vs XML ;-)
if(Path.GetFileName(rf.HintPath).CompareTo("System.XML.dll") == 0)
{
- rfOut.refto = "System.Xml.dll";
+ strRefFileName = Path.Combine (strBasePathMono1_0, Path.GetFileName("System.Xml.dll"));
+
+ // Test to see if file exist in GAC location
+ if(System.IO.File.Exists(strRefFileName) == true) {
+ try {
+ rfOut.refto = System.Reflection.Assembly.LoadFrom(strRefFileName).FullName;
+ rfOut.type = MonoDevelop.Prj2Make.Schema.Prjx.ReferenceType.Gac;
+ rfOut.localcopy = MonoDevelop.Prj2Make.Schema.Prjx.ReferenceLocalcopy.True;
+ bIsWhereExpected = true;
+ } catch (Exception exc) {
+ Console.WriteLine ("Error doing Assembly.LoadFrom with File: {0}\nErr Msg: {1}",
+ strRefFileName,
+ exc.Message );
+ }
+ }
+
+ strRefFileName = Path.Combine (strBasePathMono2_0, Path.GetFileName("System.Xml.dll"));
+
+ // Test to see if file exist in GAC location
+ if(System.IO.File.Exists(strRefFileName) == true) {
+ try {
+ rfOut.refto = System.Reflection.Assembly.LoadFrom(strRefFileName).FullName;
+ rfOut.type = MonoDevelop.Prj2Make.Schema.Prjx.ReferenceType.Gac;
+ rfOut.localcopy = MonoDevelop.Prj2Make.Schema.Prjx.ReferenceLocalcopy.True;
+ bIsWhereExpected = true;
+ } catch (Exception exc) {
+ Console.WriteLine ("Error doing Assembly.LoadFrom with File: {0}\nErr Msg: {1}",
+ strRefFileName,
+ exc.Message );
+ }
+ }
+ } else {
+ strRefFileName = Path.Combine (strBasePathMono1_0, Path.GetFileName(rf.HintPath));
+
+
+ // Test to see if file exist in GAC location
+ if(System.IO.File.Exists(strRefFileName) == true) {
+ try {
+ rfOut.refto = System.Reflection.Assembly.LoadFrom(strRefFileName).FullName;
+ rfOut.type = MonoDevelop.Prj2Make.Schema.Prjx.ReferenceType.Gac;
+ rfOut.localcopy = MonoDevelop.Prj2Make.Schema.Prjx.ReferenceLocalcopy.True;
+ bIsWhereExpected = true;
+ } catch (Exception exc) {
+ Console.WriteLine ("Error doing Assembly.LoadFrom with File: {0}\nErr Msg: {1}",
+ strRefFileName,
+ exc.Message );
+ }
+ }
+
+ strRefFileName = Path.Combine (strBasePathMono2_0, Path.GetFileName(rf.HintPath));
+
+ // Test to see if file exist in GAC location
+ if(System.IO.File.Exists(strRefFileName) == true) {
+ try {
+ rfOut.refto = System.Reflection.Assembly.LoadFrom(strRefFileName).FullName;
+ rfOut.type = MonoDevelop.Prj2Make.Schema.Prjx.ReferenceType.Gac;
+ rfOut.localcopy = MonoDevelop.Prj2Make.Schema.Prjx.ReferenceLocalcopy.True;
+ bIsWhereExpected = true;
+ } catch (Exception exc) {
+ Console.WriteLine ("Error doing Assembly.LoadFrom with File: {0}\nErr Msg: {1}",
+ strRefFileName,
+ exc.Message );
+ }
+ }
+
+ strRefFileName = Path.Combine (strBasePathGtkSharp, Path.GetFileName(rf.HintPath));
+
+ // Test to see if file exist in GAC location
+ if(System.IO.File.Exists(strRefFileName) == true) {
+ try {
+ rfOut.refto = System.Reflection.Assembly.LoadFrom(strRefFileName).FullName;
+ rfOut.type = MonoDevelop.Prj2Make.Schema.Prjx.ReferenceType.Gac;
+ rfOut.localcopy = MonoDevelop.Prj2Make.Schema.Prjx.ReferenceLocalcopy.True;
+ bIsWhereExpected = true;
+ } catch (Exception exc) {
+ Console.WriteLine ("Error doing Assembly.LoadFrom with File: {0}\nErr Msg: {1}",
+ strRefFileName,
+ exc.Message );
+ }
+ }
+
+ if(bIsWhereExpected == false)
+ {
+ rfOut.refto = Path.GetFileName(rf.HintPath);
+ rfOut.type = MonoDevelop.Prj2Make.Schema.Prjx.ReferenceType.Gac;
+ rfOut.localcopy = MonoDevelop.Prj2Make.Schema.Prjx.ReferenceLocalcopy.True;
+ }
}
- else
- {
- rfOut.refto = Path.GetFileName(rf.HintPath);
- }
- rfOut.localcopy = MonoDevelop.Prj2Make.Schema.Prjx.ReferenceLocalcopy.True;
+
// increment the iterator value
theReferences[i++] = rfOut;
}
Modified: trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/Prj2MakeSharp.prjx
===================================================================
--- trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/Prj2MakeSharp.prjx 2004-06-13 20:04:28 UTC (rev 1758)
+++ trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/Prj2MakeSharp.prjx 2004-06-14 15:25:53 UTC (rev 1759)
@@ -16,8 +16,13 @@
</Contents>
<References>
<Reference type="Gac" refto="System.Xml, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" localcopy="True" />
- <Reference type="Project" refto="MonoDevelop.Core" localcopy="True" />
- <Reference type="Project" refto="MonoDevelop.Base" localcopy="True" />
+ <Reference type="Gac" refto="System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" localcopy="True" />
+ <Reference type="Assembly" refto="../../../../../usr/lib/monodevelop/bin/MonoDevelop.Base.dll" localcopy="True" />
+ <Reference type="Assembly" refto="../../../../../usr/lib/monodevelop/bin/MonoDevelop.Core.dll" localcopy="True" />
+ <Reference type="Gac" refto="gtk-sharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" localcopy="True" />
+ <Reference type="Gac" refto="glib-sharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" localcopy="True" />
+ <Reference type="Gac" refto="gdk-sharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" localcopy="True" />
+ <Reference type="Gac" refto="pango-sharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" localcopy="True" />
</References>
<DeploymentInformation target="" script="" strategy="File" />
<Configuration runwithwarnings="False" name="Debug">
Modified: trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/PrjxInfo.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/PrjxInfo.cs 2004-06-13 20:04:28 UTC (rev 1758)
+++ trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/PrjxInfo.cs 2004-06-14 15:25:53 UTC (rev 1759)
@@ -18,7 +18,8 @@
public string assembly_name;
public string res;
public string src;
- private MonoDevelop.Prj2Make.Schema.Prjx.Project m_projObject;
+ private bool m_bAllowUnsafeCode;
+ private MonoDevelop.Prj2Make.Schema.Prjx.Project m_projObject;
public string ext_refs = "";
public string switches = "";
@@ -27,6 +28,11 @@
get { return m_projObject; }
}
+ public bool AllowUnsafeCode
+ {
+ get { return m_bAllowUnsafeCode; }
+ }
+
// Project desirialization
protected MonoDevelop.Prj2Make.Schema.Prjx.Project LoadPrjFromFile (string strIn)
{
@@ -42,11 +48,14 @@
public PrjxInfo(bool isUnixMode, bool isMcsMode, string csprojpath)
{
+ MonoDevelop.Prj2Make.Schema.Prjx.Configuration activeConf = null;
this.csprojpath = csprojpath;
// convert backslashes to slashes
csprojpath = csprojpath.Replace("\\", "/");
+ m_bAllowUnsafeCode = false;
+
// loads the file in order to deserialize and
// build the object graph
try {
@@ -66,6 +75,24 @@
makename = name.Replace('.','_').ToUpper();
makename_ext = makename + "_EXT";
+ // Get the configuration to be used and
+ // copy it to a local configuration object
+ foreach(MonoDevelop.Prj2Make.Schema.Prjx.Configuration cnfObj in m_projObject.Configurations.Configuration)
+ {
+ if(cnfObj.name.CompareTo(m_projObject.Configurations.active) == 0)
+ {
+ // Assign the active configuration
+ activeConf = cnfObj;
+ break;
+ }
+ }
+
+ // Establish if the allow unsafe code flag is true
+ if(activeConf.CodeGeneration.unsafecodeallowed == MonoDevelop.Prj2Make.Schema.Prjx.CodeGenerationUnsafecodeallowed.True)
+ {
+ m_bAllowUnsafeCode = true;
+ }
+
switch (m_projObject.Configuration.CodeGeneration.target)
{
case "Library":
Added: trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/pkgconfiginvoker.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/pkgconfiginvoker.cs 2004-06-13 20:04:28 UTC (rev 1758)
+++ trunk/MonoDevelop/src/AddIns/prj2make-sharp-lib/pkgconfiginvoker.cs 2004-06-14 15:25:53 UTC (rev 1759)
@@ -0,0 +1,97 @@
+// created on 6/8/2004 at 5:44 AM
+using System;
+using System.Diagnostics;
+
+namespace MonoDevelop.Prj2Make
+{
+ public sealed class PkgConfigInvoker
+ {
+
+ public static string GetPkgConfigVersion()
+ {
+ string pkgout = null;
+
+ pkgout = RunPkgConfig("--version");
+
+ if(pkgout != null)
+ {
+ return pkgout;
+ }
+
+ return null;
+ }
+
+ public static string GetPkgVariableValue(string strPkg, string strVarName)
+ {
+ string pkgout = null;
+
+ pkgout = RunPkgConfig(String.Format("--variable={0} {1}",
+ strVarName, strPkg));
+
+ if(pkgout != null)
+ {
+ return pkgout;
+ }
+
+ return null;
+ }
+
+ public static string GetPkgConfigModuleVersion(string strPkg)
+ {
+ string pkgout = null;
+
+ pkgout = RunPkgConfig(String.Format("--modversion {0}", strPkg));
+
+ if(pkgout != null)
+ {
+ return pkgout;
+ }
+
+ return null;
+ }
+
+ public static string RunPkgConfig(string strArgLine)
+ {
+ string pkgout;
+
+ ProcessStartInfo pi = new ProcessStartInfo ();
+ pi.FileName = "pkg-config";
+ pi.RedirectStandardOutput = true;
+ pi.UseShellExecute = false;
+ pi.Arguments = strArgLine;
+ Process p = null;
+ try
+ {
+ p = Process.Start (pi);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Couldn't run pkg-config: " + e.Message);
+ Environment.Exit (1);
+ }
+
+ if (p.StandardOutput == null)
+ {
+ Console.WriteLine("Specified package did not return any information");
+ }
+
+ pkgout = p.StandardOutput.ReadToEnd ();
+ p.WaitForExit ();
+ if (p.ExitCode != 0)
+ {
+ Console.WriteLine("Error running pkg-config. Check the above output.");
+ Environment.Exit (1);
+ }
+
+ if (pkgout != null)
+ {
+ p.Close ();
+ return pkgout;
+ }
+
+ p.Close ();
+
+ return null;
+ }
+ }
+}
More information about the Monodevelop-patches-list
mailing list