Example #1
0
        private void runMSBuild(string destinationFolder, string arguments = "")
        {
            Process          p    = new Process();
            ProcessStartInfo info = CreateVisualStudioCommandPromptProcessStartInfo(compilerType, platform);

            info.RedirectStandardInput  = true;
            info.UseShellExecute        = false;
            info.RedirectStandardOutput = true;
            info.RedirectStandardError  = true;
            info.WindowStyle            = ProcessWindowStyle.Hidden;

            p.StartInfo = info;
            p.Start();

            using (StreamWriter sw = p.StandardInput)
            {
                string extractFolderName = LibLASInfo.GetLibLASInfo(libLASVersion, libLASSupportedBoostVersion).ExtractFolderName;

                if (sw.BaseStream.CanWrite)
                {
                    sw.WriteLine("cd /D " + Path.GetFullPath(Path.Combine(destinationFolder, extractFolderName, "bin")));
                    sw.WriteLine("\"" + Executable.msbuildExePath + "\"" + " libLAS.sln" + arguments);
                }
            }

            readStandardOutput(p);
            readStandardError(p);

            p.WaitForExit();
            p.Close();
        }
Example #2
0
        /// <summary>
        ///     DownloadAndBuild method downloads selected libLAS version and builds it for selected parameters (i.e. x64
        ///     and Visual Studio 13)
        /// </summary>
        public void DownloadAndBuild()
        {
            try
            {
                if (!Directory.Exists(destinationFolder))
                {
                    Directory.CreateDirectory(destinationFolder);
                }

                message("Checking Dependencies...");

                DependencyChecker.CheckCommanDependency();

                message("Checking Dependencies done!");

                message("Downloading libLAS...");

                string libLASDownloadURL = LibLASInfo.GetDownloadURL(libLASVersion);
                string libLASZIPFilename = LibLASInfo.GetLibLASZipFileName(libLASVersion);

                DownloadHelper.DownloadFileFromURL(libLASDownloadURL, destinationFolder + libLASZIPFilename);

                message("Start to unzip libLAS...");

                // Unzip libLAS
                SevenZip.Decompress(destinationFolder + "/" + libLASZIPFilename, destinationFolder);

                if (libLASVersion == eLibLASVersion.LibLAS1_8_0)
                {
                    SevenZip.Decompress(destinationFolder + "/" + "libLAS-1.8.0.tar", destinationFolder);
                }

                message("libLAS has been unzipped!");

                message("Start to build libLAS...");

                runCMake(destinationFolder);
                runMSBuild(destinationFolder, " /property:Configuration=Release");

                message("libLAS successfully built!");

                // remove downloaded file
                if (File.Exists(Path.Combine(destinationFolder, libLASZIPFilename)))
                {
                    System.IO.File.Delete(Path.Combine(destinationFolder, libLASZIPFilename));
                }

                OnFinished();
            }
            catch (Exception ex)
            {
                message(string.Empty);
                OnFailure();
                MessageBox.Show(ex.ToString());
            }
        }
