Example #1
0
        private void configureQT4()
        {
            eCompiler compiler = compilerType;

            Process          p    = new Process();
            ProcessStartInfo info = CreateVisualStudioCommandPromptProcessStartInfo(compilerType, platform);

            info.RedirectStandardInput  = true;
            info.UseShellExecute        = false;
            info.RedirectStandardOutput = true;
            info.RedirectStandardError  = true;
            info.CreateNoWindow         = true;

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

            string extractFolderName = QtInfo.GetQtInfo(qtVersion).ExtractFolderName;

            using (StreamWriter sw = p.StandardInput)
            {
                if (sw.BaseStream.CanWrite)
                {
                    sw.WriteLine("cd /D " + destinationFolder + extractFolderName);

                    if (compiler == eCompiler.VS2010 || qtVersion == eQtVersion.Qt4_8_3)// Qt 4.8.3 does not know platform msvc2012
                    {
                        sw.WriteLine("configure -mp -opensource -nomake demos -nomake examples -platform win32-msvc2010" + qtCommandLineArguments + withLibraries);
                    }
                    else
                    {
                        sw.WriteLine("configure -mp -opensource -nomake demos -nomake examples -platform win32-msvc2012" + qtCommandLineArguments + withLibraries);
                    }

                    sw.WriteLine("y");
                }
            }

            readStandardOutput(p);
            readStandardError(p);

            p.WaitForExit();
            p.Close();
        }
Example #2
0
        private void buildQT()
        {
            using (Process process = new Process())
            {
                process.StartInfo = CreateVisualStudioCommandPromptProcessStartInfo(compilerType, platform);

                process.StartInfo.UseShellExecute        = false;
                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.RedirectStandardError  = true;
                process.StartInfo.RedirectStandardInput  = true;

                StringBuilder output = new StringBuilder();
                StringBuilder error  = new StringBuilder();

                using (AutoResetEvent outputWaitHandle = new AutoResetEvent(false))
                    using (AutoResetEvent errorWaitHandle = new AutoResetEvent(false))
                    {
                        process.OutputDataReceived += (sender, e) =>
                        {
                            if (e.Data == null)
                            {
                                outputWaitHandle.Set();
                            }
                            else
                            {
                                output.AppendLine(e.Data);
                                writeStandardOutputMessage(e.Data);
                            }
                        };

                        process.ErrorDataReceived += (sender, e) =>
                        {
                            if (e.Data == null)
                            {
                                errorWaitHandle.Set();
                            }
                            else
                            {
                                error.AppendLine(e.Data);
                                writeStandardErrorMessage(e.Data);
                            }
                        };

                        process.Start();

                        process.BeginOutputReadLine();
                        process.BeginErrorReadLine();

                        using (StreamWriter sw = process.StandardInput)
                        {
                            if (sw.BaseStream.CanWrite)
                            {
                                string extractFolderName = QtInfo.GetQtInfo(qtVersion).ExtractFolderName;

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

                                //sw.WriteLine("y");
                            }
                        }

                        int timeoutInOneDay = 1000 * 60 * 60 * 24; // 1 day
                        if (process.WaitForExit(timeoutInOneDay) &&
                            outputWaitHandle.WaitOne(timeoutInOneDay) &&
                            errorWaitHandle.WaitOne(timeoutInOneDay))
                        {
                            // Process completed. Check process.ExitCode here.
                            //process.ExitCode
                        }
                        else
                        {
                            // Timed out.
                            throw new Exception("Build Qt5: TimeOut");
                        }
                    }
            }
        }
