Esempio n. 1
0
        /// <summary>
        /// Returns the Windows CE Qt builds which are available.
        /// </summary>
        /// <returns>List of string</returns>
        public ArrayList GetQtWinCEVersions(EnvDTE.DTE dte)
        {
            ArrayList        list = new ArrayList();
            QtVersionManager vm   = QtVersionManager.The();

            foreach (string qtVersion in vm.GetVersions())
            {
                VersionInformation vi           = vm.GetVersionInfo(qtVersion);
                string             platformName = GetWinCEPlatformName(qtVersion, vm);
                if (vi.IsWinCEVersion() && HelperFunctions.IsPlatformAvailable(dte, platformName))
                {
                    list.Add(qtVersion);
                }
            }
            return(list);
        }
Esempio n. 2
0
 public List <string> GetLibs(bool isDebugCfg, VersionInformation vi)
 {
     return(GetLibs(isDebugCfg, vi.IsStaticBuild(), vi.IsWinCEVersion()));
 }
Esempio n. 3
0
 public List<string> GetLibs(bool isDebugCfg, VersionInformation vi)
 {
     return GetLibs(isDebugCfg, vi.IsStaticBuild(), vi.IsWinCEVersion());
 }
Esempio n. 4
0
 private static bool isQtWinCE(VersionInformation vi)
 {
     return vi.IsWinCEVersion();
 }
Esempio n. 5
0
 private static bool isDesktopQt(VersionInformation vi)
 {
     return !vi.IsWinCEVersion();
 }
