Exemplo n.º 1
0
        protected void ParseSolution(string fname)
        {
            FileStream   fis    = new FileStream(fname, FileMode.Open, FileAccess.Read, FileShare.Read);
            StreamReader reader = new StreamReader(fis);
            Regex        regex  = new Regex(@"Project\(""\{(.*)\}""\) = ""(.*)"", ""(.*)"", ""(\{.*\})""");

            while (true)
            {
                string s = reader.ReadLine();
                Match  match;

                match = regex.Match(s);
                if (match.Success)
                {
                    string projectName = match.Groups[2].Value;
                    string csprojPath  = match.Groups[3].Value;
                    string projectGuid = match.Groups[4].Value;

                    if (csprojPath.EndsWith(".csproj") && !csprojPath.StartsWith("http://"))
                    {
                        CsprojInfo pi = new CsprojInfo(m_bIsUnix, m_bIsMcs, projectName, projectGuid, csprojPath);

                        projNameInfo[projectName] = pi;
                        projGuidInfo[projectGuid] = pi;
                    }
                }

                if (s.StartsWith("Global"))
                {
                    break;
                }
            }
        }
Exemplo n.º 2
0
        protected void ParseMsCsProj(string fname)
        {
            string projectName = System.IO.Path.GetFileNameWithoutExtension(fname);
            string csprojPath  = System.IO.Path.GetFileName(fname);
            string projectGuid = "";

            CsprojInfo pi = new CsprojInfo(m_bIsUnix, m_bIsMcs, projectName, projectGuid, csprojPath);

            projNameInfo[projectName] = pi;
            projGuidInfo[projectGuid] = pi;
        }
Exemplo n.º 3
0
        protected void ParseMsCsProj(string fname)
        {
            string projectName = System.IO.Path.GetFileNameWithoutExtension(fname);
            string csprojPath  = System.IO.Path.GetFileName(fname);
            string projectGuid = "";

            if (m_strCsprojVer.StartsWith("7.1"))
            {
                CsprojInfo pi = new CsprojInfo(m_bIsUnix, m_bIsMcs, projectName, projectGuid, csprojPath);

                projNameInfo[projectName] = pi;
                projGuidInfo[projectGuid] = pi;
            }
            else if (m_strCsprojVer.StartsWith("8"))
            {
                CsprojInfo2005 pi = new CsprojInfo2005(m_bIsUnix, m_bIsMcs, projectName, projectGuid, csprojPath);

                projNameInfo[projectName] = pi;
                projGuidInfo[projectGuid] = pi;
            }
        }