Example #3
0
        private void configureQT5()
        {
            using (Process process = new Process())
            {
                process.StartInfo = CreateVisualStudioCommandPromptProcessStartInfo(compilerType, platform);

                process.StartInfo.UseShellExecute        = false;
                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.RedirectStandardError  = true;
                process.StartInfo.RedirectStandardInput  = true;

                StringBuilder output = new StringBuilder();
                StringBuilder error  = new StringBuilder();

                using (AutoResetEvent outputWaitHandle = new AutoResetEvent(false))
                    using (AutoResetEvent errorWaitHandle = new AutoResetEvent(false))
                    {
                        process.OutputDataReceived += (sender, e) =>
                        {
                            if (e.Data == null)
                            {
                                outputWaitHandle.Set();
                            }
                            else
                            {
                                output.AppendLine(e.Data);
                                writeStandardOutputMessage(e.Data);
                            }
                        };

                        process.ErrorDataReceived += (sender, e) =>
                        {
                            if (e.Data == null)
                            {
                                errorWaitHandle.Set();
                            }
                            else
                            {
                                error.AppendLine(e.Data);
                                writeStandardErrorMessage(e.Data);
                            }
                        };

                        process.Start();

                        process.BeginOutputReadLine();
                        process.BeginErrorReadLine();

                        using (StreamWriter sw = process.StandardInput)
                        {
                            if (sw.BaseStream.CanWrite)
                            {
                                string extractFolderName = QtInfo.GetQtInfo(qtVersion).ExtractFolderName;

                                sw.WriteLine("cd /D " + destinationFolder + extractFolderName);
                                if (compilerType == eCompiler.VS2010)
                                {
                                    sw.WriteLine("configure -developer-build -opensource -nomake examples -nomake tests" + qtCommandLineArguments + withLibraries);
                                }
                                else
                                {
                                    sw.WriteLine("configure -developer-build -opensource -nomake examples -nomake tests" + qtCommandLineArguments + withLibraries);
                                }

                                sw.WriteLine("y");
                            }
                        }

                        int timeoutIn30Seconds = 1000 * 60 * 30; // 30 minutes
                        if (process.WaitForExit(timeoutIn30Seconds) &&
                            outputWaitHandle.WaitOne(timeoutIn30Seconds) &&
                            errorWaitHandle.WaitOne(timeoutIn30Seconds))
                        {
                            // Process completed. Check process.ExitCode here.
                            //process.ExitCode
                        }
                        else
                        {
                            // Timed out.
                            throw new Exception("Configure Qt5: TimeOut");
                        }
                    }
            }
        }
Example #4
0
        public void DownloadAndBuild()
        {
            try
            {
                if (!Directory.Exists(destinationFolder))
                {
                    Directory.CreateDirectory(destinationFolder);
                }

                message("downloading QT");

                string QtDownloadURL = QtInfo.GetDownloadURL(qtVersion);
                string QtZipFilename = QtInfo.GetZipFileName(qtVersion);

                if (!File.Exists(destinationFolder + QtZipFilename) || downloadThirdPartyLibraryEveryTime)
                {
                    // Download Qt
                    DownloadHelper.DownloadFileFromURL(QtDownloadURL, destinationFolder + QtZipFilename);

                    message("extracting QT");
                }

                // Extract Qt
                SevenZip.Decompress(destinationFolder + QtZipFilename, destinationFolder);

                // patch qt
                if (compilerType == eCompiler.VS2012 && qtVersion == eQtVersion.Qt4_8_3)
                {
                    // patch Qt 4.8.3
                    message("patching Qt 4.8.3");

                    System.Reflection.Assembly a = System.Reflection.Assembly.GetEntryAssembly();
                    string baseDir         = System.IO.Path.GetDirectoryName(a.Location);
                    string qmakeConfigPath = baseDir + @"\qt4.8.3vs2012patch\qmake.conf";

                    if (!File.Exists(qmakeConfigPath))
                    {
                        throw new Exception("File " + qmakeConfigPath + " does not exist");
                    }

                    File.Copy(
                        qmakeConfigPath,
                        destinationFolder + @"qt-everywhere-opensource-src-4.8.3\mkspecs\win32-msvc2010\qmake.conf", true);

                    File.Copy(
                        @"qt4.8.3vs2012patch\HashSet.h",
                        destinationFolder + @"qt-everywhere-opensource-src-4.8.3\src\3rdparty\webkit\Source\JavaScriptCore\wtf\HashSet.h", true);
                }

                // patch qt
                if (compilerType == eCompiler.VS2012 && qtVersion == eQtVersion.Qt4_8_4)
                {
                    // patch Qt 4.8.4
                    message("patching Qt 4.8.4");

                    System.Reflection.Assembly a = System.Reflection.Assembly.GetEntryAssembly();
                    string baseDir         = System.IO.Path.GetDirectoryName(a.Location);
                    string qmakeConfigPath = baseDir + @"\qt4.8.3vs2012patch\qmake.conf";

                    if (!File.Exists(qmakeConfigPath))
                    {
                        throw new Exception("File " + qmakeConfigPath + " does not exist");
                    }

                    File.Copy(
                        qmakeConfigPath,
                        destinationFolder + @"qt-everywhere-opensource-src-4.8.4\mkspecs\win32-msvc2010\qmake.conf", true);

                    File.Copy(
                        @"qt4.8.3vs2012patch\HashSet.h",
                        destinationFolder + @"qt-everywhere-opensource-src-4.8.4\src\3rdparty\webkit\Source\JavaScriptCore\wtf\HashSet.h", true);
                }

                message("configure qt");

                if (qtVersion == eQtVersion.Qt4_8_3 ||
                    qtVersion == eQtVersion.Qt4_8_4)
                {
                    configureQT4();
                }
                else
                {
                    configureQT5();
                }

                message("building qt");

                buildQT();

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

                message("Finished buidling qt  - - - DONE");

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