private static void SetTargetMachine(VCLinkerTool linker, VersionInformation versionInfo) { String qMakeLFlagsWindows = versionInfo.GetQMakeConfEntry("QMAKE_LFLAGS_WINDOWS"); Regex rex = new Regex("/MACHINE:(\\S+)"); Match match = rex.Match(qMakeLFlagsWindows); if (match.Success) { linker.TargetMachine = HelperFunctions.TranslateMachineType(match.Groups[1].Value); } else { string platformName = versionInfo.GetVSPlatformName(); if (platformName == "Win32") linker.TargetMachine = machineTypeOption.machineX86; else if (platformName == "x64") linker.TargetMachine = machineTypeOption.machineAMD64; else linker.TargetMachine = machineTypeOption.machineNotSet; } String subsystemOption = ""; String linkerOptions = linker.AdditionalOptions; if (linkerOptions == null) linkerOptions = ""; rex = new Regex("(/SUBSYSTEM:\\S+)"); match = rex.Match(qMakeLFlagsWindows); if (match.Success) subsystemOption = match.Groups[1].Value; match = rex.Match(linkerOptions); if (match.Success) { linkerOptions = rex.Replace(linkerOptions, subsystemOption); } else { if (linkerOptions.Length > 0) linkerOptions += " "; linkerOptions += subsystemOption; } linker.AdditionalOptions = linkerOptions; }
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(); }
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); }
public static void RemovePlatformDependencies(VCConfiguration config, VersionInformation viOld) { CompilerToolWrapper compiler = CompilerToolWrapper.Create(config); SimpleSet minuend = new SimpleSet(compiler.PreprocessorDefinitions); SimpleSet subtrahend = new SimpleSet(viOld.GetQMakeConfEntry("DEFINES").Split(new char[] { ' ', '\t' })); compiler.SetPreprocessorDefinitions(minuend.Minus(subtrahend).JoinElements(',')); }
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(); }