Exemplo n.º 4
0
        public PrjxInfo(bool isUnixMode, bool isMcsMode, string csprojpath)
        {
            Mfconsulting.General.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 {
                m_projObject = LoadPrjFromFile(csprojpath);
            } catch (Exception exc) {
                Console.WriteLine("Could not load the file {0}\n{1}: {2}",
                                  csprojpath,
                                  exc.GetType().Name,
                                  exc.Message
                                  );
                return;
            }

            this.name = m_projObject.name;

            makename     = name.Replace('.', '_').ToUpper();
            makename_ext = makename + "_EXT";

            // Get the configuration to be used and
            // copy it to a local configuration object
            foreach (Mfconsulting.General.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 == Mfconsulting.General.Prj2Make.Schema.Prjx.CodeGenerationUnsafecodeallowed.True)
            {
                m_bAllowUnsafeCode = true;
            }

            switch (activeConf.CodeGeneration.target)
            {
            case "Library":
                makename_ext  = makename + "_DLL";
                assembly_name = activeConf.Output.assembly + ".dll";
                switches     += " -target:library";
                break;

            case "Exe":
                makename_ext  = makename + "_EXE";
                assembly_name = activeConf.Output.assembly + ".exe";
                switches     += " -target:exe";
                break;

            case "WinExe":
                makename_ext  = makename + "_EXE";
                assembly_name = activeConf.Output.assembly + ".exe";
                switches     += " -target:winexe";
                break;

            default:
                throw new NotSupportedException("Unsupported OutputType: " + activeConf.CodeGeneration.target);
            }

            src = "";
            string basePath = Path.GetDirectoryName(csprojpath);
            string s;

            // Process Source code files for compiling
            foreach (Mfconsulting.General.Prj2Make.Schema.Prjx.File f in m_projObject.Contents)
            {
                if (f.buildaction == Mfconsulting.General.Prj2Make.Schema.Prjx.FileBuildaction.Compile)
                {
                    if (src != "")
                    {
                        src += " \\\n\t";
                    }

                    s = System.IO.Path.Combine(basePath, f.name);
                    s = s.Replace("\\", "/");
                    if (CmbxMaker.slash != "/")
                    {
                        s = s.Replace("/", CmbxMaker.slash);
                    }

                    // Test for spaces
                    if (isUnixMode == false)
                    {
                        // We are in win32 using a cmd.exe or other
                        // DOS shell
                        if (s.IndexOf(' ') > -1)
                        {
                            src += String.Format("\"{0}\"", s);
                        }
                        else
                        {
                            src += s;
                        }
                    }
                    else
                    {
                        // We are in *NIX or some other
                        // GNU like shell
                        src += CsprojInfo.Quote(s);
                    }
                }
            }

            // Process resources for embedding
            res = "";
            string rootNS = this.name;
            string relPath;

            foreach (Mfconsulting.General.Prj2Make.Schema.Prjx.File f in m_projObject.Contents)
            {
                if (f.buildaction == Mfconsulting.General.Prj2Make.Schema.Prjx.FileBuildaction.EmbedAsResource)
                {
                    if (src != "")
                    {
                        src += " \\\n\t";
                    }

                    relPath = f.name.Replace("\\", "/");
                    s       = System.IO.Path.Combine(basePath, relPath);
                    s       = String.Format(" -resource:{0},{1}", s, System.IO.Path.GetFileName(relPath));
                    s       = s.Replace("\\", "/");
                    if (CmbxMaker.slash != "/")
                    {
                        s = s.Replace("/", CmbxMaker.slash);
                    }
                    res += s;
                }
            }
        }