Esempio n. 6
0
        public void WriteProjectBasicConfigurations(uint type, bool usePrecompiledHeader, VersionInformation vi)
        {
            ConfigurationTypes configType = ConfigurationTypes.typeApplication;
            string targetExtension = ".exe";
            string qtVersion = null;
            QtVersionManager vm = QtVersionManager.The();
            if (vi == null)
            {
                qtVersion = vm.GetDefaultVersion();
                vi = vm.GetVersionInfo(qtVersion);
            }

            switch (type & TemplateType.ProjectType)
            {
                case TemplateType.DynamicLibrary:
                    configType = ConfigurationTypes.typeDynamicLibrary;
                    targetExtension = ".dll";
                    break;
                case TemplateType.StaticLibrary:
                    configType = ConfigurationTypes.typeStaticLibrary;
                    targetExtension = ".lib";
                    break;
            }

            foreach (VCConfiguration config in (IVCCollection)vcPro.Configurations)
            {
                config.ConfigurationType = configType;
                CompilerToolWrapper compiler = CompilerToolWrapper.Create(config);
                VCLinkerTool linker = (VCLinkerTool)((IVCCollection)config.Tools).Item("VCLinkerTool");
                VCLibrarianTool librarian = (VCLibrarianTool)((IVCCollection)config.Tools).Item("VCLibrarianTool");

                // for some stupid reason you have to set this for it to be updated...
                // the default value is the same... +platform now
            #if (VS2010 || VS2012 || VS2013)
                config.OutputDirectory = "$(SolutionDir)$(Platform)\\$(Configuration)\\";
            #else
                config.OutputDirectory = "$(SolutionDir)$(PlatformName)\\$(ConfigurationName)";
            #endif

            #if ENABLE_WINCE
                // This is mainly for Visual Studio consistency compared with a smartdevice MFC project.
                config.IntermediateDirectory = config.OutputDirectory;
            #endif

                // add some common defines
                compiler.SetPreprocessorDefinitions(vi.GetQMakeConfEntry("DEFINES").Replace(" ", ","));

                if (!vi.IsStaticBuild())
                {
                    compiler.AddPreprocessorDefinition("QT_DLL");
                }

                if (linker != null)
                {
                    if (vi.IsWinCEVersion())
                    {
                        linker.SubSystem = subSystemOption.subSystemNotSet;
                        SetTargetMachine(linker, vi);
                    }
                    else
                    {
                        if ((type & TemplateType.ConsoleSystem) != 0)
                            linker.SubSystem = subSystemOption.subSystemConsole;
                        else
                            linker.SubSystem = subSystemOption.subSystemWindows;
                    }
                    linker.OutputFile = "$(OutDir)\\$(ProjectName)" + targetExtension;
                    linker.AdditionalLibraryDirectories = "$(QTDIR)\\lib";
                    if (vi.IsStaticBuild())
                    {
                        linker.AdditionalDependencies = vi.GetQMakeConfEntry("QMAKE_LIBS_CORE");
                        if ((type & TemplateType.GUISystem) != 0)
                        {
                            linker.AdditionalDependencies += " " + vi.GetQMakeConfEntry("QMAKE_LIBS_GUI");
                            if (vi.IsWinCEVersion())
                                linker.AdditionalDependencies += " qmenu_wince.res";
                        }
                    }
                }
                else
                {
                    librarian.OutputFile = "$(OutDir)\\$(ProjectName)" + targetExtension;
                    librarian.AdditionalLibraryDirectories = "$(QTDIR)\\lib";
                }

                if ((type & TemplateType.GUISystem) != 0)
                    compiler.SetAdditionalIncludeDirectories(QtVSIPSettings.GetUicDirectory(envPro) + ";");

                if ((type & TemplateType.PluginProject) != 0)
                {
                    compiler.AddPreprocessorDefinition("QT_PLUGIN");
                }

                bool isDebugConfiguration = false;
                if (config.Name.StartsWith("Release"))
                {
                    compiler.AddPreprocessorDefinition("QT_NO_DEBUG,NDEBUG");
                    compiler.SetDebugInformationFormat(debugOption.debugDisabled);
                    compiler.SetRuntimeLibrary(runtimeLibraryOption.rtMultiThreadedDLL);
                }
                else if (config.Name.StartsWith("Debug"))
                {
                    isDebugConfiguration = true;
                    compiler.SetOptimization(optimizeOption.optimizeDisabled);
                    compiler.SetDebugInformationFormat(debugOption.debugEnabled);
                    compiler.SetRuntimeLibrary(runtimeLibraryOption.rtMultiThreadedDebugDLL);
                }
                compiler.AddAdditionalIncludeDirectories(
                    ".;" + "$(QTDIR)\\include;" + QtVSIPSettings.GetMocDirectory(envPro));

                compiler.SetTreatWChar_tAsBuiltInType(true);

                if (linker != null)
                    linker.GenerateDebugInformation = isDebugConfiguration;

            #if ENABLE_WINCE
                if (vi.IsWinCEVersion())
                {
                    compiler.SetWarningLevel(warningLevelOption.warningLevel_3);
                    compiler.SetBufferSecurityCheck(isDebugConfiguration);
                    DeploymentToolWrapper deploymentTool = DeploymentToolWrapper.Create(config);
                    if (deploymentTool != null)
                    {
                        deploymentTool.AddWinCEMSVCStandardLib(isDebugConfiguration, dte);

                        string signatureFile = vi.GetSignatureFile();
                        if (signatureFile != null)
                        {
                            Object postBuildEventToolObj = ((IVCCollection)config.Tools).Item("VCPostBuildEventTool");
                            VCPostBuildEventTool postBuildEventTool = postBuildEventToolObj as VCPostBuildEventTool;
                            if (postBuildEventTool != null)
                            {
                                string cmdline = postBuildEventTool.CommandLine;
                                if (cmdline == null)
                                    cmdline = "";
                                if (cmdline.Length > 0)
                                    postBuildEventTool.CommandLine += "\n";
                                cmdline += "signtool sign /F " + signatureFile + " \"$(TargetPath)\"";
                                postBuildEventTool.CommandLine = cmdline;
                            }
                        }
                    }
                    IVCCollection tools = ((IVCCollection)config.Tools);
                    object cst = tools.Item("VCCodeSignTool");
                    if (cst != null)
                    {
                        Type t = cst.GetType();
                        object r = t.InvokeMember("ExecutionBucket",
                            System.Reflection.BindingFlags.GetProperty,
                            null, cst, null);
                        if (r != null)
                            config.ExcludeBuckets = r.ToString();
                    }
                }
            #endif

                if (usePrecompiledHeader)
                    UsePrecompiledHeaders(config);
            }
            if ((type & TemplateType.PluginProject) != 0)
                MarkAsDesignerPluginProject();
        }
