Esempio n. 1
0
        public void DownloadAndBuild()
        {
            try
            {
                if (!Directory.Exists(destinationFolder))
                {
                    Directory.CreateDirectory(destinationFolder);
                }

                // Boost.IOStreams Zlib filters see http://stackoverflow.com/questions/2629421/how-to-use-boost-in-visual-studio-2010
                bool bBuildBoostIOStreams = false;
                if (bBuildBoostIOStreams)
                {
                    message("Downloading zlib127...");
                    DownloadHelper.DownloadFileFromURL(@"http://zlib.net/zlib127.zip", destinationFolder + "zlib127.zip");
                    message("Start to unzip zlib127...");
                    // Unzip zlib127
                    SevenZip.Decompress(destinationFolder + "/" + "zlib127.zip", destinationFolder);

                    string ZLIB_SOURCE  = destinationFolder + "zlib127";
                    string ZLIB_INCLUDE = destinationFolder + "zlib127";
                }

                message("Downloading boost...");

                string boostDownloadURL = BoostInfo.GetDownloadURL(boostVersion);
                string boostZIPFilename = BoostInfo.GetBoostZipFileName(boostVersion);
                if (boostVersion == eBoostVersion.FromSourceSVN)
                {
                    string boostFromSourceSVNFolderPath = Path.Combine(destinationFolder, BoostHelper.BoostFromSourceSVNFolderName);
                    DownloadHelper.CheckOutFromSourceSVN("svn", boostDownloadURL, boostFromSourceSVNFolderPath);
                }
                else
                {
                    DownloadHelper.DownloadFileFromURL(boostDownloadURL, destinationFolder + boostZIPFilename);

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

                    if (boostVersion == eBoostVersion.Boost1_51_0)
                    {
                        FileInfo fi         = new FileInfo(destinationFolder + boostZIPFilename);
                        long     fileLength = fi.Length;

                        if (fileLength != 91365553)
                        {
                            MessageBox.Show("Invalid file size of " + boostZIPFilename + " Size in bytes should be 91365553");
                        }
                    }

                    // Unzip Boost
                    SevenZip.Decompress(destinationFolder + "/" + boostZIPFilename, destinationFolder);

                    message("boost has been unzipped!");
                }

                if (boostVersion == eBoostVersion.Boost1_54_0 || compilerType == eCompiler.VS2013)
                {
                    // patch boost!
                    // https://svn.boost.org/trac/boost/attachment/ticket/8750/vc12.patch
                }

                if (boostVersion == eBoostVersion.Boost1_58_0 && compilerType == eCompiler.VS2015)
                {
                    message("Patching boost 1.58.0 config file to support VS2015.");
                    // patch boost!
                    // http://stackoverflow.com/questions/30760889/c-c-unknown-compiler-version-while-compiling-boost-with-msvc-14-0-vs-2015/30959156#30959156
                    File.Copy(@"boost1.58.0patch\vc14_visualc.hpp", destinationFolder + @"\boost_1_58_0\boost\config\compiler\visualc.hpp", true);
                }

                message("start building boost...");

                // Build boost
                if (boostVersion == eBoostVersion.Boost1_51_0 || boostVersion == eBoostVersion.Boost1_44_0)
                {
                    buildBoost_1_51_0_x64(destinationFolder);
                }
                else
                {
                    bootstrapBoost_1_52_0_AndLaterVersion();
                    buildBoost_1_52_0_AndLaterVersion();
                }

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

                message("boost successfully built!");


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