cmGlobalFastbuildGenerator.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  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> LinkerNode;
  286. std::string RealOutput;
  287. FastbuildAliasNode PreBuildExecNodes, ExecNodes;
  288. std::vector<FastbuildAliasNode> AliasNodes;
  289. // This alias must be written before all other nodes, since they might need
  290. // to refer to it.
  291. FastbuildAliasNode DependenciesAlias;
  292. std::vector<FastbuildCopyNode> CopyNodes;
  293. FastbuildExecNodes PreLinkExecNodes;
  294. FastbuildExecNodes PostBuildExecNodes;
  295. bool IsGlobal = false;
  296. bool ExcludeFromAll = false;
  297. bool AllowDistribution = true;
  298. FastbuildTarget()
  299. : FastbuildTargetBase(FastbuildTargetType::LINK)
  300. {
  301. }
  302. void GenerateAliases();
  303. };
  304. class cmGlobalFastbuildGenerator : public cmGlobalCommonGenerator
  305. {
  306. public:
  307. cmGlobalFastbuildGenerator(cmake* cm);
  308. void ReadCompilerOptions(FastbuildCompiler& compiler, cmMakefile* mf);
  309. void ProcessEnvironment();
  310. static std::unique_ptr<cmGlobalGeneratorFactory> NewFactory();
  311. void Generate() override;
  312. bool FindMakeProgram(cmMakefile* mf) override;
  313. bool CheckLanguages(std::vector<std::string> const& languages,
  314. cmMakefile* mf) const override;
  315. void EnableLanguage(std::vector<std::string> const& lang, cmMakefile* mf,
  316. bool optional) override;
  317. bool IsFastbuild() const override { return true; }
  318. std::vector<GeneratedMakeCommand> GenerateBuildCommand(
  319. std::string const& makeProgram, std::string const& projectName,
  320. std::string const& projectDir, std::vector<std::string> const& targetNames,
  321. std::string const& config, int jobs, bool verbose,
  322. cmBuildOptions buildOptions = cmBuildOptions(),
  323. std::vector<std::string> const& makeOptions = std::vector<std::string>(),
  324. BuildTryCompile isInTryCompile = BuildTryCompile::No) override;
  325. std::unique_ptr<cmLocalGenerator> CreateLocalGenerator(
  326. cmMakefile* makefile) override;
  327. std::string GetName() const override
  328. {
  329. return cmGlobalFastbuildGenerator::GetActualName();
  330. }
  331. bool IsMultiConfig() const override { return false; }
  332. bool SupportsCustomObjectNames() const override { return false; }
  333. void ComputeTargetObjectDirectory(cmGeneratorTarget*) const override;
  334. void AppendDirectoryForConfig(std::string const& prefix,
  335. std::string const& config,
  336. std::string const& suffix,
  337. std::string& dir) override;
  338. static std::string GetActualName() { return "FASTBuild"; }
  339. static std::string RequiredFastbuildVersion() { return "1.14"; }
  340. // Setup target names
  341. char const* GetAllTargetName() const override
  342. {
  343. return FASTBUILD_ALL_TARGET_NAME;
  344. }
  345. char const* GetInstallTargetName() const override { return "install"; }
  346. char const* GetCleanTargetName() const override
  347. {
  348. return FASTBUILD_CLEAN_TARGET_NAME;
  349. }
  350. char const* GetInstallLocalTargetName() const override
  351. {
  352. return "install/local";
  353. }
  354. char const* GetInstallStripTargetName() const override
  355. {
  356. return "install/strip";
  357. }
  358. char const* GetInstallParallelTargetName() const
  359. {
  360. return "install/parallel";
  361. }
  362. char const* GetTestTargetName() const override { return "test"; }
  363. char const* GetPackageTargetName() const override { return "package"; }
  364. char const* GetPackageSourceTargetName() const override
  365. {
  366. return "package_source";
  367. }
  368. char const* GetRebuildCacheTargetName() const override
  369. {
  370. return "rebuild_cache";
  371. }
  372. char const* GetCMakeCFGIntDir() const override { return "."; }
  373. /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation()
  374. static cmDocumentationEntry GetDocumentation();
  375. static bool SupportsToolset() { return false; }
  376. static bool SupportsPlatform() { return false; }
  377. bool IsIPOSupported() const override { return true; }
  378. void OpenBuildFileStream();
  379. void CloseBuildFileStream();
  380. std::vector<std::string> const& GetConfigNames() const;
  381. bool Open(std::string const& bindir, std::string const& projectName,
  382. bool dryRun) override;
  383. std::string ConvertToFastbuildPath(std::string const& path) const;
  384. std::unique_ptr<cmLinkLineComputer> CreateLinkLineComputer(
  385. cmOutputConverter* outputConverter,
  386. cmStateDirectory const& /* stateDir */) const override;
  387. bool SupportsCustomCommandDepfile() const override { return true; }
  388. cm::optional<cmDepfileFormat> DepfileFormat() const override
  389. {
  390. return cm::nullopt;
  391. }
  392. static std::string Quote(std::string const& str,
  393. std::string const& quotation = "'");
  394. static std::string QuoteIfHasSpaces(std::string str);
  395. template <class T>
  396. static std::vector<std::string> Wrap(T const& in,
  397. std::string const& prefix = "'",
  398. std::string const& suffix = "'",
  399. bool escape_dollar = true);
  400. void WriteDivider();
  401. void WriteComment(std::string const& comment, int indent = 0);
  402. /// Write @a count times INDENT level to output stream @a os.
  403. void Indent(int count);
  404. void WriteVariable(std::string const& key, std::string const& value,
  405. std::string const& op, int indent = 0);
  406. void WriteVariable(std::string const& key, std::string const& value,
  407. int indent = 0);
  408. void WriteCommand(std::string const& command,
  409. std::string const& value = std::string(), int indent = 0);
  410. void WriteArray(std::string const& key,
  411. std::vector<std::string> const& values, int indent = 0);
  412. void WriteStruct(
  413. std::string const& name,
  414. std::vector<std::pair<std::string, std::string>> const& variables,
  415. int indent = 0);
  416. void WriteArray(std::string const& key,
  417. std::vector<std::string> const& values,
  418. std::string const& op, int indent = 0);
  419. template <typename T>
  420. std::vector<std::string> ConvertToFastbuildPath(T const& container) const
  421. {
  422. std::vector<std::string> ret;
  423. ret.reserve(container.size());
  424. for (auto const& path : container) {
  425. ret.push_back(ConvertToFastbuildPath(path));
  426. }
  427. return ret;
  428. }
  429. // Wrapper to sort array of conforming structs (which have .Name
  430. // and .PreBuildDependencies fields).
  431. template <class T>
  432. static void TopologicalSort(std::vector<T>& nodes)
  433. {
  434. static_assert(std::is_base_of<FastbuildTargetBase, T>::value,
  435. "T must be derived from FastbuildTargetBase");
  436. std::vector<FastbuildTargetPtrT> tmp;
  437. tmp.reserve(nodes.size());
  438. for (auto& node : nodes) {
  439. tmp.emplace_back(cm::make_unique<T>(std::move(node)));
  440. }
  441. nodes.clear();
  442. TopologicalSort(tmp);
  443. for (auto& node : tmp) {
  444. nodes.emplace_back(std::move(static_cast<T&>(*node)));
  445. }
  446. }
  447. // Stable topological sort.
  448. static void TopologicalSort(std::vector<FastbuildTargetPtrT>& nodes);
  449. void WriteDisclaimer();
  450. void WriteEnvironment();
  451. void WriteSettings();
  452. void WriteCompilers();
  453. void WriteTargets();
  454. void WriteTarget(FastbuildTarget const& target);
  455. void WriteExec(FastbuildExecNode const& Exec, int indent = 1);
  456. void WriteUnity(FastbuildUnityNode const& Unity);
  457. void WriteObjectList(FastbuildObjectListNode const& ObjectList,
  458. bool allowDistribution);
  459. void WriteLinker(FastbuildLinkerNode const&, bool);
  460. void WriteAlias(FastbuildAliasNode const& Alias, int indent = 1);
  461. void WriteCopy(FastbuildCopyNode const& Copy);
  462. void WriteIDEProjects();
  463. std::string GetIDEBuildArgs() const;
  464. void WriteVSBuildCommands();
  465. void WriteXCodeBuildCommands();
  466. void WriteIDEProjectCommon(IDEProjectCommon const& project);
  467. void WriteIDEProjectConfig(std::vector<IDEProjectConfig> const& configs,
  468. std::string const& keyName = "ProjectConfigs");
  469. void WriteSolution();
  470. void WriteXCodeTopLevelProject();
  471. void WriteTargetRebuildBFF();
  472. void WriteCleanScript();
  473. void WriteTargetClean();
  474. void AddTargetAll();
  475. void AddGlobCheckExec();
  476. void AddCompiler(std::string const& lang, cmMakefile* mf);
  477. void AddLauncher(std::string const& prefix, std::string const& launcher,
  478. std::string const& lang, std::string const& args);
  479. void AddIDEProject(FastbuildTarget const& target, std::string const& config);
  480. template <class T>
  481. void AddTarget(T target)
  482. {
  483. // Sometimes equivalent CCs are added to different targets. We try to
  484. // de-dup it by assigning all execs a name which is a hash computed based
  485. // on various properties (like input, output, deps.). Apparently, there are
  486. // still some CCs intersection between different targets.
  487. auto val = AllGeneratedCommands.emplace(target.Name);
  488. if (val.second) {
  489. FastbuildTargets.emplace_back(cm::make_unique<T>(std::move(target)));
  490. }
  491. // Get the intersection of CC's deps. Just mimicking what
  492. // cmLocalNinjaGenerator::WriteCustomCommandBuildStatement does. (I don't
  493. // think it's right in general case, each CC should be added only to 1
  494. // target, not to multiple )
  495. else {
  496. auto it =
  497. std::find_if(FastbuildTargets.begin(), FastbuildTargets.end(),
  498. [&target](FastbuildTargetPtrT const& existingTarget) {
  499. return existingTarget->Name == target.Name;
  500. });
  501. assert(it != FastbuildTargets.end());
  502. std::set<FastbuildTargetDep> intersection;
  503. std::set_intersection(
  504. target.PreBuildDependencies.begin(), target.PreBuildDependencies.end(),
  505. (*it)->PreBuildDependencies.begin(), (*it)->PreBuildDependencies.end(),
  506. std::inserter(intersection, intersection.end()));
  507. (*it)->PreBuildDependencies = std::move(intersection);
  508. }
  509. }
  510. static std::string GetExternalShellExecutable();
  511. std::string GetTargetName(cmGeneratorTarget const* GeneratorTarget) const;
  512. cm::optional<FastbuildTarget> GetTargetByOutputName(
  513. std::string const& output) const;
  514. void AskCMakeToMakeRebuildBFFUpToDate(std::string const& workingDir) const;
  515. void ExecuteFastbuildTarget(
  516. std::string const& dir, std::string const& target, std::string& output,
  517. std::vector<std::string> const& fbuildOptions = {}) const;
  518. bool IsExcluded(cmGeneratorTarget* target);
  519. void LogMessage(std::string const& m) const;
  520. void AddFileToClean(std::string const& file);
  521. /// The set of compilers added to the generated build system.
  522. std::map<std::string, FastbuildCompiler> Compilers;
  523. std::vector<FastbuildTargetPtrT> FastbuildTargets;
  524. /// The file containing the build statement.
  525. std::unique_ptr<cmGeneratedFileStream> BuildFileStream;
  526. std::string FastbuildCommand;
  527. std::string FastbuildVersion;
  528. std::map<std::string, std::unique_ptr<cmFastbuildTargetGenerator>> Targets;
  529. std::unordered_set<std::string> AllFoldersToClean;
  530. // Sometime we need to keep some files that are generated only during
  531. // configuration (like .objs files used to create module definition from
  532. // objects).
  533. std::unordered_set<std::string> AllFilesToKeep;
  534. bool UsingRelativePaths = false;
  535. private:
  536. std::unordered_set<std::string> AllFilesToClean;
  537. // https://cmake.org/cmake/help/latest/module/ExternalProject.html#command:externalproject_add_steptargets
  538. std::unordered_set<std::string /*exec name*/> AllGeneratedCommands;
  539. std::unordered_map<std::string /*base target name (without -config)*/,
  540. std::pair<VCXProject, XCodeProject>>
  541. IDEProjects;
  542. // Env that we're going to embed to the generated file.
  543. std::vector<std::string> LocalEnvironment;
  544. };