Example #3
0
        private void runCMake(string destinationFolder)
        {
            Process          p    = new Process();
            ProcessStartInfo info = CreateVisualStudioCommandPromptProcessStartInfo(compilerType, platform);

            info.RedirectStandardInput  = true;
            info.UseShellExecute        = false;
            info.RedirectStandardOutput = true;
            info.RedirectStandardError  = true;
            info.WindowStyle            = ProcessWindowStyle.Hidden;

            p.StartInfo = info;
            p.Start();

            using (StreamWriter sw = p.StandardInput)
            {
                string extractFolderName = LibLASInfo.GetLibLASInfo(libLASVersion, libLASSupportedBoostVersion).ExtractFolderName;

                if (this.libLASVersion == eLibLASVersion.LibLAS1_8_0)
                {
                    extractFolderName = extractFolderName.Substring(0, extractFolderName.Length - 4);
                }

                const string BinFolderName = "bin";

                if (sw.BaseStream.CanWrite)
                {
                    string boostFullPath      = string.Empty;
                    string boostFolder        = string.Empty;
                    string cmakeCommand       = string.Empty;
                    string cmakeGeneratorName = string.Empty;

                    if (compilerType == eCompiler.VS2015)
                    {
                        boostFolder   = getSupportedBoostFolder(libLASSupportedBoostVersion);
                        boostFullPath = Path.GetFullPath(Path.Combine(PreferencesManager.Instance.ThirdPartyDownloadFolder, eCompiler.VS2015.ToString(), platform.ToString(), boostFolder));

                        if (platform == ePlatform.x64)
                        {
                            cmakeGeneratorName = string.Concat(Helper.GetVisualStudioProductName(eVisualStudioProduct.Visual_Studio_14_2015), " ", "Win64");
                        }
                        else if (platform == ePlatform.x86)
                        {
                            cmakeGeneratorName = Helper.GetVisualStudioProductName(eVisualStudioProduct.Visual_Studio_14_2015);
                        }

                        if (!Directory.Exists(boostFullPath))
                        {
                            throw new Exception("Supported boost folder:" + boostFolder + " does not exists!\n libLAS requires supported compiled boost version.");
                        }

                        sw.WriteLine("cd /D " + destinationFolder + extractFolderName);

                        cmakeCommand = "\"" + Path.GetFullPath(Executable.cmakeExePath) + "\"" +
                                       " -G\"" + cmakeGeneratorName + "\"" +
                                       " -H\"" + Path.GetFullPath(Path.Combine(destinationFolder, extractFolderName)) + "\"" +
                                       " -B\"" + Path.GetFullPath(Path.Combine(destinationFolder, extractFolderName, BinFolderName)) + "\"" +
                                       " -DBOOST_ROOT=" + "\"" + boostFullPath + "\"";

                        sw.WriteLine(cmakeCommand);
                    }
                    else if (compilerType == eCompiler.VS2013)
                    {
                        boostFolder   = getSupportedBoostFolder(libLASSupportedBoostVersion);
                        boostFullPath = Path.GetFullPath(Path.Combine(PreferencesManager.Instance.ThirdPartyDownloadFolder, eCompiler.VS2013.ToString(), platform.ToString(), boostFolder));

                        if (platform == ePlatform.x64)
                        {
                            cmakeGeneratorName = string.Concat(Helper.GetVisualStudioProductName(eVisualStudioProduct.Visual_Studio_12_2013), " ", "Win64");
                        }
                        else if (platform == ePlatform.x86)
                        {
                            cmakeGeneratorName = Helper.GetVisualStudioProductName(eVisualStudioProduct.Visual_Studio_12_2013);
                        }

                        if (!Directory.Exists(boostFullPath))
                        {
                            throw new Exception("Supported boost folder:" + boostFolder + " does not exists!\n libLAS requires supported compiled boost version.");
                        }

                        sw.WriteLine("cd /D " + destinationFolder + extractFolderName);

                        cmakeCommand = "\"" + Path.GetFullPath(Executable.cmakeExePath) + "\"" +
                                       " -G\"" + cmakeGeneratorName + "\"" +
                                       " -H\"" + Path.GetFullPath(Path.Combine(destinationFolder, extractFolderName)) + "\"" +
                                       " -B\"" + Path.GetFullPath(Path.Combine(destinationFolder, extractFolderName, BinFolderName)) + "\"" +
                                       " -DBOOST_ROOT=" + "\"" + boostFullPath + "\"";

                        sw.WriteLine(cmakeCommand);
                    }
                    else if (compilerType == eCompiler.VS2012)
                    {
                        boostFolder   = getSupportedBoostFolder(libLASSupportedBoostVersion);
                        boostFullPath = Path.GetFullPath(Path.Combine(PreferencesManager.Instance.ThirdPartyDownloadFolder, eCompiler.VS2012.ToString(), platform.ToString(), boostFolder));

                        if (platform == ePlatform.x64)
                        {
                            cmakeGeneratorName = string.Concat(Helper.GetVisualStudioProductName(eVisualStudioProduct.Visual_Studio_11_2012), " ", "Win64");
                        }
                        else if (platform == ePlatform.x86)
                        {
                            cmakeGeneratorName = Helper.GetVisualStudioProductName(eVisualStudioProduct.Visual_Studio_11_2012);
                        }

                        if (!Directory.Exists(boostFullPath))
                        {
                            throw new Exception("Supported boost folder:" + boostFolder + " does not exists!\n libLAS requires supported compiled boost version.");
                        }

                        sw.WriteLine("cd /D " + destinationFolder + extractFolderName);

                        cmakeCommand = "\"" + Path.GetFullPath(Executable.cmakeExePath) + "\"" +
                                       " -G\"" + cmakeGeneratorName + "\"" +
                                       " -H\"" + Path.GetFullPath(Path.Combine(destinationFolder, extractFolderName)) + "\"" +
                                       " -B\"" + Path.GetFullPath(Path.Combine(destinationFolder, extractFolderName, BinFolderName)) + "\"" +
                                       " -DBOOST_ROOT=" + "\"" + boostFullPath + "\"";

                        sw.WriteLine(cmakeCommand);
                    }
                    else if (compilerType == eCompiler.VS2010)
                    {
                        boostFolder   = getSupportedBoostFolder(libLASSupportedBoostVersion);
                        boostFullPath = Path.GetFullPath(Path.Combine(PreferencesManager.Instance.ThirdPartyDownloadFolder, eCompiler.VS2010.ToString(), platform.ToString(), boostFolder));

                        if (platform == ePlatform.x64)
                        {
                            cmakeGeneratorName = string.Concat(Helper.GetVisualStudioProductName(eVisualStudioProduct.Visual_Studio_10_2010), " ", "Win64");
                        }
                        else if (platform == ePlatform.x86)
                        {
                            cmakeGeneratorName = Helper.GetVisualStudioProductName(eVisualStudioProduct.Visual_Studio_10_2010);
                        }

                        if (!Directory.Exists(boostFullPath))
                        {
                            throw new Exception("Supported boost folder:" + boostFolder + " does not exists!\n libLAS requires supported compiled boost version.");
                        }

                        sw.WriteLine("cd /D " + destinationFolder + extractFolderName);

                        cmakeCommand = "\"" + Path.GetFullPath(Executable.cmakeExePath) + "\"" +
                                       " -G\"" + cmakeGeneratorName + "\"" +
                                       " -H\"" + Path.GetFullPath(Path.Combine(destinationFolder, extractFolderName)) + "\"" +
                                       " -B\"" + Path.GetFullPath(Path.Combine(destinationFolder, extractFolderName, BinFolderName)) + "\"" +
                                       " -DBOOST_ROOT=" + "\"" + boostFullPath + "\"";

                        sw.WriteLine(cmakeCommand);
                    }
                }
            }

            readStandardOutput(p);
            readStandardError(p);

            p.WaitForExit();
            p.Close();
        }