From 1ef6c140ec7efc202e253f4072cd019f5c03b745 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 14 Feb 2012 10:19:02 +0000 Subject: [PATCH] Introjucer: added an option for setting custom Xcode flags. Cleaned up some MSVC library naming settings. --- .../Project Saving/jucer_ProjectExport_MSVC.h | 105 +++++++++++------- .../jucer_ProjectExport_XCode.h | 10 ++ .../Project Saving/jucer_ProjectExporter.cpp | 12 +- .../Source/Utility/jucer_PresetIDs.h | 3 +- 4 files changed, 81 insertions(+), 49 deletions(-) diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h index 256fd7d156..d5b41070b8 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h @@ -33,7 +33,6 @@ class MSVCProjectExporterBase : public ProjectExporter { public: - //============================================================================== MSVCProjectExporterBase (Project& project_, const ValueTree& settings_, const char* const folderName) : ProjectExporter (project_, settings_), hasIcon (false) { @@ -45,14 +44,7 @@ public: projectGUID = createGUID (project.getProjectUID()); - const String oldStylePrebuildCommand (getSetting (Ids::prebuildCommand).toString()); - if (oldStylePrebuildCommand.isNotEmpty()) // update an old project format.. - { - for (ConfigIterator config (*this); config.next();) - dynamic_cast (*config).getPrebuildCommand() = oldStylePrebuildCommand; - - settings.removeProperty (Ids::prebuildCommand, nullptr); - } + updateOldSettings(); } //============================================================================== @@ -71,14 +63,6 @@ public: const int libTypeValues[] = { 1, 2, 0 }; props.add (new ChoicePropertyComponent (getLibraryType(), "Library Type", StringArray (libTypes), Array (libTypeValues))); - - props.add (new TextPropertyComponent (getSetting (Ids::libraryName_Debug), "Library Name (Debug)", 128, false), - "If set, this name will override the binary name specified in the configuration settings, for a debug build. " - "You must include the .lib or .dll suffix on this filename."); - - props.add (new TextPropertyComponent (getSetting (Ids::libraryName_Release), "Library Name (Release)", 128, false), - "If set, this name will override the binary name specified in the configuration settings, for a release build. " - "You must include the .lib or .dll suffix on this filename."); } } @@ -92,6 +76,38 @@ protected: Value getLibraryType() const { return getSetting (Ids::libraryType); } bool isLibraryDLL() const { return msvcIsDLL || (projectType.isLibrary() && getLibraryType() == 2); } + void updateOldSettings() + { + { + const String oldStylePrebuildCommand (getSetting (Ids::prebuildCommand).toString()); + settings.removeProperty (Ids::prebuildCommand, nullptr); + + if (oldStylePrebuildCommand.isNotEmpty()) + for (ConfigIterator config (*this); config.next();) + dynamic_cast (*config).getPrebuildCommand() = oldStylePrebuildCommand; + } + + { + const String oldStyleLibName (getSetting ("libraryName_Debug").toString()); + settings.removeProperty ("libraryName_Debug", nullptr); + + if (oldStyleLibName.isNotEmpty()) + for (ConfigIterator config (*this); config.next();) + if (config->isDebug().getValue()) + config->getTargetBinaryName() = oldStyleLibName; + } + + { + const String oldStyleLibName (getSetting ("libraryName_Release").toString()); + settings.removeProperty ("libraryName_Release", nullptr); + + if (oldStyleLibName.isNotEmpty()) + for (ConfigIterator config (*this); config.next();) + if (! config->isDebug().getValue()) + config->getTargetBinaryName() = oldStyleLibName; + } + } + //============================================================================== class MSVCBuildConfiguration : public BuildConfiguration { @@ -117,6 +133,16 @@ protected: Value shouldGenerateManifest() const { return getValue (Ids::generateManifest); } + String getOutputFilename (const String& suffix, bool forceSuffix) const + { + const String target (File::createLegalFileName (getTargetBinaryName().toString().trim())); + + if (forceSuffix || ! target.containsChar ('.')) + return target.upToLastOccurrenceOf (".", false, false) + suffix; + + return target; + } + void createPropertyEditors (PropertyListBuilder& props) { createBasicPropertyEditors (props); @@ -205,15 +231,6 @@ protected: return searchPaths; } - String getBinaryFileForConfig (const BuildConfiguration& config) const - { - const String targetBinary (getSetting (config.isDebug().getValue() ? Ids::libraryName_Debug : Ids::libraryName_Release).toString().trim()); - if (targetBinary.isNotEmpty()) - return targetBinary; - - return config.getTargetBinaryName().toString() + msvcTargetSuffix; - } - virtual String createConfigName (const BuildConfiguration& config) const { return config.getName().toString() + "|Win32"; @@ -577,7 +594,6 @@ protected: String binariesPath (getConfigTargetPath (config)); String intermediatesPath (getIntermediatesPath (config)); const bool isDebug = (bool) config.isDebug().getValue(); - const String binaryName (File::createLegalFileName (config.getTargetBinaryName().toString())); xml.setAttribute ("Name", createConfigName (config)); xml.setAttribute ("OutputDirectory", FileHelpers::windowsStylePath (binariesPath)); @@ -609,7 +625,8 @@ protected: midl->setAttribute ("MkTypLibCompatible", "true"); midl->setAttribute ("SuppressStartupBanner", "true"); midl->setAttribute ("TargetEnvironment", "1"); - midl->setAttribute ("TypeLibraryName", FileHelpers::windowsStylePath (intermediatesPath + "/" + binaryName + ".tlb")); + midl->setAttribute ("TypeLibraryName", FileHelpers::windowsStylePath (intermediatesPath + "/" + + config.getOutputFilename (".tlb", true))); midl->setAttribute ("HeaderFileName", ""); } @@ -636,7 +653,8 @@ protected: : (isDebug ? 1 : 0)); // MT static compiler->setAttribute ("RuntimeTypeInfo", "true"); compiler->setAttribute ("UsePrecompiledHeader", "0"); - compiler->setAttribute ("PrecompiledHeaderFile", FileHelpers::windowsStylePath (intermediatesPath + "/" + binaryName + ".pch")); + compiler->setAttribute ("PrecompiledHeaderFile", FileHelpers::windowsStylePath (intermediatesPath + "/" + + config.getOutputFilename (".pch", true))); compiler->setAttribute ("AssemblerListingLocation", FileHelpers::windowsStylePath (intermediatesPath + "/")); compiler->setAttribute ("ObjectFile", FileHelpers::windowsStylePath (intermediatesPath + "/")); compiler->setAttribute ("ProgramDataBaseFileName", FileHelpers::windowsStylePath (intermediatesPath + "/")); @@ -657,18 +675,17 @@ protected: createToolElement (xml, "VCPreLinkEventTool"); - const String outputFileName (getBinaryFileForConfig (config)); - if (! projectType.isLibrary()) { XmlElement* linker = createToolElement (xml, "VCLinkerTool"); - linker->setAttribute ("OutputFile", FileHelpers::windowsStylePath (binariesPath + "/" + outputFileName)); + linker->setAttribute ("OutputFile", FileHelpers::windowsStylePath (binariesPath + "/" + config.getOutputFilename (msvcTargetSuffix, false))); linker->setAttribute ("SuppressStartupBanner", "true"); linker->setAttribute ("IgnoreDefaultLibraryNames", isDebug ? "libcmt.lib, msvcrt.lib" : ""); linker->setAttribute ("GenerateDebugInformation", isDebug ? "true" : "false"); - linker->setAttribute ("ProgramDatabaseFile", FileHelpers::windowsStylePath (intermediatesPath + "/" + binaryName + ".pdb")); + linker->setAttribute ("ProgramDatabaseFile", FileHelpers::windowsStylePath (intermediatesPath + "/" + + config.getOutputFilename (".pdb", true))); linker->setAttribute ("SubSystem", msvcIsWindowsSubsystem ? "2" : "1"); const StringArray librarySearchPaths (config.getLibrarySearchPaths()); @@ -706,17 +723,17 @@ protected: XmlElement* linker = createToolElement (xml, "VCLinkerTool"); String extraLinkerOptions (getExtraLinkerFlags().toString()); - extraLinkerOptions << " /IMPLIB:" << FileHelpers::windowsStylePath (binariesPath + "/" + outputFileName.upToLastOccurrenceOf (".", false, false) + ".lib"); + extraLinkerOptions << " /IMPLIB:" << FileHelpers::windowsStylePath (binariesPath + "/" + config.getOutputFilename (".lib", true)); linker->setAttribute ("AdditionalOptions", replacePreprocessorTokens (config, extraLinkerOptions).trim()); - linker->setAttribute ("OutputFile", FileHelpers::windowsStylePath (binariesPath + "/" + outputFileName)); + linker->setAttribute ("OutputFile", FileHelpers::windowsStylePath (binariesPath + "/" + config.getOutputFilename (msvcTargetSuffix, false))); linker->setAttribute ("IgnoreDefaultLibraryNames", isDebug ? "libcmt.lib, msvcrt.lib" : ""); } else { XmlElement* librarian = createToolElement (xml, "VCLibrarianTool"); - librarian->setAttribute ("OutputFile", FileHelpers::windowsStylePath (binariesPath + "/" + outputFileName)); + librarian->setAttribute ("OutputFile", FileHelpers::windowsStylePath (binariesPath + "/" + config.getOutputFilename (msvcTargetSuffix, false))); librarian->setAttribute ("IgnoreDefaultLibraryNames", isDebug ? "libcmt.lib, msvcrt.lib" : ""); } } @@ -728,7 +745,8 @@ protected: { XmlElement* bscMake = createToolElement (xml, "VCBscMakeTool"); bscMake->setAttribute ("SuppressStartupBanner", "true"); - bscMake->setAttribute ("OutputFile", FileHelpers::windowsStylePath (intermediatesPath + "/" + binaryName + ".bsc")); + bscMake->setAttribute ("OutputFile", FileHelpers::windowsStylePath (intermediatesPath + "/" + + config.getOutputFilename (".bsc", true))); } createToolElement (xml, "VCFxCopTool"); @@ -1001,7 +1019,7 @@ protected: { XmlElement* name = props->createNewChildElement ("TargetName"); setConditionAttribute (*name, config); - name->addTextElement (getBinaryFileForConfig (config).upToLastOccurrenceOf (".", false, false)); + name->addTextElement (config.getOutputFilename (String::empty, true)); } { @@ -1028,8 +1046,6 @@ protected: String binariesPath (getConfigTargetPath (config)); String intermediatesPath (getIntermediatesPath (config)); const bool isDebug = (bool) config.isDebug().getValue(); - const String binaryName (File::createLegalFileName (config.getTargetBinaryName().toString())); - const String outputFileName (getBinaryFileForConfig (config)); XmlElement* group = projectXml.createNewChildElement ("ItemDefinitionGroup"); setConditionAttribute (*group, config); @@ -1080,12 +1096,14 @@ protected: { XmlElement* link = group->createNewChildElement ("Link"); - link->createNewChildElement ("OutputFile")->addTextElement (FileHelpers::windowsStylePath (binariesPath + "/" + outputFileName)); + link->createNewChildElement ("OutputFile") + ->addTextElement (FileHelpers::windowsStylePath (binariesPath + "/" + config.getOutputFilename (msvcTargetSuffix, false))); link->createNewChildElement ("SuppressStartupBanner")->addTextElement ("true"); link->createNewChildElement ("IgnoreSpecificDefaultLibraries")->addTextElement (isDebug ? "libcmt.lib; msvcrt.lib;;%(IgnoreSpecificDefaultLibraries)" : "%(IgnoreSpecificDefaultLibraries)"); link->createNewChildElement ("GenerateDebugInformation")->addTextElement (isDebug ? "true" : "false"); - link->createNewChildElement ("ProgramDatabaseFile")->addTextElement (FileHelpers::windowsStylePath (intermediatesPath + "/" + binaryName + ".pdb")); + link->createNewChildElement ("ProgramDatabaseFile")->addTextElement (FileHelpers::windowsStylePath (intermediatesPath + "/" + + config.getOutputFilename (".pdb", true))); link->createNewChildElement ("SubSystem")->addTextElement (msvcIsWindowsSubsystem ? "Windows" : "Console"); if (! is64Bit (config)) @@ -1106,7 +1124,8 @@ protected: { XmlElement* bsc = group->createNewChildElement ("Bscmake"); bsc->createNewChildElement ("SuppressStartupBanner")->addTextElement ("true"); - bsc->createNewChildElement ("OutputFile")->addTextElement (FileHelpers::windowsStylePath (intermediatesPath + "/" + binaryName + ".bsc")); + bsc->createNewChildElement ("OutputFile")->addTextElement (FileHelpers::windowsStylePath (intermediatesPath + + "/" + config.getOutputFilename (".bsc", true))); } if (config.msvcPreBuildCommand.isNotEmpty()) diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h index f8a76a1536..792a8c80ca 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h @@ -174,6 +174,7 @@ protected: Value getMacSDKVersion() const { return getValue (Ids::osxSDK); } Value getMacCompatibilityVersion() const { return getValue (Ids::osxCompatibility); } Value getMacArchitecture() const { return getValue (Ids::osxArchitecture); } + Value getCustomXcodeFlags() const { return getValue (Ids::customXcodeFlags); } void createPropertyEditors (PropertyListBuilder& props) { @@ -202,6 +203,10 @@ protected: props.add (new ChoicePropertyComponent (getMacArchitecture(), "OSX Architecture", StringArray (osxArch), Array (osxArchValues)), "The type of OSX binary that will be produced."); + + props.add (new TextPropertyComponent (getCustomXcodeFlags(), "Custom Xcode flags", 8192, false), + "A comma-separated list of custom Xcode setting flags which will be appended to the list of generated flags, " + "e.g. MACOSX_DEPLOYMENT_TARGET_i386 = 10.5, VALID_ARCHS = \"ppc i386 x86_64\""); } }; @@ -688,6 +693,11 @@ private: s.add ("GCC_PREPROCESSOR_DEFINITIONS = (" + indentList (defsList, ",") + ")"); } + s.addTokens (config.getCustomXcodeFlags().toString(), ",", "\"'"); + s.trim(); + s.removeEmptyStrings(); + s.removeDuplicates (false); + return s; } diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp b/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp index c73ebe0abf..06ae540487 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp @@ -464,14 +464,17 @@ void ProjectExporter::BuildConfiguration::createBasicPropertyEditors (PropertyLi const char* optimisationLevels[] = { "No optimisation", "Optimise for size and speed", "Optimise for maximum speed", 0 }; const int optimisationLevelValues[] = { 1, 2, 3, 0 }; - props.add (new ChoicePropertyComponent (getOptimisationLevel(), "Optimisation", StringArray (optimisationLevels), Array (optimisationLevelValues)), + props.add (new ChoicePropertyComponent (getOptimisationLevel(), "Optimisation", + StringArray (optimisationLevels), Array (optimisationLevelValues)), "The optimisation level for this configuration"); props.add (new TextPropertyComponent (getTargetBinaryName(), "Binary name", 256, false), - "The filename to use for the destination binary executable file. Don't add a suffix to this, because platform-specific suffixes will be added for each target platform."); + "The filename to use for the destination binary executable file. If you don't add a suffix to this name, " + "a suitable platform-specific suffix will be added automatically."); props.add (new TextPropertyComponent (getTargetBinaryRelativePath(), "Binary location", 1024, false), - "The folder in which the finished binary should be placed. Leave this blank to cause the binary to be placed in its default location in the build folder."); + "The folder in which the finished binary should be placed. Leave this blank to cause the binary to be placed " + "in its default location in the build folder."); props.add (new TextPropertyComponent (getHeaderSearchPath(), "Header search paths", 16384, false), "Extra header search paths. Use semi-colons to separate multiple paths."); @@ -480,7 +483,8 @@ void ProjectExporter::BuildConfiguration::createBasicPropertyEditors (PropertyLi "Extra library search paths. Use semi-colons to separate multiple paths."); props.add (new TextPropertyComponent (getBuildConfigPreprocessorDefs(), "Preprocessor definitions", 32768, false), - "Extra preprocessor definitions. Use the form \"NAME1=value NAME2=value\", using whitespace or commas to separate the items - to include a space or comma in a definition, precede it with a backslash."); + "Extra preprocessor definitions. Use the form \"NAME1=value NAME2=value\", using whitespace or commas to separate " + "the items - to include a space or comma in a definition, precede it with a backslash."); props.setPreferredHeight (22); } diff --git a/extras/Introjucer/Source/Utility/jucer_PresetIDs.h b/extras/Introjucer/Source/Utility/jucer_PresetIDs.h index f89681b48f..1df73c0a9c 100644 --- a/extras/Introjucer/Source/Utility/jucer_PresetIDs.h +++ b/extras/Introjucer/Source/Utility/jucer_PresetIDs.h @@ -49,8 +49,6 @@ namespace Ids DECLARE_ID (extraCompilerFlags); DECLARE_ID (extraLinkerFlags); DECLARE_ID (extraDefs); - DECLARE_ID (libraryName_Debug); - DECLARE_ID (libraryName_Release); DECLARE_ID (libraryType); DECLARE_ID (isDebug); DECLARE_ID (targetName); @@ -59,6 +57,7 @@ namespace Ids DECLARE_ID (defines); DECLARE_ID (headerPath); DECLARE_ID (libraryPath); + DECLARE_ID (customXcodeFlags); DECLARE_ID (osxSDK); DECLARE_ID (osxCompatibility); DECLARE_ID (osxArchitecture);