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.

130 lines
4.4 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. //
  4. //=============================================================================
  5. #ifndef BASEPROJECTDATACOLLECTOR_H
  6. #define BASEPROJECTDATACOLLECTOR_H
  7. #ifdef _WIN32
  8. #pragma once
  9. #endif
  10. #ifdef STEAM
  11. #include "tier1/keyvalues.h"
  12. #else
  13. #include "tier1/keyvalues.h"
  14. #endif
  15. #include "tier1/utlstack.h"
  16. class CSpecificConfig
  17. {
  18. public:
  19. CSpecificConfig( CSpecificConfig *pParentConfig );
  20. ~CSpecificConfig();
  21. const char *GetConfigName();
  22. const char *GetOption( const char *pOptionName );
  23. public:
  24. CSpecificConfig *m_pParentConfig;
  25. KeyValues *m_pKV;
  26. bool m_bFileExcluded; // Is the file that holds this config excluded from the build?
  27. bool m_bIsSchema; // Is this a schema file?
  28. };
  29. class CFileConfig
  30. {
  31. public:
  32. ~CFileConfig();
  33. void Term();
  34. const char *GetName();
  35. CSpecificConfig *GetConfig( const char *pConfigName );
  36. CSpecificConfig *GetOrCreateConfig( const char *pConfigName, CSpecificConfig *pParentConfig );
  37. bool IsExcludedFrom( const char *pConfigName );
  38. public:
  39. CUtlDict< CSpecificConfig*, int > m_Configurations;
  40. CUtlString m_Filename; // "" if this is the config data for the whole project.
  41. };
  42. // This just holds the list of property names that we're supposed to scan for.
  43. class CRelevantPropertyNames
  44. {
  45. public:
  46. const char **m_pNames;
  47. int m_nNames;
  48. };
  49. //
  50. // This class is shared by the makefile and SlickEdit project file generator.
  51. // It just collects interesting file properties into KeyValues and then the project file generator
  52. // is responsible for using that data to write out a project file.
  53. //
  54. class CBaseProjectDataCollector : public IBaseProjectGenerator
  55. {
  56. // IBaseProjectGenerator implementation.
  57. public:
  58. CBaseProjectDataCollector( CRelevantPropertyNames *pNames );
  59. ~CBaseProjectDataCollector();
  60. // Called before doing anything in a project (in g_pVPC->GetOutputFilename()).
  61. virtual void StartProject();
  62. virtual void EndProject();
  63. // Access the project name.
  64. virtual CUtlString GetProjectName();
  65. virtual void SetProjectName( const char *pProjectName );
  66. // Get a list of all configurations.
  67. virtual void GetAllConfigurationNames( CUtlVector< CUtlString > &configurationNames );
  68. // Configuration data is specified in between these calls and inside BeginPropertySection/EndPropertySection.
  69. // If bFileSpecific is set, then the configuration data only applies to the last file added.
  70. virtual void StartConfigurationBlock( const char *pConfigName, bool bFileSpecific );
  71. virtual void EndConfigurationBlock();
  72. // These functions are called when it enters a section like $Compiler, $Linker, etc.
  73. // In between the BeginPropertySection/EndPropertySection, it'll call HandleProperty for any properties inside that section.
  74. //
  75. // If you pass pCustomScriptData to HandleProperty, it won't touch the global parsing state -
  76. // it'll parse the platform filters and property value from pCustomScriptData instead.
  77. virtual bool StartPropertySection( configKeyword_e keyword, bool *pbShouldSkip = NULL );
  78. virtual void HandleProperty( const char *pProperty, const char *pCustomScriptData = NULL );
  79. virtual void EndPropertySection( configKeyword_e keyword );
  80. // Files go in folders. The generator should maintain a stack of folders as they're added.
  81. virtual void StartFolder( const char *pFolderName );
  82. virtual void EndFolder();
  83. // Add files. Any config blocks/properties between StartFile/EndFile apply to this file only.
  84. // It will only ever have one active file.
  85. virtual bool StartFile( const char *pFilename, bool bWarnIfAlreadyExists );
  86. virtual void EndFile();
  87. // This is actually just per-file configuration data.
  88. virtual void FileExcludedFromBuild( bool bExcluded );
  89. virtual void FileIsSchema( bool bIsSchema );
  90. // Remove the specified file.
  91. virtual bool RemoveFile( const char *pFilename ); // returns ture if a file was removed
  92. public:
  93. // This is called in EndProject if bAutoCleanupAfterProject is set.
  94. void Term();
  95. static void DoStandardVisualStudioReplacements( const char *pStartString, const char *pFullInputFilename, char *pOut, int outLen );
  96. public:
  97. CUtlString m_ProjectName;
  98. CUtlDict< CFileConfig *, int > m_Files;
  99. CFileConfig m_BaseConfigData;
  100. CUtlStack< CFileConfig* > m_CurFileConfig; // Either m_BaseConfigData or one of the files.
  101. CUtlStack< CSpecificConfig* > m_CurSpecificConfig; // Debug, release?
  102. CRelevantPropertyNames m_RelevantPropertyNames;
  103. };
  104. #endif // BASEPROJECTDATACOLLECTOR_H