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