92 | | // Map containing a project-specific list of warnings |
93 | | // TODO: Remove the use of global variables |
94 | | std::map<std::string, std::string> g_projectWarnings; |
95 | | std::string g_globalWarnings; |
| 92 | /** |
| 93 | * Structure representing a file tree. This contains two |
| 94 | * members: name and children. "name" holds the name of |
| 95 | * the node. "children" does contain all the node's children. |
| 96 | * When the list "children" is empty, the node is a file entry, |
| 97 | * otherwise it's a directory. |
| 98 | */ |
| 99 | struct FileNode { |
| 100 | typedef std::list<FileNode *> NodeList; |
| 101 | |
| 102 | FileNode(const std::string &n) : name(n), children() {} |
| 103 | |
| 104 | ~FileNode() { |
| 105 | for (NodeList::iterator i = children.begin(); i != children.end(); ++i) |
| 106 | delete *i; |
| 107 | } |
| 108 | |
| 109 | std::string name; ///< Name of the node |
| 110 | NodeList children; ///< List of children for the node |
| 111 | }; |
| 112 | |
| 113 | /** |
| 114 | * Structure for describing an FSNode. This is a very minimalistic |
| 115 | * description, which includes everything we need. |
| 116 | * It only contains the name of the node and whether it is a directory |
| 117 | * or not. |
| 118 | */ |
| 119 | struct FSNode { |
| 120 | FSNode() : name(), isDirectory(false) {} |
| 121 | FSNode(const std::string &n, bool iD) : name(n), isDirectory(iD) {} |
| 122 | |
| 123 | std::string name; ///< Name of the file system node |
| 124 | bool isDirectory; ///< Whether it is a directory or not |
| 125 | }; |
| 126 | |
| 127 | typedef std::list<FSNode> FileList; |
| 128 | |
| 129 | class ProjectProvider { |
| 130 | public: |
| 131 | typedef std::map<std::string, std::string> UUIDMap; |
| 132 | |
| 133 | protected: |
| 134 | const int _version; ///< Target MSVC version |
| 135 | std::string _globalWarnings; ///< Global warnings |
| 136 | std::map<std::string, std::string> _projectWarnings; ///< Per-project warnings |
| 137 | |
| 138 | UUIDMap _uuidMap; ///< List of (project name, UUID) pairs |
| 139 | |
| 140 | public: |
| 141 | /** |
| 142 | * Instantiate new ProjectProvider class |
| 143 | * |
| 144 | * @param version Target MSVC version. |
| 145 | */ |
| 146 | ProjectProvider(const int version, std::string global_warnings, std::map<std::string, std::string> project_warnings); |
| 147 | virtual ~ProjectProvider() {} |
| 148 | |
| 149 | /** |
| 150 | * Creates all MSVC build files: the solution |
| 151 | * for all projects, all projects itself and the |
| 152 | * global config files. |
| 153 | * |
| 154 | * @param setup Description of the desired build setup. |
| 155 | */ |
| 156 | void createMSVCProject(const BuildSetup &setup); |
| 157 | |
| 158 | /** |
| 159 | * Creates the main solution file "scummvm.sln" for a specific |
| 160 | * build setup. |
| 161 | * |
| 162 | * @param setup Description of the desired build. |
| 163 | */ |
| 164 | void createScummVMSolution(const BuildSetup &setup); |
| 165 | |
| 166 | /** |
| 167 | * Create a project file for the specified list of files. |
| 168 | * |
| 169 | * @param name Name of the project file. |
| 170 | * @param uuid UUID of the project file. |
| 171 | * @param setup Description of the desired build. |
| 172 | * @param moduleDir Path to the module. |
| 173 | * @param includeList Files to include (must have "moduleDir" as prefix). |
| 174 | * @param excludeList Files to exclude (must have "moduleDir" as prefix). |
| 175 | */ |
| 176 | virtual void createProjectFile(const std::string &name, const std::string &uuid, const BuildSetup &setup, const std::string &moduleDir, |
| 177 | const StringList &includeList, const StringList &excludeList) = 0; |
| 178 | |
| 179 | /** |
| 180 | * Writes file entries for the specified directory node into |
| 181 | * the given project file. It will also take care of duplicate |
| 182 | * object files. |
| 183 | * |
| 184 | * @param dir Directory node. |
| 185 | * @param projectFile File stream to write to. |
| 186 | * @param indentation Indentation level to use. |
| 187 | * @param duplicate List of duplicate object file names. |
| 188 | * @param objPrefix Prefix to use for object files, which would name clash. |
| 189 | * @param filePrefix Generic prefix to all files of the node. |
| 190 | */ |
| 191 | virtual void writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int indentation, |
| 192 | const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix) = 0; |
| 193 | |
| 194 | /** |
| 195 | * Output a list of project references to the file stream |
| 196 | * |
| 197 | * @param output File stream to write to. |
| 198 | */ |
| 199 | virtual void writeReferences(std::ofstream &output) = 0; |
| 200 | |
| 201 | /** |
| 202 | * Outputs a property file based on the input parameters. |
| 203 | * |
| 204 | * It can be easily used to create different global properties files |
| 205 | * for a 64 bit and a 32 bit version. It will also take care that the |
| 206 | * two platform configurations will output their files into different |
| 207 | * directories. |
| 208 | * |
| 209 | * @param properties File stream in which to write the property settings. |
| 210 | * @param bits Number of bits the platform supports. |
| 211 | * @param defines Defines the platform needs to have set. |
| 212 | * @param prefix File prefix, used to add additional include paths. |
| 213 | */ |
| 214 | virtual void outputGlobalPropFile(std::ofstream &properties, int bits, const std::string &defines, const std::string &prefix) = 0; |
| 215 | |
| 216 | /** |
| 217 | * Generates the project properties for debug and release settings. |
| 218 | * |
| 219 | * @param setup Description of the desired build setup. |
| 220 | */ |
| 221 | virtual void createBuildProp(const BuildSetup &setup) = 0; |
| 222 | |
| 223 | /** |
| 224 | * Get the file extension for project files |
| 225 | */ |
| 226 | virtual const char *getProjectExtension() = 0; |
| 227 | |
| 228 | /** |
| 229 | * Get the file extension for property files |
| 230 | */ |
| 231 | virtual const char *getPropertiesExtension() = 0; |
| 232 | |
| 233 | /** |
| 234 | * Get the Visual Studio version (used by the VS shell extension to launch the correct VS version) |
| 235 | */ |
| 236 | virtual int getVisualStudioVersion() = 0; |
| 237 | |
| 238 | /** |
| 239 | * Create the global project properties. |
| 240 | * |
| 241 | * @param setup Description of the desired build setup. |
| 242 | */ |
| 243 | void createGlobalProp(const BuildSetup &setup); |
| 244 | |
| 245 | /** |
| 246 | * Adds files of the specified directory recursively to given project file. |
| 247 | * |
| 248 | * @param dir Path to the directory. |
| 249 | * @param projectFile Output stream object, where all data should be written to. |
| 250 | * @param includeList Files to include (must have a relative directory as prefix). |
| 251 | * @param excludeList Files to exclude (must have a relative directory as prefix). |
| 252 | * @param filePrefix Prefix to use for relative path arguments. |
| 253 | */ |
| 254 | void addFilesToProject(const std::string &dir, std::ofstream &projectFile, |
| 255 | const StringList &includeList, const StringList &excludeList, |
| 256 | const std::string &filePrefix); |
| 257 | |
| 258 | /** |
| 259 | * Creates a list of files of the specified module. This also |
| 260 | * creates a list of files, which should not be included. |
| 261 | * All filenames will have "moduleDir" as prefix. |
| 262 | * |
| 263 | * @param moduleDir Path to the module. |
| 264 | * @param defines List of set defines. |
| 265 | * @param includeList Reference to a list, where included files should be added. |
| 266 | * @param excludeList Reference to a list, where excluded files should be added. |
| 267 | */ |
| 268 | void createModuleList(const std::string &moduleDir, const StringList &defines, StringList &includeList, StringList &excludeList); |
| 269 | }; |
| 270 | |
| 271 | class VisualStudioProvider : public ProjectProvider { |
| 272 | public: |
| 273 | VisualStudioProvider(const int version, std::string global_warnings, std::map<std::string, std::string> project_warnings); |
| 274 | |
| 275 | void createProjectFile(const std::string &name, const std::string &uuid, const BuildSetup &setup, const std::string &moduleDir, |
| 276 | const StringList &includeList, const StringList &excludeList); |
| 277 | |
| 278 | void writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int indentation, |
| 279 | const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix); |
| 280 | |
| 281 | void writeReferences(std::ofstream &output); |
| 282 | |
| 283 | void outputGlobalPropFile(std::ofstream &properties, int bits, const std::string &defines, const std::string &prefix); |
| 284 | |
| 285 | void createBuildProp(const BuildSetup &setup); |
| 286 | |
| 287 | const char *getProjectExtension(); |
| 288 | const char *getPropertiesExtension(); |
| 289 | int getVisualStudioVersion(); |
| 290 | }; |
| 291 | |
830 | | void createProjectFile(const std::string &name, const std::string &uuid, const BuildSetup &setup, const std::string &moduleDir, |
831 | | const StringList &includeList, const StringList &excludeList, const int version) { |
832 | | const std::string projectFile = setup.outputDir + '/' + name + ".vcproj"; |
833 | | std::ofstream project(projectFile.c_str()); |
834 | | if (!project) |
835 | | error("Could not open \"" + projectFile + "\" for writing"); |
836 | | |
837 | | project << "<?xml version=\"1.0\" encoding=\"windows-1252\"?>\n" |
838 | | "<VisualStudioProject\n" |
839 | | "\tProjectType=\"Visual C++\"\n" |
840 | | "\tVersion=\"" << version << ".00\"\n" |
841 | | "\tName=\"" << name << "\"\n" |
842 | | "\tProjectGUID=\"{" << uuid << "}\"\n" |
843 | | "\tRootNamespace=\"" << name << "\"\n" |
844 | | "\tKeyword=\"Win32Proj\"\n"; |
845 | | |
846 | | if (version >= 9) |
847 | | project << "\tTargetFrameworkVersion=\"131072\"\n"; |
848 | | |
849 | | project << "\t>\n" |
850 | | "\t<Platforms>\n" |
851 | | "\t\t<Platform Name=\"Win32\" />\n" |
852 | | "\t\t<Platform Name=\"x64\" />\n" |
853 | | "\t</Platforms>\n" |
854 | | "\t<Configurations>\n"; |
855 | | |
856 | | // Check for project-specific warnings: |
857 | | std::map<std::string, std::string>::iterator warnings = g_projectWarnings.find(name); |
858 | | |
859 | | if (name == "scummvm") { |
860 | | std::string libraries; |
861 | | |
862 | | for (StringList::const_iterator i = setup.libraries.begin(); i != setup.libraries.end(); ++i) |
863 | | libraries += ' ' + *i; |
864 | | |
865 | | // Win32 |
866 | | project << "\t\t<Configuration Name=\"Debug|Win32\" ConfigurationType=\"1\" InheritedPropertySheets=\".\\ScummVM_Debug.vsprops\">\n" |
867 | | "\t\t\t<Tool\tName=\"VCCLCompilerTool\" DisableLanguageExtensions=\"false\" />\n" |
868 | | "\t\t\t<Tool\tName=\"VCLinkerTool\" OutputFile=\"$(OutDir)/scummvm.exe\"\n" |
869 | | "\t\t\t\tAdditionalDependencies=\"" << libraries << "\"\n" |
870 | | "\t\t\t/>\n" |
871 | | "\t\t</Configuration>\n" |
872 | | "\t\t<Configuration Name=\"Release|Win32\" ConfigurationType=\"1\" InheritedPropertySheets=\".\\ScummVM_Release.vsprops\">\n" |
873 | | "\t\t\t<Tool\tName=\"VCCLCompilerTool\" DisableLanguageExtensions=\"false\" />\n" |
874 | | "\t\t\t<Tool\tName=\"VCLinkerTool\" OutputFile=\"$(OutDir)/scummvm.exe\"\n" |
875 | | "\t\t\t\tAdditionalDependencies=\"" << libraries << "\"\n" |
876 | | "\t\t\t/>\n" |
877 | | "\t\t</Configuration>\n"; |
878 | | |
879 | | // x64 |
880 | | // For 'x64' we must disable NASM support. Usually we would need to disable the "nasm" feature for that and |
881 | | // re-create the library list, BUT since NASM doesn't link any additional libraries, we can just use the |
882 | | // libraries list created for IA-32. If that changes in the future, we need to adjust this part! |
883 | | project << "\t\t<Configuration Name=\"Debug|x64\" ConfigurationType=\"1\" InheritedPropertySheets=\".\\ScummVM_Debug64.vsprops\">\n" |
884 | | "\t\t\t<Tool\tName=\"VCCLCompilerTool\" DisableLanguageExtensions=\"false\" />\n" |
885 | | "\t\t\t<Tool\tName=\"VCLinkerTool\" OutputFile=\"$(OutDir)/scummvm.exe\"\n" |
886 | | "\t\t\t\tAdditionalDependencies=\"" << libraries << "\"\n" |
887 | | "\t\t\t/>\n" |
888 | | "\t\t</Configuration>\n" |
889 | | "\t\t<Configuration Name=\"Release|x64\" ConfigurationType=\"1\" InheritedPropertySheets=\".\\ScummVM_Release64.vsprops\">\n" |
890 | | "\t\t\t<Tool\tName=\"VCCLCompilerTool\" DisableLanguageExtensions=\"false\" />\n" |
891 | | "\t\t\t<Tool\tName=\"VCLinkerTool\" OutputFile=\"$(OutDir)/scummvm.exe\"\n" |
892 | | "\t\t\t\tAdditionalDependencies=\"" << libraries << "\"\n" |
893 | | "\t\t\t/>\n" |
894 | | "\t\t</Configuration>\n"; |
895 | | } else if (warnings != g_projectWarnings.end()) { |
896 | | // Win32 |
897 | | project << "\t\t<Configuration Name=\"Debug|Win32\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Debug.vsprops\">\n" |
898 | | "\t\t\t<Tool Name=\"VCCLCompilerTool\" DisableSpecificWarnings=\"" << warnings->second << "\" />\n" |
899 | | "\t\t</Configuration>\n" |
900 | | "\t\t<Configuration Name=\"Release|Win32\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Release.vsprops\">\n" |
901 | | "\t\t\t<Tool Name=\"VCCLCompilerTool\" DisableSpecificWarnings=\"" << warnings->second << "\" />\n" |
902 | | "\t\t</Configuration>\n"; |
903 | | // x64 |
904 | | project << "\t\t<Configuration Name=\"Debug|x64\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Debug64.vsprops\">\n" |
905 | | "\t\t\t<Tool Name=\"VCCLCompilerTool\" DisableSpecificWarnings=\"" << warnings->second << "\" />\n" |
906 | | "\t\t</Configuration>\n" |
907 | | "\t\t<Configuration Name=\"Release|x64\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Release64.vsprops\">\n" |
908 | | "\t\t\t<Tool Name=\"VCCLCompilerTool\" DisableSpecificWarnings=\"" << warnings->second << "\" />\n" |
909 | | "\t\t</Configuration>\n"; |
910 | | } else if (name == "tinsel") { |
911 | | // Win32 |
912 | | project << "\t\t<Configuration Name=\"Debug|Win32\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Debug.vsprops\">\n" |
913 | | "\t\t\t<Tool Name=\"VCCLCompilerTool\" DebugInformationFormat=\"3\" />\n" |
914 | | "\t\t</Configuration>\n" |
915 | | "\t\t<Configuration Name=\"Release|Win32\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Release.vsprops\" />\n"; |
916 | | // x64 |
917 | | project << "\t\t<Configuration Name=\"Debug|x64\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Debug64.vsprops\">\n" |
918 | | "\t\t\t<Tool Name=\"VCCLCompilerTool\" DebugInformationFormat=\"3\" />\n" |
919 | | "\t\t</Configuration>\n" |
920 | | "\t\t<Configuration Name=\"Release|x64\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Release64.vsprops\" />\n"; |
921 | | } else { |
922 | | // Win32 |
923 | | project << "\t\t<Configuration Name=\"Debug|Win32\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Debug.vsprops\" />\n" |
924 | | "\t\t<Configuration Name=\"Release|Win32\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Release.vsprops\" />\n"; |
925 | | // x64 |
926 | | project << "\t\t<Configuration Name=\"Debug|x64\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Debug64.vsprops\" />\n" |
927 | | "\t\t<Configuration Name=\"Release|x64\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Release64.vsprops\" />\n"; |
928 | | } |
929 | | project << "\t</Configurations>\n" |
930 | | "\t<Files>\n"; |
931 | | |
932 | | std::string modulePath; |
933 | | if (!moduleDir.compare(0, setup.srcDir.size(), setup.srcDir)) { |
934 | | modulePath = moduleDir.substr(setup.srcDir.size()); |
935 | | if (!modulePath.empty() && modulePath.at(0) == '/') |
936 | | modulePath.erase(0, 1); |
937 | | } |
938 | | |
939 | | if (modulePath.size()) |
940 | | addFilesToProject(moduleDir, project, includeList, excludeList, setup.filePrefix + '/' + modulePath); |
941 | | else |
942 | | addFilesToProject(moduleDir, project, includeList, excludeList, setup.filePrefix); |
943 | | |
944 | | project << "\t</Files>\n" |
945 | | "</VisualStudioProject>\n"; |
946 | | } |
947 | | |
949 | | * Outputs a property file based on the input parameters. |
950 | | * |
951 | | * It can be easily used to create different global properties files |
952 | | * for a 64 bit and a 32 bit version. It will also take care that the |
953 | | * two platform configurations will output their files into different |
954 | | * directories. |
955 | | * |
956 | | * @param properties File stream in which to write the property settings. |
957 | | * @param bits Number of bits the platform supports. |
958 | | * @param defines Defines the platform needs to have set. |
959 | | * @param prefix File prefix, used to add additional include paths. |
960 | | */ |
961 | | void outputGlobalPropFile(std::ofstream &properties, int bits, const std::string &defines, const std::string &prefix) { |
962 | | properties << "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n" |
963 | | "<VisualStudioPropertySheet\n" |
964 | | "\tProjectType=\"Visual C++\"\n" |
965 | | "\tVersion=\"8.00\"\n" |
966 | | "\tName=\"ScummVM_Global\"\n" |
967 | | "\tOutputDirectory=\"$(ConfigurationName)" << bits << "\"\n" |
968 | | "\tIntermediateDirectory=\"$(ConfigurationName)" << bits << "/$(ProjectName)\"\n" |
969 | | "\t>\n" |
970 | | "\t<Tool\n" |
971 | | "\t\tName=\"VCCLCompilerTool\"\n" |
972 | | "\t\tDisableLanguageExtensions=\"true\"\n" |
973 | | "\t\tDisableSpecificWarnings=\"" << g_globalWarnings << "\"\n" |
974 | | "\t\tAdditionalIncludeDirectories=\"" << prefix << ";" << prefix << "\\engines\"\n" |
975 | | "\t\tPreprocessorDefinitions=\"" << defines << "\"\n" |
976 | | "\t\tExceptionHandling=\"0\"\n" |
977 | | "\t\tRuntimeTypeInfo=\"false\"\n" |
978 | | "\t\tWarningLevel=\"4\"\n" |
979 | | "\t\tWarnAsError=\"false\"\n" |
980 | | "\t\tCompileAs=\"0\"\n" |
981 | | "\t\t/>\n" |
982 | | "\t<Tool\n" |
983 | | "\t\tName=\"VCLibrarianTool\"\n" |
984 | | "\t\tIgnoreDefaultLibraryNames=\"\"\n" |
985 | | "\t/>\n" |
986 | | "\t<Tool\n" |
987 | | "\t\tName=\"VCLinkerTool\"\n" |
988 | | "\t\tIgnoreDefaultLibraryNames=\"\"\n" |
989 | | "\t\tSubSystem=\"1\"\n" |
990 | | "\t\tEntryPointSymbol=\"WinMainCRTStartup\"\n" |
991 | | "\t/>\n" |
992 | | "\t<Tool\n" |
993 | | "\t\tName=\"VCResourceCompilerTool\"\n" |
994 | | "\t\tPreprocessorDefinitions=\"HAS_INCLUDE_SET\"\n" |
995 | | "\t\tAdditionalIncludeDirectories=\"" << prefix << "\"\n" |
996 | | "\t/>\n" |
997 | | "</VisualStudioPropertySheet>\n"; |
998 | | |
999 | | properties.flush(); |
1000 | | } |
1001 | | |
1002 | | void createGlobalProp(const BuildSetup &setup, const int /*version*/) { |
1003 | | std::ofstream properties((setup.outputDir + '/' + "ScummVM_Global.vsprops").c_str()); |
1004 | | if (!properties) |
1005 | | error("Could not open \"" + setup.outputDir + '/' + "ScummVM_Global.vsprops\" for writing"); |
1006 | | |
1007 | | std::string defines; |
1008 | | for (StringList::const_iterator i = setup.defines.begin(); i != setup.defines.end(); ++i) { |
1009 | | if (i != setup.defines.begin()) |
1010 | | defines += ';'; |
1011 | | defines += *i; |
1012 | | } |
1013 | | |
1014 | | outputGlobalPropFile(properties, 32, defines, convertPathToWin(setup.filePrefix)); |
1015 | | properties.close(); |
1016 | | |
1017 | | properties.open((setup.outputDir + '/' + "ScummVM_Global64.vsprops").c_str()); |
1018 | | if (!properties) |
1019 | | error("Could not open \"" + setup.outputDir + '/' + "ScummVM_Global64.vsprops\" for writing"); |
1020 | | |
1021 | | // HACK: We must disable the "nasm" feature for x64. To achieve that we must duplicate the feature list and |
1022 | | // recreate a define list. |
1023 | | FeatureList x64Features = setup.features; |
1024 | | setFeatureBuildState("nasm", x64Features, false); |
1025 | | StringList x64Defines = getFeatureDefines(x64Features); |
1026 | | StringList x64EngineDefines = getEngineDefines(setup.engines); |
1027 | | x64Defines.splice(x64Defines.end(), x64EngineDefines); |
1028 | | |
1029 | | defines.clear(); |
1030 | | for (StringList::const_iterator i = x64Defines.begin(); i != x64Defines.end(); ++i) { |
1031 | | if (i != x64Defines.begin()) |
1032 | | defines += ';'; |
1033 | | defines += *i; |
1034 | | } |
1035 | | |
1036 | | outputGlobalPropFile(properties, 64, defines, convertPathToWin(setup.filePrefix)); |
1037 | | } |
1038 | | |
1039 | | void createBuildProp(const BuildSetup &setup, const int /*version*/) { |
1040 | | std::ofstream properties((setup.outputDir + '/' + "ScummVM_Debug.vsprops").c_str()); |
1041 | | if (!properties) |
1042 | | error("Could not open \"" + setup.outputDir + '/' + "ScummVM_Debug.vsprops\" for writing"); |
1043 | | |
1044 | | properties << "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n" |
1045 | | "<VisualStudioPropertySheet\n" |
1046 | | "\tProjectType=\"Visual C++\"\n" |
1047 | | "\tVersion=\"8.00\"\n" |
1048 | | "\tName=\"ScummVM_Debug32\"\n" |
1049 | | "\tInheritedPropertySheets=\".\\ScummVM_Global.vsprops\"\n" |
1050 | | "\t>\n" |
1051 | | "\t<Tool\n" |
1052 | | "\t\tName=\"VCCLCompilerTool\"\n" |
1053 | | "\t\tOptimization=\"0\"\n" |
1054 | | "\t\tPreprocessorDefinitions=\"WIN32\"\n" |
1055 | | "\t\tMinimalRebuild=\"true\"\n" |
1056 | | "\t\tBasicRuntimeChecks=\"3\"\n" |
1057 | | "\t\tRuntimeLibrary=\"1\"\n" |
1058 | | "\t\tEnableFunctionLevelLinking=\"true\"\n" |
1059 | | "\t\tWarnAsError=\"false\"\n" |
1060 | | "\t\tDebugInformationFormat=\"4\"\n" |
1061 | | "\t/>\n" |
1062 | | "\t<Tool\n" |
1063 | | "\t\tName=\"VCLinkerTool\"\n" |
1064 | | "\t\tLinkIncremental=\"2\"\n" |
1065 | | "\t\tGenerateDebugInformation=\"true\"\n" |
1066 | | "\t\tIgnoreDefaultLibraryNames=\"libcmt.lib\"\n" |
1067 | | "\t/>\n" |
1068 | | "</VisualStudioPropertySheet>\n"; |
1069 | | |
1070 | | properties.flush(); |
1071 | | properties.close(); |
1072 | | |
1073 | | properties.open((setup.outputDir + '/' + "ScummVM_Debug64.vsprops").c_str()); |
1074 | | if (!properties) |
1075 | | error("Could not open \"" + setup.outputDir + '/' + "ScummVM_Debug64.vsprops\" for writing"); |
1076 | | |
1077 | | properties << "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n" |
1078 | | "<VisualStudioPropertySheet\n" |
1079 | | "\tProjectType=\"Visual C++\"\n" |
1080 | | "\tVersion=\"8.00\"\n" |
1081 | | "\tName=\"ScummVM_Debug64\"\n" |
1082 | | "\tInheritedPropertySheets=\".\\ScummVM_Global64.vsprops\"\n" |
1083 | | "\t>\n" |
1084 | | "\t<Tool\n" |
1085 | | "\t\tName=\"VCCLCompilerTool\"\n" |
1086 | | "\t\tOptimization=\"0\"\n" |
1087 | | "\t\tPreprocessorDefinitions=\"WIN32\"\n" |
1088 | | "\t\tMinimalRebuild=\"true\"\n" |
1089 | | "\t\tBasicRuntimeChecks=\"3\"\n" |
1090 | | "\t\tRuntimeLibrary=\"1\"\n" |
1091 | | "\t\tEnableFunctionLevelLinking=\"true\"\n" |
1092 | | "\t\tWarnAsError=\"false\"\n" |
1093 | | "\t\tDebugInformationFormat=\"3\"\n" // For x64 format "4" (Edit and continue) is not supported, thus we default to "3" |
1094 | | "\t/>\n" |
1095 | | "\t<Tool\n" |
1096 | | "\t\tName=\"VCLinkerTool\"\n" |
1097 | | "\t\tLinkIncremental=\"2\"\n" |
1098 | | "\t\tGenerateDebugInformation=\"true\"\n" |
1099 | | "\t\tIgnoreDefaultLibraryNames=\"libcmt.lib\"\n" |
1100 | | "\t/>\n" |
1101 | | "</VisualStudioPropertySheet>\n"; |
1102 | | |
1103 | | properties.flush(); |
1104 | | properties.close(); |
1105 | | |
1106 | | properties.open((setup.outputDir + '/' + "ScummVM_Release.vsprops").c_str()); |
1107 | | if (!properties) |
1108 | | error("Could not open \"" + setup.outputDir + '/' + "ScummVM_Release.vsprops\" for writing"); |
1109 | | |
1110 | | properties << "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n" |
1111 | | "<VisualStudioPropertySheet\n" |
1112 | | "\tProjectType=\"Visual C++\"\n" |
1113 | | "\tVersion=\"8.00\"\n" |
1114 | | "\tName=\"ScummVM_Release32\"\n" |
1115 | | "\tInheritedPropertySheets=\".\\ScummVM_Global.vsprops\"\n" |
1116 | | "\t>\n" |
1117 | | "\t<Tool\n" |
1118 | | "\t\tName=\"VCCLCompilerTool\"\n" |
1119 | | "\t\tEnableIntrinsicFunctions=\"true\"\n" |
1120 | | "\t\tWholeProgramOptimization=\"true\"\n" |
1121 | | "\t\tPreprocessorDefinitions=\"WIN32\"\n" |
1122 | | "\t\tStringPooling=\"true\"\n" |
1123 | | "\t\tBufferSecurityCheck=\"false\"\n" |
1124 | | "\t\tDebugInformationFormat=\"0\"\n" |
1125 | | "\t/>\n" |
1126 | | "\t<Tool\n" |
1127 | | "\t\tName=\"VCLinkerTool\"\n" |
1128 | | "\t\tLinkIncremental=\"1\"\n" |
1129 | | "\t\tIgnoreDefaultLibraryNames=\"\"\n" |
1130 | | "\t\tSetChecksum=\"true\"\n" |
1131 | | "\t/>\n" |
1132 | | "</VisualStudioPropertySheet>\n"; |
1133 | | |
1134 | | properties.flush(); |
1135 | | properties.close(); |
1136 | | |
1137 | | properties.open((setup.outputDir + '/' + "ScummVM_Release64.vsprops").c_str()); |
1138 | | if (!properties) |
1139 | | error("Could not open \"" + setup.outputDir + '/' + "ScummVM_Release64.vsprops\" for writing"); |
1140 | | |
1141 | | properties << "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n" |
1142 | | "<VisualStudioPropertySheet\n" |
1143 | | "\tProjectType=\"Visual C++\"\n" |
1144 | | "\tVersion=\"8.00\"\n" |
1145 | | "\tName=\"ScummVM_Release64\"\n" |
1146 | | "\tInheritedPropertySheets=\".\\ScummVM_Global64.vsprops\"\n" |
1147 | | "\t>\n" |
1148 | | "\t<Tool\n" |
1149 | | "\t\tName=\"VCCLCompilerTool\"\n" |
1150 | | "\t\tEnableIntrinsicFunctions=\"true\"\n" |
1151 | | "\t\tWholeProgramOptimization=\"true\"\n" |
1152 | | "\t\tPreprocessorDefinitions=\"WIN32\"\n" |
1153 | | "\t\tStringPooling=\"true\"\n" |
1154 | | "\t\tBufferSecurityCheck=\"false\"\n" |
1155 | | "\t\tDebugInformationFormat=\"0\"\n" |
1156 | | "\t/>\n" |
1157 | | "\t<Tool\n" |
1158 | | "\t\tName=\"VCLinkerTool\"\n" |
1159 | | "\t\tLinkIncremental=\"1\"\n" |
1160 | | "\t\tIgnoreDefaultLibraryNames=\"\"\n" |
1161 | | "\t\tSetChecksum=\"true\"\n" |
1162 | | "\t/>\n" |
1163 | | "</VisualStudioPropertySheet>\n"; |
1164 | | |
1165 | | properties.flush(); |
1166 | | properties.close(); |
1167 | | } |
1168 | | |
1169 | | /** |
| 1368 | |
| 1369 | ////////////////////////////////////////////////////////////////////////// |
| 1370 | // Visual Studio Provider |
| 1371 | ////////////////////////////////////////////////////////////////////////// |
| 1372 | |
| 1373 | VisualStudioProvider::VisualStudioProvider(const int version, std::string global_warnings, std::map<std::string, std::string> project_warnings) |
| 1374 | : ProjectProvider(version, global_warnings, project_warnings) { |
| 1375 | } |
| 1376 | |
| 1377 | const char *VisualStudioProvider::getProjectExtension() { |
| 1378 | return ".vcproj"; |
| 1379 | } |
| 1380 | |
| 1381 | const char *VisualStudioProvider::getPropertiesExtension() { |
| 1382 | return ".vsprops"; |
| 1383 | } |
| 1384 | |
| 1385 | int VisualStudioProvider::getVisualStudioVersion() { |
| 1386 | if (_version == 9) |
| 1387 | return 2008; |
| 1388 | |
| 1389 | if (_version == 8) |
| 1390 | return 2005; |
| 1391 | |
| 1392 | error("Unsupported version passed to createScummVMSolution"); |
| 1393 | return 0; |
| 1394 | } |
| 1395 | |
| 1396 | void VisualStudioProvider::createProjectFile(const std::string &name, const std::string &uuid, const BuildSetup &setup, const std::string &moduleDir, |
| 1397 | const StringList &includeList, const StringList &excludeList) { |
| 1398 | const std::string projectFile = setup.outputDir + '/' + name + getProjectExtension(); |
| 1399 | std::ofstream project(projectFile.c_str()); |
| 1400 | if (!project) |
| 1401 | error("Could not open \"" + projectFile + "\" for writing"); |
| 1402 | |
| 1403 | project << "<?xml version=\"1.0\" encoding=\"windows-1252\"?>\n" |
| 1404 | "<VisualStudioProject\n" |
| 1405 | "\tProjectType=\"Visual C++\"\n" |
| 1406 | "\tVersion=\"" << _version << ".00\"\n" |
| 1407 | "\tName=\"" << name << "\"\n" |
| 1408 | "\tProjectGUID=\"{" << uuid << "}\"\n" |
| 1409 | "\tRootNamespace=\"" << name << "\"\n" |
| 1410 | "\tKeyword=\"Win32Proj\"\n"; |
| 1411 | |
| 1412 | if (_version >= 9) |
| 1413 | project << "\tTargetFrameworkVersion=\"131072\"\n"; |
| 1414 | |
| 1415 | project << "\t>\n" |
| 1416 | "\t<Platforms>\n" |
| 1417 | "\t\t<Platform Name=\"Win32\" />\n" |
| 1418 | "\t\t<Platform Name=\"x64\" />\n" |
| 1419 | "\t</Platforms>\n" |
| 1420 | "\t<Configurations>\n"; |
| 1421 | |
| 1422 | // Check for project-specific warnings: |
| 1423 | std::map<std::string, std::string>::iterator warnings = _projectWarnings.find(name); |
| 1424 | |
| 1425 | if (name == "scummvm") { |
| 1426 | std::string libraries; |
| 1427 | |
| 1428 | for (StringList::const_iterator i = setup.libraries.begin(); i != setup.libraries.end(); ++i) |
| 1429 | libraries += ' ' + *i; |
| 1430 | |
| 1431 | // Win32 |
| 1432 | project << "\t\t<Configuration Name=\"Debug|Win32\" ConfigurationType=\"1\" InheritedPropertySheets=\".\\ScummVM_Debug.vsprops\">\n" |
| 1433 | "\t\t\t<Tool\tName=\"VCCLCompilerTool\" DisableLanguageExtensions=\"false\" />\n" |
| 1434 | "\t\t\t<Tool\tName=\"VCLinkerTool\" OutputFile=\"$(OutDir)/scummvm.exe\"\n" |
| 1435 | "\t\t\t\tAdditionalDependencies=\"" << libraries << "\"\n" |
| 1436 | "\t\t\t/>\n" |
| 1437 | "\t\t</Configuration>\n" |
| 1438 | "\t\t<Configuration Name=\"Release|Win32\" ConfigurationType=\"1\" InheritedPropertySheets=\".\\ScummVM_Release.vsprops\">\n" |
| 1439 | "\t\t\t<Tool\tName=\"VCCLCompilerTool\" DisableLanguageExtensions=\"false\" />\n" |
| 1440 | "\t\t\t<Tool\tName=\"VCLinkerTool\" OutputFile=\"$(OutDir)/scummvm.exe\"\n" |
| 1441 | "\t\t\t\tAdditionalDependencies=\"" << libraries << "\"\n" |
| 1442 | "\t\t\t/>\n" |
| 1443 | "\t\t</Configuration>\n"; |
| 1444 | |
| 1445 | // x64 |
| 1446 | // For 'x64' we must disable NASM support. Usually we would need to disable the "nasm" feature for that and |
| 1447 | // re-create the library list, BUT since NASM doesn't link any additional libraries, we can just use the |
| 1448 | // libraries list created for IA-32. If that changes in the future, we need to adjust this part! |
| 1449 | project << "\t\t<Configuration Name=\"Debug|x64\" ConfigurationType=\"1\" InheritedPropertySheets=\".\\ScummVM_Debug64.vsprops\">\n" |
| 1450 | "\t\t\t<Tool\tName=\"VCCLCompilerTool\" DisableLanguageExtensions=\"false\" />\n" |
| 1451 | "\t\t\t<Tool\tName=\"VCLinkerTool\" OutputFile=\"$(OutDir)/scummvm.exe\"\n" |
| 1452 | "\t\t\t\tAdditionalDependencies=\"" << libraries << "\"\n" |
| 1453 | "\t\t\t/>\n" |
| 1454 | "\t\t</Configuration>\n" |
| 1455 | "\t\t<Configuration Name=\"Release|x64\" ConfigurationType=\"1\" InheritedPropertySheets=\".\\ScummVM_Release64.vsprops\">\n" |
| 1456 | "\t\t\t<Tool\tName=\"VCCLCompilerTool\" DisableLanguageExtensions=\"false\" />\n" |
| 1457 | "\t\t\t<Tool\tName=\"VCLinkerTool\" OutputFile=\"$(OutDir)/scummvm.exe\"\n" |
| 1458 | "\t\t\t\tAdditionalDependencies=\"" << libraries << "\"\n" |
| 1459 | "\t\t\t/>\n" |
| 1460 | "\t\t</Configuration>\n"; |
| 1461 | } else if (warnings != _projectWarnings.end()) { |
| 1462 | // Win32 |
| 1463 | project << "\t\t<Configuration Name=\"Debug|Win32\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Debug.vsprops\">\n" |
| 1464 | "\t\t\t<Tool Name=\"VCCLCompilerTool\" DisableSpecificWarnings=\"" << warnings->second << "\" />\n" |
| 1465 | "\t\t</Configuration>\n" |
| 1466 | "\t\t<Configuration Name=\"Release|Win32\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Release.vsprops\">\n" |
| 1467 | "\t\t\t<Tool Name=\"VCCLCompilerTool\" DisableSpecificWarnings=\"" << warnings->second << "\" />\n" |
| 1468 | "\t\t</Configuration>\n"; |
| 1469 | // x64 |
| 1470 | project << "\t\t<Configuration Name=\"Debug|x64\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Debug64.vsprops\">\n" |
| 1471 | "\t\t\t<Tool Name=\"VCCLCompilerTool\" DisableSpecificWarnings=\"" << warnings->second << "\" />\n" |
| 1472 | "\t\t</Configuration>\n" |
| 1473 | "\t\t<Configuration Name=\"Release|x64\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Release64.vsprops\">\n" |
| 1474 | "\t\t\t<Tool Name=\"VCCLCompilerTool\" DisableSpecificWarnings=\"" << warnings->second << "\" />\n" |
| 1475 | "\t\t</Configuration>\n"; |
| 1476 | } else if (name == "tinsel") { |
| 1477 | // Win32 |
| 1478 | project << "\t\t<Configuration Name=\"Debug|Win32\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Debug.vsprops\">\n" |
| 1479 | "\t\t\t<Tool Name=\"VCCLCompilerTool\" DebugInformationFormat=\"3\" />\n" |
| 1480 | "\t\t</Configuration>\n" |
| 1481 | "\t\t<Configuration Name=\"Release|Win32\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Release.vsprops\" />\n"; |
| 1482 | // x64 |
| 1483 | project << "\t\t<Configuration Name=\"Debug|x64\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Debug64.vsprops\">\n" |
| 1484 | "\t\t\t<Tool Name=\"VCCLCompilerTool\" DebugInformationFormat=\"3\" />\n" |
| 1485 | "\t\t</Configuration>\n" |
| 1486 | "\t\t<Configuration Name=\"Release|x64\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Release64.vsprops\" />\n"; |
| 1487 | } else { |
| 1488 | // Win32 |
| 1489 | project << "\t\t<Configuration Name=\"Debug|Win32\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Debug.vsprops\" />\n" |
| 1490 | "\t\t<Configuration Name=\"Release|Win32\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Release.vsprops\" />\n"; |
| 1491 | // x64 |
| 1492 | project << "\t\t<Configuration Name=\"Debug|x64\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Debug64.vsprops\" />\n" |
| 1493 | "\t\t<Configuration Name=\"Release|x64\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_Release64.vsprops\" />\n"; |
| 1494 | } |
| 1495 | project << "\t</Configurations>\n" |
| 1496 | "\t<Files>\n"; |
| 1497 | |
| 1498 | std::string modulePath; |
| 1499 | if (!moduleDir.compare(0, setup.srcDir.size(), setup.srcDir)) { |
| 1500 | modulePath = moduleDir.substr(setup.srcDir.size()); |
| 1501 | if (!modulePath.empty() && modulePath.at(0) == '/') |
| 1502 | modulePath.erase(0, 1); |
| 1503 | } |
| 1504 | |
| 1505 | if (modulePath.size()) |
| 1506 | addFilesToProject(moduleDir, project, includeList, excludeList, setup.filePrefix + '/' + modulePath); |
| 1507 | else |
| 1508 | addFilesToProject(moduleDir, project, includeList, excludeList, setup.filePrefix); |
| 1509 | |
| 1510 | project << "\t</Files>\n" |
| 1511 | "</VisualStudioProject>\n"; |
| 1512 | } |
| 1513 | |
| 1514 | void VisualStudioProvider::writeReferences(std::ofstream &output) { |
| 1515 | output << "\tProjectSection(ProjectDependencies) = postProject\n"; |
| 1516 | |
| 1517 | for (UUIDMap::const_iterator i = _uuidMap.begin(); i != _uuidMap.end(); ++i) { |
| 1518 | if (i->first == "scummvm") |
| 1519 | continue; |
| 1520 | |
| 1521 | output << "\t\t{" << i->second << "} = {" << i->second << "}\n"; |
| 1522 | } |
| 1523 | |
| 1524 | output << "\tEndProjectSection\n"; |
| 1525 | } |
| 1526 | |
| 1527 | void VisualStudioProvider::outputGlobalPropFile(std::ofstream &properties, int bits, const std::string &defines, const std::string &prefix) { |
| 1528 | properties << "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n" |
| 1529 | "<VisualStudioPropertySheet\n" |
| 1530 | "\tProjectType=\"Visual C++\"\n" |
| 1531 | "\tVersion=\"8.00\"\n" |
| 1532 | "\tName=\"ScummVM_Global\"\n" |
| 1533 | "\tOutputDirectory=\"$(ConfigurationName)" << bits << "\"\n" |
| 1534 | "\tIntermediateDirectory=\"$(ConfigurationName)" << bits << "/$(ProjectName)\"\n" |
| 1535 | "\t>\n" |
| 1536 | "\t<Tool\n" |
| 1537 | "\t\tName=\"VCCLCompilerTool\"\n" |
| 1538 | "\t\tDisableLanguageExtensions=\"true\"\n" |
| 1539 | "\t\tDisableSpecificWarnings=\"" << _globalWarnings << "\"\n" |
| 1540 | "\t\tAdditionalIncludeDirectories=\"" << prefix << ";" << prefix << "\\engines\"\n" |
| 1541 | "\t\tPreprocessorDefinitions=\"" << defines << "\"\n" |
| 1542 | "\t\tExceptionHandling=\"0\"\n" |
| 1543 | "\t\tRuntimeTypeInfo=\"false\"\n" |
| 1544 | "\t\tWarningLevel=\"4\"\n" |
| 1545 | "\t\tWarnAsError=\"false\"\n" |
| 1546 | "\t\tCompileAs=\"0\"\n" |
| 1547 | "\t\t/>\n" |
| 1548 | "\t<Tool\n" |
| 1549 | "\t\tName=\"VCLibrarianTool\"\n" |
| 1550 | "\t\tIgnoreDefaultLibraryNames=\"\"\n" |
| 1551 | "\t/>\n" |
| 1552 | "\t<Tool\n" |
| 1553 | "\t\tName=\"VCLinkerTool\"\n" |
| 1554 | "\t\tIgnoreDefaultLibraryNames=\"\"\n" |
| 1555 | "\t\tSubSystem=\"1\"\n" |
| 1556 | "\t\tEntryPointSymbol=\"WinMainCRTStartup\"\n" |
| 1557 | "\t/>\n" |
| 1558 | "\t<Tool\n" |
| 1559 | "\t\tName=\"VCResourceCompilerTool\"\n" |
| 1560 | "\t\tPreprocessorDefinitions=\"HAS_INCLUDE_SET\"\n" |
| 1561 | "\t\tAdditionalIncludeDirectories=\"" << prefix << "\"\n" |
| 1562 | "\t/>\n" |
| 1563 | "</VisualStudioPropertySheet>\n"; |
| 1564 | |
| 1565 | properties.flush(); |
| 1566 | } |
| 1567 | |
| 1568 | void VisualStudioProvider::createBuildProp(const BuildSetup &setup) { |
| 1569 | std::ofstream properties((setup.outputDir + '/' + "ScummVM_Debug" + getPropertiesExtension()).c_str()); |
| 1570 | if (!properties) |
| 1571 | error("Could not open \"" + setup.outputDir + '/' + "ScummVM_Debug" + + getPropertiesExtension() + "\" for writing"); |
| 1572 | |
| 1573 | properties << "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n" |
| 1574 | "<VisualStudioPropertySheet\n" |
| 1575 | "\tProjectType=\"Visual C++\"\n" |
| 1576 | "\tVersion=\"8.00\"\n" |
| 1577 | "\tName=\"ScummVM_Debug32\"\n" |
| 1578 | "\tInheritedPropertySheets=\".\\ScummVM_Global.vsprops\"\n" |
| 1579 | "\t>\n" |
| 1580 | "\t<Tool\n" |
| 1581 | "\t\tName=\"VCCLCompilerTool\"\n" |
| 1582 | "\t\tOptimization=\"0\"\n" |
| 1583 | "\t\tPreprocessorDefinitions=\"WIN32\"\n" |
| 1584 | "\t\tMinimalRebuild=\"true\"\n" |
| 1585 | "\t\tBasicRuntimeChecks=\"3\"\n" |
| 1586 | "\t\tRuntimeLibrary=\"1\"\n" |
| 1587 | "\t\tEnableFunctionLevelLinking=\"true\"\n" |
| 1588 | "\t\tWarnAsError=\"false\"\n" |
| 1589 | "\t\tDebugInformationFormat=\"4\"\n" |
| 1590 | "\t/>\n" |
| 1591 | "\t<Tool\n" |
| 1592 | "\t\tName=\"VCLinkerTool\"\n" |
| 1593 | "\t\tLinkIncremental=\"2\"\n" |
| 1594 | "\t\tGenerateDebugInformation=\"true\"\n" |
| 1595 | "\t\tIgnoreDefaultLibraryNames=\"libcmt.lib\"\n" |
| 1596 | "\t/>\n" |
| 1597 | "</VisualStudioPropertySheet>\n"; |
| 1598 | |
| 1599 | properties.flush(); |
| 1600 | properties.close(); |
| 1601 | |
| 1602 | properties.open((setup.outputDir + '/' + "ScummVM_Debug64" + getPropertiesExtension()).c_str()); |
| 1603 | if (!properties) |
| 1604 | error("Could not open \"" + setup.outputDir + '/' + "ScummVM_Debug64" + getPropertiesExtension() + "\" for writing"); |
| 1605 | |
| 1606 | properties << "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n" |
| 1607 | "<VisualStudioPropertySheet\n" |
| 1608 | "\tProjectType=\"Visual C++\"\n" |
| 1609 | "\tVersion=\"8.00\"\n" |
| 1610 | "\tName=\"ScummVM_Debug64\"\n" |
| 1611 | "\tInheritedPropertySheets=\".\\ScummVM_Global64.vsprops\"\n" |
| 1612 | "\t>\n" |
| 1613 | "\t<Tool\n" |
| 1614 | "\t\tName=\"VCCLCompilerTool\"\n" |
| 1615 | "\t\tOptimization=\"0\"\n" |
| 1616 | "\t\tPreprocessorDefinitions=\"WIN32\"\n" |
| 1617 | "\t\tMinimalRebuild=\"true\"\n" |
| 1618 | "\t\tBasicRuntimeChecks=\"3\"\n" |
| 1619 | "\t\tRuntimeLibrary=\"1\"\n" |
| 1620 | "\t\tEnableFunctionLevelLinking=\"true\"\n" |
| 1621 | "\t\tWarnAsError=\"false\"\n" |
| 1622 | "\t\tDebugInformationFormat=\"3\"\n" // For x64 format "4" (Edit and continue) is not supported, thus we default to "3" |
| 1623 | "\t/>\n" |
| 1624 | "\t<Tool\n" |
| 1625 | "\t\tName=\"VCLinkerTool\"\n" |
| 1626 | "\t\tLinkIncremental=\"2\"\n" |
| 1627 | "\t\tGenerateDebugInformation=\"true\"\n" |
| 1628 | "\t\tIgnoreDefaultLibraryNames=\"libcmt.lib\"\n" |
| 1629 | "\t/>\n" |
| 1630 | "</VisualStudioPropertySheet>\n"; |
| 1631 | |
| 1632 | properties.flush(); |
| 1633 | properties.close(); |
| 1634 | |
| 1635 | properties.open((setup.outputDir + '/' + "ScummVM_Release" + getPropertiesExtension()).c_str()); |
| 1636 | if (!properties) |
| 1637 | error("Could not open \"" + setup.outputDir + '/' + "ScummVM_Release" + getPropertiesExtension() + "\" for writing"); |
| 1638 | |
| 1639 | properties << "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n" |
| 1640 | "<VisualStudioPropertySheet\n" |
| 1641 | "\tProjectType=\"Visual C++\"\n" |
| 1642 | "\tVersion=\"8.00\"\n" |
| 1643 | "\tName=\"ScummVM_Release32\"\n" |
| 1644 | "\tInheritedPropertySheets=\".\\ScummVM_Global.vsprops\"\n" |
| 1645 | "\t>\n" |
| 1646 | "\t<Tool\n" |
| 1647 | "\t\tName=\"VCCLCompilerTool\"\n" |
| 1648 | "\t\tEnableIntrinsicFunctions=\"true\"\n" |
| 1649 | "\t\tWholeProgramOptimization=\"true\"\n" |
| 1650 | "\t\tPreprocessorDefinitions=\"WIN32\"\n" |
| 1651 | "\t\tStringPooling=\"true\"\n" |
| 1652 | "\t\tBufferSecurityCheck=\"false\"\n" |
| 1653 | "\t\tDebugInformationFormat=\"0\"\n" |
| 1654 | "\t/>\n" |
| 1655 | "\t<Tool\n" |
| 1656 | "\t\tName=\"VCLinkerTool\"\n" |
| 1657 | "\t\tLinkIncremental=\"1\"\n" |
| 1658 | "\t\tIgnoreDefaultLibraryNames=\"\"\n" |
| 1659 | "\t\tSetChecksum=\"true\"\n" |
| 1660 | "\t/>\n" |
| 1661 | "</VisualStudioPropertySheet>\n"; |
| 1662 | |
| 1663 | properties.flush(); |
| 1664 | properties.close(); |
| 1665 | |
| 1666 | properties.open((setup.outputDir + '/' + "ScummVM_Release64" + getPropertiesExtension()).c_str()); |
| 1667 | if (!properties) |
| 1668 | error("Could not open \"" + setup.outputDir + '/' + "ScummVM_Release64" + getPropertiesExtension() + "\" for writing"); |
| 1669 | |
| 1670 | properties << "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n" |
| 1671 | "<VisualStudioPropertySheet\n" |
| 1672 | "\tProjectType=\"Visual C++\"\n" |
| 1673 | "\tVersion=\"8.00\"\n" |
| 1674 | "\tName=\"ScummVM_Release64\"\n" |
| 1675 | "\tInheritedPropertySheets=\".\\ScummVM_Global64.vsprops\"\n" |
| 1676 | "\t>\n" |
| 1677 | "\t<Tool\n" |
| 1678 | "\t\tName=\"VCCLCompilerTool\"\n" |
| 1679 | "\t\tEnableIntrinsicFunctions=\"true\"\n" |
| 1680 | "\t\tWholeProgramOptimization=\"true\"\n" |
| 1681 | "\t\tPreprocessorDefinitions=\"WIN32\"\n" |
| 1682 | "\t\tStringPooling=\"true\"\n" |
| 1683 | "\t\tBufferSecurityCheck=\"false\"\n" |
| 1684 | "\t\tDebugInformationFormat=\"0\"\n" |
| 1685 | "\t/>\n" |
| 1686 | "\t<Tool\n" |
| 1687 | "\t\tName=\"VCLinkerTool\"\n" |
| 1688 | "\t\tLinkIncremental=\"1\"\n" |
| 1689 | "\t\tIgnoreDefaultLibraryNames=\"\"\n" |
| 1690 | "\t\tSetChecksum=\"true\"\n" |
| 1691 | "\t/>\n" |
| 1692 | "</VisualStudioPropertySheet>\n"; |
| 1693 | |
| 1694 | properties.flush(); |
| 1695 | properties.close(); |
| 1696 | } |
| 1697 | |
| 1698 | void VisualStudioProvider::writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int indentation, |
| 1699 | const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix) { |
| 1700 | const std::string indentString = getIndent(indentation + 2); |
| 1701 | |
| 1702 | if (indentation) |
| 1703 | projectFile << getIndent(indentation + 1) << "<Filter\tName=\"" << dir.name << "\">\n"; |
| 1704 | |
| 1705 | for (FileNode::NodeList::const_iterator i = dir.children.begin(); i != dir.children.end(); ++i) { |
| 1706 | const FileNode *node = *i; |
| 1707 | |
| 1708 | if (!node->children.empty()) { |
| 1709 | writeFileListToProject(*node, projectFile, indentation + 1, duplicate, objPrefix + node->name + '_', filePrefix + node->name + '/'); |
| 1710 | } else { |
| 1711 | if (producesObjectFile(node->name)) { |
| 1712 | std::string name, ext; |
| 1713 | splitFilename(node->name, name, ext); |
| 1714 | const bool isDuplicate = (std::find(duplicate.begin(), duplicate.end(), name + ".o") != duplicate.end()); |
| 1715 | |
| 1716 | if (ext == "asm") { |
| 1717 | std::string objFileName = "$(IntDir)\\"; |
| 1718 | if (isDuplicate) |
| 1719 | objFileName += objPrefix; |
| 1720 | objFileName += "$(InputName).obj"; |
| 1721 | |
| 1722 | const std::string toolLine = indentString + "\t\t<Tool Name=\"VCCustomBuildTool\" CommandLine=\"nasm.exe -f win32 -g -o "" + objFileName + "" "$(InputPath)"
\" Outputs=\"" + objFileName + "\" />\n"; |
| 1723 | |
| 1724 | // NASM is not supported for x64, thus we do not need to add additional entries here :-). |
| 1725 | projectFile << indentString << "<File RelativePath=\"" << convertPathToWin(filePrefix + node->name) << "\">\n" |
| 1726 | << indentString << "\t<FileConfiguration Name=\"Debug|Win32\">\n" |
| 1727 | << toolLine |
| 1728 | << indentString << "\t</FileConfiguration>\n" |
| 1729 | << indentString << "\t<FileConfiguration Name=\"Release|Win32\">\n" |
| 1730 | << toolLine |
| 1731 | << indentString << "\t</FileConfiguration>\n" |
| 1732 | << indentString << "</File>\n"; |
| 1733 | } else { |
| 1734 | if (isDuplicate) { |
| 1735 | const std::string toolLine = indentString + "\t\t<Tool Name=\"VCCLCompilerTool\" ObjectFile=\"$(IntDir)\\" + objPrefix + "$(InputName).obj\" XMLDocumentationFileName=\"$(IntDir)\\" + objPrefix + "$(InputName).xdc\" />\n"; |
| 1736 | |
| 1737 | projectFile << indentString << "<File RelativePath=\"" << convertPathToWin(filePrefix + node->name) << "\">\n" |
| 1738 | << indentString << "\t<FileConfiguration Name=\"Debug|Win32\">\n" |
| 1739 | << toolLine |
| 1740 | << indentString << "\t</FileConfiguration>\n" |
| 1741 | << indentString << "\t<FileConfiguration Name=\"Release|Win32\">\n" |
| 1742 | << toolLine |
| 1743 | << indentString << "\t</FileConfiguration>\n" |
| 1744 | << indentString << "\t<FileConfiguration Name=\"Debug|x64\">\n" |
| 1745 | << toolLine |
| 1746 | << indentString << "\t</FileConfiguration>\n" |
| 1747 | << indentString << "\t<FileConfiguration Name=\"Release|x64\">\n" |
| 1748 | << toolLine |
| 1749 | << indentString << "\t</FileConfiguration>\n" |
| 1750 | << indentString << "</File>\n"; |
| 1751 | } else { |
| 1752 | projectFile << indentString << "<File RelativePath=\"" << convertPathToWin(filePrefix + node->name) << "\" />\n"; |
| 1753 | } |
| 1754 | } |
| 1755 | } else { |
| 1756 | projectFile << indentString << "<File RelativePath=\"" << convertPathToWin(filePrefix + node->name) << "\" />\n"; |
| 1757 | } |
| 1758 | } |
| 1759 | } |
| 1760 | |
| 1761 | if (indentation) |
| 1762 | projectFile << getIndent(indentation + 1) << "</Filter>\n"; |
| 1763 | } |
| 1764 | |