Exemplo n.º 5
0
        public string MsSlnHelper(bool isUnixMode, bool isMcsMode, bool isSln, string slnFile)
        {
            bool          noCommonTargets  = false;
            bool          noProjectTargets = false;
            bool          noFlags          = false;
            StringBuilder MakefileBuilder  = new StringBuilder();

            m_bIsUnix = isUnixMode;
            m_bIsMcs  = isMcsMode;

            if (m_bIsUnix == true && m_bIsMcs == true)
            {
                m_bIsUsingLib = true;
            }

            if (m_bIsUnix)
            {
                slash = "/";
            }
            else
            {
                slash = "\\";
            }

            try
            {
                string d = Path.GetDirectoryName(slnFile);
                if (d != "")
                {
                    Directory.SetCurrentDirectory(d);
                }

                if (isSln == true)
                {
                    // Get the sln file version
                    m_strSlnVer = GetSlnFileVersion(slnFile);

                    // We invoke the ParseSolution
                    // by passing the file obtained
                    ParseSolution(slnFile);
                }
                else
                {
                    // Get the Csproj version
                    m_strCsprojVer = GetCsprojFileVersion(slnFile);

                    // We invoke the ParseMsCsProj
                    // by passing the file obtained
                    ParseMsCsProj(slnFile);
                }

                if (!noFlags)
                {
                    if (m_bIsUnix)                     // gmake
                    {
                        MakefileBuilder.Append("ifndef TARGET\n");
                        MakefileBuilder.Append("\tTARGET=./bin/Debug\n");
                        MakefileBuilder.Append("else\n");
                        MakefileBuilder.Append("\tTARGET=./bin/$(TARGET)\n");
                        MakefileBuilder.Append("endif\n\n");

                        if (this.m_bIsMcs == false)
                        {
                            MakefileBuilder.Append("MCS=csc\n");
                            MakefileBuilder.Append("RESGEN=resgen\n");
                            MakefileBuilder.Append("MCSFLAGS=-nologo\n\n");
                            MakefileBuilder.Append("ifdef (RELEASE)\n");
                            MakefileBuilder.Append("\tMCSFLAGS=$(MCSFLAGS) -optimize+ -d:TRACE\n");
                            MakefileBuilder.Append("else\n");
                            MakefileBuilder.Append("\tMCSFLAGS=$(MCSFLAGS) -debug+ -d:TRACE,DEBUG\n");
                            MakefileBuilder.Append("endif\n");
                        }
                        else
                        {
                            MakefileBuilder.Append("MCS=mcs\n");
                            MakefileBuilder.Append("RESGEN=resgen\n");
                            MakefileBuilder.Append("ifndef (RELEASE)\n");
                            MakefileBuilder.Append("\tMCSFLAGS=-debug \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)
                            {
                                string strlibDir = PkgConfigInvoker.GetPkgVariableValue("mono", "libdir");

                                if (strlibDir == null)
                                {
                                    strlibDir = "/usr/lib";
                                }

                                MakefileBuilder.AppendFormat("LIBS=-lib:{0} -lib:{1}\n\n",
                                                             Utils.Escape(Path.Combine(strlibDir.TrimEnd(), "mono/1.0")),
                                                             Utils.Escape(Path.Combine(strlibDir.TrimEnd(), "mono/gtk-sharp"))
                                                             );
                            }
                        }
                    }
                    else                     // nmake
                    {
                        MakefileBuilder.Append("!if !defined (TARGET)\n");
                        MakefileBuilder.Append("TARGET=.\\bin\\Debug\n");
                        MakefileBuilder.Append("!else\n");
                        MakefileBuilder.Append("TARGET=.\\bin\\$(TARGET)\n");
                        MakefileBuilder.Append("!endif\n\n");

                        if (m_bIsMcs == false)
                        {
                            MakefileBuilder.Append("MCS=csc\n");
                            MakefileBuilder.Append("RESGEN=resgen\n");
                            MakefileBuilder.Append("MCSFLAGS=-nologo\n\n");
                            MakefileBuilder.Append("!if !defined(RELEASE)\n");
                            MakefileBuilder.Append("MCSFLAGS=$(MCSFLAGS) -optimize+ -d:TRACE\n");
                            MakefileBuilder.Append("!else\n");
                            MakefileBuilder.Append("MCSFLAGS=$(MCSFLAGS) -debug+ -d:TRACE,DEBUG\n");
                            MakefileBuilder.Append("!endif\n");
                        }
                        else
                        {
                            MakefileBuilder.Append("MCS=mcs\n");
                            MakefileBuilder.Append("RESGEN=resgen\n");
                            MakefileBuilder.Append("!if !defined(RELEASE)\n");
                            MakefileBuilder.Append("MCSFLAGS=-debug \n");
                            MakefileBuilder.Append("!endif\n");
                        }
                    }

                    MakefileBuilder.Append("\n");
                }
                else
                {
                    MakefileBuilder.Append("!if !defined(MCS)\n");
                    MakefileBuilder.Append("!error You must provide MCS when making\n");
                    MakefileBuilder.Append("!endif\n\n");
                }

                foreach (CsprojInfo pi in projNameInfo.Values)
                {
                    MakefileBuilder.AppendFormat("{0}=$(TARGET){1}{2}\n", pi.makename_ext, slash, pi.assembly_name);
                    MakefileBuilder.AppendFormat("{0}_PDB=$(TARGET){1}{2}\n", pi.makename, slash, pi.assembly_name.Replace(".dll", ".pdb"));
                    MakefileBuilder.AppendFormat("{0}_SRC={1}\n", pi.makename, pi.src);
                    MakefileBuilder.AppendFormat("{0}_RESX={1}\n", pi.makename, pi.resgen);
                    MakefileBuilder.AppendFormat("{0}_RES={1}\n\n", pi.makename, pi.res);
                }


                MakefileBuilder.Append("all: ");

                foreach (CsprojInfo pi in projNameInfo.Values)
                {
                    MakefileBuilder.AppendFormat("\\\n$({0})", pi.makename_ext);
                }

                MakefileBuilder.Append("\n");

                foreach (CsprojInfo pi in projNameInfo.Values)
                {
                    string refs = "";
                    string deps = "";

                    Hashtable libdirs = new Hashtable();

                    foreach (Mfconsulting.General.Prj2Make.Schema.Csproj.Reference rf in pi.Proyecto.CSHARP.Build.References)
                    {
                        if (rf.Package == null || rf.Package.CompareTo("") == 0)
                        {
                            // Add space in between references as
                            // it becomes necessary
                            if (refs != "")
                            {
                                refs += " ";
                            }

                            string assemblyName = rf.AssemblyName;
                            if (rf.HintPath != null)
                            {
                                string potentialPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(pi.csprojpath), rf.HintPath));
                                if (isUnixMode)
                                {
                                    potentialPath = potentialPath.Replace('\\', '/');
                                }
                                if (System.IO.File.Exists(potentialPath))
                                {
                                    // assemblyName = potentialPath;
                                    pi.libdirs.Add(Path.GetDirectoryName(potentialPath));
                                }
                            }

                            // HACK - under Unix filenames are case sensitive
                            // Under Windows there's no agreement on Xml vs XML ;-)
                            if (0 == String.Compare(assemblyName, "System.Xml", true))
                            {
                                assemblyName = "System.Xml";
                            }

                            // Check if this assembly is actually one compiled earlier in the project.
                            // If so we must add the TARGET path to this line.
                            string thisref;
                            if (CheckReference(rf.AssemblyName) == true)
                            {
                                thisref = "-r:$(TARGET)" + Path.DirectorySeparatorChar + assemblyName;
                            }
                            else
                            {
                                thisref = "-r:" + assemblyName;
                            }

                            if (!thisref.EndsWith(".dll"))
                            {
                                thisref += ".dll";
                            }
                            refs += thisref;
                        }
                        else
                        {
                            try
                            {
                                CsprojInfo pi2 = (CsprojInfo)projGuidInfo[rf.Project];

                                if (refs != "")
                                {
                                    refs += " ";
                                }

                                if (deps != "")
                                {
                                    deps += " ";
                                }

                                refs += "-r:$(" + pi2.makename_ext + ")";
                                deps += "$(" + pi2.makename_ext + ")";

                                foreach (string libdir in pi2.libdirs)
                                {
                                    if (!libdirs.ContainsKey(libdir))
                                    {
                                        libdirs[libdir] = 1;
                                    }
                                }
                            }
                            catch (System.NullReferenceException)
                            {
                                refs += String.Format("-r:{0}.dll", rf.Name);
                                deps += String.Format("# Missing dependency project {1} ID:{0}?",
                                                      rf.Project,
                                                      rf.Name
                                                      );


                                Console.WriteLine(String.Format(
                                                      "Warning: The project {0}, ID: {1} may be required and appears missing.",
                                                      rf.Name, rf.Project)
                                                  );
                            }
                        }
                    }

                    MakefileBuilder.AppendFormat("$({0}): $({1}_SRC) {2}\n", pi.makename_ext, pi.makename, deps);

                    if (isUnixMode)
                    {
                        MakefileBuilder.Append("\t-mkdir -p $(TARGET)\n");
                    }
                    else
                    {
                        MakefileBuilder.Append("\t-md $(TARGET)\n");
                    }

                    if (pi.resgen != null && pi.resgen != String.Empty)
                    {
                        MakefileBuilder.AppendFormat("\t$(RESGEN) /compile {0}\n", pi.resgen);
                    }

                    MakefileBuilder.Append("\t$(MCS) $(MCSFLAGS)");

                    foreach (string libdir in libdirs.Keys)
                    {
                        MakefileBuilder.AppendFormat(" -lib:{0}", Utils.Escape(libdir));
                    }

                    foreach (string libdir in pi.libdirs)
                    {
                        MakefileBuilder.AppendFormat(" -lib:{0}", Utils.Escape(libdir));
                    }

                    // 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)
                {
                    MakefileBuilder.Append("\n");
                    MakefileBuilder.Append("# common targets\n\n");
                    MakefileBuilder.Append("all:\t");

                    bool first = true;

                    foreach (CsprojInfo pi in projNameInfo.Values)
                    {
                        if (!first)
                        {
                            MakefileBuilder.Append(" \\\n\t");
                        }
                        MakefileBuilder.AppendFormat("$({0})", pi.makename_ext);
                        first = false;
                    }
                    MakefileBuilder.Append("\n\n");

                    MakefileBuilder.Append("clean:\n");

                    foreach (CsprojInfo pi in projNameInfo.Values)
                    {
                        if (isUnixMode)
                        {
                            MakefileBuilder.AppendFormat("\t-rm -f \"$({0})\" 2> /dev/null\n", pi.makename_ext);
                            MakefileBuilder.AppendFormat("\t-rm -f \"$({0}_PDB)\" 2> /dev/null\n", pi.makename);
                        }
                        else
                        {
                            MakefileBuilder.AppendFormat("\t-del \"$({0})\" 2> nul\n", pi.makename_ext);
                            MakefileBuilder.AppendFormat("\t-del \"$({0}_PDB)\" 2> nul\n", pi.makename);
                        }
                    }
                    MakefileBuilder.Append("\n");
                }

                if (!noProjectTargets)
                {
                    MakefileBuilder.Append("\n");
                    MakefileBuilder.Append("# project names as targets\n\n");
                    foreach (CsprojInfo pi in projNameInfo.Values)
                    {
                        MakefileBuilder.AppendFormat("{0}: $({1})\n", pi.name, pi.makename_ext);
                    }
                }

                return(MakefileBuilder.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine("EXCEPTION: {0}\n", e);
                return("");
            }
        }
Exemplo n.º 6
0
        public string MsSlnHelper(bool isUnixMode, bool isMcsMode, bool isSln, string slnFile)
        {
            bool          noCommonTargets  = false;
            bool          noProjectTargets = false;
            bool          noFlags          = false;
            StringBuilder MakefileBuilder  = new StringBuilder();

            m_bIsUnix = isUnixMode;
            m_bIsMcs  = isMcsMode;

            if (m_bIsUnix == true && m_bIsMcs == true)
            {
                m_bIsUsingLib = true;
            }

            if (m_bIsUnix)
            {
                slash = "/";
            }
            else
            {
                slash = "\\";
            }

            try
            {
                string d = Path.GetDirectoryName(slnFile);
                if (d != "")
                {
                    Directory.SetCurrentDirectory(d);
                }

                if (isSln == true)

                {
                    // Get the sln file version
                    m_strSlnVer = GetSlnFileVersion(slnFile);

                    // We invoke the ParseSolution
                    // by passing the file obtained
                    ParseSolution(slnFile);
                }

                else

                {
                    // Get the Csproj version
                    m_strCsprojVer = GetCsprojFileVersion(slnFile);

                    // We invoke the ParseMsCsProj
                    // by passing the file obtained
                    ParseMsCsProj(slnFile);
                }

                System.Reflection.Assembly curAssam = System.Reflection.Assembly.GetExecutingAssembly();
                MakefileBuilder.AppendFormat("# Makefile created with Prj2MakeSharpWin32 ver. {0}\n# on {1}\n\n",
                                             curAssam.GetName().Version.ToString(),
                                             System.DateTime.Now.ToUniversalTime().ToString()
                                             );

                if (!noFlags)
                {
                    if (m_bIsUnix)                     // gmake
                    {
                        MakefileBuilder.Append("ifndef TARGET\n");
                        MakefileBuilder.Append("\tTARGET=./bin/Debug\n");
                        MakefileBuilder.Append("else\n");
                        MakefileBuilder.Append("\tTARGET=./bin/$(TARGET)\n");
                        MakefileBuilder.Append("endif\n\n");

                        if (this.m_bIsMcs == false)
                        {
                            MakefileBuilder.Append("MCS=csc\n");
                            MakefileBuilder.Append("MCSFLAGS=-nologo\n\n");
                            MakefileBuilder.Append("ifdef (RELEASE)\n");
                            MakefileBuilder.Append("\tMCSFLAGS=$(MCSFLAGS) -optimize+ -d:TRACE\n");
                            MakefileBuilder.Append("else\n");
                            MakefileBuilder.Append("\tMCSFLAGS=$(MCSFLAGS) -debug+ -d:TRACE,DEBUG\n");
                            MakefileBuilder.Append("endif\n");
                        }
                        else
                        {
                            MakefileBuilder.Append("MCS=mcs\n");
                            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)
                            {
                                MakefileBuilder.AppendFormat("LIBS=-lib:{0}/mono/1.0 -lib:{1}/mono/gtk-sharp\n\n",
                                                             "`pkg-config --variable=libdir mono`",
                                                             "`pkg-config --variable=libdir gtk-sharp`"
                                                             );
                            }
                        }
                    }
                    else                     // nmake
                    {
                        MakefileBuilder.Append("!if !defined (TARGET)\n");
                        MakefileBuilder.Append("TARGET=.\\bin\\Debug\n");
                        MakefileBuilder.Append("!else\n");
                        MakefileBuilder.Append("TARGET=.\\bin\\$(TARGET)\n");
                        MakefileBuilder.Append("!endif\n\n");

                        if (m_bIsMcs == false)
                        {
                            MakefileBuilder.Append("MCS=csc\n");
                            MakefileBuilder.Append("MCSFLAGS=-nologo\n\n");
                            MakefileBuilder.Append("!if !defined(RELEASE)\n");
                            MakefileBuilder.Append("MCSFLAGS=$(MCSFLAGS) -optimize+ -d:TRACE\n");
                            MakefileBuilder.Append("!else\n");
                            MakefileBuilder.Append("MCSFLAGS=$(MCSFLAGS) -debug+ -d:TRACE,DEBUG\n");
                            MakefileBuilder.Append("!endif\n");
                        }
                        else
                        {
                            MakefileBuilder.Append("MCS=mcs\n");
                            MakefileBuilder.Append("!if !defined(RELEASE)\n");
                            MakefileBuilder.Append("MCSFLAGS=-debug --stacktrace\n");
                            MakefileBuilder.Append("!endif\n");
                        }
                    }

                    MakefileBuilder.Append("\n");
                }
                else
                {
                    MakefileBuilder.Append("!if !defined(MCS)\n");
                    MakefileBuilder.Append("!error You must provide MCS when making\n");
                    MakefileBuilder.Append("!endif\n\n");
                }

                foreach (CsprojInfo pi in projNameInfo.Values)
                {
                    MakefileBuilder.AppendFormat("{0}=$(TARGET){1}{2}\n", pi.makename_ext, slash, pi.assembly_name);
                    MakefileBuilder.AppendFormat("{0}_PDB=$(TARGET){1}{2}\n", pi.makename, slash, pi.assembly_name.Replace(".dll", ".pdb"));
                    MakefileBuilder.AppendFormat("{0}_SRC={1}\n", pi.makename, pi.src);
                    MakefileBuilder.AppendFormat("{0}_RES={1}\n\n", pi.makename, pi.res);
                }

                foreach (CsprojInfo pi in projNameInfo.Values)
                {
                    string refs = "";
                    string deps = "";

                    foreach (Mfconsulting.General.Prj2Make.Schema.Csproj.Reference rf in pi.Proyecto.CSHARP.Build.References)
                    {
                        if (rf.Package == null || rf.Package.CompareTo("") == 0)
                        {
                            // Add space in between references as
                            // it becomes necessary
                            if (refs != "")
                            {
                                refs += " ";
                            }

                            string assemblyName = rf.AssemblyName;

                            // HACK - under Unix filenames are case sensitive
                            // Under Windows there's no agreement on Xml vs XML ;-)
                            if (0 == String.Compare(assemblyName, "System.Xml", true))
                            {
                                assemblyName = "System.Xml";
                            }
                            refs += "-r:" + assemblyName + ".dll";
                        }
                        else
                        {
                            try
                            {
                                CsprojInfo pi2 = (CsprojInfo)projGuidInfo[rf.Project];

                                if (refs != "")
                                {
                                    refs += " ";
                                }

                                if (deps != "")
                                {
                                    deps += " ";
                                }

                                refs += "-r:$(" + pi2.makename_ext + ")";
                                deps += "$(" + pi2.makename_ext + ")";
                            }
                            catch (System.NullReferenceException)
                            {
                                refs += String.Format("-r:{0}.dll", rf.Name);
                                deps += String.Format("# Missing dependency project {1} ID:{0}?", rf.Project,
                                                      rf.Name);
                                Console.WriteLine(String.Format(
                                                      "Warning: The project {0}, ID: {1} may be required and appears missing.",
                                                      rf.Name, rf.Project)
                                                  );
                            }
                        }
                    }

                    MakefileBuilder.AppendFormat("$({0}): $({1}_SRC) {2}\n", pi.makename_ext, pi.makename, deps);

                    if (isUnixMode)
                    {
                        MakefileBuilder.Append("\t-mkdir -p $(TARGET)\n");
                    }
                    else
                    {
                        MakefileBuilder.Append("\t-md $(TARGET)\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)
                {
                    MakefileBuilder.Append("\n");
                    MakefileBuilder.Append("# common targets\n\n");
                    MakefileBuilder.Append("all:\t");

                    bool first = true;

                    foreach (CsprojInfo pi in projNameInfo.Values)
                    {
                        if (!first)
                        {
                            MakefileBuilder.Append(" \\\n\t");
                        }
                        MakefileBuilder.AppendFormat("$({0})", pi.makename_ext);
                        first = false;
                    }
                    MakefileBuilder.Append("\n\n");

                    MakefileBuilder.Append("clean:\n");

                    foreach (CsprojInfo pi in projNameInfo.Values)
                    {
                        if (isUnixMode)
                        {
                            MakefileBuilder.AppendFormat("\t-rm -f \"$({0})\" 2> /dev/null\n", pi.makename_ext);
                            MakefileBuilder.AppendFormat("\t-rm -f \"$({0}_PDB)\" 2> /dev/null\n", pi.makename);
                        }
                        else
                        {
                            MakefileBuilder.AppendFormat("\t-del \"$({0})\" 2> nul\n", pi.makename_ext);
                            MakefileBuilder.AppendFormat("\t-del \"$({0}_PDB)\" 2> nul\n", pi.makename);
                        }
                    }
                    MakefileBuilder.Append("\n");
                }

                if (!noProjectTargets)
                {
                    MakefileBuilder.Append("\n");
                    MakefileBuilder.Append("# project names as targets\n\n");
                    foreach (CsprojInfo pi in projNameInfo.Values)
                    {
                        MakefileBuilder.AppendFormat("{0}: $({1})\n", pi.name, pi.makename_ext);
                    }
                }

                return(MakefileBuilder.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine("EXCEPTION: {0}\n", e);
                return("");
            }
        }
Exemplo n.º 7
0
        protected void ParseSolution(string fname)
        {
            FileStream fis = new FileStream(fname,FileMode.Open, FileAccess.Read, FileShare.Read);
            StreamReader reader = new StreamReader(fis);
            Regex regex = new Regex(@"Project\(""\{(.*)\}""\) = ""(.*)"", ""(.*)"", ""(\{.*\})""");

            while (true)
            {
                string s = reader.ReadLine();
                Match match;

                match = regex.Match(s);
                if (match.Success)
                {
                    string projectName = match.Groups[2].Value;
                    string csprojPath = match.Groups[3].Value;
                    string projectGuid = match.Groups[4].Value;

                    if (csprojPath.EndsWith (".csproj") && !csprojPath.StartsWith("http://"))
                    {
                        CsprojInfo pi = new CsprojInfo (m_bIsUnix, m_bIsMcs, projectName, projectGuid, csprojPath);

                        projNameInfo[projectName] = pi;
                        projGuidInfo[projectGuid] = pi;
                    }
                }

                if (s.StartsWith("Global"))
                {
                    break;
                }
            }
        }
Exemplo n.º 8
0
        protected void ParseMsCsProj(string fname)
        {
            string projectName = System.IO.Path.GetFileNameWithoutExtension (fname);
            string csprojPath = System.IO.Path.GetFileName (fname);
            string projectGuid = "";

            if (m_strCsprojVer.StartsWith("7.1"))
            {
                CsprojInfo pi = new CsprojInfo(m_bIsUnix, m_bIsMcs, projectName, projectGuid, csprojPath);

                projNameInfo[projectName] = pi;
                projGuidInfo[projectGuid] = pi;
            }
            else if(m_strCsprojVer.StartsWith("8"))
            {
                CsprojInfo2005 pi = new CsprojInfo2005(m_bIsUnix, m_bIsMcs, projectName, projectGuid, csprojPath);

                projNameInfo[projectName] = pi;
                projGuidInfo[projectGuid] = pi;
            }
        }
Exemplo n.º 9
0
        protected void ParseMsCsProj(string fname)
        {
            string projectName = System.IO.Path.GetFileNameWithoutExtension (fname);
            string csprojPath = System.IO.Path.GetFileName (fname);
            string projectGuid = "";

            CsprojInfo pi = new CsprojInfo (m_bIsUnix, m_bIsMcs, projectName, projectGuid, csprojPath);

            projNameInfo[projectName] = pi;
            projGuidInfo[projectGuid] = pi;
        }