mirror of
https://github.com/Kitware/CMake.git
synced 2026-11-07 05:46:42 +00:00
1 parent
1cb225d90f
commit
01147454e7
84 files changed
+6336
-65
No files matched your search
@@ -0,0 +1,8 @@
|
||||
CMAKE_FASTBUILD_VERBOSE_GENERATOR
|
||||
---------------------------------
|
||||
|
||||
.. include:: include/ENV_VAR.rst
|
||||
|
||||
The ``CMAKE_FASTBUILD_VERBOSE_GENERATOR`` environment variable specifies a custom default
|
||||
value for the :variable:`CMAKE_FASTBUILD_VERBOSE_GENERATOR` variable in place of the
|
||||
default values specified by CMake itself.
|
||||
@@ -0,0 +1,69 @@
|
||||
FASTBuild
|
||||
=========
|
||||
|
||||
Generates a ``fbuild.bff`` file, which can be used to build the project with
|
||||
`FASTBuild <https://www.fastbuild.org/docs/home.html>`_.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Specify the generator when invoking :manual:`cmake(1)`:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
cmake [<options>] -G FASTBuild -B <path-to-build> [-S <path-to-source>]
|
||||
|
||||
This writes a FASTBuild configuration file named ``fbuild.bff`` into
|
||||
``<path-to-build>``.
|
||||
|
||||
.. note::
|
||||
|
||||
This generator also produces IDE project files for Visual Studio and Xcode,
|
||||
which are placed under:
|
||||
|
||||
* ``<path-to-build>/VisualStudio`` – Visual Studio solution and projects
|
||||
* ``<path-to-build>/XCode`` – Xcode workspace and projects
|
||||
|
||||
These IDE files can be generated by building ``xcode`` or ``solution`` targets
|
||||
and will build using FASTBuild as the backend.
|
||||
|
||||
Configuration Variables
|
||||
-----------------------
|
||||
|
||||
The following variables can be used to configure this generator:
|
||||
|
||||
* :variable:`CMAKE_FASTBUILD_CACHE_PATH`
|
||||
* :variable:`CMAKE_FASTBUILD_CAPTURE_SYSTEM_ENV`
|
||||
* :variable:`CMAKE_FASTBUILD_COMPILER_EXTRA_FILES`
|
||||
* :variable:`CMAKE_FASTBUILD_ENV_OVERRIDES`
|
||||
* :variable:`CMAKE_FASTBUILD_TRACK_BYPRODUCTS_AS_OUTPUT`
|
||||
* :variable:`CMAKE_FASTBUILD_USE_LIGHTCACHE`
|
||||
* :variable:`CMAKE_FASTBUILD_VERBOSE_GENERATOR`
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
* This generator does not support directories as outputs of custom commands.
|
||||
If you do specify a directory as an output, it should be marked with the
|
||||
``SYMBOLIC`` property to avoid incorrect behavior.
|
||||
* It is highly advised to use custom commands with only one output.
|
||||
If multiple outputs are specified, the generator will emit an additional
|
||||
rule to check the outputs at build time. This adds overhead and is necessary
|
||||
because FASTBuild natively supports only a single output per custom step.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
cmake [<options>] -G FASTBuild -B <path-to-build> -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build <path-to-build> --target my_app
|
||||
|
||||
This generates ``fbuild.bff`` in ``<path-to-build>`` and uses FASTBuild
|
||||
to build the ``my_app`` target.
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
||||
* :manual:`cmake-generators(7)`
|
||||
* `FASTBuild Documentation <https://www.fastbuild.org/docs/documentation.html>`_
|
||||
@@ -54,6 +54,7 @@ Environment Variables that Control the Build
|
||||
/envvar/CMAKE_CROSSCOMPILING_EMULATOR
|
||||
/envvar/CMAKE_EXPORT_BUILD_DATABASE
|
||||
/envvar/CMAKE_EXPORT_COMPILE_COMMANDS
|
||||
/envvar/CMAKE_FASTBUILD_VERBOSE_GENERATOR
|
||||
/envvar/CMAKE_GENERATOR
|
||||
/envvar/CMAKE_GENERATOR_INSTANCE
|
||||
/envvar/CMAKE_GENERATOR_PLATFORM
|
||||
|
||||
@@ -63,6 +63,14 @@ Ninja Generators
|
||||
/generator/Ninja
|
||||
/generator/Ninja Multi-Config
|
||||
|
||||
FASTBuild Generator
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
/generator/FASTBuild
|
||||
|
||||
.. _`IDE Build Tool Generators`:
|
||||
|
||||
IDE Build Tool Generators
|
||||
|
||||
@@ -55,6 +55,13 @@ Variables that Provide Information
|
||||
/variable/CMAKE_EXECUTABLE_SUFFIX
|
||||
/variable/CMAKE_EXECUTABLE_SUFFIX_LANG
|
||||
/variable/CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES
|
||||
/variable/CMAKE_FASTBUILD_CACHE_PATH
|
||||
/variable/CMAKE_FASTBUILD_CAPTURE_SYSTEM_ENV
|
||||
/variable/CMAKE_FASTBUILD_COMPILER_EXTRA_FILES
|
||||
/variable/CMAKE_FASTBUILD_ENV_OVERRIDES
|
||||
/variable/CMAKE_FASTBUILD_TRACK_BYPRODUCTS_AS_OUTPUT
|
||||
/variable/CMAKE_FASTBUILD_USE_LIGHTCACHE
|
||||
/variable/CMAKE_FASTBUILD_VERBOSE_GENERATOR
|
||||
/variable/CMAKE_FIND_DEBUG_MODE
|
||||
/variable/CMAKE_FIND_DEBUG_MODE_NO_IMPLICIT_CONFIGURE_LOG
|
||||
/variable/CMAKE_FIND_PACKAGE_NAME
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
FASTBuild
|
||||
---------
|
||||
|
||||
* The :generator:`FASTBuild` generator was added.
|
||||
@@ -0,0 +1,9 @@
|
||||
CMAKE_FASTBUILD_CACHE_PATH
|
||||
---------------------------
|
||||
|
||||
Specifies the directory for the FASTBuild artifact cache.
|
||||
|
||||
Defaults to :variable:`CMAKE_BINARY_DIR` ``/fbuild.cache`` if not set.
|
||||
|
||||
See the `FASTBuild caching documentation <https://www.fastbuild.org/docs/features/caching.html>`_
|
||||
for more information.
|
||||
@@ -0,0 +1,13 @@
|
||||
CMAKE_FASTBUILD_CAPTURE_SYSTEM_ENV
|
||||
----------------------------------
|
||||
|
||||
Controls capturing of the system environment into ``fbuild.bff``.
|
||||
Setting it to ``OFF`` makes the invocation of all tools (compilers and other external processes) hermetic.
|
||||
|
||||
.. note::
|
||||
|
||||
Setting this variable to ``OFF`` can break MSVC toolchains that rely on
|
||||
environment variables such as ``INCLUDE`` or ``LIB`` unless these are
|
||||
manually configured elsewhere.
|
||||
|
||||
Defaults to ``ON``.
|
||||
@@ -0,0 +1,8 @@
|
||||
CMAKE_FASTBUILD_COMPILER_EXTRA_FILES
|
||||
-------------------------------------
|
||||
|
||||
Specifies a semicolon-separated list of additional files (usually DLLs) to
|
||||
include in the FASTBuild ``Compiler()`` node.
|
||||
|
||||
See the `FASTBuild Compiler() documentation <https://www.fastbuild.org/docs/functions/compiler.html>`_
|
||||
for more information.
|
||||
@@ -0,0 +1,30 @@
|
||||
CMAKE_FASTBUILD_ENV_OVERRIDES
|
||||
-----------------------------
|
||||
|
||||
Allows overriding environment variables in the captured environment written to
|
||||
``fbuild.bff``.
|
||||
|
||||
Specify a CMake-style list of key=value pairs. These values will override the
|
||||
corresponding variables in the environment block that FASTBuild uses during
|
||||
execution of tools (e.g., compilers, linkers, resource compilers, etc.).
|
||||
|
||||
This is especially useful for ensuring consistent behavior when tools depend
|
||||
on environment variables (e.g., overriding ``PATH`` to control tool resolution
|
||||
for ``rc.exe`` or ``mt.exe``).
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
set(CMAKE_FASTBUILD_ENV_OVERRIDES
|
||||
"PATH=C:/MyTools/bin"
|
||||
"TMP=C:/temp"
|
||||
"MY_CUSTOM_VAR=some_value"
|
||||
)
|
||||
|
||||
.. note::
|
||||
|
||||
This only affects the environment seen by FASTBuild-generated rules.
|
||||
It does **not** modify the environment in which CMake itself runs.
|
||||
|
||||
Defaults to empty (no overrides).
|
||||
@@ -0,0 +1,15 @@
|
||||
CMAKE_FASTBUILD_TRACK_BYPRODUCTS_AS_OUTPUT
|
||||
------------------------------------------
|
||||
|
||||
By default, custom commands declaring only ``BYPRODUCTS`` will always
|
||||
run unconditionally.
|
||||
You can use this variable to make FASTBuild rerun the command only when its
|
||||
inputs have changed or the byproduct file is missing.
|
||||
|
||||
.. note::
|
||||
|
||||
When this variable is ``OFF`` (the default), ``BYPRODUCTS`` are treated
|
||||
similarly to how Ninja handles them — as opaque side effects — and the
|
||||
generator emits ``ExecAlways`` nodes to ensure they always run.
|
||||
|
||||
Defaults to ``OFF``.
|
||||
@@ -0,0 +1,8 @@
|
||||
CMAKE_FASTBUILD_USE_LIGHTCACHE
|
||||
-------------------------------
|
||||
|
||||
Enables FASTBuild’s *light caching* mode, which accelerates cache lookups by
|
||||
parsing source files directly (instead of invoking the compiler preprocessor).
|
||||
|
||||
See the `FASTBuild Compiler() documentation <https://www.fastbuild.org/docs/functions/compiler.html>`_
|
||||
for more information.
|
||||
@@ -0,0 +1,9 @@
|
||||
CMAKE_FASTBUILD_VERBOSE_GENERATOR
|
||||
----------------------------------
|
||||
|
||||
Enables verbose logging during FASTBuild file generation.
|
||||
|
||||
Initialized by the :envvar:`CMAKE_FASTBUILD_VERBOSE_GENERATOR`
|
||||
environment variable.
|
||||
|
||||
Defaults to ``OFF``.
|
||||
@@ -4,9 +4,10 @@
|
||||
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake)
|
||||
include(${CMAKE_ROOT}/Modules/CMakeParseImplicitLinkInfo.cmake)
|
||||
|
||||
if(NOT ((CMAKE_GENERATOR MATCHES "Make") OR
|
||||
(CMAKE_GENERATOR MATCHES "Ninja") OR
|
||||
(CMAKE_GENERATOR MATCHES "Visual Studio (1|[9][0-9])")))
|
||||
if( NOT ( ("${CMAKE_GENERATOR}" MATCHES "Make") OR
|
||||
("${CMAKE_GENERATOR}" MATCHES "Ninja") OR
|
||||
("${CMAKE_GENERATOR}" MATCHES "FASTBuild") OR
|
||||
("${CMAKE_GENERATOR}" MATCHES "Visual Studio (1|[9][0-9])") ) )
|
||||
message(FATAL_ERROR "CUDA language not currently supported by \"${CMAKE_GENERATOR}\" generator")
|
||||
endif()
|
||||
|
||||
|
||||
@@ -242,7 +242,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
|
||||
set(CMAKE_EXECUTABLE_FORMAT "Unknown" CACHE INTERNAL "Executable file format")
|
||||
endif()
|
||||
|
||||
if((CMAKE_GENERATOR MATCHES "^Ninja"
|
||||
if((CMAKE_GENERATOR MATCHES "^Ninja|FASTBuild"
|
||||
OR ((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER)
|
||||
AND CMAKE_GENERATOR MATCHES "Makefiles|WMake"))
|
||||
AND MSVC_${lang}_ARCHITECTURE_ID)
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file LICENSE.rst or https://cmake.org/licensing for details.
|
||||
|
||||
find_program(CMAKE_MAKE_PROGRAM
|
||||
NAMES fbuild
|
||||
DOC "Program used to build from FASTBuild .bff files.")
|
||||
mark_as_advanced(CMAKE_MAKE_PROGRAM)
|
||||
@@ -86,7 +86,10 @@ function(cmake_parse_implicit_link_info2 text log_var obj_regex)
|
||||
# whole line and just the command (argv[0]).
|
||||
set(linker_regex "^( *|.*[/\\])(${linker}|${startfile}|([^/\\]+-)?ld|collect2)[^/\\]*( |$)")
|
||||
set(linker_exclude_regex "collect2 version |^[A-Za-z0-9_]+=|/ldfe ")
|
||||
set(linker_tool_regex "^[ \t]*(->|\")?[ \t]*(([^\"]*[/\\])?(${linker}))(\"|,| |$)")
|
||||
|
||||
# Skip FASTBuild's output mangling, like:
|
||||
# "2> -Build: 0 ms .../link.exe"/"13>-Build: 0 ms .../link.exe"
|
||||
set(linker_tool_regex "^[ \t]*(->|\"|[0-9]+>[ \t-]*Build:[ \t0-9]+ ms[ \t]*)?[ \t]*(([^\"]*[/\\])?(${linker}))(\"|,| |$)")
|
||||
set(linker_tool_exclude_regex "cuda-fake-ld|-fuse-ld=|^ExecuteExternalTool ")
|
||||
if(is_lfortran_less_0_40)
|
||||
# lfortran < 0.40 has no way to pass -v to clang/gcc driver.
|
||||
|
||||
@@ -86,7 +86,7 @@ if(NOT _CTEST_TARGETS_ADDED)
|
||||
endforeach()
|
||||
|
||||
# For Makefile generators add more granular targets.
|
||||
if("${CMAKE_GENERATOR}" MATCHES "(Ninja|Make)")
|
||||
if("${CMAKE_GENERATOR}" MATCHES "(Ninja|Make|FASTBuild)")
|
||||
# Make targets for Experimental builds
|
||||
foreach(mode Nightly Experimental Continuous)
|
||||
foreach(testtype
|
||||
|
||||
@@ -60,7 +60,7 @@ if(NOT DEFINED CTEST_USE_LAUNCHERS AND DEFINED ENV{CTEST_USE_LAUNCHERS_DEFAULT})
|
||||
CACHE INTERNAL "CTEST_USE_LAUNCHERS initial value from ENV")
|
||||
endif()
|
||||
|
||||
if(NOT "${CMAKE_GENERATOR}" MATCHES "Make|Ninja")
|
||||
if(NOT "${CMAKE_GENERATOR}" MATCHES "Make|Ninja|FASTBuild")
|
||||
set(CTEST_USE_LAUNCHERS 0)
|
||||
endif()
|
||||
|
||||
@@ -77,7 +77,7 @@ if(CTEST_USE_LAUNCHERS)
|
||||
set(__launch_custom_options
|
||||
"${__launch_common_options} --output <OUTPUT>")
|
||||
|
||||
if("${CMAKE_GENERATOR}" MATCHES "Ninja")
|
||||
if("${CMAKE_GENERATOR}" MATCHES "Ninja|FASTBuild")
|
||||
string(APPEND __launch_compile_options " --filter-prefix <CMAKE_CL_SHOWINCLUDES_PREFIX>")
|
||||
endif()
|
||||
|
||||
|
||||
@@ -113,8 +113,14 @@ else()
|
||||
if(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0.0 AND NOT __is_apple_clang)
|
||||
set(CMAKE_${lang}_COMPILE_OPTIONS_INSTANTIATE_TEMPLATES_PCH -fpch-instantiate-templates)
|
||||
endif()
|
||||
set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Xclang -include-pch -Xclang <PCH_FILE> -Xclang -include -Xclang <PCH_HEADER>)
|
||||
set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Xclang -emit-pch -Xclang -include -Xclang <PCH_HEADER> -x ${__pch_header_${lang}})
|
||||
if (CMAKE_GENERATOR MATCHES "FASTBuild")
|
||||
# We can't use "-Xclang -emit-pch" since Fastbuild gets spammed with binary content of the .pch file while trying to scan dependencies.
|
||||
set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -include-pch <PCH_FILE> -Xclang -include -Xclang <PCH_HEADER>)
|
||||
set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Xclang -include -Xclang <PCH_HEADER> -x ${__pch_header_${lang}})
|
||||
else()
|
||||
set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Xclang -include-pch -Xclang <PCH_FILE> -Xclang -include -Xclang <PCH_HEADER>)
|
||||
set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Xclang -emit-pch -Xclang -include -Xclang <PCH_HEADER> -x ${__pch_header_${lang}})
|
||||
endif()
|
||||
|
||||
# '-fcolor-diagnostics' introduced since Clang 2.6
|
||||
if(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 2.6)
|
||||
|
||||
@@ -3231,11 +3231,11 @@ function(ExternalProject_Add name)
|
||||
# rebuilds. It is important that 'done' is not the output of any
|
||||
# custom command so that CMake does not propagate build rules to
|
||||
# other external project targets, which may cause problems during
|
||||
# parallel builds. However, the Ninja generator needs to see the entire
|
||||
# parallel builds. However, the Ninja and Fastbuild generators need to see the entire
|
||||
# dependency graph, and can cope with custom commands belonging to
|
||||
# multiple targets, so we add the 'done' mark as an output for Ninja only.
|
||||
# multiple targets, so we add the 'done' mark as an output for Ninja and Fastbuild only.
|
||||
set(complete_outputs ${complete_stamp_file})
|
||||
if(${CMAKE_GENERATOR} MATCHES "Ninja")
|
||||
if(${CMAKE_GENERATOR} MATCHES "Ninja|FASTBuild")
|
||||
set(complete_outputs ${complete_outputs} ${done_stamp_file})
|
||||
endif()
|
||||
|
||||
|
||||
@@ -388,7 +388,7 @@ endif()
|
||||
unset(__WINDOWS_MSVC_CMP0184)
|
||||
|
||||
macro(__windows_compiler_msvc lang)
|
||||
if(NOT MSVC_VERSION LESS 1400)
|
||||
if(NOT MSVC_VERSION LESS 1400 AND NOT CMAKE_GENERATOR MATCHES "FASTBuild")
|
||||
# for 2005 make sure the manifest is put in the dll with mt
|
||||
set(_CMAKE_VS_LINK_DLL "<CMAKE_COMMAND> -E vs_link_dll --msvc-ver=${MSVC_VERSION} --intdir=<OBJECT_DIR> --rc=<CMAKE_RC_COMPILER> --mt=<CMAKE_MT> --manifests <MANIFESTS> -- ")
|
||||
set(_CMAKE_VS_LINK_EXE "<CMAKE_COMMAND> -E vs_link_exe --msvc-ver=${MSVC_VERSION} --intdir=<OBJECT_DIR> --rc=<CMAKE_RC_COMPILER> --mt=<CMAKE_MT> --manifests <MANIFESTS> -- ")
|
||||
|
||||
@@ -782,6 +782,18 @@ add_library(
|
||||
cmNinjaLinkLineComputer.h
|
||||
cmNinjaLinkLineDeviceComputer.cxx
|
||||
cmNinjaLinkLineDeviceComputer.h
|
||||
# FASTBuild support
|
||||
cmGlobalFastbuildGenerator.cxx
|
||||
cmGlobalFastbuildGenerator.h
|
||||
cmLocalFastbuildGenerator.cxx
|
||||
cmLocalFastbuildGenerator.h
|
||||
cmFastbuildTargetGenerator.cxx
|
||||
cmFastbuildTargetGenerator.h
|
||||
cmFastbuildLinkLineComputer.cxx
|
||||
cmFastbuildNormalTargetGenerator.cxx
|
||||
cmFastbuildNormalTargetGenerator.h
|
||||
cmFastbuildUtilityTargetGenerator.cxx
|
||||
cmFastbuildUtilityTargetGenerator.h
|
||||
|
||||
cm_get_date.h
|
||||
cm_get_date.c
|
||||
|
||||
@@ -57,7 +57,8 @@ bool cmCTestBuildAndTest::RunCMake(cmake* cm)
|
||||
}
|
||||
if (!this->BuildMakeProgram.empty() &&
|
||||
(this->BuildGenerator.find("Make") != std::string::npos ||
|
||||
this->BuildGenerator.find("Ninja") != std::string::npos)) {
|
||||
this->BuildGenerator.find("Ninja") != std::string::npos ||
|
||||
this->BuildGenerator.find("FASTBuild") != std::string::npos)) {
|
||||
args.push_back("-DCMAKE_MAKE_PROGRAM:FILEPATH=" + this->BuildMakeProgram);
|
||||
}
|
||||
|
||||
|
||||
@@ -458,7 +458,8 @@ std::string cmCommonTargetGenerator::GenerateCodeCheckRules(
|
||||
this->GeneratorTarget->GetLocalGenerator()->EscapeForShell(
|
||||
cmStrCat(tidy, ";--extra-arg-before=--driver-mode=", driverMode,
|
||||
exportFixes));
|
||||
} else if (generatorName.find("Ninja") != std::string::npos) {
|
||||
} else if (generatorName.find("Ninja") != std::string::npos ||
|
||||
generatorName.find("FASTBuild") != std::string::npos) {
|
||||
if (!clangTidyExportFixedDir.empty()) {
|
||||
this->GlobalCommonGenerator->AddClangTidyExportFixesFile(fixesFile);
|
||||
cmSystemTools::MakeDirectory(
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file LICENSE.rst or https://cmake.org/licensing for details. */
|
||||
|
||||
#include "cmFastbuildLinkLineComputer.h"
|
||||
|
||||
#include "cmGlobalFastbuildGenerator.h"
|
||||
|
||||
class cmOutputConverter;
|
||||
|
||||
cmFastbuildLinkLineComputer::cmFastbuildLinkLineComputer(
|
||||
cmOutputConverter* outputConverter, cmStateDirectory const& stateDir,
|
||||
cmGlobalFastbuildGenerator const* gg)
|
||||
: cmLinkLineComputer(outputConverter, stateDir)
|
||||
, GG(gg)
|
||||
{
|
||||
}
|
||||
|
||||
std::string cmFastbuildLinkLineComputer::ConvertToLinkReference(
|
||||
std::string const& lib) const
|
||||
{
|
||||
return this->GG->ConvertToFastbuildPath(lib);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file LICENSE.rst or https://cmake.org/licensing for details. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cmConfigure.h" // IWYU pragma: keep
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "cmLinkLineComputer.h"
|
||||
|
||||
class cmGlobalFastbuildGenerator;
|
||||
class cmOutputConverter;
|
||||
class cmStateDirectory;
|
||||
|
||||
class cmFastbuildLinkLineComputer : public cmLinkLineComputer
|
||||
{
|
||||
public:
|
||||
cmFastbuildLinkLineComputer(cmOutputConverter* outputConverter,
|
||||
cmStateDirectory const& stateDir,
|
||||
cmGlobalFastbuildGenerator const* gg);
|
||||
|
||||
cmFastbuildLinkLineComputer(cmFastbuildLinkLineComputer const&) = delete;
|
||||
cmFastbuildLinkLineComputer& operator=(cmFastbuildLinkLineComputer const&) =
|
||||
delete;
|
||||
|
||||
std::string ConvertToLinkReference(std::string const& input) const override;
|
||||
|
||||
private:
|
||||
cmGlobalFastbuildGenerator const* GG;
|
||||
};
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,141 @@
|
||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file LICENSE.rst or https://cmake.org/licensing for details. */
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "cmComputeLinkInformation.h"
|
||||
#include "cmFastbuildTargetGenerator.h"
|
||||
#include "cmGeneratorTarget.h"
|
||||
#include "cmRulePlaceholderExpander.h"
|
||||
class cmSourceFile;
|
||||
struct FastbuildExecNode;
|
||||
struct FastbuildLinkerNode;
|
||||
struct FastbuildObjectListNode;
|
||||
struct FastbuildTarget;
|
||||
struct FastbuildTargetDep;
|
||||
|
||||
class cmFastbuildNormalTargetGenerator : public cmFastbuildTargetGenerator
|
||||
{
|
||||
std::unique_ptr<cmRulePlaceholderExpander> const RulePlaceholderExpander;
|
||||
std::string const ObjectOutDir;
|
||||
std::set<std::string> const Languages;
|
||||
std::unordered_map<std::string, std::string> const CompileObjectCmakeRules;
|
||||
|
||||
// Now we're adding our link deps to command line and using .Libraries2 for
|
||||
// tracking deps.
|
||||
bool UsingCommandLine = false;
|
||||
|
||||
std::unordered_map<std::string, std::string> TargetIncludesByLanguage;
|
||||
std::map<std::pair<std::string, std::string>, std::string>
|
||||
CompileFlagsByLangAndArch;
|
||||
|
||||
public:
|
||||
cmFastbuildNormalTargetGenerator(cmGeneratorTarget* gt, std::string config);
|
||||
|
||||
void Generate() override;
|
||||
|
||||
private:
|
||||
void GenerateLink(FastbuildTarget& target,
|
||||
std::vector<std::string> const& objectDepends);
|
||||
bool DetectBaseLinkerCommand(std::string& command, std::string const& arch,
|
||||
cmGeneratorTarget::Names const& targetNames);
|
||||
|
||||
// Get languages used by the target.
|
||||
std::set<std::string> GetLanguages();
|
||||
// Returns mapping from language to command how to compile object file for
|
||||
// the it.
|
||||
// Example return value: {"CXX" : "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES>
|
||||
// <FLAGS> -o <OBJECT> -c <SOURCE>" }
|
||||
std::unordered_map<std::string, std::string> GetCompileObjectCommand() const;
|
||||
std::string GetLinkCommand() const;
|
||||
|
||||
void AddCompilerLaunchersForLanguages();
|
||||
void AddLinkerLauncher();
|
||||
void AddCMakeLauncher();
|
||||
|
||||
void ComputePaths(FastbuildTarget& fastbuildTarget) const;
|
||||
|
||||
std::string ComputeCodeCheckOptions(cmSourceFile const& srcFile);
|
||||
|
||||
cmRulePlaceholderExpander::RuleVariables ComputeRuleVariables() const;
|
||||
|
||||
std::vector<std::string> GetSourceProperty(cmSourceFile const& srcFile,
|
||||
std::string const& prop) const;
|
||||
|
||||
std::string GetCompileOptions(cmSourceFile const& srcFile,
|
||||
std::string const& arch);
|
||||
|
||||
std::vector<std::string> GetArches() const;
|
||||
|
||||
std::vector<FastbuildObjectListNode> GenerateObjects();
|
||||
// Computes .CompilerOptions for the ObjectList node.
|
||||
void ComputeCompilerAndOptions(std::string const& compilerOptions,
|
||||
std::string const& staticCheckOptions,
|
||||
std::string const& language,
|
||||
FastbuildObjectListNode& outObjectList);
|
||||
|
||||
std::string GetImportedLoc(cmComputeLinkInformation::Item const& item) const;
|
||||
std::string ResolveIfAlias(std::string const& targetName) const;
|
||||
|
||||
void AppendExtraResources(std::set<std::string>& deps) const;
|
||||
void AppendExternalObject(FastbuildLinkerNode& linkerNode,
|
||||
std::set<std::string>& linkedObjects) const;
|
||||
void AppendExeToLink(FastbuildLinkerNode& linkerNode,
|
||||
cmComputeLinkInformation::Item const& item) const;
|
||||
void AppendTargetDep(FastbuildLinkerNode& linkerNode,
|
||||
std::set<std::string>& linkedObjects,
|
||||
cmComputeLinkInformation::Item const& item) const;
|
||||
void AppendPrebuildDeps(FastbuildLinkerNode& linkerNode,
|
||||
cmComputeLinkInformation::Item const& item) const;
|
||||
void AppendTransitivelyLinkedObjects(
|
||||
cmGeneratorTarget const& target,
|
||||
std::set<std::string>& linkedObjects) const;
|
||||
void AppendCommandLineDep(FastbuildLinkerNode& linkerNode,
|
||||
cmComputeLinkInformation::Item const& item) const;
|
||||
void AppendToLibraries2IfApplicable(FastbuildLinkerNode& linkerNode,
|
||||
std::string dep) const;
|
||||
void AppendLINK_DEPENDS(FastbuildLinkerNode& linkerNode) const;
|
||||
void AppendLinkDep(FastbuildLinkerNode& linkerNode, std::string dep) const;
|
||||
void AppendDirectObjectLibs(FastbuildLinkerNode& linkerNode,
|
||||
std::set<std::string>& linkedObjects);
|
||||
|
||||
void AppendLinkDeps(std::set<FastbuildTargetDep>& preBuildDeps,
|
||||
FastbuildLinkerNode& linkerNode);
|
||||
void AddLipoCommand(FastbuildTarget& target);
|
||||
void GenerateModuleDefinitionInfo(FastbuildTarget& target) const;
|
||||
std::vector<FastbuildExecNode> GetSymlinkExecs() const;
|
||||
void ProcessManifests(FastbuildLinkerNode& linkerNode) const;
|
||||
void AddStampExeIfApplicable(FastbuildTarget& fastbuildTarget) const;
|
||||
void CollapseAllExecsIntoOneScriptfile(
|
||||
std::string const& scriptFileName,
|
||||
std::vector<FastbuildExecNode> const& execs) const;
|
||||
|
||||
void AddPrebuildDeps(FastbuildTarget& target) const;
|
||||
|
||||
std::string DetectCompilerFlags(cmSourceFile const& srcFile,
|
||||
std::string const& arch);
|
||||
|
||||
void GetLinkerExecutableAndArgs(std::string const& command,
|
||||
std::string& outLinkerExecutable,
|
||||
std::string& outLinkerArgs);
|
||||
|
||||
void ApplyCompileRuleLauncher(std::string& command);
|
||||
void ApplyLinkRuleLauncher(std::string& command);
|
||||
void ApplyLWYUToLinkerCommand(FastbuildLinkerNode& linkerNode);
|
||||
|
||||
std::string ComputeDefines(cmSourceFile const& srcFile);
|
||||
|
||||
void ComputePCH(cmSourceFile const& srcFile, FastbuildObjectListNode& node,
|
||||
std::set<std::string>& createdPCH);
|
||||
|
||||
std::vector<std::string> GetManifestsAsFastbuildPath() const;
|
||||
|
||||
void EnsureDirectoryExists(std::string const& path) const;
|
||||
};
|
||||
@@ -0,0 +1,896 @@
|
||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file LICENSE.rst or https://cmake.org/licensing for details. */
|
||||
#include "cmFastbuildTargetGenerator.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
#include <cm/memory>
|
||||
#include <cm/optional>
|
||||
|
||||
#include "cmCryptoHash.h"
|
||||
#include "cmCustomCommand.h"
|
||||
#include "cmCustomCommandGenerator.h"
|
||||
#include "cmCustomCommandLines.h"
|
||||
#include "cmFastbuildNormalTargetGenerator.h"
|
||||
#include "cmFastbuildUtilityTargetGenerator.h"
|
||||
#include "cmGeneratorExpression.h"
|
||||
#include "cmGeneratorTarget.h"
|
||||
#include "cmGlobalCommonGenerator.h"
|
||||
#include "cmGlobalFastbuildGenerator.h"
|
||||
#include "cmList.h"
|
||||
#include "cmListFileCache.h"
|
||||
#include "cmLocalCommonGenerator.h"
|
||||
#include "cmLocalFastbuildGenerator.h"
|
||||
#include "cmLocalGenerator.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmOSXBundleGenerator.h"
|
||||
#include "cmOutputConverter.h"
|
||||
#include "cmRulePlaceholderExpander.h"
|
||||
#include "cmSourceFile.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTarget.h"
|
||||
#include "cmValue.h"
|
||||
|
||||
#define FASTBUILD_DOLLAR_TAG "FASTBUILD_DOLLAR_TAG"
|
||||
|
||||
constexpr auto FASTBUILD_TRACK_BYPRODUCTS_AS_OUTPUT =
|
||||
"CMAKE_FASTBUILD_TRACK_BYPRODUCTS_AS_OUTPUT";
|
||||
constexpr auto FASTBUILD_DISABLE_OUTPUT_PRECHECK_EXEC =
|
||||
"CMAKE_FASTBUILD_DISABLE_OUTPUT_PRECHECK_EXEC";
|
||||
|
||||
cmFastbuildTargetGenerator* cmFastbuildTargetGenerator::New(
|
||||
cmGeneratorTarget* target, std::string config)
|
||||
{
|
||||
switch (target->GetType()) {
|
||||
case cmStateEnums::EXECUTABLE:
|
||||
case cmStateEnums::SHARED_LIBRARY:
|
||||
case cmStateEnums::STATIC_LIBRARY:
|
||||
case cmStateEnums::MODULE_LIBRARY:
|
||||
case cmStateEnums::OBJECT_LIBRARY:
|
||||
return new cmFastbuildNormalTargetGenerator(target, std::move(config));
|
||||
|
||||
case cmStateEnums::UTILITY:
|
||||
case cmStateEnums::GLOBAL_TARGET:
|
||||
case cmStateEnums::INTERFACE_LIBRARY:
|
||||
return new cmFastbuildUtilityTargetGenerator(target, std::move(config));
|
||||
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
cmFastbuildTargetGenerator::cmFastbuildTargetGenerator(
|
||||
cmGeneratorTarget* target, std::string configParam)
|
||||
: cmCommonTargetGenerator(target)
|
||||
, LocalGenerator(
|
||||
static_cast<cmLocalFastbuildGenerator*>(target->GetLocalGenerator()))
|
||||
, TargetDirectDependencies(
|
||||
this->GlobalCommonGenerator->GetTargetDirectDepends(GeneratorTarget))
|
||||
, Config(std::move(configParam))
|
||||
{
|
||||
this->MacOSXContentGenerator =
|
||||
cm::make_unique<MacOSXContentGeneratorType>(this, Config);
|
||||
}
|
||||
|
||||
void cmFastbuildTargetGenerator::LogMessage(std::string const& m) const
|
||||
{
|
||||
this->GetGlobalGenerator()->LogMessage(m);
|
||||
}
|
||||
|
||||
std::string cmFastbuildTargetGenerator::GetUtilityAliasFromBuildStep(
|
||||
FastbuildBuildStep step) const
|
||||
{
|
||||
if (step == FastbuildBuildStep::PRE_BUILD) {
|
||||
return GetTargetName() + FASTBUILD_PRE_BUILD_ALIAS_POSTFIX;
|
||||
}
|
||||
if (step == FastbuildBuildStep::PRE_LINK) {
|
||||
return GetTargetName() + FASTBUILD_PRE_LINK_ALIAS_POSTFIX;
|
||||
}
|
||||
if (step == FastbuildBuildStep::POST_BUILD) {
|
||||
return GetTargetName() + FASTBUILD_POST_BUILD_ALIAS_POSTFIX;
|
||||
}
|
||||
return GetTargetName() + FASTBUILD_CUSTOM_COMMAND_ALIAS_POSTFIX;
|
||||
}
|
||||
|
||||
void cmFastbuildTargetGenerator::MacOSXContentGeneratorType::operator()(
|
||||
cmSourceFile const& source, char const* pkgloc,
|
||||
std::string const& configName)
|
||||
{
|
||||
// Skip OS X content when not building a Framework or Bundle.
|
||||
if (!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the input file location.
|
||||
std::string input = source.GetFullPath();
|
||||
input = this->Generator->GetGlobalGenerator()->ConvertToFastbuildPath(input);
|
||||
|
||||
// Get the output file location.
|
||||
std::string output =
|
||||
this->Generator->OSXBundleGenerator->InitMacOSXContentDirectory(
|
||||
pkgloc, configName);
|
||||
|
||||
output += "/";
|
||||
output += cmSystemTools::GetFilenameName(input);
|
||||
output =
|
||||
this->Generator->GetGlobalGenerator()->ConvertToFastbuildPath(output);
|
||||
|
||||
FastbuildCopyNode node;
|
||||
node.Name = "Copy_" + output;
|
||||
node.Source = std::move(input);
|
||||
if (cmSystemTools::FileIsDirectory(node.Source)) {
|
||||
node.CopyDir = true;
|
||||
}
|
||||
node.Dest = std::move(output);
|
||||
// Just in case if "from" is generated by some custom command.
|
||||
// Tested in "BundleTest" test.
|
||||
node.PreBuildDependencies =
|
||||
this->Generator->GetTargetName() + FASTBUILD_CUSTOM_COMMAND_ALIAS_POSTFIX;
|
||||
|
||||
this->Generator->CopyNodes.emplace_back(std::move(node));
|
||||
}
|
||||
|
||||
std::string cmFastbuildTargetGenerator::GetCustomCommandTargetName(
|
||||
cmCustomCommand const& cc, FastbuildBuildStep step) const
|
||||
{
|
||||
std::string const extra = this->Makefile->GetCurrentBinaryDirectory();
|
||||
std::string targetName = "cc";
|
||||
|
||||
std::string extras = extra;
|
||||
|
||||
// Compute hash based on commands & args & output.
|
||||
for (cmCustomCommandLine const& commandLine : cc.GetCommandLines()) {
|
||||
extras += cmJoin(commandLine, "");
|
||||
}
|
||||
for (std::string const& output : cc.GetOutputs()) {
|
||||
extras += output;
|
||||
}
|
||||
|
||||
extras += std::to_string(static_cast<int>(step));
|
||||
|
||||
cmCryptoHash hash(cmCryptoHash::AlgoSHA256);
|
||||
targetName += "-" + hash.HashString(extras).substr(0, 7);
|
||||
|
||||
return targetName;
|
||||
}
|
||||
|
||||
std::vector<std::string> cmFastbuildTargetGenerator::GetInputFiles(
|
||||
cmCustomCommandGenerator const& ccg, FastbuildBuildStep step) const
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
auto const& cc = ccg.GetCC();
|
||||
LogMessage("CC Name: " + GetCustomCommandTargetName(cc, step));
|
||||
for (std::string const& dep : ccg.GetDepends()) {
|
||||
LogMessage("Custom command dep: " + dep);
|
||||
// Tested in EmptyDepends test.
|
||||
std::string realDep;
|
||||
if (this->LocalCommonGenerator->GetRealDependency(dep, Config, realDep)) {
|
||||
auto list = cmList{ cmGeneratorExpression::Evaluate(
|
||||
this->ConvertToFastbuildPath(realDep), this->LocalGenerator, Config) };
|
||||
if (!realDep.empty()) {
|
||||
LogMessage("Custom command real dep: " + realDep);
|
||||
for (auto const& item : list) {
|
||||
result.emplace_back(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cc.HasMainDependency()) {
|
||||
LogMessage("CC main dep: " + cc.GetMainDependency());
|
||||
}
|
||||
LogMessage("cc Target: " + cc.GetTarget());
|
||||
for (auto const& impDep : cc.GetImplicitDepends()) {
|
||||
LogMessage("CC imp dep: " + impDep.first + ", " + impDep.second);
|
||||
}
|
||||
for (std::string const& dep : cc.GetOutputs()) {
|
||||
LogMessage("Custom command output: " + this->ConvertToFastbuildPath(dep));
|
||||
}
|
||||
for (std::string const& dep : cc.GetByproducts()) {
|
||||
LogMessage("Custom command byproducts: " +
|
||||
this->ConvertToFastbuildPath(dep));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void cmFastbuildTargetGenerator::WriteScriptProlog(cmsys::ofstream& file) const
|
||||
{
|
||||
#ifdef _WIN32
|
||||
file << "@echo off\n";
|
||||
#else
|
||||
file << "set -e\n\n";
|
||||
#endif
|
||||
}
|
||||
void cmFastbuildTargetGenerator::WriteScriptEpilog(cmsys::ofstream& file) const
|
||||
{
|
||||
(void)file;
|
||||
#ifdef _WIN32
|
||||
file << "goto :EOF\n\n"
|
||||
":ABORT\n"
|
||||
"set ERROR_CODE=%ERRORLEVEL%\n"
|
||||
"echo Batch file failed at line %FAIL_LINE% "
|
||||
"with errorcode %ERRORLEVEL%\n"
|
||||
"exit /b %ERROR_CODE%";
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string cmFastbuildTargetGenerator::GetScriptWorkingDir(
|
||||
cmCustomCommandGenerator const& ccg) const
|
||||
{
|
||||
std::string workingDirectory = ccg.GetWorkingDirectory();
|
||||
if (workingDirectory.empty()) {
|
||||
return this->LocalCommonGenerator->GetCurrentBinaryDirectory();
|
||||
}
|
||||
return workingDirectory;
|
||||
}
|
||||
|
||||
std::string cmFastbuildTargetGenerator::GetScriptFilename(
|
||||
std::string const& utilityTargetName) const
|
||||
{
|
||||
std::string scriptFileName = Makefile->GetCurrentBinaryDirectory();
|
||||
scriptFileName += "/CMakeFiles/";
|
||||
scriptFileName += utilityTargetName;
|
||||
scriptFileName += FASTBUILD_SCRIPT_FILE_EXTENSION;
|
||||
return scriptFileName;
|
||||
}
|
||||
|
||||
void cmFastbuildTargetGenerator::AddCommentPrinting(
|
||||
std::vector<std::string>& cmdLines,
|
||||
cmCustomCommandGenerator const& ccg) const
|
||||
{
|
||||
std::string cmakeCommand = this->GetLocalGenerator()->ConvertToOutputFormat(
|
||||
cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL);
|
||||
auto const comment = ccg.GetComment();
|
||||
if (comment) {
|
||||
// Comment printing should be first. Tested in
|
||||
// RunCMake.ExternalProject:EnvVars-build test.
|
||||
cmdLines.insert(
|
||||
cmdLines.begin(),
|
||||
cmakeCommand.append(" -E echo ")
|
||||
.append(LocalGenerator->EscapeForShell(cmGeneratorExpression::Evaluate(
|
||||
*comment, this->LocalGenerator, Config))));
|
||||
}
|
||||
}
|
||||
|
||||
std::string cmFastbuildTargetGenerator::GetCdCommand(
|
||||
cmCustomCommandGenerator const& ccg) const
|
||||
{
|
||||
return cmStrCat(FASTBUILD_SCRIPT_CD,
|
||||
this->LocalGenerator->ConvertToOutputFormat(
|
||||
GetScriptWorkingDir(ccg), cmOutputConverter::SHELL));
|
||||
}
|
||||
|
||||
void cmFastbuildTargetGenerator::WriteCmdsToFile(
|
||||
cmsys::ofstream& file, std::vector<std::string> const& cmds) const
|
||||
{
|
||||
#ifdef _WIN32
|
||||
int line = 1;
|
||||
for (auto cmd : cmds) {
|
||||
// On Windows batch, '%' is a special character that needs to be
|
||||
// doubled to be escaped
|
||||
cmSystemTools::ReplaceString(cmd, "%", "%%");
|
||||
file << cmd << " || (set FAIL_LINE=" << ++line << "& goto :ABORT)" << '\n';
|
||||
#else
|
||||
for (auto const& cmd : cmds) {
|
||||
file << cmd << '\n';
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void cmFastbuildTargetGenerator::AddOutput(cmCustomCommandGenerator const& ccg,
|
||||
FastbuildExecNode& exec)
|
||||
{
|
||||
std::string dummyOutput = cmSystemTools::JoinPath(
|
||||
{ LocalCommonGenerator->GetMakefile()->GetHomeOutputDirectory(),
|
||||
"/_fbuild_dummy" });
|
||||
this->GetGlobalGenerator()->AllFoldersToClean.insert(dummyOutput);
|
||||
|
||||
dummyOutput.append("/").append(exec.Name).append(
|
||||
FASTBUILD_DUMMY_OUTPUT_EXTENSION);
|
||||
|
||||
std::vector<std::string> const& outputs = ccg.GetOutputs();
|
||||
std::vector<std::string> const& byproducts = ccg.GetByproducts();
|
||||
|
||||
exec.OutputsAlias.Name = exec.Name + FASTBUILD_OUTPUTS_ALIAS_POSTFIX;
|
||||
// If CC doesn't have any output - we should always run it.
|
||||
// Tested in "RunCMake.CMakePresetsBuild" test.
|
||||
bool hasAnyNonSymbolicOutput = false;
|
||||
|
||||
bool const trackByproducts =
|
||||
this->Makefile->IsDefinitionSet(FASTBUILD_TRACK_BYPRODUCTS_AS_OUTPUT);
|
||||
|
||||
auto const isSymbolic = [this](std::string const& file) {
|
||||
cmSourceFile* sf = this->Makefile->GetSource(file);
|
||||
if (sf && sf->GetPropertyAsBool("SYMBOLIC")) {
|
||||
LogMessage("Skipping symbolic file: " + file);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
for (std::string const& output : outputs) {
|
||||
// Tested in "RunCMake.BuildDepends".
|
||||
if (isSymbolic(output)) {
|
||||
continue;
|
||||
}
|
||||
hasAnyNonSymbolicOutput = true;
|
||||
std::string const outputPath = this->ConvertToFastbuildPath(output);
|
||||
LogMessage("CC's output: " + outputPath);
|
||||
exec.OutputsAlias.PreBuildDependencies.emplace(outputPath);
|
||||
// Ensure output path exists. For some reason, "CMake -E touch" fails with
|
||||
// "cmake -E touch: failed to update "...
|
||||
cmSystemTools::MakeDirectory(cmSystemTools::GetFilenamePath(outputPath));
|
||||
this->GetGlobalGenerator()->AddFileToClean(outputPath);
|
||||
}
|
||||
|
||||
exec.ByproductsAlias.Name = exec.Name + FASTBUILD_BYPRODUCTS_ALIAS_POSTFIX;
|
||||
for (std::string const& byproduct : byproducts) {
|
||||
if (trackByproducts) {
|
||||
hasAnyNonSymbolicOutput = true;
|
||||
}
|
||||
std::string const byproductPath = this->ConvertToFastbuildPath(byproduct);
|
||||
exec.ByproductsAlias.PreBuildDependencies.emplace(byproductPath);
|
||||
this->GetGlobalGenerator()->AddFileToClean(byproductPath);
|
||||
}
|
||||
|
||||
auto const addDummyOutput = [&] {
|
||||
// So that the dummy file is always created.
|
||||
exec.ExecUseStdOutAsOutput = true;
|
||||
exec.ExecOutput = this->ConvertToFastbuildPath(dummyOutput);
|
||||
for (auto const& output : exec.OutputsAlias.PreBuildDependencies) {
|
||||
OutputsToReplace[output.Name] = exec.ExecOutput;
|
||||
LogMessage("Adding replace from " + output.Name + " to " +
|
||||
exec.ExecOutput);
|
||||
}
|
||||
};
|
||||
|
||||
// We don't have any output that is expected to appear on disk -> run always.
|
||||
// Tested in "RunCMake.ExternalProject":BUILD_ALWAYS
|
||||
if (!hasAnyNonSymbolicOutput) {
|
||||
exec.ExecAlways = true;
|
||||
addDummyOutput();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!exec.OutputsAlias.PreBuildDependencies.empty()) {
|
||||
exec.ExecOutput = this->ConvertToFastbuildPath(
|
||||
exec.OutputsAlias.PreBuildDependencies.begin()->Name);
|
||||
} else {
|
||||
exec.ExecOutput = this->ConvertToFastbuildPath(
|
||||
exec.ByproductsAlias.PreBuildDependencies.begin()->Name);
|
||||
}
|
||||
|
||||
// Optionally add the "deps-check" Exec if we have more than 1 OUTPUT, but
|
||||
// allow user to opt out.
|
||||
if (exec.OutputsAlias.PreBuildDependencies.size() > 1 &&
|
||||
!this->Makefile->IsDefinitionSet(
|
||||
FASTBUILD_DISABLE_OUTPUT_PRECHECK_EXEC)) {
|
||||
exec.NeedsDepsCheckExec = true;
|
||||
}
|
||||
}
|
||||
|
||||
void cmFastbuildTargetGenerator::AddExecArguments(
|
||||
FastbuildExecNode& exec, std::string const& scriptFilename) const
|
||||
{
|
||||
exec.ExecArguments = FASTBUILD_SCRIPT_FILE_ARG;
|
||||
exec.ExecArguments +=
|
||||
cmGlobalFastbuildGenerator::QuoteIfHasSpaces(scriptFilename);
|
||||
|
||||
exec.ScriptFile = scriptFilename;
|
||||
exec.ExecExecutable =
|
||||
cmGlobalFastbuildGenerator::GetExternalShellExecutable();
|
||||
}
|
||||
|
||||
std::vector<std::string> cmFastbuildTargetGenerator::GetDepends(
|
||||
cmCustomCommandGenerator const& ccg) const
|
||||
{
|
||||
std::vector<std::string> res;
|
||||
for (auto dep : ccg.GetDepends()) {
|
||||
LogMessage("Dep: " + dep);
|
||||
auto orig = dep;
|
||||
if (this->LocalCommonGenerator->GetRealDependency(dep, Config, dep)) {
|
||||
LogMessage("Real dep: " + dep);
|
||||
}
|
||||
dep = this->ConvertToFastbuildPath(dep);
|
||||
LogMessage("Real dep converted: " + dep);
|
||||
|
||||
auto const targetInfo = this->LocalGenerator->GetSourcesWithOutput(dep);
|
||||
if (targetInfo.Target) {
|
||||
LogMessage("dep: " + dep + ", target: " + targetInfo.Target->GetName());
|
||||
auto const& target = targetInfo.Target;
|
||||
auto const processCCs = [this, &res,
|
||||
dep](std::vector<cmCustomCommand> const& ccs,
|
||||
FastbuildBuildStep step) {
|
||||
for (auto const& cc : ccs) {
|
||||
for (auto const& output : cc.GetOutputs()) {
|
||||
LogMessage("dep: " + dep + ", post output: " +
|
||||
this->ConvertToFastbuildPath(output));
|
||||
if (this->ConvertToFastbuildPath(output) == dep) {
|
||||
auto ccName = this->GetCustomCommandTargetName(cc, step);
|
||||
LogMessage("Additional CC dep from target: " + ccName);
|
||||
res.emplace_back(std::move(ccName));
|
||||
}
|
||||
}
|
||||
for (auto const& byproduct : cc.GetByproducts()) {
|
||||
LogMessage("dep: " + dep + ", post byproduct: " +
|
||||
this->ConvertToFastbuildPath(byproduct));
|
||||
if (this->ConvertToFastbuildPath(byproduct) == dep) {
|
||||
auto ccName = this->GetCustomCommandTargetName(cc, step);
|
||||
LogMessage("Additional CC dep from target: " + ccName);
|
||||
res.emplace_back(std::move(ccName));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
processCCs(target->GetPreBuildCommands(), FastbuildBuildStep::PRE_BUILD);
|
||||
processCCs(target->GetPreLinkCommands(), FastbuildBuildStep::PRE_LINK);
|
||||
processCCs(target->GetPostBuildCommands(),
|
||||
FastbuildBuildStep::POST_BUILD);
|
||||
continue;
|
||||
}
|
||||
if (!targetInfo.Source) {
|
||||
LogMessage("dep: " + dep + ", no source, byproduct: " +
|
||||
std::to_string(targetInfo.SourceIsByproduct));
|
||||
// Tested in "OutDir" test.
|
||||
res.emplace_back(std::move(orig));
|
||||
continue;
|
||||
}
|
||||
if (!targetInfo.Source->GetCustomCommand()) {
|
||||
LogMessage("dep: " + dep + ", no GetCustomCommand");
|
||||
continue;
|
||||
}
|
||||
if (targetInfo.Source && targetInfo.Source->GetCustomCommand()) {
|
||||
auto ccName = this->GetCustomCommandTargetName(
|
||||
*targetInfo.Source->GetCustomCommand(), FastbuildBuildStep::REST);
|
||||
LogMessage("Additional CC dep: " + ccName);
|
||||
res.emplace_back(std::move(ccName));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void cmFastbuildTargetGenerator::ReplaceProblematicMakeVars(
|
||||
std::string& command) const
|
||||
{
|
||||
// TODO: fix problematic global targets. For now, search and replace the
|
||||
// makefile vars.
|
||||
cmSystemTools::ReplaceString(
|
||||
command, "$(CMAKE_SOURCE_DIR)",
|
||||
this->LocalGenerator->ConvertToOutputFormat(
|
||||
this->LocalGenerator->GetSourceDirectory(), cmOutputConverter::SHELL));
|
||||
cmSystemTools::ReplaceString(
|
||||
command, "$(CMAKE_BINARY_DIR)",
|
||||
this->LocalGenerator->ConvertToOutputFormat(
|
||||
this->LocalGenerator->GetBinaryDirectory(), cmOutputConverter::SHELL));
|
||||
cmSystemTools::ReplaceString(command, "$(ARGS)", "");
|
||||
}
|
||||
|
||||
FastbuildExecNode cmFastbuildTargetGenerator::GetAppleTextStubCommand() const
|
||||
{
|
||||
FastbuildExecNode res;
|
||||
if (!this->GeneratorTarget->IsApple() ||
|
||||
!this->GeneratorTarget->HasImportLibrary(Config)) {
|
||||
return res;
|
||||
}
|
||||
|
||||
auto const names = DetectOutput();
|
||||
std::string const outpathImp =
|
||||
this->ConvertToFastbuildPath(this->GeneratorTarget->GetDirectory(
|
||||
Config, cmStateEnums::ImportLibraryArtifact));
|
||||
|
||||
std::string const binPath =
|
||||
this->ConvertToFastbuildPath(this->GeneratorTarget->GetDirectory(
|
||||
Config, cmStateEnums::RuntimeBinaryArtifact));
|
||||
|
||||
cmSystemTools::MakeDirectory(outpathImp);
|
||||
|
||||
std::string rule = this->LocalGenerator->GetMakefile()->GetSafeDefinition(
|
||||
"CMAKE_CREATE_TEXT_STUBS");
|
||||
LogMessage("CMAKE_CREATE_TEXT_STUBS:" + rule);
|
||||
|
||||
auto rulePlaceholderExpander =
|
||||
this->GetLocalGenerator()->CreateRulePlaceholderExpander();
|
||||
|
||||
cmRulePlaceholderExpander::RuleVariables vars;
|
||||
res.ExecOutput = cmStrCat(outpathImp, '/', names.ImportReal);
|
||||
res.ExecInput = { cmStrCat(binPath, '/', names.SharedObject) };
|
||||
|
||||
vars.Target = res.ExecInput[0].c_str();
|
||||
rulePlaceholderExpander->SetTargetImpLib(res.ExecOutput);
|
||||
rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(), rule,
|
||||
vars);
|
||||
|
||||
LogMessage("CMAKE_CREATE_TEXT_STUBS expanded:" + rule);
|
||||
std::string executable;
|
||||
std::string args;
|
||||
if (!cmSystemTools::SplitProgramFromArgs(rule, executable, args)) {
|
||||
cmSystemTools::Error("Failed to split program from args: " + rule);
|
||||
return res;
|
||||
}
|
||||
|
||||
res.Name = "create_" + names.ImportOutput + "_text_stub";
|
||||
res.ExecExecutable = std::move(executable);
|
||||
res.ExecArguments = std::move(args);
|
||||
res.ExecWorkingDir = this->LocalCommonGenerator->GetCurrentBinaryDirectory();
|
||||
|
||||
// Wait for the build.
|
||||
res.PreBuildDependencies.emplace(this->GetTargetName());
|
||||
return res;
|
||||
}
|
||||
FastbuildExecNode cmFastbuildTargetGenerator::GetDepsCheckExec(
|
||||
FastbuildExecNode const& depender)
|
||||
{
|
||||
FastbuildExecNode exec;
|
||||
exec.Name = depender.Name + "-check-depends";
|
||||
exec.ExecAlways = true;
|
||||
exec.ExecUseStdOutAsOutput = true;
|
||||
exec.ExecOutput = depender.ExecOutput + ".deps-checker";
|
||||
exec.ExecExecutable = cmSystemTools::GetCMakeCommand();
|
||||
exec.ExecArguments += "-E cmake_fastbuild_check_depends ";
|
||||
exec.ExecArguments += depender.ExecOutput + " ";
|
||||
char const* sep = "";
|
||||
for (auto const& dep : depender.OutputsAlias.PreBuildDependencies) {
|
||||
exec.ExecArguments += sep;
|
||||
exec.ExecArguments += dep.Name;
|
||||
sep = " ";
|
||||
}
|
||||
for (auto const& dep : depender.ByproductsAlias.PreBuildDependencies) {
|
||||
exec.ExecArguments += sep;
|
||||
exec.ExecArguments += dep.Name;
|
||||
sep = " ";
|
||||
}
|
||||
return exec;
|
||||
}
|
||||
|
||||
FastbuildExecNodes cmFastbuildTargetGenerator::GenerateCommands(
|
||||
FastbuildBuildStep buildStep)
|
||||
{
|
||||
FastbuildExecNodes execs;
|
||||
execs.Alias.Name = GetUtilityAliasFromBuildStep(buildStep);
|
||||
|
||||
std::vector<cmCustomCommand> commands;
|
||||
if (buildStep == FastbuildBuildStep::PRE_BUILD) {
|
||||
commands = GeneratorTarget->GetPreBuildCommands();
|
||||
LogMessage("STEP: PRE_BUILD");
|
||||
} else if (buildStep == FastbuildBuildStep::PRE_LINK) {
|
||||
commands = GeneratorTarget->GetPreLinkCommands();
|
||||
LogMessage("STEP: PRE_LINK");
|
||||
} else if (buildStep == FastbuildBuildStep::POST_BUILD) {
|
||||
commands = GeneratorTarget->GetPostBuildCommands();
|
||||
LogMessage("STEP: POST_BUILD");
|
||||
} else {
|
||||
LogMessage("STEP: ALL CUSTOM COMMANDS");
|
||||
std::vector<cmSourceFile const*> customCommands;
|
||||
GeneratorTarget->GetCustomCommands(customCommands, Config);
|
||||
for (cmSourceFile const* source : customCommands) {
|
||||
cmCustomCommand const* cmd = source->GetCustomCommand();
|
||||
if (!cmd->GetCommandLines().empty()) {
|
||||
commands.emplace_back(*cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
LogMessage(cmStrCat("Number of custom commands: ", commands.size()));
|
||||
for (cmCustomCommand const& customCommand : commands) {
|
||||
cmCustomCommandGenerator ccg(customCommand, Config, LocalCommonGenerator);
|
||||
std::string launcher = this->MakeCustomLauncher(ccg);
|
||||
|
||||
std::string const execName =
|
||||
GetCustomCommandTargetName(customCommand, buildStep);
|
||||
|
||||
std::vector<std::string> cmdLines;
|
||||
if (ccg.GetNumberOfCommands() > 0) {
|
||||
cmdLines.push_back(GetCdCommand(ccg));
|
||||
}
|
||||
|
||||
// Since we are not using FASTBuild Exec nodes natively, we need to
|
||||
// have shell specific escape.
|
||||
this->LocalGenerator->GetState()->SetFastbuildMake(false);
|
||||
// To avoid replacing $ with $$ in the command line.
|
||||
this->LocalGenerator->SetLinkScriptShell(true);
|
||||
for (unsigned j = 0; j != ccg.GetNumberOfCommands(); ++j) {
|
||||
std::string const command = ccg.GetCommand(j);
|
||||
// Tested in "CustomCommand" ("empty_command") test.
|
||||
if (!command.empty()) {
|
||||
|
||||
cmdLines.emplace_back(launcher +
|
||||
this->LocalGenerator->ConvertToOutputFormat(
|
||||
command, cmOutputConverter::SHELL));
|
||||
|
||||
std::string& cmd = cmdLines.back();
|
||||
ccg.AppendArguments(j, cmd);
|
||||
ReplaceProblematicMakeVars(cmd);
|
||||
LogMessage("cmCustomCommandLine: " + cmd);
|
||||
}
|
||||
}
|
||||
if (cmdLines.empty()) {
|
||||
return {};
|
||||
}
|
||||
this->LocalGenerator->GetState()->SetFastbuildMake(true);
|
||||
|
||||
FastbuildExecNode execNode;
|
||||
execNode.Name = execName;
|
||||
std::vector<std::string> const inputFiles = GetInputFiles(ccg, buildStep);
|
||||
for (std::string const& file : inputFiles) {
|
||||
LogMessage("Input file: " + file);
|
||||
}
|
||||
for (auto const& util : ccg.GetUtilities()) {
|
||||
auto const& utilTargetName = util.Value.first;
|
||||
LogMessage("Util: " + utilTargetName +
|
||||
", cross: " + std::to_string(util.Value.second));
|
||||
auto* const target = this->Makefile->FindTargetToUse(utilTargetName);
|
||||
|
||||
if (target && target->IsImported()) {
|
||||
std::string importedLoc =
|
||||
this->ConvertToFastbuildPath(target->ImportedGetFullPath(
|
||||
Config, cmStateEnums::ArtifactType::RuntimeBinaryArtifact));
|
||||
if (importedLoc.empty()) {
|
||||
importedLoc =
|
||||
this->ConvertToFastbuildPath(target->ImportedGetFullPath(
|
||||
Config, cmStateEnums::ArtifactType::ImportLibraryArtifact));
|
||||
}
|
||||
LogMessage("adding file level dep on imporated target: " +
|
||||
importedLoc);
|
||||
execNode.PreBuildDependencies.emplace(std::move(importedLoc));
|
||||
continue;
|
||||
}
|
||||
// This CC uses some executable produced by another target. Add explicit
|
||||
// dep. Tested in "CustomCommand" test.
|
||||
if (util.Value.second) {
|
||||
if (utilTargetName != customCommand.GetTarget()) {
|
||||
LogMessage("Adding util dep: " + utilTargetName);
|
||||
execNode.PreBuildDependencies.emplace(utilTargetName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
execNode.ExecInput = inputFiles;
|
||||
execs.Alias.PreBuildDependencies.emplace(execNode.Name);
|
||||
|
||||
LogMessage(cmStrCat("cmdLines size ", cmdLines.size()));
|
||||
|
||||
if (!cmdLines.empty()) {
|
||||
std::string const scriptFileName = GetScriptFilename(execName);
|
||||
cmsys::ofstream scriptFile(scriptFileName.c_str());
|
||||
|
||||
AddOutput(ccg, execNode);
|
||||
AddExecArguments(execNode, scriptFileName);
|
||||
AddCommentPrinting(cmdLines, ccg);
|
||||
|
||||
WriteScriptProlog(scriptFile);
|
||||
WriteCmdsToFile(scriptFile, cmdLines);
|
||||
WriteScriptEpilog(scriptFile);
|
||||
|
||||
execNode.ExecWorkingDir = GetScriptWorkingDir(ccg);
|
||||
}
|
||||
|
||||
// Tested in "ObjectLibrary / complexOneConfig" tests.
|
||||
for (std::string& additionalDep : GetDepends(ccg)) {
|
||||
if (additionalDep != execName) {
|
||||
LogMessage("Adding additional dep: " + additionalDep);
|
||||
execNode.PreBuildDependencies.emplace(std::move(additionalDep));
|
||||
}
|
||||
}
|
||||
|
||||
if (buildStep == FastbuildBuildStep::POST_BUILD) {
|
||||
execNode.PreBuildDependencies.emplace(GetTargetName() +
|
||||
FASTBUILD_BUILD_ALIAS_POSTFIX);
|
||||
// Execute POST_BUILD in order in which they are declared.
|
||||
// Tested in "complex" test.
|
||||
for (auto& exec : execs.Nodes) {
|
||||
execNode.PreBuildDependencies.emplace(exec.Name);
|
||||
}
|
||||
}
|
||||
for (auto const& out : execNode.OutputsAlias.PreBuildDependencies) {
|
||||
LogMessage("Adding replace from " + out.Name + " to " + execName);
|
||||
OutputToExecName[out.Name] = execName;
|
||||
}
|
||||
execs.Nodes.emplace_back(std::move(execNode));
|
||||
}
|
||||
for (auto& exec : execs.Nodes) {
|
||||
for (auto& inputFile : exec.ExecInput) {
|
||||
auto const iter = OutputsToReplace.find(inputFile);
|
||||
if (iter != OutputsToReplace.end()) {
|
||||
LogMessage("Replacing input: " + inputFile + " with " + iter->second);
|
||||
inputFile = iter->second;
|
||||
}
|
||||
auto const depIter = std::find_if(
|
||||
exec.PreBuildDependencies.begin(), exec.PreBuildDependencies.end(),
|
||||
[this](FastbuildTargetDep const& dep) {
|
||||
return !OutputToExecName[dep.Name].empty();
|
||||
});
|
||||
if (depIter != exec.PreBuildDependencies.end()) {
|
||||
LogMessage("Replacing dep " + depIter->Name + " with " +
|
||||
OutputToExecName[depIter->Name]);
|
||||
exec.PreBuildDependencies.emplace(OutputToExecName[depIter->Name]);
|
||||
exec.PreBuildDependencies.erase(depIter);
|
||||
}
|
||||
}
|
||||
if (exec.NeedsDepsCheckExec) {
|
||||
auto depsCheckExec = GetDepsCheckExec(exec);
|
||||
LogMessage("Adding deps check Exec: " + depsCheckExec.Name);
|
||||
exec.PreBuildDependencies.emplace(depsCheckExec.Name);
|
||||
this->GetGlobalGenerator()->AddTarget(std::move(depsCheckExec));
|
||||
}
|
||||
}
|
||||
return execs;
|
||||
}
|
||||
|
||||
std::string cmFastbuildTargetGenerator::MakeCustomLauncher(
|
||||
cmCustomCommandGenerator const& ccg)
|
||||
{
|
||||
// Copied from cmLocalNinjaGenerator::MakeCustomLauncher.
|
||||
cmValue property_value = this->Makefile->GetProperty("RULE_LAUNCH_CUSTOM");
|
||||
|
||||
if (!cmNonempty(property_value)) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
// Expand rule variables referenced in the given launcher command.
|
||||
cmRulePlaceholderExpander::RuleVariables vars;
|
||||
|
||||
std::string output;
|
||||
std::vector<std::string> const& outputs = ccg.GetOutputs();
|
||||
for (size_t i = 0; i < outputs.size(); ++i) {
|
||||
output =
|
||||
cmStrCat(output,
|
||||
this->LocalGenerator->ConvertToOutputFormat(
|
||||
ccg.GetWorkingDirectory().empty()
|
||||
? this->LocalGenerator->MaybeRelativeToCurBinDir(outputs[i])
|
||||
: outputs[i],
|
||||
cmOutputConverter::SHELL));
|
||||
if (i != outputs.size() - 1) {
|
||||
output = cmStrCat(output, ',');
|
||||
}
|
||||
}
|
||||
vars.Output = output.c_str();
|
||||
vars.Role = ccg.GetCC().GetRole().c_str();
|
||||
|
||||
auto rulePlaceholderExpander =
|
||||
this->LocalGenerator->CreateRulePlaceholderExpander();
|
||||
|
||||
std::string launcher = *property_value;
|
||||
rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, launcher,
|
||||
vars);
|
||||
if (!launcher.empty()) {
|
||||
launcher += " ";
|
||||
}
|
||||
|
||||
LogMessage("CC Launcher: " + launcher);
|
||||
return launcher;
|
||||
}
|
||||
|
||||
std::string cmFastbuildTargetGenerator::GetTargetName() const
|
||||
{
|
||||
if (this->GeneratorTarget->GetType() == cmStateEnums::GLOBAL_TARGET) {
|
||||
return this->GetGlobalGenerator()->GetTargetName(GeneratorTarget);
|
||||
}
|
||||
return this->GeneratorTarget->GetName();
|
||||
}
|
||||
|
||||
cmGeneratorTarget::Names cmFastbuildTargetGenerator::DetectOutput() const
|
||||
{
|
||||
if (GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) {
|
||||
return GeneratorTarget->GetExecutableNames(Config);
|
||||
}
|
||||
return GeneratorTarget->GetLibraryNames(Config);
|
||||
}
|
||||
|
||||
void cmFastbuildTargetGenerator::AddObjectDependencies(
|
||||
FastbuildTarget& fastbuildTarget,
|
||||
std::vector<std::string>& allObjectDepends) const
|
||||
{
|
||||
auto const FindObjListWhichOutputs = [&fastbuildTarget](
|
||||
std::string const& output) {
|
||||
for (FastbuildObjectListNode const& objList :
|
||||
fastbuildTarget.ObjectListNodes) {
|
||||
if (objList.ObjectOutputs.find(output) != objList.ObjectOutputs.end()) {
|
||||
return objList.Name;
|
||||
}
|
||||
}
|
||||
return std::string{};
|
||||
};
|
||||
|
||||
for (FastbuildObjectListNode& objList : fastbuildTarget.ObjectListNodes) {
|
||||
objList.PreBuildDependencies.emplace(
|
||||
fastbuildTarget.Name + FASTBUILD_DEPS_ARTIFACTS_ALIAS_POSTFIX);
|
||||
for (auto const& objDep : objList.ObjectDepends) {
|
||||
// Check if there is another object list which outputs (OBJECT_OUTPUTS)
|
||||
// something that this object list needs (OBJECT_DEPENDS).
|
||||
auto anotherObjList = FindObjListWhichOutputs(objDep);
|
||||
if (!anotherObjList.empty()) {
|
||||
LogMessage("Adding explicit <OBJECT_DEPENDS> dep: " + anotherObjList);
|
||||
allObjectDepends.emplace_back(anotherObjList);
|
||||
objList.PreBuildDependencies.emplace(std::move(anotherObjList));
|
||||
|
||||
} else {
|
||||
LogMessage("Adding <OBJECT_DEPENDS> dep: " + objDep);
|
||||
allObjectDepends.emplace_back(objDep);
|
||||
objList.PreBuildDependencies.emplace(objDep);
|
||||
}
|
||||
}
|
||||
}
|
||||
cmGlobalFastbuildGenerator::TopologicalSort(fastbuildTarget.ObjectListNodes);
|
||||
}
|
||||
|
||||
void cmFastbuildTargetGenerator::AddLinkerNodeDependnecies(
|
||||
FastbuildTarget& fastbuildTarget)
|
||||
{
|
||||
for (auto& linkerNode : fastbuildTarget.LinkerNode) {
|
||||
linkerNode.PreBuildDependencies.emplace(
|
||||
fastbuildTarget.Name + FASTBUILD_DEPS_ARTIFACTS_ALIAS_POSTFIX);
|
||||
|
||||
if (!fastbuildTarget.PreLinkExecNodes.Nodes.empty()) {
|
||||
linkerNode.PreBuildDependencies.emplace(
|
||||
fastbuildTarget.Name + FASTBUILD_PRE_LINK_ALIAS_POSTFIX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string cmFastbuildTargetGenerator::GetClangTidyReplacementsFilePath(
|
||||
std::string const& directory, cmSourceFile const& source,
|
||||
std::string const& /*config*/) const
|
||||
{
|
||||
|
||||
std::string objectDir =
|
||||
this->ConvertToFastbuildPath(this->GeneratorTarget->GetSupportDirectory());
|
||||
std::string const& objectName =
|
||||
this->GeneratorTarget->GetObjectName(&source);
|
||||
std::string path =
|
||||
cmStrCat(directory, '/', objectDir, '/', objectName, ".yaml");
|
||||
LogMessage("ClangTidy replacements file: " + path);
|
||||
return path;
|
||||
}
|
||||
|
||||
void cmFastbuildTargetGenerator::AddIncludeFlags(std::string& languageFlags,
|
||||
std::string const& language,
|
||||
std::string const&)
|
||||
{
|
||||
std::vector<std::string> includes;
|
||||
this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget,
|
||||
language, Config);
|
||||
// Add include directory flags.
|
||||
std::string includeFlags = this->LocalGenerator->GetIncludeFlags(
|
||||
includes, this->GeneratorTarget, language, Config, false);
|
||||
|
||||
this->LocalGenerator->AppendFlags(languageFlags, includeFlags);
|
||||
}
|
||||
|
||||
std::string cmFastbuildTargetGenerator::GetName()
|
||||
{
|
||||
return GeneratorTarget->GetName();
|
||||
}
|
||||
|
||||
std::string cmFastbuildTargetGenerator::ConvertToFastbuildPath(
|
||||
std::string const& path) const
|
||||
{
|
||||
return GetGlobalGenerator()->ConvertToFastbuildPath(path);
|
||||
}
|
||||
|
||||
cmGlobalFastbuildGenerator* cmFastbuildTargetGenerator::GetGlobalGenerator()
|
||||
const
|
||||
{
|
||||
return this->LocalGenerator->GetGlobalFastbuildGenerator();
|
||||
}
|
||||
|
||||
void cmFastbuildTargetGenerator::AdditionalCleanFiles()
|
||||
{
|
||||
if (cmValue prop_value =
|
||||
this->GeneratorTarget->GetProperty("ADDITIONAL_CLEAN_FILES")) {
|
||||
auto* lg = this->LocalGenerator;
|
||||
cmList cleanFiles(cmGeneratorExpression::Evaluate(*prop_value, lg, Config,
|
||||
this->GeneratorTarget));
|
||||
std::string const& binaryDir = lg->GetCurrentBinaryDirectory();
|
||||
auto* gg = lg->GetGlobalFastbuildGenerator();
|
||||
for (auto const& cleanFile : cleanFiles) {
|
||||
// Support relative paths
|
||||
gg->AddFileToClean(gg->ConvertToFastbuildPath(
|
||||
cmSystemTools::CollapseFullPath(cleanFile, binaryDir)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file LICENSE.rst or https://cmake.org/licensing for details. */
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "cmsys/FStream.hxx"
|
||||
|
||||
#include "cmCommonTargetGenerator.h"
|
||||
#include "cmGeneratorTarget.h"
|
||||
#include "cmGlobalFastbuildGenerator.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmOSXBundleGenerator.h"
|
||||
|
||||
class cmCustomCommand;
|
||||
class cmCustomCommandGenerator;
|
||||
class cmLocalFastbuildGenerator;
|
||||
class cmMakefile;
|
||||
class cmSourceFile;
|
||||
|
||||
enum class FastbuildBuildStep
|
||||
{
|
||||
PRE_BUILD,
|
||||
PRE_LINK,
|
||||
POST_BUILD,
|
||||
REST,
|
||||
};
|
||||
|
||||
class cmFastbuildTargetGenerator : public cmCommonTargetGenerator
|
||||
{
|
||||
public:
|
||||
/// Create a cmFastbuildTargetGenerator according to the @a target's type and
|
||||
/// config.
|
||||
static cmFastbuildTargetGenerator* New(cmGeneratorTarget* target,
|
||||
std::string config);
|
||||
|
||||
cmFastbuildTargetGenerator(cmGeneratorTarget* target, std::string config);
|
||||
|
||||
virtual void Generate() {}
|
||||
|
||||
std::string GetClangTidyReplacementsFilePath(
|
||||
std::string const& directory, cmSourceFile const& source,
|
||||
std::string const& Config) const override;
|
||||
|
||||
void AddIncludeFlags(std::string& languageFlags, std::string const& language,
|
||||
std::string const&) override;
|
||||
|
||||
cmGeneratorTarget::Names DetectOutput() const;
|
||||
|
||||
void AddObjectDependencies(FastbuildTarget& fastbuildTarget,
|
||||
std::vector<std::string>& allObjectDepends) const;
|
||||
void AddLinkerNodeDependnecies(FastbuildTarget& fastbuildTarget);
|
||||
|
||||
std::string ConvertToFastbuildPath(std::string const& path) const;
|
||||
|
||||
cmGlobalFastbuildGenerator* GetGlobalGenerator() const;
|
||||
|
||||
std::string GetName();
|
||||
|
||||
cmMakefile* GetMakefile() const { return this->Makefile; }
|
||||
|
||||
cmGeneratorTarget* GetGeneratorTarget() const
|
||||
{
|
||||
return this->GeneratorTarget;
|
||||
}
|
||||
|
||||
void LogMessage(std::string const& m) const;
|
||||
|
||||
private:
|
||||
std::string GetUtilityAliasFromBuildStep(FastbuildBuildStep step) const;
|
||||
|
||||
protected:
|
||||
cmLocalFastbuildGenerator* GetLocalGenerator() const
|
||||
{
|
||||
return this->LocalGenerator;
|
||||
}
|
||||
|
||||
std::string GetTargetName() const;
|
||||
std::string GetCdCommand(cmCustomCommandGenerator const& ccg) const;
|
||||
std::string GetScriptWorkingDir(cmCustomCommandGenerator const& ccg) const;
|
||||
std::string GetScriptFilename(std::string const& utilityTargetName) const;
|
||||
std::vector<std::string> GetDepends(
|
||||
cmCustomCommandGenerator const& ccg) const;
|
||||
|
||||
void AddCommentPrinting(std::vector<std::string>& cmdLines,
|
||||
cmCustomCommandGenerator const& ccg) const;
|
||||
|
||||
void WriteCmdsToFile(cmsys::ofstream& file,
|
||||
std::vector<std::string> const& cmds) const;
|
||||
|
||||
void AddOutput(cmCustomCommandGenerator const& ccg, FastbuildExecNode& exec);
|
||||
|
||||
void AddExecArguments(FastbuildExecNode& exec,
|
||||
std::string const& scriptFilename) const;
|
||||
|
||||
void ReplaceProblematicMakeVars(std::string& command) const;
|
||||
|
||||
FastbuildExecNodes GenerateCommands(FastbuildBuildStep buildStep);
|
||||
FastbuildExecNode GetAppleTextStubCommand() const;
|
||||
FastbuildExecNode GetDepsCheckExec(FastbuildExecNode const& depender);
|
||||
|
||||
std::string MakeCustomLauncher(cmCustomCommandGenerator const& ccg);
|
||||
|
||||
std::string GetCustomCommandTargetName(cmCustomCommand const& cc,
|
||||
FastbuildBuildStep step) const;
|
||||
|
||||
std::vector<std::string> GetInputFiles(cmCustomCommandGenerator const& ccg,
|
||||
FastbuildBuildStep step) const;
|
||||
|
||||
void WriteScriptProlog(cmsys::ofstream& file) const;
|
||||
void WriteScriptEpilog(cmsys::ofstream& file) const;
|
||||
|
||||
void AdditionalCleanFiles();
|
||||
|
||||
// write rules for Mac OS X Application Bundle content.
|
||||
struct MacOSXContentGeneratorType
|
||||
: cmOSXBundleGenerator::MacOSXContentGeneratorType
|
||||
{
|
||||
MacOSXContentGeneratorType(cmFastbuildTargetGenerator* g, std::string cfg)
|
||||
: Generator(g)
|
||||
, Config(std::move(cfg))
|
||||
{
|
||||
}
|
||||
|
||||
void operator()(cmSourceFile const& source, char const* pkgloc,
|
||||
std::string const& config) override;
|
||||
|
||||
private:
|
||||
cmFastbuildTargetGenerator* Generator;
|
||||
std::string const Config;
|
||||
};
|
||||
friend struct MacOSXContentGeneratorType;
|
||||
|
||||
// "MacOSXContentGenerator" has to be per-config once multiconfig generator
|
||||
// is implemented.
|
||||
std::unique_ptr<MacOSXContentGeneratorType> MacOSXContentGenerator;
|
||||
std::unique_ptr<cmOSXBundleGenerator> OSXBundleGenerator;
|
||||
std::set<std::string> MacContentFolders;
|
||||
|
||||
std::vector<FastbuildCopyNode> CopyNodes;
|
||||
|
||||
cmLocalFastbuildGenerator* LocalGenerator;
|
||||
cmGlobalGenerator::TargetDependSet const TargetDirectDependencies;
|
||||
std::string const Config;
|
||||
|
||||
// Sometimes CMake adds equivalent custom commands to different targets.
|
||||
// Not really supported by FBuild (can't have different exec nodes producing
|
||||
// same output). So, in such cases we need to "re-map" the exec to produce a
|
||||
// "dummy" output (and update all deps within the target).
|
||||
// TODO: potentially 1 map should be enough?
|
||||
std::unordered_map<std::string, std::string> OutputsToReplace;
|
||||
std::unordered_map<std::string, std::string> OutputToExecName;
|
||||
};
|
||||
@@ -0,0 +1,126 @@
|
||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file LICENSE.rst or https://cmake.org/licensing for details. */
|
||||
|
||||
#include "cmFastbuildUtilityTargetGenerator.h"
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "cmFastbuildTargetGenerator.h"
|
||||
#include "cmGeneratorTarget.h"
|
||||
#include "cmGlobalFastbuildGenerator.h"
|
||||
#include "cmListFileCache.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmTarget.h"
|
||||
#include "cmTargetDepend.h"
|
||||
|
||||
cmFastbuildUtilityTargetGenerator::cmFastbuildUtilityTargetGenerator(
|
||||
cmGeneratorTarget* gt, std::string configParam)
|
||||
: cmFastbuildTargetGenerator(gt, std::move(configParam))
|
||||
{
|
||||
}
|
||||
|
||||
void cmFastbuildUtilityTargetGenerator::Generate()
|
||||
{
|
||||
std::string targetName = GeneratorTarget->GetName();
|
||||
|
||||
if (this->GeneratorTarget->GetType() == cmStateEnums::GLOBAL_TARGET) {
|
||||
targetName = GetGlobalGenerator()->GetTargetName(GeneratorTarget);
|
||||
}
|
||||
|
||||
FastbuildAliasNode fastbuildTarget;
|
||||
fastbuildTarget.Name = targetName;
|
||||
|
||||
LogMessage("<-------------->");
|
||||
LogMessage("Generate Utility target: " + targetName);
|
||||
LogMessage("Config: " + Config);
|
||||
for (auto const& dep : TargetDirectDependencies) {
|
||||
LogMessage("Dep: " + dep->GetName());
|
||||
}
|
||||
|
||||
std::vector<std::string> nonImportedUtils;
|
||||
for (BT<std::pair<std::string, bool>> const& util :
|
||||
this->GeneratorTarget->GetUtilities()) {
|
||||
if (util.Value.first == targetName) {
|
||||
continue;
|
||||
}
|
||||
auto const& utilTargetName =
|
||||
this->ConvertToFastbuildPath(util.Value.first);
|
||||
LogMessage("Util: " + utilTargetName);
|
||||
auto* const target = this->Makefile->FindTargetToUse(utilTargetName);
|
||||
if (target && target->IsImported()) {
|
||||
LogMessage("Skipping imported util target: " + utilTargetName);
|
||||
continue;
|
||||
}
|
||||
// Since interface target don't appear in the generated build files,
|
||||
// transitively propagate their deps (if any).
|
||||
// Tested in "ExternalProjectSubdir" test.
|
||||
if (target && target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
|
||||
for (auto const& dep : target->GetUtilities()) {
|
||||
auto const& depName = this->ConvertToFastbuildPath(dep.Value.first);
|
||||
LogMessage("Transitively propagating iface dep: " + depName +
|
||||
", is cross: " + std::to_string(dep.Value.second));
|
||||
nonImportedUtils.emplace_back(depName);
|
||||
fastbuildTarget.PreBuildDependencies.emplace(
|
||||
this->ConvertToFastbuildPath(depName));
|
||||
}
|
||||
} else {
|
||||
nonImportedUtils.emplace_back(utilTargetName);
|
||||
fastbuildTarget.PreBuildDependencies.emplace(utilTargetName);
|
||||
}
|
||||
}
|
||||
if (this->GetGlobalGenerator()->IsExcluded(this->GetGeneratorTarget())) {
|
||||
LogMessage("Excluding " + targetName + " from ALL");
|
||||
fastbuildTarget.ExcludeFromAll = true;
|
||||
}
|
||||
auto preBuild = GenerateCommands(FastbuildBuildStep::PRE_BUILD);
|
||||
|
||||
// Tested in "RunCMake.CPack*" tests.
|
||||
// Utility target "package" has packaging steps as "POST_BUILD".
|
||||
for (auto& exec : GenerateCommands(FastbuildBuildStep::POST_BUILD).Nodes) {
|
||||
fastbuildTarget.PreBuildDependencies.emplace(exec.Name);
|
||||
for (std::string const& util : nonImportedUtils) {
|
||||
LogMessage("Adding: util " + util);
|
||||
exec.PreBuildDependencies.emplace(util);
|
||||
}
|
||||
// So POST_BUILD is executed AFTER PRE_BUILD (tested in "CustomCommand"
|
||||
// test).
|
||||
for (auto const& pre : preBuild.Nodes) {
|
||||
LogMessage("Adding: " + pre.Name);
|
||||
exec.PreBuildDependencies.emplace(pre.Name);
|
||||
}
|
||||
this->GetGlobalGenerator()->AddTarget(std::move(exec));
|
||||
}
|
||||
|
||||
for (auto& exec : preBuild.Nodes) {
|
||||
LogMessage("Adding exec " + exec.Name);
|
||||
fastbuildTarget.PreBuildDependencies.emplace(exec.Name);
|
||||
this->GetGlobalGenerator()->AddTarget(std::move(exec));
|
||||
}
|
||||
|
||||
for (auto& exec : GenerateCommands(FastbuildBuildStep::REST).Nodes) {
|
||||
fastbuildTarget.PreBuildDependencies.emplace(exec.Name);
|
||||
for (auto const& dep : TargetDirectDependencies) {
|
||||
LogMessage("Direct dep " + dep->GetName() +
|
||||
"-all propagating to CC: " + exec.Name);
|
||||
// All custom commands from within the target must be executed AFTER all
|
||||
// the target's deps.
|
||||
FastbuildTargetDep execDep{ dep->GetName() };
|
||||
execDep.Type = FastbuildTargetDepType::ALL;
|
||||
exec.PreBuildDependencies.emplace(std::move(execDep));
|
||||
}
|
||||
this->GetGlobalGenerator()->AddTarget(std::move(exec));
|
||||
}
|
||||
if (fastbuildTarget.PreBuildDependencies.empty()) {
|
||||
if (fastbuildTarget.ExcludeFromAll) {
|
||||
return;
|
||||
}
|
||||
fastbuildTarget.PreBuildDependencies.emplace(FASTBUILD_NOOP_FILE_NAME);
|
||||
}
|
||||
fastbuildTarget.Hidden = false;
|
||||
this->AdditionalCleanFiles();
|
||||
this->GetGlobalGenerator()->AddTarget(std::move(fastbuildTarget));
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file LICENSE.rst or https://cmake.org/licensing for details. */
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <cmFastbuildTargetGenerator.h>
|
||||
|
||||
class cmGeneratorTarget;
|
||||
|
||||
class cmFastbuildUtilityTargetGenerator : public cmFastbuildTargetGenerator
|
||||
{
|
||||
public:
|
||||
cmFastbuildUtilityTargetGenerator(cmGeneratorTarget* gt,
|
||||
std::string configParam);
|
||||
|
||||
void Generate() override;
|
||||
};
|
||||
@@ -2413,6 +2413,7 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode
|
||||
genName.find("Visual Studio") == std::string::npos &&
|
||||
genName.find("Xcode") == std::string::npos &&
|
||||
genName.find("Watcom WMake") == std::string::npos &&
|
||||
genName.find("FASTBuild") == std::string::npos &&
|
||||
genName.find("Green Hills MULTI") == std::string::npos) {
|
||||
reportError(context, content->GetOriginalExpression(),
|
||||
"$<COMPILE_LANGUAGE:...> not supported for this generator.");
|
||||
@@ -2460,6 +2461,7 @@ static const struct CompileLanguageAndIdNode : public cmGeneratorExpressionNode
|
||||
std::string genName = gg->GetName();
|
||||
if (genName.find("Makefiles") == std::string::npos &&
|
||||
genName.find("Ninja") == std::string::npos &&
|
||||
genName.find("FASTBuild") == std::string::npos &&
|
||||
genName.find("Visual Studio") == std::string::npos &&
|
||||
genName.find("Xcode") == std::string::npos &&
|
||||
genName.find("Watcom WMake") == std::string::npos &&
|
||||
@@ -2514,6 +2516,7 @@ static const struct LinkLanguageNode : public cmGeneratorExpressionNode
|
||||
std::string genName = gg->GetName();
|
||||
if (genName.find("Makefiles") == std::string::npos &&
|
||||
genName.find("Ninja") == std::string::npos &&
|
||||
genName.find("FASTBuild") == std::string::npos &&
|
||||
genName.find("Visual Studio") == std::string::npos &&
|
||||
genName.find("Xcode") == std::string::npos &&
|
||||
genName.find("Watcom WMake") == std::string::npos &&
|
||||
@@ -2605,6 +2608,7 @@ static const struct LinkLanguageAndIdNode : public cmGeneratorExpressionNode
|
||||
std::string genName = gg->GetName();
|
||||
if (genName.find("Makefiles") == std::string::npos &&
|
||||
genName.find("Ninja") == std::string::npos &&
|
||||
genName.find("FASTBuild") == std::string::npos &&
|
||||
genName.find("Visual Studio") == std::string::npos &&
|
||||
genName.find("Xcode") == std::string::npos &&
|
||||
genName.find("Watcom WMake") == std::string::npos &&
|
||||
|
||||
@@ -3233,8 +3233,17 @@ std::string cmGeneratorTarget::GetPchCreateCompileOptions(
|
||||
std::string const pchHeader = this->GetPchHeader(config, language, arch);
|
||||
std::string const pchFile = this->GetPchFile(config, language, arch);
|
||||
|
||||
cmSystemTools::ReplaceString(createOptionList, "<PCH_HEADER>", pchHeader);
|
||||
cmSystemTools::ReplaceString(createOptionList, "<PCH_FILE>", pchFile);
|
||||
if (GlobalGenerator->IsFastbuild()) {
|
||||
// Account for potential spaces in a shell-friendly way.
|
||||
cmSystemTools::ReplaceString(createOptionList, "<PCH_HEADER>",
|
||||
'"' + pchHeader + '"');
|
||||
cmSystemTools::ReplaceString(createOptionList, "<PCH_FILE>",
|
||||
'"' + pchFile + '"');
|
||||
} else {
|
||||
cmSystemTools::ReplaceString(createOptionList, "<PCH_HEADER>",
|
||||
pchHeader);
|
||||
cmSystemTools::ReplaceString(createOptionList, "<PCH_FILE>", pchFile);
|
||||
}
|
||||
}
|
||||
return inserted.first->second;
|
||||
}
|
||||
@@ -3268,8 +3277,16 @@ std::string cmGeneratorTarget::GetPchUseCompileOptions(
|
||||
std::string const pchHeader = this->GetPchHeader(config, language, arch);
|
||||
std::string const pchFile = this->GetPchFile(config, language, arch);
|
||||
|
||||
cmSystemTools::ReplaceString(useOptionList, "<PCH_HEADER>", pchHeader);
|
||||
cmSystemTools::ReplaceString(useOptionList, "<PCH_FILE>", pchFile);
|
||||
if (GlobalGenerator->IsFastbuild()) {
|
||||
// Account for potential spaces in a shell-friendly way.
|
||||
cmSystemTools::ReplaceString(useOptionList, "<PCH_HEADER>",
|
||||
'"' + pchHeader + '"');
|
||||
cmSystemTools::ReplaceString(useOptionList, "<PCH_FILE>",
|
||||
'"' + pchFile + '"');
|
||||
} else {
|
||||
cmSystemTools::ReplaceString(useOptionList, "<PCH_HEADER>", pchHeader);
|
||||
cmSystemTools::ReplaceString(useOptionList, "<PCH_FILE>", pchFile);
|
||||
}
|
||||
}
|
||||
return inserted.first->second;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,602 @@
|
||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file LICENSE.rst or https://cmake.org/licensing for details. */
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <cm/memory>
|
||||
#include <cm/optional>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "cmBuildOptions.h"
|
||||
#include "cmGeneratedFileStream.h"
|
||||
#include "cmGlobalCommonGenerator.h"
|
||||
class cmFastbuildTargetGenerator;
|
||||
class cmGeneratorTarget;
|
||||
class cmGlobalGeneratorFactory;
|
||||
class cmLinkLineComputer;
|
||||
class cmLocalGenerator;
|
||||
class cmMakefile;
|
||||
class cmOutputConverter;
|
||||
class cmStateDirectory;
|
||||
class cmake;
|
||||
enum class cmDepfileFormat;
|
||||
struct cmDocumentationEntry;
|
||||
|
||||
#define FASTBUILD_DOLLAR_TAG "FASTBUILD_DOLLAR_TAG"
|
||||
#define FASTBUILD_1_INPUT_PLACEHOLDER \
|
||||
FASTBUILD_DOLLAR_TAG "FB_INPUT_1_PLACEHOLDER" FASTBUILD_DOLLAR_TAG
|
||||
#define FASTBUILD_1_0_INPUT_PLACEHOLDER \
|
||||
FASTBUILD_DOLLAR_TAG "FB_INPUT_1_0_PLACEHOLDER" FASTBUILD_DOLLAR_TAG
|
||||
#define FASTBUILD_1_1_INPUT_PLACEHOLDER \
|
||||
FASTBUILD_DOLLAR_TAG "FB_INPUT_1_1_PLACEHOLDER" FASTBUILD_DOLLAR_TAG
|
||||
|
||||
#define FASTBUILD_2_INPUT_PLACEHOLDER \
|
||||
FASTBUILD_DOLLAR_TAG "FB_INPUT_2_PLACEHOLDER" FASTBUILD_DOLLAR_TAG
|
||||
|
||||
#define FASTBUILD_3_INPUT_PLACEHOLDER \
|
||||
FASTBUILD_DOLLAR_TAG "FB_INPUT_3_PLACEHOLDER" FASTBUILD_DOLLAR_TAG
|
||||
|
||||
// Alias to artifacts that can be consumed by the linker (DLL or Library).
|
||||
#define FASTBUILD_LINK_ARTIFACTS_ALIAS_POSTFIX "-link-artifacts"
|
||||
// Alias to all the ObjectList nodes.
|
||||
#define FASTBUILD_OBJECTS_ALIAS_POSTFIX "-objects"
|
||||
// Alias to all the dependencies of the target.
|
||||
#define FASTBUILD_DEPS_ARTIFACTS_ALIAS_POSTFIX "-deps"
|
||||
// Alias to build the target.
|
||||
#define FASTBUILD_BUILD_ALIAS_POSTFIX "-build"
|
||||
#define FASTBUILD_PRE_BUILD_ALIAS_POSTFIX "-pre-build"
|
||||
#define FASTBUILD_PRE_LINK_ALIAS_POSTFIX "-pre-link"
|
||||
#define FASTBUILD_POST_BUILD_ALIAS_POSTFIX "-post-build"
|
||||
// Alias to all other custom commands in the target.
|
||||
#define FASTBUILD_CUSTOM_COMMAND_ALIAS_POSTFIX "-custom-commands"
|
||||
// Alias to outputs produced by a custom command (since FASTBuild exec node
|
||||
// does not support more than 1 output).
|
||||
#define FASTBUILD_OUTPUTS_ALIAS_POSTFIX "-outputs"
|
||||
// Alias to byproducts produced by a custom command (since FASTBuild exec node
|
||||
// does not support more than 1 output).
|
||||
#define FASTBUILD_BYPRODUCTS_ALIAS_POSTFIX "-byproducts"
|
||||
// Alias to build & run all the custom commands.
|
||||
#define FASTBUILD_ALL_ALIAS_POSTFIX "-all"
|
||||
|
||||
#define FASTBUILD_COMPILER_PREFIX "Compiler_"
|
||||
#define FASTBUILD_LAUNCHER_PREFIX "Launcher_"
|
||||
#define FASTBUILD_LINKER_LAUNCHER_PREFIX "LinkerLauncher_"
|
||||
|
||||
#define FASTBUILD_RESTAT_FILE "FASTBUILD_RESTAT"
|
||||
|
||||
#define FASTBUILD_UTIL_CONCURRENCY_GROUP_NAME "Utils"
|
||||
|
||||
#define FASTBUILD_ALL_TARGET_NAME "all"
|
||||
#define FASTBUILD_CLEAN_TARGET_NAME "clean"
|
||||
|
||||
#define FASTBUILD_NOOP_FILE_NAME "fbuild_noop"
|
||||
|
||||
#define FASTBUILD_BUILD_FILE "fbuild.bff"
|
||||
|
||||
#define FASTBUILD_DUMMY_OUTPUT_EXTENSION ".fbuild-cc-out"
|
||||
|
||||
#if defined(_WIN32)
|
||||
# define FASTBUILD_SCRIPT_FILE_EXTENSION ".bat"
|
||||
# define FASTBUILD_SCRIPT_FILE_ARG "/C "
|
||||
# define FASTBUILD_SCRIPT_CD "cd /D "
|
||||
#else
|
||||
# define FASTBUILD_SCRIPT_FILE_EXTENSION ".sh"
|
||||
# define FASTBUILD_SCRIPT_FILE_ARG ""
|
||||
# define FASTBUILD_SCRIPT_CD "cd "
|
||||
#endif
|
||||
|
||||
enum class FastbuildTargetDepType
|
||||
{
|
||||
ALL,
|
||||
BUILD,
|
||||
ORDER_ONLY,
|
||||
NONE,
|
||||
};
|
||||
struct FastbuildTargetDep
|
||||
{
|
||||
std::string Name;
|
||||
FastbuildTargetDepType Type = FastbuildTargetDepType::NONE;
|
||||
FastbuildTargetDep(std::string n)
|
||||
: Name(std::move(n))
|
||||
{
|
||||
}
|
||||
bool operator==(FastbuildTargetDep const& rhs) const
|
||||
{
|
||||
return this->Name == rhs.Name;
|
||||
}
|
||||
bool operator<(FastbuildTargetDep const& rhs) const
|
||||
{
|
||||
return this->Name < rhs.Name;
|
||||
}
|
||||
};
|
||||
|
||||
enum class FastbuildTargetType
|
||||
{
|
||||
ALIAS, // Alias node
|
||||
EXEC, // Exec node
|
||||
LINK, // Library, DLL or Executable
|
||||
OBJECTLIST,
|
||||
};
|
||||
|
||||
struct FastbuildTargetBase
|
||||
{
|
||||
// Target name with config postfix.
|
||||
std::string Name;
|
||||
// Target name without config postfix, we use it to locate IDE project for
|
||||
// the given target and add +1 config to it.
|
||||
std::string BaseName;
|
||||
std::string BasePath;
|
||||
std::set<FastbuildTargetDep> PreBuildDependencies;
|
||||
bool Hidden = true;
|
||||
FastbuildTargetType Type;
|
||||
explicit FastbuildTargetBase(FastbuildTargetType TargetType)
|
||||
: Type(TargetType)
|
||||
{
|
||||
}
|
||||
};
|
||||
using FastbuildTargetPtrT = std::unique_ptr<FastbuildTargetBase>;
|
||||
|
||||
struct FastbuildAliasNode : public FastbuildTargetBase
|
||||
{
|
||||
bool ExcludeFromAll = false;
|
||||
FastbuildAliasNode()
|
||||
: FastbuildTargetBase(FastbuildTargetType::ALIAS)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct FastbuildExecNode : public FastbuildTargetBase
|
||||
{
|
||||
std::string ExecExecutable;
|
||||
std::string ExecArguments;
|
||||
std::string ScriptFile;
|
||||
std::string ExecWorkingDir;
|
||||
bool ExecUseStdOutAsOutput = false;
|
||||
std::string ExecOutput;
|
||||
std::vector<std::string> ExecInput;
|
||||
std::vector<std::string> ExecInputPath;
|
||||
std::vector<std::string> ExecInputPattern;
|
||||
bool ExecInputPathRecurse = false;
|
||||
bool ExecAlways = false;
|
||||
FastbuildAliasNode OutputsAlias;
|
||||
FastbuildAliasNode ByproductsAlias;
|
||||
std::string ConcurrencyGroupName;
|
||||
bool ExcludeFromAll = false;
|
||||
FastbuildExecNode()
|
||||
: FastbuildTargetBase(FastbuildTargetType::EXEC)
|
||||
{
|
||||
}
|
||||
|
||||
bool NeedsDepsCheckExec = false;
|
||||
};
|
||||
|
||||
struct FastbuildCompiler
|
||||
{
|
||||
std::map<std::string, std::string> ExtraVariables;
|
||||
std::string Name;
|
||||
std::string Executable;
|
||||
std::string CmakeCompilerID;
|
||||
std::string CmakeCompilerVersion;
|
||||
std::string Language;
|
||||
std::vector<std::string> ExtraFiles;
|
||||
bool UseLightCache = false;
|
||||
// Only used for launchers.
|
||||
std::string Args;
|
||||
bool DontUseEnv = false;
|
||||
};
|
||||
|
||||
struct FastbuildObjectListNode : public FastbuildTargetBase
|
||||
{
|
||||
std::string Compiler;
|
||||
std::string CompilerOptions;
|
||||
std::string CompilerOutputPath;
|
||||
std::string CompilerOutputExtension;
|
||||
std::string PCHInputFile;
|
||||
std::string PCHOutputFile;
|
||||
std::string PCHOptions;
|
||||
|
||||
std::vector<std::string> CompilerInputFiles;
|
||||
|
||||
std::set<std::string> ObjectOutputs;
|
||||
std::set<std::string> ObjectDepends;
|
||||
|
||||
// Apple only.
|
||||
std::string arch;
|
||||
FastbuildObjectListNode()
|
||||
: FastbuildTargetBase(FastbuildTargetType::OBJECTLIST)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct IDEProjectConfig
|
||||
{
|
||||
std::string Config;
|
||||
std::string Target;
|
||||
// VS only.
|
||||
std::string Platform;
|
||||
|
||||
std::string XCodeBaseSDK;
|
||||
std::string XCodeDebugWorkingDir;
|
||||
std::string XCodeIphoneOSDeploymentTarget;
|
||||
};
|
||||
|
||||
struct IDEProjectCommon
|
||||
{
|
||||
std::string Alias;
|
||||
std::string ProjectOutput;
|
||||
std::string ProjectBasePath;
|
||||
|
||||
std::vector<IDEProjectConfig> ProjectConfigs;
|
||||
};
|
||||
|
||||
struct XCodeProject : public IDEProjectCommon
|
||||
{
|
||||
};
|
||||
|
||||
struct VCXProject : public IDEProjectCommon
|
||||
{
|
||||
};
|
||||
|
||||
struct FastbuildLinkerNode
|
||||
{
|
||||
enum
|
||||
{
|
||||
EXECUTABLE,
|
||||
SHARED_LIBRARY,
|
||||
STATIC_LIBRARY,
|
||||
NONE
|
||||
} Type = NONE;
|
||||
|
||||
std::string Name;
|
||||
std::string Compiler;
|
||||
std::string CompilerOptions;
|
||||
std::string Linker;
|
||||
std::string LinkerType;
|
||||
std::string LinkerOutput;
|
||||
std::string LinkerOptions;
|
||||
std::vector<std::string> LibrarianAdditionalInputs;
|
||||
// We only use Libraries2 for tracking dependencies.
|
||||
std::vector<std::string> Libraries2;
|
||||
std::set<std::string> PreBuildDependencies;
|
||||
bool LinkerLinkObjects = false;
|
||||
std::string LinkerStampExe;
|
||||
std::string LinkerStampExeArgs;
|
||||
// Apple only.
|
||||
std::string Arch;
|
||||
};
|
||||
|
||||
struct FastbuildCopyNode
|
||||
{
|
||||
std::string Name;
|
||||
std::string Source;
|
||||
std::string Dest;
|
||||
std::string PreBuildDependencies;
|
||||
bool CopyDir = false;
|
||||
};
|
||||
|
||||
struct FastbuildExecNodes
|
||||
{
|
||||
std::vector<FastbuildExecNode> Nodes;
|
||||
FastbuildAliasNode Alias;
|
||||
};
|
||||
|
||||
struct FastbuildTarget : public FastbuildTargetBase
|
||||
{
|
||||
std::map<std::string, std::string> Variables;
|
||||
std::vector<FastbuildObjectListNode> ObjectListNodes;
|
||||
// Potentially multiple libs for different archs (apple only);
|
||||
std::vector<FastbuildLinkerNode> LinkerNode;
|
||||
std::string RealOutput;
|
||||
FastbuildAliasNode PreBuildExecNodes, ExecNodes;
|
||||
std::vector<FastbuildAliasNode> AliasNodes;
|
||||
// This alias must be written before all other nodes, since they might need
|
||||
// to refer to it.
|
||||
FastbuildAliasNode DependenciesAlias;
|
||||
std::vector<FastbuildCopyNode> CopyNodes;
|
||||
FastbuildExecNodes PreLinkExecNodes;
|
||||
FastbuildExecNodes PostBuildExecNodes;
|
||||
// Must be written after the build, but before custom commands, since post
|
||||
// build commands need to depend on it.
|
||||
FastbuildAliasNode BuildAlias;
|
||||
bool IsGlobal = false;
|
||||
bool ExcludeFromAll = false;
|
||||
bool AllowDistribution = true;
|
||||
FastbuildTarget()
|
||||
: FastbuildTargetBase(FastbuildTargetType::LINK)
|
||||
{
|
||||
}
|
||||
|
||||
void GenerateAliases();
|
||||
};
|
||||
|
||||
class cmGlobalFastbuildGenerator : public cmGlobalCommonGenerator
|
||||
{
|
||||
public:
|
||||
cmGlobalFastbuildGenerator(cmake* cm);
|
||||
|
||||
void ProcessEnvironment();
|
||||
|
||||
static std::unique_ptr<cmGlobalGeneratorFactory> NewFactory();
|
||||
void Generate() override;
|
||||
|
||||
bool FindMakeProgram(cmMakefile* mf) override;
|
||||
|
||||
void EnableLanguage(std::vector<std::string> const& lang, cmMakefile* mf,
|
||||
bool optional) override;
|
||||
|
||||
bool IsFastbuild() const override { return true; }
|
||||
|
||||
std::vector<GeneratedMakeCommand> GenerateBuildCommand(
|
||||
std::string const& makeProgram, std::string const& projectName,
|
||||
std::string const& projectDir, std::vector<std::string> const& targetNames,
|
||||
std::string const& config, int jobs, bool verbose,
|
||||
cmBuildOptions buildOptions = cmBuildOptions(),
|
||||
std::vector<std::string> const& makeOptions =
|
||||
std::vector<std::string>()) override;
|
||||
|
||||
std::unique_ptr<cmLocalGenerator> CreateLocalGenerator(
|
||||
cmMakefile* makefile) override;
|
||||
std::string GetName() const override
|
||||
{
|
||||
return cmGlobalFastbuildGenerator::GetActualName();
|
||||
}
|
||||
|
||||
bool IsMultiConfig() const override { return false; }
|
||||
|
||||
void ComputeTargetObjectDirectory(cmGeneratorTarget*) const override;
|
||||
void AppendDirectoryForConfig(std::string const& prefix,
|
||||
std::string const& config,
|
||||
std::string const& suffix,
|
||||
std::string& dir) override;
|
||||
|
||||
static std::string GetActualName() { return "FASTBuild"; }
|
||||
static std::string RequiredFastbuildVersion() { return "1.14"; }
|
||||
|
||||
// Setup target names
|
||||
char const* GetAllTargetName() const override
|
||||
{
|
||||
return FASTBUILD_ALL_TARGET_NAME;
|
||||
}
|
||||
char const* GetInstallTargetName() const override { return "install"; }
|
||||
char const* GetCleanTargetName() const override
|
||||
{
|
||||
return FASTBUILD_CLEAN_TARGET_NAME;
|
||||
}
|
||||
char const* GetInstallLocalTargetName() const override
|
||||
{
|
||||
return "install/local";
|
||||
}
|
||||
char const* GetInstallStripTargetName() const override
|
||||
{
|
||||
return "install/strip";
|
||||
}
|
||||
char const* GetInstallParallelTargetName() const
|
||||
{
|
||||
return "install/parallel";
|
||||
}
|
||||
char const* GetTestTargetName() const override { return "test"; }
|
||||
char const* GetPackageTargetName() const override { return "package"; }
|
||||
char const* GetPackageSourceTargetName() const override
|
||||
{
|
||||
return "package_source";
|
||||
}
|
||||
char const* GetRebuildCacheTargetName() const override
|
||||
{
|
||||
return "rebuild_cache";
|
||||
}
|
||||
char const* GetCMakeCFGIntDir() const override { return "."; }
|
||||
|
||||
/// Overloaded methods. @see cmGlobalGenerator::GetDocumentation()
|
||||
static cmDocumentationEntry GetDocumentation();
|
||||
|
||||
static bool SupportsToolset() { return false; }
|
||||
|
||||
static bool SupportsPlatform() { return false; }
|
||||
|
||||
bool IsIPOSupported() const override { return true; }
|
||||
|
||||
void OpenBuildFileStream();
|
||||
void CloseBuildFileStream();
|
||||
|
||||
std::vector<std::string> const& GetConfigNames() const;
|
||||
|
||||
bool Open(std::string const& bindir, std::string const& projectName,
|
||||
bool dryRun) override;
|
||||
|
||||
std::string ConvertToFastbuildPath(std::string const& path) const;
|
||||
std::unique_ptr<cmLinkLineComputer> CreateLinkLineComputer(
|
||||
cmOutputConverter* outputConverter,
|
||||
cmStateDirectory const& /* stateDir */) const override;
|
||||
|
||||
bool SupportsCustomCommandDepfile() const override { return true; }
|
||||
cm::optional<cmDepfileFormat> DepfileFormat() const override
|
||||
{
|
||||
return cm::nullopt;
|
||||
}
|
||||
|
||||
static std::string Quote(std::string const& str,
|
||||
std::string const& quotation = "'");
|
||||
static std::string QuoteIfHasSpaces(std::string str);
|
||||
|
||||
template <class T>
|
||||
static std::vector<std::string> Wrap(T const& in,
|
||||
std::string const& prefix = "'",
|
||||
std::string const& suffix = "'",
|
||||
bool escape_dollar = true);
|
||||
|
||||
void WriteDivider();
|
||||
void WriteComment(std::string const& comment, int indent = 0);
|
||||
|
||||
/// Write @a count times INDENT level to output stream @a os.
|
||||
void Indent(int count);
|
||||
|
||||
void WriteVariable(std::string const& key, std::string const& value,
|
||||
std::string const& op, int indent = 0);
|
||||
void WriteVariable(std::string const& key, std::string const& value,
|
||||
int indent = 0);
|
||||
void WriteCommand(std::string const& command,
|
||||
std::string const& value = std::string(), int indent = 0);
|
||||
void WriteArray(std::string const& key,
|
||||
std::vector<std::string> const& values, int indent = 0);
|
||||
void WriteStruct(
|
||||
std::string const& name,
|
||||
std::vector<std::pair<std::string, std::string>> const& variables,
|
||||
int indent = 0);
|
||||
void WriteArray(std::string const& key,
|
||||
std::vector<std::string> const& values,
|
||||
std::string const& op, int indent = 0);
|
||||
|
||||
template <typename T>
|
||||
std::vector<std::string> ConvertToFastbuildPath(T const& container) const
|
||||
{
|
||||
std::vector<std::string> ret;
|
||||
ret.reserve(container.size());
|
||||
for (auto const& path : container) {
|
||||
ret.push_back(ConvertToFastbuildPath(path));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Wrapper to sort array of conforming structs (which have .Name
|
||||
// and .PreBuildDependencies fields).
|
||||
template <class T>
|
||||
static void TopologicalSort(std::vector<T>& nodes)
|
||||
{
|
||||
static_assert(std::is_base_of<FastbuildTargetBase, T>::value,
|
||||
"T must be derived from FastbuildTargetBase");
|
||||
std::vector<FastbuildTargetPtrT> tmp;
|
||||
tmp.reserve(nodes.size());
|
||||
for (auto& node : nodes) {
|
||||
tmp.emplace_back(cm::make_unique<T>(std::move(node)));
|
||||
}
|
||||
nodes.clear();
|
||||
TopologicalSort(tmp);
|
||||
for (auto& node : tmp) {
|
||||
nodes.emplace_back(std::move(static_cast<T&>(*node)));
|
||||
}
|
||||
}
|
||||
// Stable topological sort.
|
||||
static void TopologicalSort(std::vector<FastbuildTargetPtrT>& nodes);
|
||||
|
||||
void WriteDisclaimer();
|
||||
void WriteEnvironment();
|
||||
void WriteSettings();
|
||||
void WriteCompilers();
|
||||
void WriteTargets();
|
||||
|
||||
void WriteTarget(FastbuildTarget const& target);
|
||||
void WriteExec(FastbuildExecNode const& Exec, int indent = 1);
|
||||
void WriteObjectList(FastbuildObjectListNode const& ObjectList,
|
||||
bool allowDistribution);
|
||||
void WriteLinker(FastbuildLinkerNode const&, bool);
|
||||
void WriteAlias(FastbuildAliasNode const& Alias, int indent = 1);
|
||||
void WriteCopy(FastbuildCopyNode const& Copy);
|
||||
|
||||
void WriteIDEProjects();
|
||||
void WriteVSBuildCommands();
|
||||
void WriteXCodeBuildCommands();
|
||||
void WriteIDEProjectCommon(IDEProjectCommon const& project);
|
||||
void WriteIDEProjectConfig(std::vector<IDEProjectConfig> const& configs,
|
||||
std::string const& keyName = "ProjectConfigs");
|
||||
|
||||
void WriteSolution();
|
||||
void WriteXCodeTopLevelProject();
|
||||
void WriteTargetRebuildBFF();
|
||||
void WriteTargetClean();
|
||||
|
||||
void AddTargetAll();
|
||||
void AddGlobCheckExec();
|
||||
|
||||
void AddCompiler(std::string const& lang, cmMakefile* mf);
|
||||
void AddLauncher(std::string const& prefix, std::string const& launcher,
|
||||
std::string const& lang, std::string const& args);
|
||||
void AddIDEProject(FastbuildTarget const& target, std::string const& config);
|
||||
|
||||
template <class T>
|
||||
void AddTarget(T target)
|
||||
{
|
||||
// Sometimes equivalent CCs are added to different targets. We try to
|
||||
// de-dup it by assigning all execs a name which is a hash computed based
|
||||
// on various properties (like input, output, deps.). Apparently, there are
|
||||
// still some CCs intersection between different targets.
|
||||
auto val = AllGeneratedCommands.emplace(target.Name);
|
||||
if (val.second) {
|
||||
FastbuildTargets.emplace_back(cm::make_unique<T>(std::move(target)));
|
||||
}
|
||||
// Get the intersection of CC's deps. Just mimicking what
|
||||
// cmLocalNinjaGenerator::WriteCustomCommandBuildStatement does. (I don't
|
||||
// think it's right in general case, each CC should be added only to 1
|
||||
// target, not to multiple )
|
||||
else {
|
||||
auto it =
|
||||
std::find_if(FastbuildTargets.begin(), FastbuildTargets.end(),
|
||||
[&target](FastbuildTargetPtrT const& existingTarget) {
|
||||
return existingTarget->Name == target.Name;
|
||||
});
|
||||
assert(it != FastbuildTargets.end());
|
||||
|
||||
std::set<FastbuildTargetDep> intersection;
|
||||
std::set_intersection(
|
||||
target.PreBuildDependencies.begin(), target.PreBuildDependencies.end(),
|
||||
(*it)->PreBuildDependencies.begin(), (*it)->PreBuildDependencies.end(),
|
||||
std::inserter(intersection, intersection.end()));
|
||||
(*it)->PreBuildDependencies = std::move(intersection);
|
||||
}
|
||||
}
|
||||
|
||||
static std::string GetExternalShellExecutable();
|
||||
std::string GetTargetName(cmGeneratorTarget const* GeneratorTarget) const;
|
||||
cm::optional<FastbuildTarget> GetTargetByOutputName(
|
||||
std::string const& output) const;
|
||||
void AskCMakeToMakeRebuildBFFUpToDate(std::string const& workingDir) const;
|
||||
void ExecuteFastbuildTarget(
|
||||
std::string const& dir, std::string const& target, std::string& output,
|
||||
std::vector<std::string> const& fbuildOptions = {}) const;
|
||||
|
||||
bool IsExcluded(cmGeneratorTarget* target);
|
||||
|
||||
void LogMessage(std::string const& m) const;
|
||||
|
||||
void AddFileToClean(std::string const& file);
|
||||
|
||||
/// The set of compilers added to the generated build system.
|
||||
std::map<std::string, FastbuildCompiler> Compilers;
|
||||
|
||||
std::vector<FastbuildTargetPtrT> FastbuildTargets;
|
||||
|
||||
/// The file containing the build statement.
|
||||
std::unique_ptr<cmGeneratedFileStream> BuildFileStream;
|
||||
|
||||
std::string FastbuildCommand;
|
||||
std::string FastbuildVersion;
|
||||
|
||||
std::map<std::string, std::unique_ptr<cmFastbuildTargetGenerator>> Targets;
|
||||
|
||||
std::unordered_set<std::string> AllFoldersToClean;
|
||||
// Sometime we need to keep some files that are generated only during
|
||||
// configuration (like .objs files used to create module definition from
|
||||
// objects).
|
||||
std::unordered_set<std::string> AllFilesToKeep;
|
||||
|
||||
private:
|
||||
std::unordered_set<std::string> AllFilesToClean;
|
||||
// https://cmake.org/cmake/help/latest/module/ExternalProject.html#command:externalproject_add_steptargets
|
||||
std::unordered_set<std::string /*exec name*/> AllGeneratedCommands;
|
||||
|
||||
std::unordered_map<std::string /*base target name (without -config)*/,
|
||||
std::pair<VCXProject, XCodeProject>>
|
||||
IDEProjects;
|
||||
// Env that we're going to embed to the generated file.
|
||||
std::vector<std::string> LocalEnvironment;
|
||||
};
|
||||
@@ -140,6 +140,7 @@ cmGlobalGenerator::cmGlobalGenerator(cmake* cm)
|
||||
cm->GetState()->SetWindowsShell(false);
|
||||
cm->GetState()->SetWindowsVSIDE(false);
|
||||
|
||||
cm->GetState()->SetFastbuildMake(false);
|
||||
#if !defined(CMAKE_BOOTSTRAP)
|
||||
Json::StreamWriterBuilder wbuilder;
|
||||
wbuilder["indentation"] = "\t";
|
||||
|
||||
@@ -564,6 +564,8 @@ public:
|
||||
|
||||
virtual bool IsNinja() const { return false; }
|
||||
|
||||
virtual bool IsFastbuild() const { return false; }
|
||||
|
||||
/** Return true if we know the exact location of object files for the given
|
||||
cmTarget. If false, store the reason in the given string. This is
|
||||
meaningful only after EnableLanguage has been called. */
|
||||
|
||||
@@ -50,6 +50,7 @@ public:
|
||||
|
||||
std::string ComputeLinkLibraries(cmComputeLinkInformation& cli,
|
||||
std::string const& stdLibString);
|
||||
std::string ComputeRPath(cmComputeLinkInformation& cli);
|
||||
|
||||
virtual void ComputeLinkLibraries(
|
||||
cmComputeLinkInformation& cli, std::string const& stdLibString,
|
||||
@@ -62,7 +63,6 @@ protected:
|
||||
std::string ComputeLinkLibs(cmComputeLinkInformation& cli);
|
||||
void ComputeLinkLibs(cmComputeLinkInformation& cli,
|
||||
std::vector<BT<std::string>>& linkLibraries);
|
||||
std::string ComputeRPath(cmComputeLinkInformation& cli);
|
||||
|
||||
std::string ConvertToOutputFormat(std::string const& input);
|
||||
std::string ConvertToOutputForExisting(std::string const& input);
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file LICENSE.rst or https://cmake.org/licensing for details. */
|
||||
|
||||
#include "cmLocalFastbuildGenerator.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "cmFastbuildTargetGenerator.h"
|
||||
#include "cmGeneratorExpression.h"
|
||||
#include "cmGeneratorTarget.h"
|
||||
#include "cmGlobalFastbuildGenerator.h"
|
||||
#include "cmList.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmObjectLocation.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmValue.h"
|
||||
|
||||
class cmGlobalGenerator;
|
||||
|
||||
cmLocalFastbuildGenerator::cmLocalFastbuildGenerator(cmGlobalGenerator* gg,
|
||||
cmMakefile* makefile)
|
||||
: cmLocalCommonGenerator(gg, makefile)
|
||||
{
|
||||
}
|
||||
|
||||
void cmLocalFastbuildGenerator::Generate()
|
||||
{
|
||||
auto const& targets = this->GetGeneratorTargets();
|
||||
for (auto const& target : targets) {
|
||||
if (!target->IsInBuildSystem()) {
|
||||
continue;
|
||||
}
|
||||
for (std::string config : this->GetConfigNames()) {
|
||||
cmFastbuildTargetGenerator* tg =
|
||||
cmFastbuildTargetGenerator::New(target.get(), std::move(config));
|
||||
if (tg) {
|
||||
tg->Generate();
|
||||
delete tg;
|
||||
}
|
||||
// Directory level.
|
||||
this->AdditionalCleanFiles(config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cmGlobalFastbuildGenerator const*
|
||||
cmLocalFastbuildGenerator::GetGlobalFastbuildGenerator() const
|
||||
{
|
||||
return static_cast<cmGlobalFastbuildGenerator const*>(
|
||||
this->GetGlobalGenerator());
|
||||
}
|
||||
|
||||
cmGlobalFastbuildGenerator*
|
||||
cmLocalFastbuildGenerator::GetGlobalFastbuildGenerator()
|
||||
{
|
||||
return static_cast<cmGlobalFastbuildGenerator*>(this->GetGlobalGenerator());
|
||||
}
|
||||
|
||||
void cmLocalFastbuildGenerator::ComputeObjectFilenames(
|
||||
std::map<cmSourceFile const*, cmObjectLocations>& mapping,
|
||||
cmGeneratorTarget const* gt)
|
||||
{
|
||||
for (auto& si : mapping) {
|
||||
cmSourceFile const* sf = si.first;
|
||||
si.second.LongLoc =
|
||||
this->GetObjectFileNameWithoutTarget(*sf, gt->ObjectDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
void cmLocalFastbuildGenerator::AppendFlagEscape(
|
||||
std::string& flags, std::string const& rawFlag) const
|
||||
{
|
||||
std::string escapedFlag = this->EscapeForShell(rawFlag);
|
||||
// Other make systems will remove the double $ but
|
||||
// fastbuild uses ^$ to escape it. So switch to that.
|
||||
// cmSystemTools::ReplaceString(escapedFlag, "$$", "^$");
|
||||
this->AppendFlags(flags, escapedFlag);
|
||||
}
|
||||
|
||||
void cmLocalFastbuildGenerator::AdditionalCleanFiles(std::string const& config)
|
||||
{
|
||||
if (cmValue prop_value =
|
||||
this->Makefile->GetProperty("ADDITIONAL_CLEAN_FILES")) {
|
||||
cmList cleanFiles{ cmGeneratorExpression::Evaluate(*prop_value, this,
|
||||
config) };
|
||||
std::string const& binaryDir = this->GetCurrentBinaryDirectory();
|
||||
auto* gg = this->GetGlobalFastbuildGenerator();
|
||||
for (auto const& cleanFile : cleanFiles) {
|
||||
// Support relative paths
|
||||
gg->AddFileToClean(gg->ConvertToFastbuildPath(
|
||||
cmSystemTools::CollapseFullPath(cleanFile, binaryDir)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file LICENSE.rst or https://cmake.org/licensing for details. */
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "cmLocalCommonGenerator.h"
|
||||
|
||||
class cmGeneratorTarget;
|
||||
class cmGlobalFastbuildGenerator;
|
||||
class cmGlobalGenerator;
|
||||
class cmMakefile;
|
||||
class cmSourceFile;
|
||||
struct cmObjectLocations;
|
||||
|
||||
class cmLocalFastbuildGenerator : public cmLocalCommonGenerator
|
||||
{
|
||||
public:
|
||||
cmLocalFastbuildGenerator(cmGlobalGenerator* gg, cmMakefile* makefile);
|
||||
|
||||
void Generate() override;
|
||||
|
||||
void AppendFlagEscape(std::string& flags,
|
||||
std::string const& rawFlag) const override;
|
||||
|
||||
void ComputeObjectFilenames(
|
||||
std::map<cmSourceFile const*, cmObjectLocations>& mapping,
|
||||
cmGeneratorTarget const* gt = nullptr) override;
|
||||
|
||||
cmGlobalFastbuildGenerator const* GetGlobalFastbuildGenerator() const;
|
||||
cmGlobalFastbuildGenerator* GetGlobalFastbuildGenerator();
|
||||
|
||||
void AdditionalCleanFiles(std::string const& config);
|
||||
};
|
||||
@@ -2847,8 +2847,13 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
|
||||
}
|
||||
|
||||
// Link to the pch object file
|
||||
std::string pchSourceObj =
|
||||
reuseTarget->GetPchFileObject(config, lang, arch);
|
||||
std::string pchSourceObj;
|
||||
// Fastbuild will propagate pch.obj for us, no need to link to it
|
||||
// explicitly.
|
||||
if (!this->GetGlobalGenerator()->IsFastbuild()) {
|
||||
pchSourceObj =
|
||||
reuseTarget->GetPchFileObject(config, lang, arch);
|
||||
}
|
||||
|
||||
if (target->GetType() != cmStateEnums::OBJECT_LIBRARY) {
|
||||
std::string linkerProperty = "LINK_FLAGS_";
|
||||
@@ -2970,6 +2975,11 @@ void cmLocalGenerator::CopyPchCompilePdb(
|
||||
cc->SetStdPipesUTF8(true);
|
||||
cc->AppendDepends(
|
||||
{ reuseTarget->GetPchFile(config, language), copy_script });
|
||||
// Fastbuild needs to know that this custom command actually depends on a
|
||||
// target that produces PCH, so it can sort by dependencies correctly.
|
||||
if (this->GetGlobalGenerator()->IsFastbuild()) {
|
||||
cc->AppendDepends({ reuseTarget->GetName() });
|
||||
}
|
||||
|
||||
if (this->GetGlobalGenerator()->IsVisualStudio()) {
|
||||
cc->SetByproducts(outputs);
|
||||
|
||||
@@ -281,6 +281,10 @@ std::string cmOutputConverter::EscapeForShell(cm::string_view str,
|
||||
if (!this->GetState()->UseWindowsShell()) {
|
||||
flags |= Shell_Flag_IsUnix;
|
||||
}
|
||||
if (this->GetState()->UseFastbuildMake()) {
|
||||
// Fastbuild needs to escape very few characters.
|
||||
flags = Shell_Flag_Fastbuild;
|
||||
}
|
||||
|
||||
return cmOutputConverter::EscapeForShell(str, flags);
|
||||
}
|
||||
@@ -436,6 +440,10 @@ bool cmOutputConverter::Shell_CharNeedsQuotes(char c, int flags)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (flags & Shell_Flag_Fastbuild) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Quote hyphens in response files */
|
||||
if (flags & Shell_Flag_IsResponse) {
|
||||
if (c == '-') {
|
||||
@@ -645,6 +653,8 @@ std::string cmOutputConverter::Shell_GetArgument(cm::string_view in, int flags)
|
||||
quoting. Either way the $ is isolated from surrounding
|
||||
text to avoid looking like a variable reference. */
|
||||
out += "\"$\"";
|
||||
} else if (flags & Shell_Flag_Fastbuild) {
|
||||
out += "^$";
|
||||
} else {
|
||||
/* Otherwise a dollar is written just $. */
|
||||
out += '$';
|
||||
@@ -684,6 +694,8 @@ std::string cmOutputConverter::Shell_GetArgument(cm::string_view in, int flags)
|
||||
} else {
|
||||
out += '\n';
|
||||
}
|
||||
} else if (*cit == '^' && (flags & Shell_Flag_Fastbuild)) {
|
||||
out += "^^";
|
||||
} else {
|
||||
/* Store this character. */
|
||||
out += *cit;
|
||||
|
||||
@@ -103,7 +103,8 @@ public:
|
||||
Shell_Flag_IsResponse = (1 << 10),
|
||||
|
||||
/** The target shell is in a Ninja build file. */
|
||||
Shell_Flag_Ninja = (1 << 11)
|
||||
Shell_Flag_Ninja = (1 << 11),
|
||||
Shell_Flag_Fastbuild = (1 << 12),
|
||||
};
|
||||
|
||||
std::string EscapeForShell(cm::string_view str, bool makeVars = false,
|
||||
|
||||
@@ -790,6 +790,16 @@ bool cmState::UseNinjaMulti() const
|
||||
return this->NinjaMulti;
|
||||
}
|
||||
|
||||
void cmState::SetFastbuildMake(bool fastbuildMake)
|
||||
{
|
||||
this->FastbuildMake = fastbuildMake;
|
||||
}
|
||||
|
||||
bool cmState::UseFastbuildMake() const
|
||||
{
|
||||
return this->FastbuildMake;
|
||||
}
|
||||
|
||||
unsigned int cmState::GetCacheMajorVersion() const
|
||||
{
|
||||
return this->CacheManager->GetCacheMajorVersion();
|
||||
|
||||
@@ -225,6 +225,8 @@ public:
|
||||
bool UseNinja() const;
|
||||
void SetNinjaMulti(bool ninjaMulti);
|
||||
bool UseNinjaMulti() const;
|
||||
void SetFastbuildMake(bool fastbuildMake);
|
||||
bool UseFastbuildMake() const;
|
||||
|
||||
unsigned int GetCacheMajorVersion() const;
|
||||
unsigned int GetCacheMinorVersion() const;
|
||||
@@ -301,6 +303,7 @@ private:
|
||||
bool MSYSShell = false;
|
||||
bool Ninja = false;
|
||||
bool NinjaMulti = false;
|
||||
bool FastbuildMake = false;
|
||||
Mode StateMode = Unknown;
|
||||
ProjectKind StateProjectKind = ProjectKind::Normal;
|
||||
cm::optional<cmDependencyProvider> DependencyProvider;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <initializer_list>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
@@ -100,6 +101,7 @@
|
||||
# include <cmext/memory>
|
||||
|
||||
# include "cmGlobalBorlandMakefileGenerator.h"
|
||||
# include "cmGlobalFastbuildGenerator.h"
|
||||
# include "cmGlobalJOMMakefileGenerator.h"
|
||||
# include "cmGlobalNMakeMakefileGenerator.h"
|
||||
# include "cmGlobalVisualStudio14Generator.h"
|
||||
@@ -123,6 +125,7 @@
|
||||
#elif defined(CMAKE_BOOTSTRAP_NINJA)
|
||||
# include "cmGlobalNinjaGenerator.h"
|
||||
#endif
|
||||
#include "cmGlobalFastbuildGenerator.h"
|
||||
|
||||
#if !defined(CMAKE_BOOTSTRAP)
|
||||
# include "cmExtraCodeBlocksGenerator.h"
|
||||
@@ -3032,6 +3035,23 @@ int cmake::Run(std::vector<std::string> const& args, bool noconfigure)
|
||||
if (!this->CheckBuildSystem()) {
|
||||
return 0;
|
||||
}
|
||||
// After generating fbuild.bff, FastBuild sees rebuild-bff as outdated since
|
||||
// it hasn’t built the target yet. To make it a no-op for future runs, we
|
||||
// trigger a dummy fbuild invocation that creates this marker file and runs
|
||||
// CMake, marking rebuild-bff as up-to-date.
|
||||
std::string const FBuildRestatFile =
|
||||
cmStrCat(this->GetHomeOutputDirectory(), '/', FASTBUILD_RESTAT_FILE);
|
||||
if (cmSystemTools::FileExists(FBuildRestatFile)) {
|
||||
cmsys::ifstream restat(FBuildRestatFile.c_str(),
|
||||
std::ios::in | std::ios::binary);
|
||||
std::string const file((std::istreambuf_iterator<char>(restat)),
|
||||
std::istreambuf_iterator<char>());
|
||||
// On Windows can not delete file if it's still opened.
|
||||
restat.close();
|
||||
cmSystemTools::Touch(file, true);
|
||||
cmSystemTools::RemoveFile(FBuildRestatFile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CMake_ENABLE_DEBUGGER
|
||||
if (!this->StartDebuggerIfEnabled()) {
|
||||
@@ -3253,6 +3273,7 @@ void cmake::AddDefaultGenerators()
|
||||
this->Generators.push_back(cmGlobalUnixMakefileGenerator3::NewFactory());
|
||||
this->Generators.push_back(cmGlobalNinjaGenerator::NewFactory());
|
||||
this->Generators.push_back(cmGlobalNinjaMultiGenerator::NewFactory());
|
||||
this->Generators.push_back(cmGlobalFastbuildGenerator::NewFactory());
|
||||
#elif defined(CMAKE_BOOTSTRAP_NINJA)
|
||||
this->Generators.push_back(cmGlobalNinjaGenerator::NewFactory());
|
||||
#elif defined(CMAKE_BOOTSTRAP_MAKEFILES)
|
||||
|
||||
@@ -1381,6 +1381,18 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
|
||||
}
|
||||
|
||||
// Internal CMake dependency scanning support.
|
||||
// The format is: -E cmake_fastbuild_check_depends <dummy_file>
|
||||
// <space_separated_list_of_real_outputs>
|
||||
if (args[1] == "cmake_fastbuild_check_depends" && args.size() >= 3) {
|
||||
auto const dummyFile = args[2];
|
||||
for (auto const& arg : cmMakeRange(args).advance(3)) {
|
||||
if (!cmSystemTools::FileExists(arg)) {
|
||||
cmSystemTools::RemoveFile(dummyFile);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (args[1] == "cmake_depends" && args.size() >= 6) {
|
||||
bool const verbose = isCMakeVerbose();
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ if(WIN32 AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel")
|
||||
set(_cmake_options "-DCMAKE_EXE_LINKER_FLAGS=")
|
||||
endif()
|
||||
|
||||
if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja")
|
||||
if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja|FASTBuild")
|
||||
set(TEST_LINK_DEPENDS ${BuildDepends_BINARY_DIR}/Project/linkdep.txt)
|
||||
file(WRITE ${TEST_LINK_DEPENDS} "1")
|
||||
endif()
|
||||
|
||||
@@ -4,7 +4,7 @@ project(testRebuild)
|
||||
if(APPLE AND CMake_TEST_XCODE_VERSION)
|
||||
# only use multi-arch if the sysroot exists on this machine
|
||||
# Ninja needs -M which could not be used with multiple -arch flags
|
||||
if(EXISTS "${CMAKE_OSX_SYSROOT}" AND NOT "${CMAKE_GENERATOR}" MATCHES "Ninja")
|
||||
if(EXISTS "${CMAKE_OSX_SYSROOT}" AND NOT "${CMAKE_GENERATOR}" MATCHES "Ninja|FASTBuild")
|
||||
if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 12)
|
||||
set(CMAKE_OSX_ARCHITECTURES arm64 x86_64)
|
||||
elseif(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 10)
|
||||
|
||||
@@ -113,7 +113,7 @@ if(BUILD_TESTING)
|
||||
# some old versions of make simply cannot handle spaces in paths
|
||||
if(MAKE_IS_GNU OR
|
||||
CMAKE_MAKE_PROGRAM MATCHES "nmake|gmake|wmake" OR
|
||||
CMAKE_GENERATOR MATCHES "Visual Studio|Xcode|Borland|Ninja")
|
||||
CMAKE_GENERATOR MATCHES "Visual Studio|Xcode|Borland|Ninja|FASTBuild")
|
||||
set(MAKE_SUPPORTS_SPACES 1)
|
||||
else()
|
||||
set(MAKE_SUPPORTS_SPACES 0)
|
||||
@@ -786,7 +786,7 @@ if(BUILD_TESTING)
|
||||
|
||||
# test for correct sub-project generation
|
||||
# not implemented in Xcode or Ninja
|
||||
if(NOT CMAKE_GENERATOR MATCHES "Xcode|Ninja")
|
||||
if(NOT CMAKE_GENERATOR MATCHES "Xcode|Ninja|FASTBuild")
|
||||
# run cmake and configure all of SubProject
|
||||
# but only build the independent executable car
|
||||
add_test(SubProject ${CMAKE_CTEST_COMMAND}
|
||||
@@ -2113,8 +2113,7 @@ if(BUILD_TESTING)
|
||||
|
||||
ADD_TEST_MACRO(CheckCompilerRelatedVariables CheckCompilerRelatedVariables)
|
||||
|
||||
if("${CMAKE_GENERATOR}" MATCHES "Makefile" OR
|
||||
"${CMAKE_GENERATOR}" MATCHES "^Ninja$")
|
||||
if("${CMAKE_GENERATOR}" MATCHES "^Ninja$|Makefile|FASTBuild")
|
||||
add_test(MakeClean ${CMAKE_CTEST_COMMAND}
|
||||
--build-and-test
|
||||
"${CMake_SOURCE_DIR}/Tests/MakeClean"
|
||||
@@ -3131,7 +3130,7 @@ if(BUILD_TESTING)
|
||||
)
|
||||
endif()
|
||||
|
||||
if("${CMAKE_GENERATOR}" MATCHES "Makefiles" OR "${CMAKE_GENERATOR}" MATCHES "Ninja")
|
||||
if("${CMAKE_GENERATOR}" MATCHES "Makefiles|Ninja|FASTBuild")
|
||||
configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestLaunchers/test.cmake.in"
|
||||
"${CMake_BINARY_DIR}/Tests/CTestTestLaunchers/test.cmake" @ONLY ESCAPE_QUOTES)
|
||||
add_test(CTestTestLaunchers ${CMAKE_CTEST_COMMAND}
|
||||
@@ -3461,7 +3460,7 @@ if(BUILD_TESTING)
|
||||
--test-command IncludeDirectories)
|
||||
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/IncludeDirectories")
|
||||
|
||||
if(CMAKE_GENERATOR MATCHES "^((Unix|MSYS) Makefiles|Ninja)$" AND
|
||||
if(CMAKE_GENERATOR MATCHES "^((Unix|MSYS) Makefiles|Ninja|FASTBuild)$" AND
|
||||
((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.4)
|
||||
OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
|
||||
OR (CMAKE_CXX_COMPILER_ID STREQUAL "LCC")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if(NOT CMAKE_GENERATOR MATCHES "Xcode|Ninja")
|
||||
if(NOT CMAKE_GENERATOR MATCHES "Xcode|Ninja|FASTBuild")
|
||||
set(CMAKE_Swift_COMPILER "")
|
||||
return()
|
||||
endif()
|
||||
|
||||
@@ -485,6 +485,12 @@ add_library(NormOutput "${gen_file}")
|
||||
string(APPEND gen_path "/bar")
|
||||
set(gen_file "${gen_path}/bar.cxx")
|
||||
|
||||
# FASTBuild doesn't support directories as an output of custom commands,
|
||||
# so mark the output as SYMBOLIC to let FASTBuild know that it's not expected to appear on disk.
|
||||
if(CMAKE_GENERATOR MATCHES "FASTBuild")
|
||||
set_property(SOURCE "${gen_path}" PROPERTY SYMBOLIC ON)
|
||||
endif()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "${gen_path}"
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${gen_path}"
|
||||
|
||||
@@ -721,7 +721,7 @@ export(TARGETS testLinkDirectories NAMESPACE bld_ APPEND FILE ExportBuildTree.cm
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# test export of INTERFACE_LINK_DEPENDS
|
||||
if(CMAKE_GENERATOR MATCHES "Make|Ninja")
|
||||
if(CMAKE_GENERATOR MATCHES "Make|Ninja|FASTBuild")
|
||||
add_library(testLinkDepends INTERFACE)
|
||||
set_property(TARGET testLinkDepends PROPERTY INTERFACE_LINK_DEPENDS
|
||||
$<BUILD_INTERFACE:BUILD_LINK_DEPENDS>
|
||||
|
||||
@@ -435,7 +435,7 @@ set_property(TARGET testSharedLibDepends APPEND PROPERTY
|
||||
if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4)
|
||||
OR CMAKE_C_COMPILER_ID MATCHES "LCC"
|
||||
OR (CMAKE_C_COMPILER_ID STREQUAL Clang AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC"))
|
||||
AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja"))
|
||||
AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja" OR CMAKE_GENERATOR STREQUAL "FASTBuild"))
|
||||
include(CheckCXXCompilerFlag)
|
||||
check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test)
|
||||
if(run_sys_includes_test)
|
||||
@@ -607,7 +607,7 @@ checkForProperty(Req::testLinkDirectories "INTERFACE_LINK_DIRECTORIES" "${CMAKE_
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# check that imported libraries have the expected INTERFACE_LINK_DEPENDS property
|
||||
if(CMAKE_GENERATOR MATCHES "Make|Ninja")
|
||||
if(CMAKE_GENERATOR MATCHES "Make|Ninja|FASTBuild")
|
||||
checkForProperty(bld_testLinkDepends "INTERFACE_LINK_DEPENDS" "BUILD_LINK_DEPENDS")
|
||||
checkForProperty(Req::testLinkDepends "INTERFACE_LINK_DEPENDS" "${CMAKE_INSTALL_PREFIX}/INSTALL_LINK_DEPENDS")
|
||||
endif()
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(FortranModules Fortran)
|
||||
|
||||
if(CMAKE_GENERATOR MATCHES "FASTBuild")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if("${CMAKE_Fortran_COMPILER_ID};${CMAKE_Fortran_SIMULATE_ID}" MATCHES "^Intel(LLVM)?;MSVC$")
|
||||
string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -Z7")
|
||||
string(APPEND CMAKE_Fortran_FLAGS_RELWITHDEBINFO " -Z7")
|
||||
|
||||
@@ -405,7 +405,7 @@ add_executable(srcgenex_includes_basic "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_inc
|
||||
# first include directory is useless but ensure list aspect is tested
|
||||
set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_includes_basic.c"
|
||||
PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/sf_includes_basic")
|
||||
if (CMAKE_GENERATOR MATCHES "Makefiles|Ninja|Watcom WMake")
|
||||
if (CMAKE_GENERATOR MATCHES "Makefiles|Ninja|Watcom WMake|FASTBuild")
|
||||
add_executable(srcgenex_includes_COMPILE_LANGUAGE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_includes_COMPILE_LANGUAGE.c")
|
||||
# first include directory is useless but ensure list aspect is tested
|
||||
set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_includes_COMPILE_LANGUAGE.c"
|
||||
|
||||
@@ -14,6 +14,7 @@ if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREA
|
||||
CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "19.29.30036.3"))
|
||||
AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles"
|
||||
OR CMAKE_GENERATOR STREQUAL "Ninja"
|
||||
OR CMAKE_GENERATOR STREQUAL "FASTBuild"
|
||||
OR (CMAKE_GENERATOR STREQUAL "Xcode" AND NOT XCODE_VERSION VERSION_LESS 6.0)
|
||||
OR CMAKE_GENERATOR MATCHES "Visual Studio"))
|
||||
if ("x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC")
|
||||
|
||||
@@ -89,8 +89,7 @@ foreach(t ${my_targets})
|
||||
if(NOT pdb_dir)
|
||||
if (NOT with_compile)
|
||||
set(pdb_dir ${CMAKE_CURRENT_BINARY_DIR})
|
||||
elseif (CMAKE_GENERATOR MATCHES "Ninja" OR
|
||||
CMAKE_GENERATOR MATCHES "Makefiles")
|
||||
elseif (CMAKE_GENERATOR MATCHES "Ninja|Makefiles|FASTBuild")
|
||||
set(pdb_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${t}.dir)
|
||||
elseif (CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||
set(pdb_dir ${CMAKE_CURRENT_BINARY_DIR}/${t}.dir)
|
||||
|
||||
@@ -42,8 +42,7 @@ set_source_files_properties(foo_precompile.c PROPERTIES
|
||||
|
||||
# Setup dependencies for precompiled header creation and use. The VS
|
||||
# IDE takes care of this automatically.
|
||||
if("${CMAKE_GENERATOR}" MATCHES "Makefile" OR
|
||||
"${CMAKE_GENERATOR}" MATCHES "Ninja")
|
||||
if("${CMAKE_GENERATOR}" MATCHES "Makefile|Ninja|FASTBuild")
|
||||
# This source file creates the precompiled header as a side-effect.
|
||||
set_source_files_properties(foo_precompile.c PROPERTIES
|
||||
OBJECT_OUTPUTS "${PCH_DIR}/foo_precompiled.pch")
|
||||
|
||||
@@ -28,6 +28,9 @@ endif()
|
||||
if("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
|
||||
set(PP_VS 1)
|
||||
endif()
|
||||
if("${CMAKE_GENERATOR}" MATCHES "FASTBuild")
|
||||
set(PP_FASTBUILD 1)
|
||||
endif()
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND
|
||||
"x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
|
||||
set(CLANG_MSVC_WINDOWS 1)
|
||||
@@ -107,9 +110,11 @@ if(NOT PP_BORLAND AND NOT PP_MINGW AND NOT PP_NMAKE)
|
||||
endif()
|
||||
|
||||
set(EXPR_OP1 "/")
|
||||
if((NOT MSVC OR PP_NMAKE) AND
|
||||
if(NOT PP_FASTBUILD AND (NOT MSVC OR PP_NMAKE) AND
|
||||
NOT CMAKE_C_COMPILER_ID STREQUAL "Intel" AND
|
||||
NOT CLANG_MSVC_WINDOWS)
|
||||
# FASTBuild does not support escaping of '%' character in the command line.
|
||||
# See https://github.com/fastbuild/fastbuild/issues/390 for more details.
|
||||
# MSVC cl, Intel icl: %
|
||||
# When the cl compiler is invoked from the command line then % must
|
||||
# be written %% (to distinguish from %ENV% syntax). However cl does
|
||||
|
||||
@@ -9,7 +9,7 @@ function (run_cmake_AutoExport name dir)
|
||||
run_cmake(${name})
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
# don't run this test on Watcom or Borland make as it is not supported
|
||||
if(RunCMake_GENERATOR MATCHES "Watcom WMake|Borland Makefiles")
|
||||
if(RunCMake_GENERATOR MATCHES "Watcom WMake|Borland Makefiles|FASTBuild")
|
||||
return()
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "OrangeC")
|
||||
|
||||
@@ -181,11 +181,11 @@ if (DEFINED with_qt_version)
|
||||
"${RunCMake_BINARY_DIR}/AutogenDuplicateDependency-build-${LIB_LINK_COUNT}")
|
||||
run_cmake_with_options(AutogenDuplicateDependency ${RunCMake_TEST_OPTIONS} -DLIB_LINK_COUNT=${LIB_LINK_COUNT})
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
set(RunCMake_TEST_EXPECT_stdout "fancy_generated.txt")
|
||||
set(RunCMake-check-file "check-fancy-generated.cmake")
|
||||
run_cmake_command("AutogenDuplicateDependency-build"
|
||||
${CMAKE_COMMAND} --build . --target App_autogen --verbose)
|
||||
unset(RunCMake_TEST_VARIANT_DESCRIPTION)
|
||||
unset(RunCMake_TEST_EXPECT_stdout)
|
||||
unset(RunCMake-check-file)
|
||||
unset(RunCMake_TEST_NO_CLEAN)
|
||||
endforeach()
|
||||
endblock()
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/fancy_generated.txt")
|
||||
set(RunCMake_TEST_FAILED "'${RunCMake_TEST_BINARY_DIR}/fancy_generated.txt' missing")
|
||||
endif()
|
||||
@@ -73,10 +73,16 @@ if(CMake_TEST_Fortran
|
||||
# FIXME(lfortran): The compiler fails on the test's includes.
|
||||
AND NOT CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran"
|
||||
)
|
||||
run_BuildDepends(FortranInclude)
|
||||
if(NOT RunCMake_GENERATOR MATCHES "FASTBuild")
|
||||
run_BuildDepends(FortranInclude)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
run_BuildDepends(Custom-Symbolic-and-Byproduct)
|
||||
# By default, FASTBuild will only create "run always" commands if we only have SYMBOLIC output.
|
||||
# However, this declares a custom command with NON-SYMBOLIC output and expects it to always run.
|
||||
if(NOT RunCMake_GENERATOR MATCHES "FASTBuild")
|
||||
run_BuildDepends(Custom-Symbolic-and-Byproduct)
|
||||
endif()
|
||||
run_BuildDepends(Custom-Always)
|
||||
|
||||
set(RunCMake_TEST_OUTPUT_MERGE_save "${RunCMake_TEST_OUTPUT_MERGE}")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
include(RunCMake)
|
||||
|
||||
if(RunCMake_GENERATOR MATCHES "Make|Ninja")
|
||||
if(RunCMake_GENERATOR MATCHES "Make|Ninja|FASTBuild")
|
||||
set(test_target "test")
|
||||
else()
|
||||
set(test_target "RUN_TESTS")
|
||||
|
||||
@@ -11,6 +11,6 @@ run_cmake(NEW-cond-package)
|
||||
|
||||
run_cmake(alias-test-NEW)
|
||||
|
||||
if(RunCMake_GENERATOR MATCHES "Make|Ninja")
|
||||
if(RunCMake_GENERATOR MATCHES "Make|Ninja|FASTBuild")
|
||||
run_cmake(NEW-cond-package_source)
|
||||
endif()
|
||||
@@ -355,7 +355,7 @@ add_RunCMake_test(BuildDepends
|
||||
)
|
||||
set_property(TEST RunCMake.BuildDepends APPEND PROPERTY LABELS "Fortran")
|
||||
add_RunCMake_test(BuiltinTargets)
|
||||
if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja")
|
||||
if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja|FASTBuild")
|
||||
add_RunCMake_test(Byproducts)
|
||||
endif()
|
||||
add_RunCMake_test(CMakeDependentOption)
|
||||
@@ -371,7 +371,7 @@ add_RunCMake_test(CMakeRelease -DCMake_TEST_JQ=${CMake_TEST_JQ})
|
||||
if(CMAKE_GENERATOR MATCHES "Make|Ninja")
|
||||
add_RunCMake_test(Color)
|
||||
endif()
|
||||
if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja")
|
||||
if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja|FASTBuild")
|
||||
add_RunCMake_test(CompilerChange)
|
||||
endif()
|
||||
add_RunCMake_test(CompilerNotFound)
|
||||
@@ -1138,7 +1138,7 @@ add_executable(pseudo_iwyu pseudo_iwyu.c)
|
||||
add_executable(pseudo_cpplint pseudo_cpplint.c)
|
||||
add_executable(pseudo_cppcheck pseudo_cppcheck.c)
|
||||
|
||||
if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja")
|
||||
if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja|FASTBuild")
|
||||
if(UNIX AND NOT CYGWIN)
|
||||
execute_process(COMMAND ldd --help
|
||||
OUTPUT_VARIABLE LDD_HELP
|
||||
|
||||
@@ -11,7 +11,7 @@ function(run_CMakeCTestArguments)
|
||||
run_cmake_with_options(CMakeCTestArguments "-DCMAKE_CTEST_ARGUMENTS=--quiet\\;--output-log\\;output-log.txt")
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMakeCTestArguments-build)
|
||||
if(RunCMake_GENERATOR MATCHES "Make|Ninja")
|
||||
if(RunCMake_GENERATOR MATCHES "Make|Ninja|FASTBuild")
|
||||
set(test "test")
|
||||
else()
|
||||
set(test "RUN_TESTS")
|
||||
|
||||
@@ -12,6 +12,9 @@ function(run_compiler_launcher lang)
|
||||
if("${RunCMake_GENERATOR}" MATCHES "Ninja")
|
||||
set(verbose_args -- -v)
|
||||
endif()
|
||||
if("${RunCMake_GENERATOR}" MATCHES "FASTBuild")
|
||||
set(verbose_args -- -verbose)
|
||||
endif()
|
||||
run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build . ${verbose_args})
|
||||
endfunction()
|
||||
|
||||
|
||||
@@ -27,6 +27,6 @@
|
||||
*-- Separator: ,
|
||||
*-- List: 7,8,9
|
||||
.*(Performing build step for 'DefaultCommandEnvVars'|DefaultCommandEnvVars-build).*
|
||||
*-- Stage: build
|
||||
.*-- Stage: build
|
||||
*-- Separator: ,
|
||||
*-- List: 7,8,9,10
|
||||
@@ -1,8 +1,8 @@
|
||||
( )?-- stdout output is:
|
||||
( )?This is some dummy output with some long lines to ensure formatting is preserved
|
||||
( )? Including lines with leading spaces
|
||||
( )?
|
||||
( )?|
|
||||
( )?And also blank lines[
|
||||
]+
|
||||
]?
|
||||
( )?-- stderr output is:
|
||||
( )?cmake -E env: no command given
|
||||
@@ -1,7 +1,7 @@
|
||||
( )?-- Log output is:
|
||||
( )?This is some dummy output with some long lines to ensure formatting is preserved
|
||||
( )? Including lines with leading spaces
|
||||
( )?
|
||||
( )?|
|
||||
( )?And also blank lines[
|
||||
]+
|
||||
]?
|
||||
( )?cmake -E env: no command given
|
||||
@@ -12,6 +12,9 @@ function(run_linker_launcher lang)
|
||||
if("${RunCMake_GENERATOR}" MATCHES "Ninja")
|
||||
set(verbose_args -- -v)
|
||||
endif()
|
||||
if("${RunCMake_GENERATOR}" MATCHES "FASTBuild")
|
||||
set(verbose_args -- -verbose)
|
||||
endif()
|
||||
run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build . ${verbose_args})
|
||||
endfunction()
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ Warning: include-what-you-use reported diagnostics:
|
||||
should add these lines:
|
||||
*
|
||||
#include <\.\.\.>
|
||||
+
|
||||
*
|
||||
.*Tests[/\]RunCMake[/\]MultiLint[/\]main\.c:0:0: warning: message \[checker\].*
|
||||
Total errors found: 0
|
||||
.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.*
|
||||
@@ -2,7 +2,7 @@ Warning: include-what-you-use reported diagnostics:
|
||||
should add these lines:
|
||||
*
|
||||
#include <\.\.\.>
|
||||
+
|
||||
*
|
||||
.*Tests[/\]RunCMake[/\]MultiLint[/\]main\.c:0:0: warning: message \[checker\].*
|
||||
Total errors found: 0
|
||||
.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.*
|
||||
@@ -2,7 +2,7 @@ Warning: include-what-you-use reported diagnostics:
|
||||
should add these lines:
|
||||
*
|
||||
#include <\.\.\.>
|
||||
+
|
||||
?
|
||||
.*Tests[/\]RunCMake[/\]MultiLint[/\]main\.cxx:0:0: warning: message \[checker\].*
|
||||
Total errors found: 0
|
||||
.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.*
|
||||
@@ -2,7 +2,7 @@ Warning: include-what-you-use reported diagnostics:
|
||||
should add these lines:
|
||||
*
|
||||
#include <\.\.\.>
|
||||
+
|
||||
?
|
||||
.*Tests[/\]RunCMake[/\]MultiLint[/\]main\.cxx:0:0: warning: message \[checker\].*
|
||||
Total errors found: 0
|
||||
.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.*
|
||||
@@ -87,7 +87,7 @@ set(xcframework_platforms macos ios ${maybe_ios_catalyst} tvos watchos ios-simul
|
||||
if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 15.2)
|
||||
list(APPEND xcframework_platforms visionos visionos-simulator)
|
||||
endif()
|
||||
if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 12)
|
||||
if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 12 AND NOT RunCMake_GENERATOR STREQUAL "FASTBuild")
|
||||
set(macos_archs_1 "x86_64\\;arm64")
|
||||
set(macos_archs_2 "x86_64\\\\;arm64")
|
||||
set(watch_sim_archs_2 "x86_64")
|
||||
|
||||
@@ -19,6 +19,8 @@ function(run_TargetOrder)
|
||||
run_cmake(TargetOrder)
|
||||
if(RunCMake_GENERATOR STREQUAL "Ninja")
|
||||
set(build_flags -j 1 -v)
|
||||
elseif(RunCMake_GENERATOR STREQUAL "FASTBuild")
|
||||
set(build_flags -j1)
|
||||
endif()
|
||||
run_cmake_command(TargetOrder-build ${CMAKE_COMMAND} --build . -- ${build_flags})
|
||||
endfunction()
|
||||
|
||||
@@ -248,6 +248,13 @@ if (CMAKE_GENERATOR MATCHES "Ninja")
|
||||
pch_pool=1)
|
||||
endif ()
|
||||
|
||||
# FASTBuild requires that launchers actually be available
|
||||
# at configure time
|
||||
if(CMAKE_GENERATOR MATCHES FASTBuild)
|
||||
file(TOUCH "${dir}/ccache")
|
||||
file(CHMOD "${dir}/ccache" PERMISSIONS OWNER_READ OWNER_EXECUTE)
|
||||
endif()
|
||||
|
||||
prepare_target_types(can_compile_sources
|
||||
EXECUTABLE SHARED STATIC MODULE OBJECT)
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ events:(
|
||||
variable: "COMPILE_RESULT"
|
||||
cached: true
|
||||
stdout: \|.*
|
||||
exitCode: [1-9][0-9]*
|
||||
exitCode: -?[1-9][0-9]*
|
||||
-
|
||||
kind: "try_compile-v1"
|
||||
backtrace:
|
||||
|
||||
@@ -80,7 +80,7 @@ events:(
|
||||
variable: "COMPILE_RESULT"
|
||||
cached: true
|
||||
stdout: \|.*
|
||||
exitCode: [1-9][0-9]*
|
||||
exitCode: -?[1-9][0-9]*
|
||||
runResult:
|
||||
variable: "RUN_RESULT"
|
||||
cached: true
|
||||
|
||||
Reference in new issue
Block a user