cmGlobalFastbuildGenerator.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file LICENSE.rst or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include <algorithm>
  5. #include <iterator>
  6. #include <map>
  7. #include <set>
  8. #include <string>
  9. #include <type_traits>
  10. #include <unordered_map>
  11. #include <unordered_set>
  12. #include <utility>
  13. #include <vector>
  14. #include <cm/memory>
  15. #include <cm/optional>
  16. #include <assert.h>
  17. #include "cmBuildOptions.h"
  18. #include "cmGeneratedFileStream.h"
  19. #include "cmGlobalCommonGenerator.h"
  20. class cmFastbuildTargetGenerator;
  21. class cmGeneratorTarget;
  22. class cmGlobalGeneratorFactory;
  23. class cmLinkLineComputer;
  24. class cmLocalGenerator;
  25. class cmMakefile;
  26. class cmOutputConverter;
  27. class cmStateDirectory;
  28. class cmake;
  29. enum class cmDepfileFormat;
  30. struct cmDocumentationEntry;
  31. #define FASTBUILD_DOLLAR_TAG "FASTBUILD_DOLLAR_TAG"
  32. #define FASTBUILD_1_INPUT_PLACEHOLDER \
  33. FASTBUILD_DOLLAR_TAG "FB_INPUT_1_PLACEHOLDER" FASTBUILD_DOLLAR_TAG
  34. #define FASTBUILD_1_0_INPUT_PLACEHOLDER \
  35. FASTBUILD_DOLLAR_TAG "FB_INPUT_1_0_PLACEHOLDER" FASTBUILD_DOLLAR_TAG
  36. #define FASTBUILD_1_1_INPUT_PLACEHOLDER \
  37. FASTBUILD_DOLLAR_TAG "FB_INPUT_1_1_PLACEHOLDER" FASTBUILD_DOLLAR_TAG
  38. #define FASTBUILD_2_INPUT_PLACEHOLDER \
  39. FASTBUILD_DOLLAR_TAG "FB_INPUT_2_PLACEHOLDER" FASTBUILD_DOLLAR_TAG
  40. #define FASTBUILD_3_INPUT_PLACEHOLDER \
  41. FASTBUILD_DOLLAR_TAG "FB_INPUT_3_PLACEHOLDER" FASTBUILD_DOLLAR_TAG
  42. // Alias to artifacts that can be consumed by the linker (DLL or Library).
  43. #define FASTBUILD_LINK_ARTIFACTS_ALIAS_POSTFIX "-link-artifacts"
  44. // Alias to all the ObjectList nodes.
  45. #define FASTBUILD_OBJECTS_ALIAS_POSTFIX "-objects"
  46. // Alias to all the dependencies of the target.
  47. #define FASTBUILD_DEPS_ARTIFACTS_ALIAS_POSTFIX "-deps"
  48. #define FASTBUILD_PRE_BUILD_ALIAS_POSTFIX "-pre-build"
  49. #define FASTBUILD_PRE_LINK_ALIAS_POSTFIX "-pre-link"
  50. #define FASTBUILD_POST_BUILD_ALIAS_POSTFIX "-post-build"
  51. // Alias to all other custom commands in the target.
  52. #define FASTBUILD_CUSTOM_COMMAND_ALIAS_POSTFIX "-custom-commands"
  53. // Alias to outputs produced by a custom command (since FASTBuild exec node
  54. // does not support more than 1 output).
  55. #define FASTBUILD_OUTPUTS_ALIAS_POSTFIX "-outputs"
  56. // Alias to byproducts produced by a custom command (since FASTBuild exec node
  57. // does not support more than 1 output).
  58. #define FASTBUILD_BYPRODUCTS_ALIAS_POSTFIX "-byproducts"
  59. #define FASTBUILD_COMPILER_PREFIX "Compiler_"
  60. #define FASTBUILD_LAUNCHER_PREFIX "Launcher_"
  61. #define FASTBUILD_LINKER_LAUNCHER_PREFIX "LinkerLauncher_"
  62. #define FASTBUILD_RESTAT_FILE "FASTBUILD_RESTAT"
  63. #define FASTBUILD_UTIL_CONCURRENCY_GROUP_NAME "Utils"
  64. #define FASTBUILD_ALL_TARGET_NAME "all"
  65. #define FASTBUILD_CLEAN_TARGET_NAME "clean"
  66. #define FASTBUILD_NOOP_FILE_NAME "fbuild_noop"
  67. #define FASTBUILD_CLEAN_FILE_NAME "fbuild_clean-out"
  68. #define FASTBUILD_BUILD_FILE "fbuild.bff"
  69. #define FASTBUILD_DUMMY_OUTPUT_EXTENSION ".fbuild-cc-out"
  70. #if defined(_WIN32)
  71. # define FASTBUILD_SCRIPT_FILE_EXTENSION ".bat"
  72. # define FASTBUILD_SCRIPT_FILE_ARG "/C "
  73. # define FASTBUILD_SCRIPT_CD "cd /D "
  74. # define FASTBUILD_CLEAN_SCRIPT_NAME "clean" FASTBUILD_SCRIPT_FILE_EXTENSION
  75. #else
  76. # define FASTBUILD_SCRIPT_FILE_EXTENSION ".sh"
  77. # define FASTBUILD_SCRIPT_FILE_ARG ""
  78. # define FASTBUILD_SCRIPT_CD "cd "
  79. # define FASTBUILD_CLEAN_SCRIPT_NAME "clean" FASTBUILD_SCRIPT_FILE_EXTENSION
  80. #endif
  81. enum class FastbuildTargetDepType
  82. {
  83. // Order-only dependency that is not going to appear in the generated file.
  84. ORDER_ONLY,
  85. // Regular target dep.
  86. REGULAR,
  87. };
  88. struct FastbuildTargetDep
  89. {
  90. std::string Name;
  91. FastbuildTargetDepType Type = FastbuildTargetDepType::REGULAR;
  92. FastbuildTargetDep(std::string n)
  93. : Name(std::move(n))
  94. {
  95. }
  96. bool operator==(FastbuildTargetDep const& rhs) const
  97. {
  98. return this->Name == rhs.Name;
  99. }
  100. bool operator<(FastbuildTargetDep const& rhs) const
  101. {
  102. return this->Name < rhs.Name;
  103. }
  104. };
  105. enum class FastbuildTargetType
  106. {
  107. ALIAS, // Alias node
  108. EXEC, // Exec node
  109. LINK, // Library, DLL or Executable
  110. OBJECTLIST,
  111. UNITY,
  112. };
  113. struct FastbuildTargetBase
  114. {
  115. // Target name with config postfix.
  116. std::string Name;
  117. // Target name without config postfix, we use it to locate IDE project for
  118. // the given target and add +1 config to it.
  119. std::string BaseName;
  120. std::string BasePath;
  121. std::set<FastbuildTargetDep> PreBuildDependencies;
  122. bool Hidden = true;
  123. FastbuildTargetType Type;
  124. explicit FastbuildTargetBase(FastbuildTargetType TargetType)
  125. : Type(TargetType)
  126. {
  127. }
  128. };
  129. using FastbuildTargetPtrT = std::unique_ptr<FastbuildTargetBase>;
  130. struct FastbuildAliasNode : public FastbuildTargetBase
  131. {
  132. bool ExcludeFromAll = false;
  133. FastbuildAliasNode()
  134. : FastbuildTargetBase(FastbuildTargetType::ALIAS)
  135. {
  136. }
  137. };
  138. struct FastbuildExecNode : public FastbuildTargetBase
  139. {
  140. std::string ExecExecutable;
  141. std::string ExecArguments;
  142. std::string ScriptFile;
  143. std::string ExecWorkingDir;
  144. bool ExecUseStdOutAsOutput = false;
  145. std::string ExecOutput;
  146. std::vector<std::string> ExecInput;
  147. std::vector<std::string> ExecInputPath;
  148. std::vector<std::string> ExecInputPattern;
  149. bool ExecInputPathRecurse = false;
  150. bool ExecAlways = false;
  151. FastbuildAliasNode OutputsAlias;
  152. FastbuildAliasNode ByproductsAlias;
  153. std::string ConcurrencyGroupName;
  154. bool ExcludeFromAll = false;
  155. FastbuildExecNode()
  156. : FastbuildTargetBase(FastbuildTargetType::EXEC)
  157. {
  158. }
  159. bool NeedsDepsCheckExec = false;
  160. };
  161. struct FastbuildCompiler
  162. {
  163. std::map<std::string, std::string> ExtraVariables;
  164. std::string Name;
  165. std::string Executable;
  166. std::string CmakeCompilerID;
  167. std::string CompilerFamily = "custom";
  168. std::string CmakeCompilerVersion;
  169. std::string Language;
  170. std::vector<std::string> ExtraFiles;
  171. bool UseLightCache = false;
  172. bool ClangRewriteIncludes = true;
  173. bool ClangGCCUpdateXLanguageArg = false;
  174. bool AllowResponseFile = false;
  175. bool ForceResponseFile = false;
  176. bool UseRelativePaths = false;
  177. bool UseDeterministicPaths = false;
  178. std::string SourceMapping;
  179. // Only used for launchers.
  180. std::string Args;
  181. bool DontUseEnv = false;
  182. };
  183. struct FastbuildObjectListNode : public FastbuildTargetBase
  184. {
  185. std::string Compiler;
  186. std::string CompilerOptions;
  187. std::string CompilerOutputPath;
  188. std::string CompilerOutputExtension;
  189. std::vector<std::string> CompilerInputUnity;
  190. std::string PCHInputFile;
  191. std::string PCHOutputFile;
  192. std::string PCHOptions;
  193. std::vector<std::string> CompilerInputFiles;
  194. bool AllowCaching = true;
  195. bool AllowDistribution = true;
  196. std::set<std::string> ObjectOutputs;
  197. std::set<std::string> ObjectDepends;
  198. // Apple only.
  199. std::string arch;
  200. FastbuildObjectListNode()
  201. : FastbuildTargetBase(FastbuildTargetType::OBJECTLIST)
  202. {
  203. }
  204. };
  205. struct FastbuildUnityNode : public FastbuildTargetBase
  206. {
  207. std::string UnityOutputPath;
  208. std::vector<std::string> UnityInputFiles;
  209. std::string UnityOutputPattern;
  210. std::vector<std::string> UnityInputIsolatedFiles;
  211. FastbuildUnityNode()
  212. : FastbuildTargetBase(FastbuildTargetType::UNITY)
  213. {
  214. }
  215. };
  216. struct IDEProjectConfig
  217. {
  218. std::string Config;
  219. std::string Target;
  220. // VS only.
  221. std::string Platform;
  222. std::string XCodeBaseSDK;
  223. std::string XCodeDebugWorkingDir;
  224. std::string XCodeIphoneOSDeploymentTarget;
  225. };
  226. struct IDEProjectCommon
  227. {
  228. std::string Alias;
  229. std::string ProjectOutput;
  230. std::string ProjectBasePath;
  231. std::vector<IDEProjectConfig> ProjectConfigs;
  232. };
  233. struct XCodeProject : public IDEProjectCommon
  234. {
  235. };
  236. struct VCXProject : public IDEProjectCommon
  237. {
  238. std::string folder;
  239. };
  240. struct FastbuildLinkerNode
  241. {
  242. enum
  243. {
  244. EXECUTABLE,
  245. SHARED_LIBRARY,
  246. STATIC_LIBRARY,
  247. NONE
  248. } Type = NONE;
  249. std::string Name;
  250. std::string Compiler;
  251. std::string CompilerOptions;
  252. std::string Linker;
  253. std::string LinkerType;
  254. std::string LinkerOutput;
  255. std::string LinkerOptions;
  256. std::vector<std::string> LibrarianAdditionalInputs;
  257. // We only use Libraries2 for tracking dependencies.
  258. std::vector<std::string> Libraries2;
  259. std::set<std::string> PreBuildDependencies;
  260. bool LinkerLinkObjects = false;
  261. std::string LinkerStampExe;
  262. std::string LinkerStampExeArgs;
  263. // Apple only.
  264. std::string Arch;
  265. };
  266. struct FastbuildCopyNode
  267. {
  268. std::string Name;
  269. std::string Source;
  270. std::string Dest;
  271. std::string PreBuildDependencies;
  272. bool CopyDir = false;
  273. };
  274. struct FastbuildExecNodes
  275. {
  276. std::vector<FastbuildExecNode> Nodes;
  277. FastbuildAliasNode Alias;
  278. };
  279. struct FastbuildTarget : public FastbuildTargetBase
  280. {
  281. std::map<std::string, std::string> Variables;
  282. std::vector<FastbuildObjectListNode> ObjectListNodes;
  283. std::vector<FastbuildUnityNode> UnityNodes;
  284. // Potentially multiple libs for different archs (apple only)
  285. std::vector<FastbuildLinkerNode> CudaDeviceLinkNode;
  286. std::vector<FastbuildLinkerNode> LinkerNode;
  287. std::string RealOutput;
  288. FastbuildAliasNode PreBuildExecNodes, ExecNodes;
  289. std::vector<FastbuildAliasNode> AliasNodes;
  290. // This alias must be written before all other nodes, since they might need
  291. // to refer to it.
  292. FastbuildAliasNode DependenciesAlias;
  293. std::vector<FastbuildCopyNode> CopyNodes;
  294. FastbuildExecNodes PreLinkExecNodes;
  295. FastbuildExecNodes PostBuildExecNodes;
  296. bool IsGlobal = false;
  297. bool ExcludeFromAll = false;
  298. bool AllowDistribution = true;
  299. FastbuildTarget()
  300. : FastbuildTargetBase(FastbuildTargetType::LINK)
  301. {
  302. }
  303. void GenerateAliases();
  304. };
  305. class cmGlobalFastbuildGenerator : public cmGlobalCommonGenerator
  306. {
  307. public:
  308. cmGlobalFastbuildGenerator(cmake* cm);
  309. void ReadCompilerOptions(FastbuildCompiler& compiler, cmMakefile* mf);
  310. void ProcessEnvironment();
  311. static std::unique_ptr<cmGlobalGeneratorFactory> NewFactory();
  312. void Generate() override;
  313. bool FindMakeProgram(cmMakefile* mf) override;
  314. void EnableLanguage(std::vector<std::string> const& lang, cmMakefile* mf,
  315. bool optional) override;
  316. bool IsFastbuild() const override { return true; }
  317. std::vector<GeneratedMakeCommand> GenerateBuildCommand(
  318. std::string const& makeProgram, std::string const& projectName,
  319. std::string const& projectDir, std::vector<std::string> const& targetNames,
  320. std::string const& config, int jobs, bool verbose,
  321. cmBuildOptions buildOptions = cmBuildOptions(),
  322. std::vector<std::string> const& makeOptions = std::vector<std::string>(),
  323. BuildTryCompile isInTryCompile = BuildTryCompile::No) override;
  324. std::unique_ptr<cmLocalGenerator> CreateLocalGenerator(
  325. cmMakefile* makefile) override;
  326. std::string GetName() const override
  327. {
  328. return cmGlobalFastbuildGenerator::GetActualName();
  329. }
  330. bool IsMultiConfig() const override { return false; }
  331. bool SupportsCustomObjectNames() const override { return false; }
  332. void ComputeTargetObjectDirectory(cmGeneratorTarget*) const override;
  333. void AppendDirectoryForConfig(std::string const& prefix,
  334. std::string const& config,
  335. std::string const& suffix,
  336. std::string& dir) override;
  337. static std::string GetActualName() { return "FASTBuild"; }
  338. static std::string RequiredFastbuildVersion() { return "1.14"; }
  339. // Setup target names
  340. char const* GetAllTargetName() const override
  341. {
  342. return FASTBUILD_ALL_TARGET_NAME;
  343. }
  344. char const* GetInstallTargetName() const override { return "install"; }
  345. char const* GetCleanTargetName() const override
  346. {
  347. return FASTBUILD_CLEAN_TARGET_NAME;
  348. }
  349. char const* GetInstallLocalTargetName() const override
  350. {
  351. return "install/local";
  352. }
  353. char const* GetInstallStripTargetName() const override
  354. {
  355. return "install/strip";
  356. }
  357. char const* GetInstallParallelTargetName() const
  358. {
  359. return "install/parallel";
  360. }
  361. char const* GetTestTargetName() const override { return "RUN_TESTS"; }
  362. char const* GetPackageTargetName() const override { return "package"; }
  363. char const* GetPackageSourceTargetName() const override
  364. {
  365. return "package_source";
  366. }
  367. char const* GetRebuildCacheTargetName() const override
  368. {
  369. return "rebuild_cache";
  370. }
  371. char const* GetCMakeCFGIntDir() const override { return "."; }
  372. /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation()
  373. static cmDocumentationEntry GetDocumentation();
  374. static bool SupportsToolset() { return false; }
  375. static bool SupportsPlatform() { return false; }
  376. bool IsIPOSupported() const override { return true; }
  377. void OpenBuildFileStream();
  378. void CloseBuildFileStream();
  379. std::vector<std::string> const& GetConfigNames() const;
  380. bool Open(std::string const& bindir, std::string const& projectName,
  381. bool dryRun) override;
  382. std::string ConvertToFastbuildPath(std::string const& path) const;
  383. std::unique_ptr<cmLinkLineComputer> CreateLinkLineComputer(
  384. cmOutputConverter* outputConverter,
  385. cmStateDirectory const& /* stateDir */) const override;
  386. bool SupportsCustomCommandDepfile() const override { return true; }
  387. cm::optional<cmDepfileFormat> DepfileFormat() const override
  388. {
  389. return cm::nullopt;
  390. }
  391. static std::string Quote(std::string const& str,
  392. std::string const& quotation = "'");
  393. static std::string QuoteIfHasSpaces(std::string str);
  394. template <class T>
  395. static std::vector<std::string> Wrap(T const& in,
  396. std::string const& prefix = "'",
  397. std::string const& suffix = "'",
  398. bool escape_dollar = true);
  399. void WriteDivider();
  400. void WriteComment(std::string const& comment, int indent = 0);
  401. /// Write @a count times INDENT level to output stream @a os.
  402. void Indent(int count);
  403. void WriteVariable(std::string const& key, std::string const& value,
  404. std::string const& op, int indent = 0);
  405. void WriteVariable(std::string const& key, std::string const& value,
  406. int indent = 0);
  407. void WriteCommand(std::string const& command,
  408. std::string const& value = std::string(), int indent = 0);
  409. void WriteArray(std::string const& key,
  410. std::vector<std::string> const& values, int indent = 0);
  411. void WriteStruct(
  412. std::string const& name,
  413. std::vector<std::pair<std::string, std::string>> const& variables,
  414. int indent = 0);
  415. void WriteArray(std::string const& key,
  416. std::vector<std::string> const& values,
  417. std::string const& op, int indent = 0);
  418. template <typename T>
  419. std::vector<std::string> ConvertToFastbuildPath(T const& container) const
  420. {
  421. std::vector<std::string> ret;
  422. ret.reserve(container.size());
  423. for (auto const& path : container) {
  424. ret.push_back(ConvertToFastbuildPath(path));
  425. }
  426. return ret;
  427. }
  428. // Wrapper to sort array of conforming structs (which have .Name
  429. // and .PreBuildDependencies fields).
  430. template <class T>
  431. static void TopologicalSort(std::vector<T>& nodes)
  432. {
  433. static_assert(std::is_base_of<FastbuildTargetBase, T>::value,
  434. "T must be derived from FastbuildTargetBase");
  435. std::vector<FastbuildTargetPtrT> tmp;
  436. tmp.reserve(nodes.size());
  437. for (auto& node : nodes) {
  438. tmp.emplace_back(cm::make_unique<T>(std::move(node)));
  439. }
  440. nodes.clear();
  441. TopologicalSort(tmp);
  442. for (auto& node : tmp) {
  443. nodes.emplace_back(std::move(static_cast<T&>(*node)));
  444. }
  445. }
  446. // Stable topological sort.
  447. static void TopologicalSort(std::vector<FastbuildTargetPtrT>& nodes);
  448. void WriteDisclaimer();
  449. void WriteEnvironment();
  450. void WriteSettings();
  451. void WriteCompilers();
  452. void WriteTargets();
  453. void WriteTarget(FastbuildTarget const& target);
  454. void WriteExec(FastbuildExecNode const& Exec, int indent = 1);
  455. void WriteUnity(FastbuildUnityNode const& Unity);
  456. void WriteObjectList(FastbuildObjectListNode const& ObjectList,
  457. bool allowDistribution);
  458. void WriteLinker(FastbuildLinkerNode const&, bool);
  459. void WriteAlias(FastbuildAliasNode const& Alias, int indent = 1);
  460. void WriteCopy(FastbuildCopyNode const& Copy);
  461. void WriteIDEProjects();
  462. std::string GetIDEBuildArgs() const;
  463. void WriteVSBuildCommands();
  464. void WriteXCodeBuildCommands();
  465. void WriteIDEProjectCommon(IDEProjectCommon const& project);
  466. void WriteIDEProjectConfig(std::vector<IDEProjectConfig> const& configs,
  467. std::string const& keyName = "ProjectConfigs");
  468. void WriteSolution();
  469. void WriteXCodeTopLevelProject();
  470. void WriteTargetRebuildBFF();
  471. void WriteCleanScript();
  472. void WriteTargetClean();
  473. void AddTargetAll();
  474. void AddGlobCheckExec();
  475. void AddCompiler(std::string const& lang, cmMakefile* mf);
  476. void AddLauncher(std::string const& prefix, std::string const& launcher,
  477. std::string const& lang, std::string const& args);
  478. void AddIDEProject(FastbuildTarget const& target, std::string const& config);
  479. template <class T>
  480. void AddTarget(T target)
  481. {
  482. // Sometimes equivalent CCs are added to different targets. We try to
  483. // de-dup it by assigning all execs a name which is a hash computed based
  484. // on various properties (like input, output, deps.). Apparently, there are
  485. // still some CCs intersection between different targets.
  486. auto val = AllGeneratedCommands.emplace(target.Name);
  487. if (val.second) {
  488. FastbuildTargets.emplace_back(cm::make_unique<T>(std::move(target)));
  489. }
  490. // Get the intersection of CC's deps. Just mimicking what
  491. // cmLocalNinjaGenerator::WriteCustomCommandBuildStatement does. (I don't
  492. // think it's right in general case, each CC should be added only to 1
  493. // target, not to multiple )
  494. else {
  495. auto it =
  496. std::find_if(FastbuildTargets.begin(), FastbuildTargets.end(),
  497. [&target](FastbuildTargetPtrT const& existingTarget) {
  498. return existingTarget->Name == target.Name;
  499. });
  500. assert(it != FastbuildTargets.end());
  501. std::set<FastbuildTargetDep> intersection;
  502. std::set_intersection(
  503. target.PreBuildDependencies.begin(), target.PreBuildDependencies.end(),
  504. (*it)->PreBuildDependencies.begin(), (*it)->PreBuildDependencies.end(),
  505. std::inserter(intersection, intersection.end()));
  506. (*it)->PreBuildDependencies = std::move(intersection);
  507. }
  508. }
  509. static std::string GetExternalShellExecutable();
  510. std::string GetTargetName(cmGeneratorTarget const* GeneratorTarget) const;
  511. cm::optional<FastbuildTarget> GetTargetByOutputName(
  512. std::string const& output) const;
  513. void AskCMakeToMakeRebuildBFFUpToDate(std::string const& workingDir) const;
  514. void ExecuteFastbuildTarget(
  515. std::string const& dir, std::string const& target, std::string& output,
  516. std::vector<std::string> const& fbuildOptions = {}) const;
  517. bool IsExcluded(cmGeneratorTarget* target);
  518. void LogMessage(std::string const& m) const;
  519. void AddFileToClean(std::string const& file);
  520. /// The set of compilers added to the generated build system.
  521. std::map<std::string, FastbuildCompiler> Compilers;
  522. std::vector<FastbuildTargetPtrT> FastbuildTargets;
  523. /// The file containing the build statement.
  524. std::unique_ptr<cmGeneratedFileStream> BuildFileStream;
  525. std::string FastbuildCommand;
  526. std::string FastbuildVersion;
  527. std::map<std::string, std::unique_ptr<cmFastbuildTargetGenerator>> Targets;
  528. std::unordered_set<std::string> AllFoldersToClean;
  529. // Sometime we need to keep some files that are generated only during
  530. // configuration (like .objs files used to create module definition from
  531. // objects).
  532. std::unordered_set<std::string> AllFilesToKeep;
  533. bool UsingRelativePaths = false;
  534. private:
  535. std::unordered_set<std::string> AllFilesToClean;
  536. // https://cmake.org/cmake/help/latest/module/ExternalProject.html#command:externalproject_add_steptargets
  537. std::unordered_set<std::string /*exec name*/> AllGeneratedCommands;
  538. std::unordered_map<std::string /*base target name (without -config)*/,
  539. std::pair<VCXProject, XCodeProject>>
  540. IDEProjects;
  541. // Env that we're going to embed to the generated file.
  542. std::vector<std::string> LocalEnvironment;
  543. };