Beispiel #1
0
        private void patchForX64Platform()
        {
            const string toSearch = "BASIC_TYPE_SERIALIZER(char);\n";
            const string toMatch  = "BASIC_TYPE_SERIALIZER(unsigned __int64);";
            const string toPatch  = "#ifdef _MSC_VER\nBASIC_TYPE_SERIALIZER(unsigned __int64);\n#endif\nBASIC_TYPE_SERIALIZER(char);\n";

            string extractFolderName = FlannInfo.GetFlannInfo(flannVersion).ExtractFolderName;
            string filePath          = Path.Combine(destinationFolder, extractFolderName, @"src\cpp\flann\util\serialization.h");

            bool isPatch = false;

            if (File.Exists(filePath))
            {
                string fileContent = string.Empty;
                using (StreamReader streamReader = new StreamReader(filePath))
                {
                    fileContent = streamReader.ReadToEnd();
                    if (!fileContent.Contains(toMatch))
                    {
                        isPatch = true;
                    }
                }
                if (isPatch)
                {
                    fileContent = fileContent.Replace(toSearch, toPatch);
                    File.WriteAllText(filePath, fileContent);
                }
            }
            else
            {
                throw new Exception("For x64 machines, serialization.h requires patching. Patching error::" + filePath + " does not exists!");
            }
        }
Beispiel #2
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 = FlannInfo.GetFlannInfo(flannVersion).ExtractFolderName;

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

            readStandardOutput(p);
            readStandardError(p);

            p.WaitForExit();
            p.Close();
        }
Beispiel #3
0
        private void runCMake(string destinationFolder, string python2ExePath)
        {
            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 = FlannInfo.GetFlannInfo(flannVersion).ExtractFolderName;

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

                    if (compilerType == eCompiler.VS2013)
                    {
                        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);
                        }

                        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, Folder.BinFolderName)) + "\"" +
                                       " -DPYTHON_EXECUTABLE=" + "\"" + python2ExePath + "\"" +
                                       " -DBUILD_MATLAB_BINDINGS=OFF" + " -DBUILD_PYTHON_BINDINGS=OFF";

                        sw.WriteLine(cmakeCommand);
                    }
                    else if (compilerType == eCompiler.VS2012)
                    {
                        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);
                        }

                        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, Folder.BinFolderName)) + "\"" +
                                       " -DPYTHON_EXECUTABLE=" + "\"" + python2ExePath + "\"" +
                                       " -DBUILD_MATLAB_BINDINGS=OFF" + " -DBUILD_PYTHON_BINDINGS=OFF";

                        sw.WriteLine(cmakeCommand);
                    }
                    else if (compilerType == eCompiler.VS2010)
                    {
                        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);
                        }

                        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, Folder.BinFolderName)) + "\"" +
                                       " -DPYTHON_EXECUTABLE=" + "\"" + python2ExePath + "\"" +
                                       " -DBUILD_MATLAB_BINDINGS=OFF" + " -DBUILD_PYTHON_BINDINGS=OFF";

                        sw.WriteLine(cmakeCommand);
                    }
                }
            }

            readStandardOutput(p);
            readStandardError(p);

            p.WaitForExit();
            p.Close();
        }
Beispiel #4
0
        /// <summary>
        ///     DownloadAndBuild method downloads selected Flann version and builds it for selected parameters (i.e. x64
        ///     and Visual Studio 13)
        /// </summary>
        public void DownloadAndBuild()
        {
            try
            {
                // TODO: Ankit - Customize Message box with BlueGo UX
                string fVersion = FlannInfo.TransformFlannVersionToString(flannVersion);
                //prompt for dependencies
                MessageBox.Show("Information:Flann " + fVersion + " requires Python 2.x & Numpy as dependencies to build successfully!");

                if (!Directory.Exists(destinationFolder))
                {
                    Directory.CreateDirectory(destinationFolder);
                }

                message("Checking Dependencies...");

                DependencyChecker.CheckCommanDependency();

                string python2FullPath = Executable.GetPython2ExePath();

                if (String.IsNullOrEmpty(python2FullPath))
                {
                    throw new Exception(PythonAndNumpyNotInstalledMessage);
                }

                message("Checking Dependencies done!");

                message("Downloading Flann...");

                string FlannDownloadURL = FlannInfo.GetDownloadURL(flannVersion);
                string FlannZIPFilename = FlannInfo.GetFlannZipFileName(flannVersion);

                DownloadHelper.DownloadFileFromURL(FlannDownloadURL, destinationFolder + FlannZIPFilename);

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

                // Unzip Flann
                SevenZip.Decompress(destinationFolder + "/" + FlannZIPFilename, destinationFolder);

                message("Flann has been unzipped!");

                //patch the serialization.h for building successfully with x64
                if (platform == ePlatform.x64)
                {
                    patchForX64Platform();
                }

                message("Building Flann...");

                runCMake(destinationFolder, python2FullPath);
                runMSBuild(destinationFolder, " /property:Configuration=" + Folder.ReleaseFolderName);

                message("Flann successfully built!");

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

                OnFinished();
            }
            catch (Exception ex)
            {
                message(string.Empty);
                OnFailure();
                MessageBox.Show(ex.ToString());
            }
        }