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.

1281 lines
34 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_PS3PropertyNames[] =
  9. {
  10. #include "projectgenerator_ps3.inc"
  11. { -1, NULL, NULL }
  12. };
  13. IBaseProjectGenerator* GetPS3ProjectGenerator()
  14. {
  15. static CProjectGenerator_PS3 *s_pProjectGenerator = NULL;
  16. if ( !s_pProjectGenerator )
  17. {
  18. s_pProjectGenerator = new CProjectGenerator_PS3();
  19. }
  20. return s_pProjectGenerator->GetProjectGenerator();
  21. }
  22. CProjectGenerator_PS3::CProjectGenerator_PS3()
  23. {
  24. m_pVCProjGenerator = new CVCProjGenerator();
  25. m_pVCProjGenerator->SetupGeneratorDefinition( this, "ps3.def", s_PS3PropertyNames );
  26. }
  27. bool CProjectGenerator_PS3::WriteFile( CProjectFile *pFile )
  28. {
  29. m_XMLWriter.PushNode( "File" );
  30. m_XMLWriter.Write( CFmtStrMax( "RelativePath=\"%s\"", pFile->m_Name.Get() ) );
  31. m_XMLWriter.Write( ">" );
  32. for ( int i = 0; i < pFile->m_Configs.Count(); i++ )
  33. {
  34. if ( !WriteConfiguration( pFile->m_Configs[i] ) )
  35. return false;
  36. }
  37. m_XMLWriter.PopNode( true );
  38. return true;
  39. }
  40. bool CProjectGenerator_PS3::WriteFolder( CProjectFolder *pFolder )
  41. {
  42. m_XMLWriter.PushNode( "Filter" );
  43. m_XMLWriter.Write( CFmtStrMax( "Name=\"%s\"", pFolder->m_Name.Get() ) );
  44. m_XMLWriter.Write( ">" );
  45. for ( int iIndex = pFolder->m_Folders.Head(); iIndex != pFolder->m_Folders.InvalidIndex(); iIndex = pFolder->m_Folders.Next( iIndex ) )
  46. {
  47. if ( !WriteFolder( pFolder->m_Folders[iIndex] ) )
  48. return false;
  49. }
  50. for ( int iIndex = pFolder->m_Files.Head(); iIndex != pFolder->m_Files.InvalidIndex(); iIndex = pFolder->m_Files.Next( iIndex ) )
  51. {
  52. if ( !WriteFile( pFolder->m_Files[iIndex] ) )
  53. return false;
  54. }
  55. m_XMLWriter.PopNode( true );
  56. return true;
  57. }
  58. bool CProjectGenerator_PS3::WritePreBuildEventTool( CPreBuildEventTool *pPreBuildEventTool )
  59. {
  60. if ( !pPreBuildEventTool )
  61. {
  62. // not an error, some tools n/a for aconfig
  63. return true;
  64. }
  65. m_XMLWriter.PushNode( "Tool" );
  66. m_XMLWriter.Write( "Name=\"VCPreBuildEventTool\"" );
  67. for ( int i = 0; i < pPreBuildEventTool->m_PropertyStates.m_Properties.Count(); i++ )
  68. {
  69. switch ( pPreBuildEventTool->m_PropertyStates.m_Properties[i].m_pToolProperty->m_nPropertyId )
  70. {
  71. case PS3_PREBUILDEVENT_CommandLine:
  72. m_XMLWriter.Write( CFmtStrMax( "CommandLine=\"%s\"", m_XMLWriter.FixupXMLString( pPreBuildEventTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) ) );
  73. break;
  74. case PS3_PREBUILDEVENT_Description:
  75. m_XMLWriter.Write( CFmtStrMax( "Description=\"%s\"", pPreBuildEventTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  76. break;
  77. case PS3_PREBUILDEVENT_ExcludedFromBuild:
  78. m_XMLWriter.Write( CFmtStrMax( "ExcludedFromBuild=\"%s\"", BoolStringToTrueFalseString( pPreBuildEventTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) ) );
  79. break;
  80. }
  81. }
  82. m_XMLWriter.PopNode( false );
  83. return true;
  84. }
  85. bool CProjectGenerator_PS3::WriteCustomBuildTool( CCustomBuildTool *pCustomBuildTool )
  86. {
  87. if ( !pCustomBuildTool )
  88. {
  89. // not an error, some tools n/a for aconfig
  90. return true;
  91. }
  92. m_XMLWriter.PushNode( "Tool" );
  93. m_XMLWriter.Write( "Name=\"VCCustomBuildTool\"" );
  94. for ( int i = 0; i < pCustomBuildTool->m_PropertyStates.m_Properties.Count(); i++ )
  95. {
  96. switch ( pCustomBuildTool->m_PropertyStates.m_Properties[i].m_pToolProperty->m_nPropertyId )
  97. {
  98. case PS3_CUSTOMBUILDSTEP_CommandLine:
  99. m_XMLWriter.Write( CFmtStrMax( "CommandLine=\"%s\"", m_XMLWriter.FixupXMLString( pCustomBuildTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) ) );
  100. break;
  101. case PS3_CUSTOMBUILDSTEP_Description:
  102. m_XMLWriter.Write( CFmtStrMax( "Description=\"%s\"", pCustomBuildTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  103. break;
  104. case PS3_CUSTOMBUILDSTEP_Outputs:
  105. m_XMLWriter.Write( CFmtStrMax( "Outputs=\"%s\"", pCustomBuildTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  106. break;
  107. case PS3_CUSTOMBUILDSTEP_AdditionalDependencies:
  108. m_XMLWriter.Write( CFmtStrMax( "AdditionalDependencies=\"%s\"", pCustomBuildTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  109. break;
  110. }
  111. }
  112. m_XMLWriter.PopNode( false );
  113. return true;
  114. }
  115. bool CProjectGenerator_PS3::WriteSNCCompilerTool( CCompilerTool *pCompilerTool )
  116. {
  117. if ( !pCompilerTool )
  118. {
  119. // not an error, some tools n/a for a config
  120. return true;
  121. }
  122. m_XMLWriter.PushNode( "Tool" );
  123. m_XMLWriter.Write( "Name=\"VCCLCompilerTool\"" );
  124. // aggregates or purges state as needed
  125. CUtlString additionalOptions = "";
  126. for ( int i = 0; i < pCompilerTool->m_PropertyStates.m_Properties.Count(); i++ )
  127. {
  128. int nOrdinalValue = atoi( pCompilerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() );
  129. switch ( pCompilerTool->m_PropertyStates.m_Properties[i].m_pToolProperty->m_nPropertyId )
  130. {
  131. case PS3_SNCCOMPILER_AdditionalIncludeDirectories:
  132. m_XMLWriter.Write( CFmtStrMax( "AdditionalIncludeDirectories=\"%s\"", pCompilerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  133. break;
  134. case PS3_SNCCOMPILER_PreprocessorDefinitions:
  135. m_XMLWriter.Write( CFmtStrMax( "PreprocessorDefinitions=\"%s\"", pCompilerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  136. break;
  137. case PS3_SNCCOMPILER_ForceIncludes:
  138. m_XMLWriter.Write( CFmtStrMax( "ForcedIncludeFiles=\"%s\"", pCompilerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  139. break;
  140. case PS3_SNCCOMPILER_ForcedUsingFiles:
  141. m_XMLWriter.Write( CFmtStrMax( "ForcedUsingFiles=\"%s\"", pCompilerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  142. break;
  143. case PS3_SNCCOMPILER_GenerateDebugInformation:
  144. if ( nOrdinalValue )
  145. {
  146. additionalOptions += "-g ";
  147. }
  148. break;
  149. case PS3_SNCCOMPILER_Warnings:
  150. if ( nOrdinalValue )
  151. {
  152. additionalOptions += CFmtStrMax( "-Xdiag=%d ", nOrdinalValue );
  153. }
  154. break;
  155. case PS3_SNCCOMPILER_TreatMessagesAsErrors:
  156. if ( nOrdinalValue )
  157. {
  158. additionalOptions += CFmtStrMax( "-Xquit=%d ", nOrdinalValue );
  159. }
  160. break;
  161. case PS3_SNCCOMPILER_DisableSpecificWarnings:
  162. m_XMLWriter.Write( CFmtStrMax( "DisableSpecificWarnings=\"%s\"", pCompilerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  163. break;
  164. case PS3_SNCCOMPILER_ObjectFileName:
  165. m_XMLWriter.Write( CFmtStrMax( "ObjectFile=\"%s\"", pCompilerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  166. break;
  167. case PS3_SNCCOMPILER_CallprofHierarchicalProfiling:
  168. if ( nOrdinalValue )
  169. {
  170. additionalOptions += CFmtStrMax( "-Xcallprof=%d ", nOrdinalValue );
  171. }
  172. break;
  173. case PS3_SNCCOMPILER_OptimizationLevel:
  174. if ( nOrdinalValue == 0 )
  175. {
  176. // lack of any -0<x> means -O0
  177. additionalOptions += " ";
  178. }
  179. else if ( nOrdinalValue == 1 )
  180. {
  181. additionalOptions += "-O1 ";
  182. }
  183. else if ( nOrdinalValue == 2 )
  184. {
  185. additionalOptions += "-O2 ";
  186. }
  187. else if ( nOrdinalValue == 3 )
  188. {
  189. additionalOptions += "-Os ";
  190. }
  191. else if ( nOrdinalValue == 4 )
  192. {
  193. additionalOptions += "-Od ";
  194. }
  195. break;
  196. case PS3_SNCCOMPILER_FastMath:
  197. if ( nOrdinalValue )
  198. {
  199. additionalOptions += CFmtStrMax( "-Xfastmath=%d ", nOrdinalValue );
  200. }
  201. break;
  202. case PS3_SNCCOMPILER_RelaxAliasChecking:
  203. if ( nOrdinalValue >= 0 )
  204. {
  205. additionalOptions += CFmtStrMax( "-Xrelaxalias=%d ", nOrdinalValue );
  206. }
  207. break;
  208. case PS3_SNCCOMPILER_BranchlessCompares:
  209. if ( nOrdinalValue )
  210. {
  211. additionalOptions += CFmtStrMax( "-Xbranchless=%d ", nOrdinalValue );
  212. }
  213. break;
  214. case PS3_SNCCOMPILER_UnrollLoops:
  215. if ( nOrdinalValue )
  216. {
  217. additionalOptions += CFmtStrMax( "-Xunrollssa=%d ", nOrdinalValue );
  218. }
  219. break;
  220. case PS3_SNCCOMPILER_AssumeAlignedPointers:
  221. if ( nOrdinalValue )
  222. {
  223. additionalOptions += "-Xassumecorrectalignment=1 ";
  224. }
  225. break;
  226. case PS3_SNCCOMPILER_AssumeCorrectSign:
  227. if ( nOrdinalValue )
  228. {
  229. additionalOptions += "-Xassumecorrectsign=1 ";
  230. }
  231. break;
  232. case PS3_SNCCOMPILER_TOCPointerPreservation:
  233. if ( nOrdinalValue )
  234. {
  235. additionalOptions += CFmtStrMax( "-Xnotocrestore=%d ", nOrdinalValue );
  236. }
  237. break;
  238. case PS3_SNCCOMPILER_InitializedDataPlacement:
  239. additionalOptions += CFmtStrMax( "-Xbss=%d ", nOrdinalValue );
  240. break;
  241. case PS3_SNCCOMPILER_PromoteFPConstantsToDoubles:
  242. if ( nOrdinalValue )
  243. {
  244. additionalOptions += "-Xfltconst=8 ";
  245. }
  246. break;
  247. case PS3_SNCCOMPILER_CCPPDialect:
  248. if ( nOrdinalValue )
  249. {
  250. if ( nOrdinalValue == 1 )
  251. {
  252. additionalOptions += "-Xc=ansi ";
  253. }
  254. else if ( nOrdinalValue == 2 )
  255. {
  256. additionalOptions += "-Xc=arm ";
  257. }
  258. else if ( nOrdinalValue == 3 )
  259. {
  260. additionalOptions += "-Xc=cp ";
  261. }
  262. else if ( nOrdinalValue == 4 )
  263. {
  264. additionalOptions += "-Xc=cfront ";
  265. }
  266. else if ( nOrdinalValue == 5 )
  267. {
  268. additionalOptions += "-Xc=knr ";
  269. }
  270. }
  271. break;
  272. case PS3_SNCCOMPILER_CPPExceptionsAndRTTIUsage:
  273. if ( nOrdinalValue == 0 )
  274. {
  275. additionalOptions += "-Xc-=rtti -Xc-=exceptions ";
  276. }
  277. else if ( nOrdinalValue == 1 )
  278. {
  279. additionalOptions += "-Xc+=rtti -Xc-=exceptions ";
  280. }
  281. else if ( nOrdinalValue == 2 )
  282. {
  283. additionalOptions += "-Xc+=rtti -Xc+=exceptions ";
  284. }
  285. break;
  286. case PS3_SNCCOMPILER_DefaultCharUnsigned:
  287. if ( nOrdinalValue )
  288. {
  289. additionalOptions += "-Xchar=unsigned ";
  290. }
  291. break;
  292. case PS3_SNCCOMPILER_DefaultFPConstantsAsTypeFloat:
  293. if ( nOrdinalValue )
  294. {
  295. additionalOptions += "-Xsingleconst=1 ";
  296. }
  297. break;
  298. case PS3_SNCCOMPILER_BuiltInDefinitionForWCHAR_TType:
  299. if ( nOrdinalValue == 0 )
  300. {
  301. additionalOptions += "-Xwchart=uint ";
  302. }
  303. else if ( nOrdinalValue == 1 )
  304. {
  305. additionalOptions += "-Xwchart=ulong ";
  306. }
  307. else if ( nOrdinalValue == 2 )
  308. {
  309. additionalOptions += "-Xwchart=ushort ";
  310. }
  311. else if ( nOrdinalValue == 3 )
  312. {
  313. additionalOptions += "-Xwchart=uchar ";
  314. }
  315. else if ( nOrdinalValue == 4 )
  316. {
  317. additionalOptions += "-Xwchart=int ";
  318. }
  319. else if ( nOrdinalValue == 5 )
  320. {
  321. additionalOptions += "-Xwchart=long ";
  322. }
  323. else if ( nOrdinalValue == 6 )
  324. {
  325. additionalOptions += "-Xwchart=short ";
  326. }
  327. else if ( nOrdinalValue == 7 )
  328. {
  329. additionalOptions += "-Xwchart=char ";
  330. }
  331. else if ( nOrdinalValue == 8 )
  332. {
  333. additionalOptions += "-Xwchart=schar ";
  334. }
  335. break;
  336. case PS3_SNCCOMPILER_CreateUsePrecompiledHeader:
  337. if ( nOrdinalValue == 1 )
  338. {
  339. additionalOptions += CFmtStrMax( "--create_pch=&quot;%s&quot; ", pCompilerTool->m_PropertyStates.GetProperty( PS3_SNCCOMPILER_PrecompiledHeaderFile )->m_StringValue );
  340. }
  341. else if ( nOrdinalValue == 2 )
  342. {
  343. additionalOptions += "--pch --pch_dir=&quot;$(IntDir)&quot; ";
  344. }
  345. else if ( nOrdinalValue == 3 )
  346. {
  347. additionalOptions += CFmtStrMax( "--use_pch=&quot;%s&quot; ", pCompilerTool->m_PropertyStates.GetProperty( PS3_SNCCOMPILER_PrecompiledHeaderFile )->m_StringValue );
  348. }
  349. break;
  350. case PS3_SNCCOMPILER_PrecompiledHeaderFile:
  351. // already accounted for
  352. break;
  353. case PS3_SNCCOMPILER_AdditionalOptions:
  354. if ( !pCompilerTool->m_PropertyStates.m_Properties[i].m_StringValue.IsEmpty() )
  355. {
  356. additionalOptions += pCompilerTool->m_PropertyStates.m_Properties[i].m_StringValue;
  357. additionalOptions += " ";
  358. }
  359. break;
  360. }
  361. }
  362. if ( !additionalOptions.IsEmpty() )
  363. {
  364. m_XMLWriter.Write( CFmtStrMax( "AdditionalOptions=\"%s\"", additionalOptions.Get() ) );
  365. }
  366. m_XMLWriter.PopNode( false );
  367. return true;
  368. }
  369. bool CProjectGenerator_PS3::WriteGCCCompilerTool( CCompilerTool *pCompilerTool )
  370. {
  371. if ( !pCompilerTool )
  372. {
  373. // not an error, some tools n/a for a config
  374. return true;
  375. }
  376. m_XMLWriter.PushNode( "Tool" );
  377. m_XMLWriter.Write( "Name=\"VCCLCompilerTool\"" );
  378. // aggregates or purges state as needed
  379. CUtlString additionalOptions = "";
  380. for ( int i = 0; i < pCompilerTool->m_PropertyStates.m_Properties.Count(); i++ )
  381. {
  382. int nOrdinalValue = atoi( pCompilerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() );
  383. switch ( pCompilerTool->m_PropertyStates.m_Properties[i].m_pToolProperty->m_nPropertyId )
  384. {
  385. case PS3_GCCCOMPILER_AdditionalIncludeDirectories:
  386. m_XMLWriter.Write( CFmtStrMax( "AdditionalIncludeDirectories=\"%s\"", m_XMLWriter.FixupXMLString( pCompilerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) ) );
  387. break;
  388. case PS3_GCCCOMPILER_PreprocessorDefinitions:
  389. m_XMLWriter.Write( CFmtStrMax( "PreprocessorDefinitions=\"%s\"", pCompilerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  390. break;
  391. case PS3_GCCCOMPILER_ForceIncludes:
  392. m_XMLWriter.Write( CFmtStrMax( "ForcedIncludeFiles=\"%s\"", pCompilerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  393. break;
  394. case PS3_GCCCOMPILER_GenerateDebugInformation:
  395. if ( nOrdinalValue )
  396. {
  397. additionalOptions += "-g ";
  398. }
  399. break;
  400. case PS3_GCCCOMPILER_Warnings:
  401. if ( nOrdinalValue == 0 )
  402. {
  403. additionalOptions += "-w ";
  404. }
  405. else if ( nOrdinalValue == 2 )
  406. {
  407. additionalOptions += "-Wall ";
  408. }
  409. break;
  410. case PS3_GCCCOMPILER_ExtraWarnings:
  411. if ( nOrdinalValue )
  412. {
  413. additionalOptions += "-Wextra ";
  414. }
  415. break;
  416. case PS3_GCCCOMPILER_WarnLoadHitStores:
  417. break;
  418. case PS3_GCCCOMPILER_WarnMicrocodedInstruction:
  419. break;
  420. case PS3_GCCCOMPILER_TreatWarningsAsErrors:
  421. if ( nOrdinalValue )
  422. {
  423. additionalOptions += "-Werror ";
  424. }
  425. break;
  426. case PS3_GCCCOMPILER_ObjectFileName:
  427. m_XMLWriter.Write( CFmtStrMax( "ObjectFile=\"%s\"", pCompilerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  428. break;
  429. case PS3_GCCCOMPILER_CallprofHierarchicalProfiling:
  430. break;
  431. case PS3_GCCCOMPILER_SPURSUsage:
  432. if ( nOrdinalValue == 1 )
  433. {
  434. additionalOptions += "-mspurs-job-initialize ";
  435. }
  436. else if ( nOrdinalValue == 2 )
  437. {
  438. additionalOptions += "-mspurs-job ";
  439. }
  440. else if ( nOrdinalValue == 3 )
  441. {
  442. additionalOptions += "-mspurs-task ";
  443. }
  444. break;
  445. case PS3_GCCCOMPILER_OptimizationLevel:
  446. if ( nOrdinalValue == 0 )
  447. {
  448. additionalOptions += "-O0 ";
  449. }
  450. else if ( nOrdinalValue == 1 )
  451. {
  452. additionalOptions += "-O1 ";
  453. }
  454. else if ( nOrdinalValue == 2 )
  455. {
  456. additionalOptions += "-O2 ";
  457. }
  458. else if ( nOrdinalValue == 3 )
  459. {
  460. additionalOptions += "-O3 ";
  461. }
  462. else if ( nOrdinalValue == 4 )
  463. {
  464. additionalOptions += "-Os ";
  465. }
  466. break;
  467. case PS3_GCCCOMPILER_FastMath:
  468. if ( nOrdinalValue )
  469. {
  470. additionalOptions += "-ffast-math ";
  471. }
  472. break;
  473. case PS3_GCCCOMPILER_NoStrictAliasing:
  474. if ( nOrdinalValue )
  475. {
  476. additionalOptions += "-fno-strict-aliasing ";
  477. }
  478. break;
  479. case PS3_GCCCOMPILER_UnrollLoops:
  480. if ( nOrdinalValue )
  481. {
  482. additionalOptions += "-funroll-loops ";
  483. }
  484. break;
  485. case PS3_GCCCOMPILER_InlineFunctionSizeLimit:
  486. if ( nOrdinalValue )
  487. {
  488. additionalOptions += CFmtStrMax( "-finline-limit=%d ", nOrdinalValue );
  489. }
  490. break;
  491. case PS3_GCCCOMPILER_TOCUsage:
  492. break;
  493. case PS3_GCCCOMPILER_SaveRestoreFunctions:
  494. break;
  495. case PS3_GCCCOMPILER_GenerateMicrocodedInstructions:
  496. break;
  497. case PS3_GCCCOMPILER_PositionIndependentCode:
  498. if ( nOrdinalValue )
  499. {
  500. additionalOptions += "-fpic ";
  501. }
  502. break;
  503. case PS3_GCCCOMPILER_FunctionSections:
  504. if ( nOrdinalValue )
  505. {
  506. additionalOptions += "-ffunction-sections ";
  507. }
  508. break;
  509. case PS3_GCCCOMPILER_DataSections:
  510. if ( nOrdinalValue )
  511. {
  512. additionalOptions += "-fdata-sections ";
  513. }
  514. break;
  515. case PS3_GCCCOMPILER_StackCheck:
  516. if ( nOrdinalValue )
  517. {
  518. additionalOptions += "-fstack-check ";
  519. }
  520. break;
  521. case PS3_GCCCOMPILER_CPPExceptionsAndRTTIUsage:
  522. if ( nOrdinalValue == 0 )
  523. {
  524. additionalOptions += "-fno-exceptions -fno-rtti ";
  525. }
  526. break;
  527. case PS3_GCCCOMPILER_CheckANSICompliance:
  528. if ( nOrdinalValue )
  529. {
  530. additionalOptions += "-ansi ";
  531. }
  532. break;
  533. case PS3_GCCCOMPILER_DefaultCharSigned:
  534. if ( nOrdinalValue )
  535. {
  536. additionalOptions += "-fsigned-char ";
  537. }
  538. break;
  539. case PS3_GCCCOMPILER_Permissive:
  540. if ( nOrdinalValue )
  541. {
  542. additionalOptions += "-fpermissive ";
  543. }
  544. break;
  545. case PS3_GCCCOMPILER_EnableMSExtensions:
  546. break;
  547. case PS3_GCCCOMPILER_RelaxCPPCompliance:
  548. if ( nOrdinalValue )
  549. {
  550. additionalOptions += "-fsource-402 ";
  551. }
  552. break;
  553. case PS3_GCCCOMPILER_AdditionalOptions:
  554. if ( !pCompilerTool->m_PropertyStates.m_Properties[i].m_StringValue.IsEmpty() )
  555. {
  556. additionalOptions += pCompilerTool->m_PropertyStates.m_Properties[i].m_StringValue;
  557. additionalOptions += " ";
  558. }
  559. break;
  560. }
  561. }
  562. if ( !additionalOptions.IsEmpty() )
  563. {
  564. m_XMLWriter.Write( CFmtStrMax( "AdditionalOptions=\"%s\"", additionalOptions.Get() ) );
  565. }
  566. m_XMLWriter.PopNode( false );
  567. return true;
  568. }
  569. bool CProjectGenerator_PS3::WritePreLinkEventTool( CPreLinkEventTool *pPreLinkEventTool )
  570. {
  571. if ( !pPreLinkEventTool )
  572. {
  573. // not an error, some tools n/a for aconfig
  574. return true;
  575. }
  576. m_XMLWriter.PushNode( "Tool" );
  577. m_XMLWriter.Write( "Name=\"VCPreLinkEventTool\"" );
  578. for ( int i = 0; i < pPreLinkEventTool->m_PropertyStates.m_Properties.Count(); i++ )
  579. {
  580. switch ( pPreLinkEventTool->m_PropertyStates.m_Properties[i].m_pToolProperty->m_nPropertyId )
  581. {
  582. case PS3_PRELINKEVENT_CommandLine:
  583. m_XMLWriter.Write( CFmtStrMax( "CommandLine=\"%s\"", m_XMLWriter.FixupXMLString( pPreLinkEventTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) ) );
  584. break;
  585. case PS3_PRELINKEVENT_Description:
  586. m_XMLWriter.Write( CFmtStrMax( "Description=\"%s\"", pPreLinkEventTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  587. break;
  588. case PS3_PRELINKEVENT_ExcludedFromBuild:
  589. m_XMLWriter.Write( CFmtStrMax( "ExcludedFromBuild=\"%s\"", BoolStringToTrueFalseString( pPreLinkEventTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) ) );
  590. break;
  591. }
  592. }
  593. m_XMLWriter.PopNode( false );
  594. return true;
  595. }
  596. bool CProjectGenerator_PS3::WriteSNCLinkerTool( CLinkerTool *pLinkerTool )
  597. {
  598. if ( !pLinkerTool )
  599. {
  600. // not an error, some tools n/a for a config
  601. return true;
  602. }
  603. m_XMLWriter.PushNode( "Tool" );
  604. m_XMLWriter.Write( "Name=\"VCLinkerTool\"" );
  605. // aggregates or purges state as needed
  606. CUtlString additionalOptions = "";
  607. for ( int i = 0; i < pLinkerTool->m_PropertyStates.m_Properties.Count(); i++ )
  608. {
  609. int nOrdinalValue = atoi( pLinkerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() );
  610. switch ( pLinkerTool->m_PropertyStates.m_Properties[i].m_pToolProperty->m_nPropertyId )
  611. {
  612. case PS3_SNCLINKER_OutputFile:
  613. m_XMLWriter.Write( CFmtStrMax( "OutputFile=\"%s\"", pLinkerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  614. break;
  615. case PS3_SNCLINKER_OutputFormat:
  616. if ( nOrdinalValue == 1 )
  617. {
  618. additionalOptions += "-oformat=fself ";
  619. }
  620. else if ( nOrdinalValue == 2 )
  621. {
  622. additionalOptions += "-oformat=fself_npdrm ";
  623. }
  624. else if ( nOrdinalValue == 3 )
  625. {
  626. additionalOptions += "-oformat=prx -prx-with-runtime ";
  627. }
  628. else if ( nOrdinalValue == 4 )
  629. {
  630. additionalOptions += "-oformat=fsprx -prx-with-runtime ";
  631. }
  632. break;
  633. case PS3_SNCLINKER_AdditionalDependencies:
  634. m_XMLWriter.Write( CFmtStrMax( "AdditionalDependencies=\"%s\"", pLinkerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  635. break;
  636. case PS3_SNCLINKER_AdditionalLibraryDirectories:
  637. m_XMLWriter.Write( CFmtStrMax( "AdditionalLibraryDirectories=\"%s\"", pLinkerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  638. break;
  639. case PS3_SNCLINKER_IgnoreAllDefaultLibraries:
  640. if ( nOrdinalValue )
  641. {
  642. m_XMLWriter.Write( "IgnoreAllDefaultLibraries=\"true\"" );
  643. }
  644. break;
  645. case PS3_SNCLINKER_UsingExceptionHandling:
  646. if ( nOrdinalValue )
  647. {
  648. additionalOptions += "--exceptions ";
  649. }
  650. break;
  651. case PS3_SNCLINKER_TOCPointerElimination:
  652. if ( nOrdinalValue )
  653. {
  654. additionalOptions += "--notocrestore ";
  655. }
  656. break;
  657. case PS3_SNCLINKER_ForceSymbolReferences:
  658. m_XMLWriter.Write( CFmtStrMax( "ForceSymbolReferences=\"%s\"", pLinkerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  659. break;
  660. case PS3_SNCLINKER_CallprofHierarchicalProfiling:
  661. if ( nOrdinalValue )
  662. {
  663. additionalOptions += "--callprof ";
  664. }
  665. break;
  666. case PS3_SNCLINKER_DebugInfoAndSymbolStripping:
  667. if ( nOrdinalValue == 1 )
  668. {
  669. additionalOptions += "-S ";
  670. }
  671. else if ( nOrdinalValue == 2 )
  672. {
  673. additionalOptions += "-s ";
  674. }
  675. break;
  676. case PS3_SNCLINKER_UnusedFunctionAndDataStripping:
  677. if ( nOrdinalValue == 1 )
  678. {
  679. additionalOptions += "-strip-unused ";
  680. }
  681. else if ( nOrdinalValue == 2 )
  682. {
  683. additionalOptions += "-strip-unused-data ";
  684. }
  685. break;
  686. case PS3_SNCLINKER_ImportLibrary:
  687. m_XMLWriter.Write( CFmtStrMax( "ImportLibrary=\"%s\"", pLinkerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  688. break;
  689. case PS3_SNCLINKER_GenerateMapFile:
  690. if ( nOrdinalValue == 1 )
  691. {
  692. additionalOptions += CFmtStrMax( "-Map=&quot;%s&quot; ", pLinkerTool->m_PropertyStates.GetProperty( PS3_SNCLINKER_MapFileName )->m_StringValue );
  693. }
  694. else if ( nOrdinalValue == 2 )
  695. {
  696. additionalOptions += CFmtStrMax( "-Map=&quot;%s&quot; -sn-full-map ", pLinkerTool->m_PropertyStates.GetProperty( PS3_SNCLINKER_MapFileName )->m_StringValue );
  697. }
  698. break;
  699. case PS3_SNCLINKER_MapFileName:
  700. m_XMLWriter.Write( CFmtStrMax( "MapFileName=\"%s\"", pLinkerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  701. break;
  702. case PS3_SNCLINKER_LinkLibraryDependencies:
  703. m_XMLWriter.Write( CFmtStrMax( "LinkLibraryDependencies=\"%s\"", BoolStringToTrueFalseString( pLinkerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) ) );
  704. break;
  705. case PS3_SNCLINKER_AdditionalOptions:
  706. if ( !pLinkerTool->m_PropertyStates.m_Properties[i].m_StringValue.IsEmpty() )
  707. {
  708. additionalOptions += pLinkerTool->m_PropertyStates.m_Properties[i].m_StringValue;
  709. additionalOptions += " ";
  710. }
  711. break;
  712. }
  713. }
  714. if ( !additionalOptions.IsEmpty() )
  715. {
  716. m_XMLWriter.Write( CFmtStrMax( "AdditionalOptions=\"%s\"", additionalOptions.Get() ) );
  717. }
  718. m_XMLWriter.PopNode( false );
  719. return true;
  720. }
  721. bool CProjectGenerator_PS3::WriteGCCLinkerTool( CLinkerTool *pLinkerTool )
  722. {
  723. if ( !pLinkerTool )
  724. {
  725. // not an error, some tools n/a for a config
  726. return true;
  727. }
  728. m_XMLWriter.PushNode( "Tool" );
  729. m_XMLWriter.Write( "Name=\"VCLinkerTool\"" );
  730. // aggregates or purges state as needed
  731. CUtlString additionalOptions = "";
  732. for ( int i = 0; i < pLinkerTool->m_PropertyStates.m_Properties.Count(); i++ )
  733. {
  734. int nOrdinalValue = atoi( pLinkerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() );
  735. switch ( pLinkerTool->m_PropertyStates.m_Properties[i].m_pToolProperty->m_nPropertyId )
  736. {
  737. case PS3_GCCLINKER_OutputFile:
  738. m_XMLWriter.Write( CFmtStrMax( "OutputFile=\"%s\"", pLinkerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  739. break;
  740. case PS3_GCCLINKER_AdditionalDependencies:
  741. m_XMLWriter.Write( CFmtStrMax( "AdditionalDependencies=\"%s\"", pLinkerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  742. break;
  743. case PS3_GCCLINKER_AdditionalLibraryDirectories:
  744. m_XMLWriter.Write( CFmtStrMax( "AdditionalLibraryDirectories=\"%s\"", pLinkerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  745. break;
  746. case PS3_GCCLINKER_ImportLibrary:
  747. m_XMLWriter.Write( CFmtStrMax( "ImportLibrary=\"%s\"", pLinkerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  748. break;
  749. case PS3_GCCLINKER_SPURSUsage:
  750. if ( nOrdinalValue == 1 )
  751. {
  752. additionalOptions += "-mspurs-job-initialize ";
  753. }
  754. else if ( nOrdinalValue == 2 )
  755. {
  756. additionalOptions += "-mspurs-job ";
  757. }
  758. else if ( nOrdinalValue == 3 )
  759. {
  760. additionalOptions += "-mspurs-task ";
  761. }
  762. break;
  763. case PS3_GCCLINKER_PositionIndependentCode:
  764. if ( nOrdinalValue )
  765. {
  766. additionalOptions += "-fpic ";
  767. }
  768. break;
  769. case PS3_GCCLINKER_EmitRelocations:
  770. if ( nOrdinalValue )
  771. {
  772. additionalOptions += "-Wl,-q ";
  773. }
  774. break;
  775. case PS3_GCCLINKER_GarbageCollection:
  776. if ( nOrdinalValue )
  777. {
  778. additionalOptions += "-Wl,--gc-sections ";
  779. }
  780. break;
  781. case PS3_GCCLINKER_GenerateMapFile:
  782. if ( nOrdinalValue == 1 )
  783. {
  784. additionalOptions += CFmtStrMax( "-Map=&quot;%s&quot; ", pLinkerTool->m_PropertyStates.GetProperty( PS3_GCCLINKER_MapFileName )->m_StringValue );
  785. }
  786. break;
  787. case PS3_GCCLINKER_MapFileName:
  788. m_XMLWriter.Write( CFmtStrMax( "MapFileName=\"%s\"", pLinkerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  789. break;
  790. case PS3_GCCLINKER_LinkLibraryDependencies:
  791. m_XMLWriter.Write( CFmtStrMax( "LinkLibraryDependencies=\"%s\"", BoolStringToTrueFalseString( pLinkerTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) ) );
  792. break;
  793. case PS3_SNCLINKER_AdditionalOptions:
  794. case PS3_GCCLINKER_AdditionalOptions:
  795. if ( !pLinkerTool->m_PropertyStates.m_Properties[i].m_StringValue.IsEmpty() )
  796. {
  797. additionalOptions += pLinkerTool->m_PropertyStates.m_Properties[i].m_StringValue;
  798. additionalOptions += " ";
  799. }
  800. break;
  801. }
  802. }
  803. if ( !additionalOptions.IsEmpty() )
  804. {
  805. m_XMLWriter.Write( CFmtStrMax( "AdditionalOptions=\"%s\"", additionalOptions.Get() ) );
  806. }
  807. m_XMLWriter.PopNode( false );
  808. return true;
  809. }
  810. bool CProjectGenerator_PS3::WriteLibrarianTool( CLibrarianTool *pLibrarianTool )
  811. {
  812. if ( !pLibrarianTool )
  813. {
  814. // not an error, some tools n/a for aconfig
  815. return true;
  816. }
  817. m_XMLWriter.PushNode( "Tool" );
  818. m_XMLWriter.Write( "Name=\"VCLibrarianTool\"" );
  819. for ( int i = 0; i < pLibrarianTool->m_PropertyStates.m_Properties.Count(); i++ )
  820. {
  821. switch ( pLibrarianTool->m_PropertyStates.m_Properties[i].m_pToolProperty->m_nPropertyId )
  822. {
  823. case PS3_LIBRARIAN_OutputFile:
  824. m_XMLWriter.Write( CFmtStrMax( "OutputFile=\"%s\"", pLibrarianTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  825. break;
  826. case PS3_LIBRARIAN_AdditionalDependencies:
  827. m_XMLWriter.Write( CFmtStrMax( "AdditionalDependencies=\"%s\"", pLibrarianTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  828. break;
  829. case PS3_LIBRARIAN_WholeArchive:
  830. // can't decode, seems broken
  831. break;
  832. case PS3_LIBRARIAN_LinkLibraryDependencies:
  833. m_XMLWriter.Write( CFmtStrMax( "LinkLibraryDependencies=\"%s\"", BoolStringToTrueFalseString( pLibrarianTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) ) );
  834. break;
  835. }
  836. }
  837. m_XMLWriter.PopNode( false );
  838. return true;
  839. }
  840. bool CProjectGenerator_PS3::WritePostBuildEventTool( CPostBuildEventTool *pPostBuildEventTool )
  841. {
  842. if ( !pPostBuildEventTool )
  843. {
  844. // not an error, some tools n/a for aconfig
  845. return true;
  846. }
  847. m_XMLWriter.PushNode( "Tool" );
  848. m_XMLWriter.Write( "Name=\"VCPostBuildEventTool\"" );
  849. for ( int i = 0; i < pPostBuildEventTool->m_PropertyStates.m_Properties.Count(); i++ )
  850. {
  851. switch ( pPostBuildEventTool->m_PropertyStates.m_Properties[i].m_pToolProperty->m_nPropertyId )
  852. {
  853. case PS3_POSTBUILDEVENT_CommandLine:
  854. m_XMLWriter.Write( CFmtStrMax( "CommandLine=\"%s\"", m_XMLWriter.FixupXMLString( pPostBuildEventTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) ) );
  855. break;
  856. case PS3_POSTBUILDEVENT_Description:
  857. m_XMLWriter.Write( CFmtStrMax( "Description=\"%s\"", pPostBuildEventTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  858. break;
  859. case PS3_POSTBUILDEVENT_ExcludedFromBuild:
  860. m_XMLWriter.Write( CFmtStrMax( "ExcludedFromBuild=\"%s\"", BoolStringToTrueFalseString( pPostBuildEventTool->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) ) );
  861. break;
  862. }
  863. }
  864. m_XMLWriter.PopNode( false );
  865. return true;
  866. }
  867. const char *CProjectGenerator_PS3::BoolStringToTrueFalseString( const char *pValue )
  868. {
  869. return Sys_StringToBool( pValue ) ? "true" : "false";
  870. }
  871. bool CProjectGenerator_PS3::WriteConfiguration( CProjectConfiguration *pConfig )
  872. {
  873. if ( pConfig->m_bIsFileConfig )
  874. {
  875. m_XMLWriter.PushNode( "FileConfiguration" );
  876. }
  877. else
  878. {
  879. m_XMLWriter.PushNode( "Configuration" );
  880. }
  881. const char *pOutputName = "???";
  882. if ( !V_stricmp( pConfig->m_Name.Get(), "debug" ) )
  883. {
  884. if ( m_pVCProjGenerator->GetVSIType() == PS3_VSI_TYPE_SNC )
  885. {
  886. pOutputName = "PS3 Debug|Win32";
  887. }
  888. else if ( m_pVCProjGenerator->GetVSIType() == PS3_VSI_TYPE_GCC )
  889. {
  890. pOutputName = "PS3 Debug|Win32";
  891. }
  892. }
  893. else if ( !V_stricmp( pConfig->m_Name.Get(), "release" ) )
  894. {
  895. if ( m_pVCProjGenerator->GetVSIType() == PS3_VSI_TYPE_SNC )
  896. {
  897. pOutputName = "PS3 Release|Win32";
  898. }
  899. else if ( m_pVCProjGenerator->GetVSIType() == PS3_VSI_TYPE_GCC )
  900. {
  901. pOutputName = "PS3 Release|Win32";
  902. }
  903. }
  904. else if ( !V_stricmp( pConfig->m_Name.Get(), "profile" ) )
  905. {
  906. if ( m_pVCProjGenerator->GetVSIType() == PS3_VSI_TYPE_SNC )
  907. {
  908. pOutputName = "PS3 Profile|Win32";
  909. }
  910. else if ( m_pVCProjGenerator->GetVSIType() == PS3_VSI_TYPE_GCC )
  911. {
  912. pOutputName = "PS3 Profile|Win32";
  913. }
  914. }
  915. else if ( !V_stricmp( pConfig->m_Name.Get(), "retail" ) )
  916. {
  917. if ( m_pVCProjGenerator->GetVSIType() == PS3_VSI_TYPE_SNC )
  918. {
  919. pOutputName = "PS3 Retail|Win32";
  920. }
  921. else if ( m_pVCProjGenerator->GetVSIType() == PS3_VSI_TYPE_GCC )
  922. {
  923. pOutputName = "PS3 Retail|Win32";
  924. }
  925. }
  926. else
  927. {
  928. return false;
  929. }
  930. m_XMLWriter.Write( CFmtStrMax( "Name=\"%s\"", pOutputName ) );
  931. // write configuration properties
  932. for ( int i = 0; i < pConfig->m_PropertyStates.m_Properties.Count(); i++ )
  933. {
  934. switch ( pConfig->m_PropertyStates.m_Properties[i].m_pToolProperty->m_nPropertyId )
  935. {
  936. case PS3_GENERAL_ConfigurationType:
  937. m_XMLWriter.Write( CFmtStrMax( "ConfigurationType=\"%s\"", pConfig->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  938. break;
  939. case PS3_GENERAL_ExcludedFromBuild:
  940. m_XMLWriter.Write( CFmtStrMax( "ExcludedFromBuild=\"%s\"", BoolStringToTrueFalseString( pConfig->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) ) );
  941. break;
  942. case PS3_GENERAL_OutputDirectory:
  943. m_XMLWriter.Write( CFmtStrMax( "OutputDirectory=\"%s\"", pConfig->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  944. break;
  945. case PS3_GENERAL_IntermediateDirectory:
  946. m_XMLWriter.Write( CFmtStrMax( "IntermediateDirectory=\"%s\"", pConfig->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  947. break;
  948. case PS3_GENERAL_ExtensionsToDeleteOnClean:
  949. m_XMLWriter.Write( CFmtStrMax( "DeleteExtensionsOnClean=\"%s\"", pConfig->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  950. break;
  951. case PS3_GENERAL_BuildLogFile:
  952. m_XMLWriter.Write( CFmtStrMax( "BuildLogFile=\"%s\"", pConfig->m_PropertyStates.m_Properties[i].m_StringValue.Get() ) );
  953. break;
  954. case PS3_GENERAL_SystemIncludeDependencies:
  955. // ignoring
  956. break;
  957. case PS3_GENERAL_SaveDebuggerPropertiesInProject:
  958. // ignoring
  959. break;
  960. }
  961. }
  962. m_XMLWriter.Write( ">" );
  963. if ( !WritePreBuildEventTool( pConfig->GetPreBuildEventTool() ) )
  964. return false;
  965. if ( !WriteCustomBuildTool( pConfig->GetCustomBuildTool() ) )
  966. return false;
  967. if ( m_pVCProjGenerator->GetVSIType() == PS3_VSI_TYPE_SNC )
  968. {
  969. if ( !WriteSNCCompilerTool( pConfig->GetCompilerTool() ) )
  970. return false;
  971. }
  972. else if ( m_pVCProjGenerator->GetVSIType() == PS3_VSI_TYPE_GCC )
  973. {
  974. if ( !WriteGCCCompilerTool( pConfig->GetCompilerTool() ) )
  975. return false;
  976. }
  977. if ( !WritePreLinkEventTool( pConfig->GetPreLinkEventTool() ) )
  978. return false;
  979. if ( m_pVCProjGenerator->GetVSIType() == PS3_VSI_TYPE_SNC )
  980. {
  981. if ( !WriteSNCLinkerTool( pConfig->GetLinkerTool() ) )
  982. return false;
  983. }
  984. else if ( m_pVCProjGenerator->GetVSIType() == PS3_VSI_TYPE_GCC )
  985. {
  986. if ( !WriteGCCLinkerTool( pConfig->GetLinkerTool() ) )
  987. return false;
  988. }
  989. if ( !WriteLibrarianTool( pConfig->GetLibrarianTool() ) )
  990. return false;
  991. if ( !WritePostBuildEventTool( pConfig->GetPostBuildEventTool() ) )
  992. return false;
  993. m_XMLWriter.PopNode( true );
  994. return true;
  995. }
  996. bool CProjectGenerator_PS3::WriteToXML()
  997. {
  998. m_XMLWriter.PushNode( "VisualStudioProject" );
  999. m_XMLWriter.Write( "ProjectType=\"Visual C++\"" );
  1000. m_XMLWriter.Write( "Version=\"8.00\"" );
  1001. m_XMLWriter.Write( CFmtStrMax( "Name=\"%s\"", m_pVCProjGenerator->GetProjectName().Get() ) );
  1002. m_XMLWriter.Write( CFmtStrMax( "ProjectGUID=\"%s\"", m_pVCProjGenerator->GetGUIDString().Get() ) );
  1003. m_XMLWriter.Write( CFmtStrMax( "RootNamespace=\"%s\"", m_pVCProjGenerator->GetProjectName().Get() ) );
  1004. m_XMLWriter.Write( ">" );
  1005. m_XMLWriter.PushNode( "Platforms" );
  1006. m_XMLWriter.PushNode( "Platform" );
  1007. m_XMLWriter.Write( "Name=\"win32\"" );
  1008. m_XMLWriter.PopNode( false );
  1009. m_XMLWriter.PopNode( true );
  1010. m_XMLWriter.PushNode( "ToolFiles" );
  1011. m_XMLWriter.PopNode( true );
  1012. CUtlVector< CUtlString > configurationNames;
  1013. m_pVCProjGenerator->GetAllConfigurationNames( configurationNames );
  1014. // write the root configurations
  1015. m_XMLWriter.PushNode( "Configurations" );
  1016. for ( int i = 0; i < configurationNames.Count(); i++ )
  1017. {
  1018. CProjectConfiguration *pConfiguration = NULL;
  1019. if ( m_pVCProjGenerator->GetRootConfiguration( configurationNames[i].Get(), &pConfiguration ) )
  1020. {
  1021. if ( !WriteConfiguration( pConfiguration ) )
  1022. return false;
  1023. }
  1024. }
  1025. m_XMLWriter.PopNode( true );
  1026. m_XMLWriter.PushNode( "References" );
  1027. m_XMLWriter.PopNode( true );
  1028. m_XMLWriter.PushNode( "Files" );
  1029. CProjectFolder *pRootFolder = m_pVCProjGenerator->GetRootFolder();
  1030. for ( int iIndex = pRootFolder->m_Folders.Head(); iIndex != pRootFolder->m_Folders.InvalidIndex(); iIndex = pRootFolder->m_Folders.Next( iIndex ) )
  1031. {
  1032. if ( !WriteFolder( pRootFolder->m_Folders[iIndex] ) )
  1033. return false;
  1034. }
  1035. for ( int iIndex = pRootFolder->m_Files.Head(); iIndex != pRootFolder->m_Files.InvalidIndex(); iIndex = pRootFolder->m_Files.Next( iIndex ) )
  1036. {
  1037. if ( !WriteFile( pRootFolder->m_Files[iIndex] ) )
  1038. return false;
  1039. }
  1040. m_XMLWriter.PopNode( true );
  1041. m_XMLWriter.PushNode( "Globals" );
  1042. m_XMLWriter.PopNode( true );
  1043. m_XMLWriter.PopNode( true );
  1044. return true;
  1045. }
  1046. bool CProjectGenerator_PS3::Save( const char *pOutputFilename )
  1047. {
  1048. if ( !m_XMLWriter.Open( pOutputFilename ) )
  1049. return false;
  1050. bool bValid = WriteToXML();
  1051. m_XMLWriter.Close();
  1052. if ( bValid )
  1053. {
  1054. // Not sure what this file does or why, but we emit it and
  1055. // its part of a default SN project. The custom build steps
  1056. // were copied are hosted in all the vpc ps3 base scripts.
  1057. FILE *fp = fopen( "vsi.nul", "wt" );
  1058. if ( fp )
  1059. {
  1060. fprintf( fp, "SN Visual Studio Integration\n" );
  1061. fprintf( fp, "IMPORTANT: Do not remove the custom build step for this file\n" );
  1062. fclose( fp );
  1063. }
  1064. }
  1065. return bValid;
  1066. }