Esempio n. 7
0
        public void UpdateModules(VersionInformation oldVersion, VersionInformation newVersion)
        {
            foreach (VCConfiguration config in (IVCCollection)vcPro.Configurations)
            {
                VCLinkerTool linker = (VCLinkerTool)((IVCCollection)config.Tools).Item("VCLinkerTool");

                if (linker != null)
                {
                    if (oldVersion == null || oldVersion.IsWinCEVersion() != newVersion.IsWinCEVersion())
                    {
                        LinkerToolWrapper linkerWrapper = new LinkerToolWrapper(linker);
                        List<string> additionalDependencies = linkerWrapper.AdditionalDependencies;

                        List<string> libsDesktop = new List<string>();
                        List<string> libsWinCE = new List<string>();
                        foreach (QtModuleInfo module in QtModules.Instance.GetAvailableModuleInformation())
                        {
                            if (HasModule(module.ModuleId))
                            {
                                libsDesktop.AddRange(module.AdditionalLibraries);
                                libsWinCE.AddRange(module.AdditionalLibrariesWinCE);
                            }
                        }
                        List<string> libsToAdd = null;
                        List<string> libsToRemove = null;
                        if (newVersion.IsWinCEVersion())
                        {
                            libsToAdd = libsWinCE;
                            libsToRemove = libsDesktop;
                        }
                        else
                        {
                            libsToAdd = libsDesktop;
                            libsToRemove = libsWinCE;
                        }

                        bool changed = false;
                        foreach (string libToRemove in libsToRemove)
                        {
                            if (additionalDependencies.Remove(libToRemove))
                                changed = true;
                        }
                        foreach (string libToAdd in libsToAdd)
                        {
                            if (!additionalDependencies.Contains(libToAdd))
                            {
                                additionalDependencies.Add(libToAdd);
                                changed = true;
                            }
                        }
                        if (changed)
                            linkerWrapper.AdditionalDependencies = additionalDependencies;
                    }

            #if ENABLE_WINCE
                    if (newVersion.IsWinCEVersion() && newVersion.IsStaticBuild() &&
                        oldVersion != null &&
                        !(oldVersion.IsWinCEVersion() && oldVersion.IsStaticBuild()) &&
                        config.DeploymentTool != null)
                    {
                        RemoveQtDeploys(config);
                    }
            #endif

                    if (oldVersion == null || newVersion.IsStaticBuild() != oldVersion.IsStaticBuild())
                    {
                        CompilerToolWrapper compiler = CompilerToolWrapper.Create(config);
                        if (newVersion.IsStaticBuild())
                        {
                            if (compiler != null)
                                compiler.RemovePreprocessorDefinition("QT_DLL");
                        }
                        else
                        {
                            if (compiler != null)
                                compiler.AddPreprocessorDefinition("QT_DLL");
                        }
                    }

            #if ENABLE_WINCE
                    if (newVersion.IsWinCEVersion() && !newVersion.IsStaticBuild() &&
                        (oldVersion == null ||
                        !(oldVersion.IsWinCEVersion() && !oldVersion.IsStaticBuild())) &&
                        config.DeploymentTool != null)
                    {
                        MatchCollection matches = Regex.Matches(linker.AdditionalDependencies, "Qt(\\S+)5\\.lib");
                        foreach (Match m in matches)
                        {
                            string moduleName = m.ToString().Substring(0, m.ToString().Length - 5);
                            if (config.ConfigurationName.StartsWith("Debug"))
                                moduleName = moduleName.Substring(0, moduleName.Length - 1);
                            QtModule module = QtModules.Instance.ModuleIdByName(moduleName);
                            AddDeploySettings(null, module, config, null, newVersion);
                        }
                    }
            #endif
                }
            }
        }
