Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

604 lines
18 KiB

  1. //========= Copyright � 1996-2006, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: VPC
  4. //
  5. //=====================================================================================//
  6. #include "vpc.h"
  7. #define PROPERTYNAME( X, Y ) { X##_##Y, #X, #Y },
  8. static PropertyName_t s_Win32PropertyNames_2010[] =
  9. {
  10. #include "projectgenerator_win32_2010.inc"
  11. { -1, NULL, NULL }
  12. };
  13. IBaseProjectGenerator* GetWin32ProjectGenerator_2010()
  14. {
  15. static CProjectGenerator_Win32_2010 *s_pProjectGenerator = NULL;
  16. if ( !s_pProjectGenerator )
  17. {
  18. s_pProjectGenerator = new CProjectGenerator_Win32_2010();
  19. }
  20. return s_pProjectGenerator->GetProjectGenerator();
  21. }
  22. CProjectGenerator_Win32_2010::CProjectGenerator_Win32_2010()
  23. {
  24. m_pVCProjGenerator = new CVCProjGenerator();
  25. m_pVCProjGenerator->SetupGeneratorDefinition( this, "win32_2010.def", s_Win32PropertyNames_2010 );
  26. }
  27. enum TypeKeyNames_e
  28. {
  29. TKN_LIBRARY = 0,
  30. TKN_INCLUDE,
  31. TKN_COMPILE,
  32. TKN_RESOURCECOMPILE,
  33. TKN_CUSTOMBUILD,
  34. TKN_NONE,
  35. TKN_MAX_COUNT,
  36. };
  37. static const char *s_TypeKeyNames[] =
  38. {
  39. "Library",
  40. "ClInclude",
  41. "ClCompile",
  42. "ResourceCompile",
  43. "CustomBuild",
  44. "None"
  45. };
  46. const char *CProjectGenerator_Win32_2010::GetKeyNameForFile( CProjectFile *pFile )
  47. {
  48. COMPILE_TIME_ASSERT( ARRAYSIZE( s_TypeKeyNames ) == TKN_MAX_COUNT );
  49. const char *pExtension = V_GetFileExtension( pFile->m_Name.Get() );
  50. const char *pKeyName = s_TypeKeyNames[TKN_NONE];
  51. if ( pExtension )
  52. {
  53. if ( !V_stricmp( pExtension, "cpp" ) || !V_stricmp( pExtension, "cxx" ) || !V_stricmp( pExtension, "c" ) || !V_stricmp( pExtension, "cc" ) )
  54. {
  55. pKeyName = s_TypeKeyNames[TKN_COMPILE];
  56. }
  57. else if ( !V_stricmp( pExtension, "h" ) || !V_stricmp( pExtension, "hxx" ) )
  58. {
  59. pKeyName = s_TypeKeyNames[TKN_INCLUDE];
  60. }
  61. else if ( !V_stricmp( pExtension, "lib" ) )
  62. {
  63. pKeyName = s_TypeKeyNames[TKN_LIBRARY];
  64. }
  65. else if ( !V_stricmp( pExtension, "rc" ) )
  66. {
  67. pKeyName = s_TypeKeyNames[TKN_RESOURCECOMPILE];
  68. }
  69. else
  70. {
  71. if ( pFile->m_Configs.Count() && pFile->m_Configs[0]->GetCustomBuildTool() )
  72. {
  73. pKeyName = s_TypeKeyNames[TKN_CUSTOMBUILD];
  74. }
  75. }
  76. }
  77. return pKeyName;
  78. }
  79. bool CProjectGenerator_Win32_2010::WritePropertyGroupTool( CProjectTool *pProjectTool, CProjectConfiguration *pConfiguration )
  80. {
  81. if ( !pProjectTool )
  82. return true;
  83. for ( int i = 0; i < pProjectTool->m_PropertyStates.m_PropertiesInOutputOrder.Count(); i++ )
  84. {
  85. int sortedIndex = pProjectTool->m_PropertyStates.m_PropertiesInOutputOrder[i];
  86. if ( !pProjectTool->m_PropertyStates.m_Properties[sortedIndex].m_pToolProperty->m_bEmitAsGlobalProperty )
  87. continue;
  88. if ( !WriteProperty( &pProjectTool->m_PropertyStates.m_Properties[sortedIndex], true, pConfiguration->m_Name.Get() ) )
  89. return false;
  90. }
  91. return true;
  92. }
  93. bool CProjectGenerator_Win32_2010::WriteFile( CProjectFile *pFile, const char *pFileTypeName )
  94. {
  95. const char *pKeyName = GetKeyNameForFile( pFile );
  96. if ( V_stricmp( pFileTypeName, pKeyName ) )
  97. {
  98. // skip it
  99. return true;
  100. }
  101. if ( !pFile->m_Configs.Count() )
  102. {
  103. m_XMLWriter.Write( CFmtStrMax( "<%s Include=\"%s\" />", pKeyName, pFile->m_Name.Get() ) );
  104. }
  105. else
  106. {
  107. m_XMLWriter.PushNode( pKeyName, CFmtStr( "Include=\"%s\"", pFile->m_Name.Get() ) );
  108. for ( int i = 0; i < pFile->m_Configs.Count(); i++ )
  109. {
  110. if ( !WriteConfiguration( pFile->m_Configs[i] ) )
  111. return false;
  112. }
  113. m_XMLWriter.PopNode( true );
  114. }
  115. return true;
  116. }
  117. bool CProjectGenerator_Win32_2010::WriteFolder( CProjectFolder *pFolder, const char *pFileTypeName, int nDepth )
  118. {
  119. if ( !nDepth )
  120. {
  121. m_XMLWriter.PushNode( "ItemGroup" );
  122. }
  123. for ( int iIndex = pFolder->m_Files.Head(); iIndex != pFolder->m_Files.InvalidIndex(); iIndex = pFolder->m_Files.Next( iIndex ) )
  124. {
  125. if ( !WriteFile( pFolder->m_Files[iIndex], pFileTypeName ) )
  126. return false;
  127. }
  128. for ( int iIndex = pFolder->m_Folders.Head(); iIndex != pFolder->m_Folders.InvalidIndex(); iIndex = pFolder->m_Folders.Next( iIndex ) )
  129. {
  130. if ( !WriteFolder( pFolder->m_Folders[iIndex], pFileTypeName, nDepth+1 ) )
  131. return false;
  132. }
  133. if ( !nDepth )
  134. {
  135. m_XMLWriter.PopNode( true );
  136. }
  137. return true;
  138. }
  139. bool CProjectGenerator_Win32_2010::WriteConfiguration( CProjectConfiguration *pConfig )
  140. {
  141. if ( !pConfig->m_bIsFileConfig )
  142. {
  143. const char *pTargetPlatformName = g_pVPC->IsPlatformDefined( "win64" ) ? "x64" : "Win32";
  144. m_XMLWriter.PushNode( "PropertyGroup", CFmtStr( "Condition=\"'$(Configuration)|$(Platform)'=='%s|%s'\" Label=\"Configuration\"", pConfig->m_Name.Get(), pTargetPlatformName ) );
  145. for ( int i = 0; i < pConfig->m_PropertyStates.m_PropertiesInOutputOrder.Count(); i++ )
  146. {
  147. int sortedIndex = pConfig->m_PropertyStates.m_PropertiesInOutputOrder[i];
  148. if ( pConfig->m_PropertyStates.m_Properties[sortedIndex].m_pToolProperty->m_bEmitAsGlobalProperty )
  149. continue;
  150. if ( !WriteProperty( &pConfig->m_PropertyStates.m_Properties[sortedIndex] ) )
  151. return false;
  152. }
  153. m_XMLWriter.PopNode( true );
  154. }
  155. else
  156. {
  157. for ( int i = 0; i < pConfig->m_PropertyStates.m_PropertiesInOutputOrder.Count(); i++ )
  158. {
  159. int sortedIndex = pConfig->m_PropertyStates.m_PropertiesInOutputOrder[i];
  160. if ( !WriteProperty( &pConfig->m_PropertyStates.m_Properties[sortedIndex], true, pConfig->m_Name.Get() ) )
  161. return false;
  162. }
  163. if ( !WriteTool( "ClCompile", pConfig->GetCompilerTool(), pConfig ) )
  164. return false;
  165. if ( !WriteTool( "CustomBuildStep", pConfig->GetCustomBuildTool(), pConfig ) )
  166. return false;
  167. }
  168. return true;
  169. }
  170. bool CProjectGenerator_Win32_2010::WriteTools( CProjectConfiguration *pConfig )
  171. {
  172. const char *pTargetPlatformName = g_pVPC->IsPlatformDefined( "win64" ) ? "x64" : "Win32";
  173. m_XMLWriter.PushNode( "ItemDefinitionGroup", CFmtStr( "Condition=\"'$(Configuration)|$(Platform)'=='%s|%s'\"", pConfig->m_Name.Get(), pTargetPlatformName ) );
  174. if ( !WriteTool( "PreBuildEvent", pConfig->GetPreBuildEventTool(), pConfig ) )
  175. return false;
  176. if ( !WriteTool( "ClCompile", pConfig->GetCompilerTool(), pConfig ) )
  177. return false;
  178. if ( !WriteTool( "ResourceCompile", pConfig->GetResourcesTool(), pConfig ) )
  179. return false;
  180. if ( !WriteTool( "PreLinkEvent", pConfig->GetPreLinkEventTool(), pConfig ) )
  181. return false;
  182. if ( !WriteTool( "Link", pConfig->GetLinkerTool(), pConfig ) )
  183. return false;
  184. if ( !WriteTool( "Lib", pConfig->GetLibrarianTool(), pConfig ) )
  185. return false;
  186. if ( !WriteTool( "Manifest", pConfig->GetManifestTool(), pConfig ) )
  187. return false;
  188. if ( !WriteTool( "Xdcmake", pConfig->GetXMLDocGenTool(), pConfig ) )
  189. return false;
  190. if ( !WriteTool( "Bscmake", pConfig->GetBrowseInfoTool(), pConfig ) )
  191. return false;
  192. if ( !WriteTool( "PostBuildEvent", pConfig->GetPostBuildEventTool(), pConfig ) )
  193. return false;
  194. if ( !WriteTool( "CustomBuildStep", pConfig->GetCustomBuildTool(), pConfig ) )
  195. return false;
  196. m_XMLWriter.PopNode( true );
  197. return true;
  198. }
  199. bool CProjectGenerator_Win32_2010::WritePrimaryXML( const char *pOutputFilename )
  200. {
  201. if ( !m_XMLWriter.Open( pOutputFilename, true ) )
  202. return false;
  203. const char *pTargetPlatformName = g_pVPC->IsPlatformDefined( "win64" ) ? "x64" : "Win32";
  204. m_XMLWriter.PushNode( "Project", "DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\"" );
  205. m_XMLWriter.PushNode( "ItemGroup", "Label=\"ProjectConfigurations\"" );
  206. CUtlVector< CUtlString > configurationNames;
  207. m_pVCProjGenerator->GetAllConfigurationNames( configurationNames );
  208. const char *pPlatformString = "Win32";
  209. if ( g_pVPC->IsPlatformDefined( "WIN64" ) )
  210. pPlatformString = "x64";
  211. for ( int i = 0; i < configurationNames.Count(); i++ )
  212. {
  213. m_XMLWriter.PushNode( "ProjectConfiguration", CFmtStr( "Include=\"%s|%s\"", configurationNames[i].Get(), pTargetPlatformName ) );
  214. m_XMLWriter.WriteLineNode( "Configuration", "", configurationNames[i].Get() );
  215. m_XMLWriter.WriteLineNode( "Platform", "", CFmtStr( "%s", pTargetPlatformName ) );
  216. m_XMLWriter.PopNode( true );
  217. }
  218. m_XMLWriter.PopNode( true );
  219. m_XMLWriter.PushNode( "PropertyGroup", "Label=\"Globals\"" );
  220. m_XMLWriter.WriteLineNode( "ProjectName", "", m_pVCProjGenerator->GetProjectName().Get() );
  221. m_XMLWriter.WriteLineNode( "ProjectGuid", "", m_pVCProjGenerator->GetGUIDString().Get() );
  222. m_XMLWriter.PopNode( true );
  223. m_XMLWriter.Write( "<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />" );
  224. // write the root configurations
  225. for ( int i = 0; i < configurationNames.Count(); i++ )
  226. {
  227. CProjectConfiguration *pConfiguration = NULL;
  228. if ( m_pVCProjGenerator->GetRootConfiguration( configurationNames[i].Get(), &pConfiguration ) )
  229. {
  230. if ( !WriteConfiguration( pConfiguration ) )
  231. return false;
  232. }
  233. }
  234. m_XMLWriter.Write( "<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />" );
  235. m_XMLWriter.PushNode( "ImportGroup", "Label=\"ExtensionSettings\"" );
  236. m_XMLWriter.PopNode( true );
  237. for ( int i = 0; i < configurationNames.Count(); i++ )
  238. {
  239. m_XMLWriter.PushNode( "ImportGroup", CFmtStr( "Condition=\"'$(Configuration)|$(Platform)'=='%s|%s'\" Label=\"PropertySheets\"", configurationNames[i].Get(), pTargetPlatformName ) );
  240. m_XMLWriter.Write( "<Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />" );
  241. m_XMLWriter.PopNode( true );
  242. }
  243. m_XMLWriter.Write( "<PropertyGroup Label=\"UserMacros\" />" );
  244. m_XMLWriter.PushNode( "PropertyGroup" );
  245. m_XMLWriter.WriteLineNode( "_ProjectFileVersion", "", "10.0.30319.1" );
  246. for ( int i = 0; i < configurationNames.Count(); i++ )
  247. {
  248. CProjectConfiguration *pConfiguration = NULL;
  249. if ( m_pVCProjGenerator->GetRootConfiguration( configurationNames[i].Get(), &pConfiguration ) )
  250. {
  251. for ( int j = 0; j < pConfiguration->m_PropertyStates.m_PropertiesInOutputOrder.Count(); j++ )
  252. {
  253. int sortedIndex = pConfiguration->m_PropertyStates.m_PropertiesInOutputOrder[j];
  254. if ( !pConfiguration->m_PropertyStates.m_Properties[sortedIndex].m_pToolProperty->m_bEmitAsGlobalProperty )
  255. continue;
  256. if ( !WriteProperty( &pConfiguration->m_PropertyStates.m_Properties[sortedIndex], true, pConfiguration->m_Name.Get() ) )
  257. return false;
  258. }
  259. if ( !WritePropertyGroupTool( pConfiguration->GetPreBuildEventTool(), pConfiguration ) )
  260. return false;
  261. if ( !WritePropertyGroupTool( pConfiguration->GetPreLinkEventTool(), pConfiguration ) )
  262. return false;
  263. if ( !WritePropertyGroupTool( pConfiguration->GetLinkerTool(), pConfiguration ) )
  264. return false;
  265. if ( !WritePropertyGroupTool( pConfiguration->GetLibrarianTool(), pConfiguration ) )
  266. return false;
  267. if ( !WritePropertyGroupTool( pConfiguration->GetPostBuildEventTool(), pConfiguration ) )
  268. return false;
  269. }
  270. }
  271. m_XMLWriter.PopNode( true );
  272. // write the tool configurations
  273. for ( int i = 0; i < configurationNames.Count(); i++ )
  274. {
  275. CProjectConfiguration *pConfiguration = NULL;
  276. if ( m_pVCProjGenerator->GetRootConfiguration( configurationNames[i].Get(), &pConfiguration ) )
  277. {
  278. if ( !WriteTools( pConfiguration ) )
  279. return false;
  280. }
  281. }
  282. // write root folders
  283. for ( int i = 0; i < TKN_MAX_COUNT; i++ )
  284. {
  285. if ( !WriteFolder( m_pVCProjGenerator->GetRootFolder(), s_TypeKeyNames[i], 0 ) )
  286. return false;
  287. }
  288. m_XMLWriter.Write( "<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />" );
  289. m_XMLWriter.PushNode( "ImportGroup", "Label=\"ExtensionTargets\"" );
  290. m_XMLWriter.PopNode( true );
  291. m_XMLWriter.PopNode( true );
  292. m_XMLWriter.Close();
  293. return true;
  294. }
  295. bool CProjectGenerator_Win32_2010::WriteFolderToSecondaryXML( CProjectFolder *pFolder, const char *pParentPath )
  296. {
  297. CUtlString parentPath = CFmtStr( "%s%s%s", pParentPath, pParentPath[0] ? "\\" : "", pFolder->m_Name.Get() );
  298. MD5Context_t ctx;
  299. unsigned char digest[MD5_DIGEST_LENGTH];
  300. V_memset( &ctx, 0, sizeof( ctx ) );
  301. V_memset( digest, 0, sizeof( digest ) );
  302. MD5Init( &ctx );
  303. MD5Update( &ctx, (unsigned char *)parentPath.Get(), strlen( parentPath.Get() ) );
  304. MD5Final( digest, &ctx );
  305. char szMD5[64];
  306. V_binarytohex( digest, MD5_DIGEST_LENGTH, szMD5, sizeof( szMD5 ) );
  307. V_strupr( szMD5 );
  308. char szGUID[MAX_PATH];
  309. V_snprintf( szGUID, sizeof( szGUID ), "{%8.8s-%4.4s-%4.4s-%4.4s-%12.12s}", szMD5, &szMD5[8], &szMD5[12], &szMD5[16], &szMD5[20] );
  310. m_XMLFilterWriter.PushNode( "Filter", CFmtStr( "Include=\"%s\"", parentPath.Get() ) );
  311. m_XMLFilterWriter.WriteLineNode( "UniqueIdentifier", "", szGUID );
  312. m_XMLFilterWriter.PopNode( true );
  313. for ( int iIndex = pFolder->m_Folders.Head(); iIndex != pFolder->m_Folders.InvalidIndex(); iIndex = pFolder->m_Folders.Next( iIndex ) )
  314. {
  315. if ( !WriteFolderToSecondaryXML( pFolder->m_Folders[iIndex], parentPath.Get() ) )
  316. return false;
  317. }
  318. return true;
  319. }
  320. bool CProjectGenerator_Win32_2010::WriteFileToSecondaryXML( CProjectFile *pFile, const char *pParentPath, const char *pFileTypeName )
  321. {
  322. const char *pKeyName = GetKeyNameForFile( pFile );
  323. if ( V_stricmp( pFileTypeName, pKeyName ) )
  324. {
  325. // skip it
  326. return true;
  327. }
  328. if ( pParentPath )
  329. {
  330. m_XMLFilterWriter.PushNode( pKeyName, CFmtStr( "Include=\"%s\"", pFile->m_Name.Get() ) );
  331. m_XMLFilterWriter.WriteLineNode( "Filter", "", pParentPath );
  332. m_XMLFilterWriter.PopNode( true );
  333. }
  334. else
  335. {
  336. m_XMLFilterWriter.Write( CFmtStr( "<%s Include=\"%s\" />", pKeyName, pFile->m_Name.Get() ) );
  337. }
  338. return true;
  339. }
  340. bool CProjectGenerator_Win32_2010::WriteFolderContentsToSecondaryXML( CProjectFolder *pFolder, const char *pParentPath, const char *pFileTypeName, int nDepth )
  341. {
  342. CUtlString parentPath;
  343. if ( pParentPath )
  344. {
  345. parentPath = CFmtStr( "%s%s%s", pParentPath, pParentPath[0] ? "\\" : "", pFolder->m_Name.Get() );
  346. }
  347. if ( !nDepth )
  348. {
  349. m_XMLFilterWriter.PushNode( "ItemGroup", NULL );
  350. }
  351. for ( int iIndex = pFolder->m_Files.Head(); iIndex != pFolder->m_Files.InvalidIndex(); iIndex = pFolder->m_Files.Next( iIndex ) )
  352. {
  353. if ( !WriteFileToSecondaryXML( pFolder->m_Files[iIndex], parentPath.Get(), pFileTypeName ) )
  354. return false;
  355. }
  356. for ( int iIndex = pFolder->m_Folders.Head(); iIndex != pFolder->m_Folders.InvalidIndex(); iIndex = pFolder->m_Folders.Next( iIndex ) )
  357. {
  358. if ( !WriteFolderContentsToSecondaryXML( pFolder->m_Folders[iIndex], parentPath.Get(), pFileTypeName, nDepth+1 ) )
  359. return false;
  360. }
  361. if ( !nDepth )
  362. {
  363. m_XMLFilterWriter.PopNode( true );
  364. }
  365. return true;
  366. }
  367. bool CProjectGenerator_Win32_2010::WriteSecondaryXML( const char *pOutputFilename )
  368. {
  369. if ( !m_XMLFilterWriter.Open( pOutputFilename, true ) )
  370. return false;
  371. m_XMLFilterWriter.PushNode( "Project", "ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\"" );
  372. // write the root folders
  373. m_XMLFilterWriter.PushNode( "ItemGroup", NULL );
  374. CProjectFolder *pRootFolder = m_pVCProjGenerator->GetRootFolder();
  375. for ( int iIndex = pRootFolder->m_Folders.Head(); iIndex != pRootFolder->m_Folders.InvalidIndex(); iIndex = pRootFolder->m_Folders.Next( iIndex ) )
  376. {
  377. if ( !WriteFolderToSecondaryXML( pRootFolder->m_Folders[iIndex], "" ) )
  378. return false;
  379. }
  380. m_XMLFilterWriter.PopNode( true );
  381. // write folder contents
  382. for ( int i = 0; i < TKN_MAX_COUNT; i++ )
  383. {
  384. if ( !WriteFolderContentsToSecondaryXML( pRootFolder, NULL, s_TypeKeyNames[i], 0 ) )
  385. return false;
  386. }
  387. m_XMLFilterWriter.PopNode( true );
  388. m_XMLFilterWriter.Close();
  389. return true;
  390. }
  391. bool CProjectGenerator_Win32_2010::WriteTool( const char *pToolName, const CProjectTool *pProjectTool, CProjectConfiguration *pConfig )
  392. {
  393. if ( !pProjectTool )
  394. {
  395. // not an error, some tools n/a for a config
  396. return true;
  397. }
  398. if ( !pConfig->m_bIsFileConfig )
  399. {
  400. m_XMLWriter.PushNode( pToolName, NULL );
  401. }
  402. for ( int i = 0; i < pProjectTool->m_PropertyStates.m_PropertiesInOutputOrder.Count(); i++ )
  403. {
  404. int sortedIndex = pProjectTool->m_PropertyStates.m_PropertiesInOutputOrder[i];
  405. if ( !pConfig->m_bIsFileConfig )
  406. {
  407. if ( pProjectTool->m_PropertyStates.m_Properties[sortedIndex].m_pToolProperty->m_bEmitAsGlobalProperty )
  408. continue;
  409. if ( !WriteProperty( &pProjectTool->m_PropertyStates.m_Properties[sortedIndex] ) )
  410. return false;
  411. }
  412. else
  413. {
  414. if ( !WriteProperty( &pProjectTool->m_PropertyStates.m_Properties[sortedIndex], true, pConfig->m_Name.Get() ) )
  415. return false;
  416. }
  417. }
  418. if ( !pConfig->m_bIsFileConfig )
  419. {
  420. m_XMLWriter.PopNode( true );
  421. }
  422. return true;
  423. }
  424. bool CProjectGenerator_Win32_2010::WriteProperty( const PropertyState_t *pPropertyState, bool bEmitConfiguration, const char *pConfigName, const char *pOutputName, const char *pOutputValue )
  425. {
  426. if ( !pPropertyState )
  427. {
  428. m_XMLWriter.WriteLineNode( pOutputName, "", pOutputValue );
  429. return true;
  430. }
  431. if ( !pOutputName )
  432. {
  433. pOutputName = pPropertyState->m_pToolProperty->m_OutputString.Get();
  434. if ( !pOutputName[0] )
  435. {
  436. pOutputName = pPropertyState->m_pToolProperty->m_ParseString.Get();
  437. if ( pOutputName[0] == '$' )
  438. {
  439. pOutputName++;
  440. }
  441. }
  442. }
  443. const char *pCondition = "";
  444. CUtlString conditionString;
  445. if ( bEmitConfiguration )
  446. {
  447. const char *pTargetPlatformName = g_pVPC->IsPlatformDefined( "win64" ) ? "x64" : "Win32";
  448. conditionString = CFmtStr( " Condition=\"'$(Configuration)|$(Platform)'=='%s|%s'\"", pConfigName, pTargetPlatformName );
  449. pCondition = conditionString.Get();
  450. }
  451. if ( pPropertyState )
  452. {
  453. switch ( pPropertyState->m_pToolProperty->m_nType )
  454. {
  455. case PT_BOOLEAN:
  456. {
  457. bool bEnabled = Sys_StringToBool( pPropertyState->m_StringValue.Get() );
  458. if ( pPropertyState->m_pToolProperty->m_bInvertOutput )
  459. {
  460. bEnabled ^= 1;
  461. }
  462. m_XMLWriter.WriteLineNode( pOutputName, pCondition, bEnabled ? "true" : "false" );
  463. }
  464. break;
  465. case PT_STRING:
  466. m_XMLWriter.WriteLineNode( pOutputName, pCondition, m_XMLWriter.FixupXMLString( pPropertyState->m_StringValue.Get() ) );
  467. break;
  468. case PT_LIST:
  469. case PT_INTEGER:
  470. m_XMLWriter.WriteLineNode( pOutputName, pCondition, pPropertyState->m_StringValue.Get() );
  471. break;
  472. case PT_IGNORE:
  473. break;
  474. default:
  475. g_pVPC->VPCError( "CProjectGenerator_Win32_2010: WriteProperty, %s - not implemented", pOutputName );
  476. }
  477. }
  478. return true;
  479. }
  480. bool CProjectGenerator_Win32_2010::Save( const char *pOutputFilename )
  481. {
  482. bool bValid = WritePrimaryXML( pOutputFilename );
  483. if ( bValid )
  484. {
  485. bValid = WriteSecondaryXML( CFmtStr( "%s.filters", pOutputFilename ) );
  486. if ( !bValid )
  487. {
  488. g_pVPC->VPCError( "Cannot save to the specified project '%s'", pOutputFilename );
  489. }
  490. }
  491. return bValid;
  492. }