Esempio n. 8
0
        public void SetupConfiguration(VCConfiguration config, VersionInformation viNew)
        {
            bool isWinPlatform = (!viNew.IsWinCEVersion());

            CompilerToolWrapper compiler = CompilerToolWrapper.Create(config);
            SimpleSet ppdefs = new SimpleSet(compiler.PreprocessorDefinitions);
            ICollection newPPDefs = viNew.GetQMakeConfEntry("DEFINES").Split(new char[] { ' ', '\t' });
            compiler.SetPreprocessorDefinitions(ppdefs.Union(newPPDefs).JoinElements(','));

            #if ENABLE_WINCE
            // search prepocessor definitions for Qt modules and add deployment settings
            if (!isWinPlatform)
            {
                DeploymentToolWrapper deploymentTool = DeploymentToolWrapper.Create(config);
                if (deploymentTool != null)
                {
                    deploymentTool.Clear();
                    deploymentTool.AddWinCEMSVCStandardLib(IsDebugConfiguration(config), dte);

                    List<QtModuleInfo> availableQtModules = QtModules.Instance.GetAvailableModuleInformation();
                    foreach (string s in ppdefs.Elements)
                    {
                        foreach (QtModuleInfo moduleInfo in availableQtModules)
                        {
                            if (moduleInfo.Defines.Contains(s))
                                AddDeploySettings(deploymentTool, moduleInfo.ModuleId, config, null, viNew);
                        }
                    }
                }
            }
            #endif

            VCLinkerTool linker = (VCLinkerTool)((IVCCollection)config.Tools).Item("VCLinkerTool");
            if (linker == null)
                return;

            if (isWinPlatform)
                linker.SubSystem = subSystemOption.subSystemWindows;
            else
                linker.SubSystem = subSystemOption.subSystemNotSet;

            SetTargetMachine(linker, viNew);
        }
        private void okButton_Click(object sender, EventArgs e)
        {
            QtVersionManager vm = QtVersionManager.The();
            VersionInformation versionInfo = null;
            try
            {
                versionInfo = new VersionInformation(pathBox.Text);
            }
            catch (Exception exception)
            {
                if (nameBox.Text == "$(QTDIR)")
                {
                    string defaultVersion = vm.GetDefaultVersion();
                    versionInfo = vm.GetVersionInfo(defaultVersion);
                }
                else
                {
                    Messages.DisplayErrorMessage(exception.Message);
                    return;
                }
            }

            if (versionInfo.IsWinCEVersion())
            {
                // check whether we have an SDK installed for this platform
                string platformName = versionInfo.GetVSPlatformName();
                if (!HelperFunctions.IsPlatformAvailable(Connect._applicationObject, platformName))
                {
                    MessageBox.Show(SR.GetString("AddQtVersionDialog_PlatformNotFoundError", platformName),
                                    null, MessageBoxButtons.OK,
                                    MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    return;
                }
            }

            string makefileGenerator = versionInfo.GetQMakeConfEntry("MAKEFILE_GENERATOR");
            if (makefileGenerator != "MSVC.NET" && makefileGenerator != "MSBUILD")
            {
                MessageBox.Show(SR.GetString("AddQtVersionDialog_IncorrectMakefileGenerator", makefileGenerator),
                                            null, MessageBoxButtons.OK,
                                            MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                return;
            }
            vm.SaveVersion(nameBox.Text, pathBox.Text);
            DialogResult = DialogResult.OK;
            Close();
        }