mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-01-26 11:04:33 +00:00
FASTBuild: optimize try_compile builds
The generator does a lot of tricks in order to make the "rebuild-bff" target up-to-date immediately after the generation. We can skip all of those during "TryCompile" runs, which should reduce configure time.
This commit is contained in:
parent
e00b84ec13
commit
e42881422f
@ -72,7 +72,8 @@ cmGlobalBorlandMakefileGenerator::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, std::vector<std::string> const& makeOptions)
|
||||
cmBuildOptions buildOptions, std::vector<std::string> const& makeOptions,
|
||||
BuildTryCompile /*isInTryCompile*/)
|
||||
{
|
||||
return this->cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
|
||||
makeProgram, projectName, projectDir, targetNames, config,
|
||||
|
||||
@ -64,8 +64,8 @@ protected:
|
||||
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::vector<std::string> const& makeOptions = std::vector<std::string>(),
|
||||
BuildTryCompile isInTryCompile = BuildTryCompile::No) override;
|
||||
|
||||
void PrintBuildCommandAdvice(std::ostream& os, int jobs) const override;
|
||||
};
|
||||
|
||||
@ -351,7 +351,8 @@ cmGlobalFastbuildGenerator::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*/, std::vector<std::string> const& makeOptions)
|
||||
cmBuildOptions /*buildOptions*/, std::vector<std::string> const& makeOptions,
|
||||
BuildTryCompile isInTryCompile)
|
||||
{
|
||||
GeneratedMakeCommand makeCommand;
|
||||
this->FastbuildCommand = this->SelectMakeProgram(makeProgram);
|
||||
@ -386,8 +387,12 @@ cmGlobalFastbuildGenerator::GenerateBuildCommand(
|
||||
makeCommand.Add("-verbose");
|
||||
}
|
||||
|
||||
// Make "rebuild-bff" target up-to-date before running the build.
|
||||
// Don't do extra work during "TryCompile".
|
||||
if (isInTryCompile == BuildTryCompile::Yes) {
|
||||
return { std::move(makeCommand) };
|
||||
}
|
||||
|
||||
// Make "rebuild-bff" target up-to-date before running the build.
|
||||
std::string output;
|
||||
ExecuteFastbuildTarget(projectDir, FASTBUILD_REBUILD_BFF_TARGET_NAME, output,
|
||||
{ "-why" });
|
||||
@ -468,10 +473,10 @@ void cmGlobalFastbuildGenerator::Generate()
|
||||
|
||||
this->RemoveUnknownClangTidyExportFixesFiles();
|
||||
|
||||
if (this->GetCMakeInstance()->GetRegenerateDuringBuild()) {
|
||||
if (this->GetCMakeInstance()->GetRegenerateDuringBuild() ||
|
||||
this->GetCMakeInstance()->GetIsInTryCompile()) {
|
||||
return;
|
||||
}
|
||||
// TODO: figure out how to skip this in TryCompile
|
||||
// Make "rebuild-bff" target up-to-date after the generation.
|
||||
// This is actually a noop, it just asks CMake to touch the generated file
|
||||
// so FASTBuild would consider the target as up-to-date.
|
||||
|
||||
@ -365,8 +365,8 @@ public:
|
||||
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::vector<std::string> const& makeOptions = std::vector<std::string>(),
|
||||
BuildTryCompile isInTryCompile = BuildTryCompile::No) override;
|
||||
|
||||
std::unique_ptr<cmLocalGenerator> CreateLocalGenerator(
|
||||
cmMakefile* makefile) override;
|
||||
|
||||
@ -2161,9 +2161,10 @@ int cmGlobalGenerator::TryCompile(int jobs, std::string const& srcdir,
|
||||
cmBuildOptions defaultBuildOptions(false, fast, PackageResolveMode::Disable);
|
||||
|
||||
std::stringstream ostr;
|
||||
auto ret = this->Build(jobs, srcdir, bindir, projectName, newTarget, ostr,
|
||||
"", config, defaultBuildOptions, true,
|
||||
this->TryCompileTimeout, cmSystemTools::OUTPUT_NONE);
|
||||
auto ret =
|
||||
this->Build(jobs, srcdir, bindir, projectName, newTarget, ostr, "", config,
|
||||
defaultBuildOptions, true, this->TryCompileTimeout,
|
||||
cmSystemTools::OUTPUT_NONE, {}, BuildTryCompile::Yes);
|
||||
output = ostr.str();
|
||||
return ret;
|
||||
}
|
||||
@ -2173,7 +2174,8 @@ cmGlobalGenerator::GenerateBuildCommand(
|
||||
std::string const& /*unused*/, std::string const& /*unused*/,
|
||||
std::string const& /*unused*/, std::vector<std::string> const& /*unused*/,
|
||||
std::string const& /*unused*/, int /*unused*/, bool /*unused*/,
|
||||
cmBuildOptions /*unused*/, std::vector<std::string> const& /*unused*/)
|
||||
cmBuildOptions /*unused*/, std::vector<std::string> const& /*unused*/,
|
||||
BuildTryCompile /*unused*/)
|
||||
{
|
||||
GeneratedMakeCommand makeCommand;
|
||||
makeCommand.Add("cmGlobalGenerator::GenerateBuildCommand not implemented");
|
||||
@ -2193,7 +2195,8 @@ int cmGlobalGenerator::Build(
|
||||
std::ostream& ostr, std::string const& makeCommandCSTR,
|
||||
std::string const& config, cmBuildOptions buildOptions, bool verbose,
|
||||
cmDuration timeout, cmSystemTools::OutputOption outputMode,
|
||||
std::vector<std::string> const& nativeOptions)
|
||||
std::vector<std::string> const& nativeOptions,
|
||||
BuildTryCompile isInTryCompile)
|
||||
{
|
||||
bool hideconsole = cmSystemTools::GetRunCommandHideConsole();
|
||||
|
||||
@ -2222,7 +2225,7 @@ int cmGlobalGenerator::Build(
|
||||
|
||||
std::vector<GeneratedMakeCommand> makeCommand = this->GenerateBuildCommand(
|
||||
makeCommandCSTR, projectName, bindir, targets, realConfig, jobs, verbose,
|
||||
buildOptions, nativeOptions);
|
||||
buildOptions, nativeOptions, isInTryCompile);
|
||||
|
||||
// Workaround to convince some commands to produce output.
|
||||
if (outputMode == cmSystemTools::OUTPUT_PASSTHROUGH &&
|
||||
|
||||
@ -108,6 +108,11 @@ class cmGlobalGenerator
|
||||
{
|
||||
public:
|
||||
using LocalGeneratorVector = std::vector<std::unique_ptr<cmLocalGenerator>>;
|
||||
enum class BuildTryCompile
|
||||
{
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
|
||||
//! Free any memory allocated with the GlobalGenerator
|
||||
cmGlobalGenerator(cmake* cm);
|
||||
@ -253,14 +258,15 @@ public:
|
||||
* empty then all is assumed. clean indicates if a "make clean" should be
|
||||
* done first.
|
||||
*/
|
||||
int Build(int jobs, std::string const& srcdir, std::string const& bindir,
|
||||
std::string const& projectName,
|
||||
std::vector<std::string> const& targetNames, std::ostream& ostr,
|
||||
std::string const& makeProgram, std::string const& config,
|
||||
cmBuildOptions buildOptions, bool verbose, cmDuration timeout,
|
||||
cmSystemTools::OutputOption outputMode,
|
||||
std::vector<std::string> const& nativeOptions =
|
||||
std::vector<std::string>());
|
||||
int Build(
|
||||
int jobs, std::string const& srcdir, std::string const& bindir,
|
||||
std::string const& projectName,
|
||||
std::vector<std::string> const& targetNames, std::ostream& ostr,
|
||||
std::string const& makeProgram, std::string const& config,
|
||||
cmBuildOptions buildOptions, bool verbose, cmDuration timeout,
|
||||
cmSystemTools::OutputOption outputMode,
|
||||
std::vector<std::string> const& nativeOptions = std::vector<std::string>(),
|
||||
BuildTryCompile isInTryCompile = BuildTryCompile::No);
|
||||
|
||||
/**
|
||||
* Open a generated IDE project given the following information.
|
||||
@ -277,7 +283,8 @@ public:
|
||||
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>());
|
||||
std::vector<std::string> const& makeOptions = std::vector<std::string>(),
|
||||
BuildTryCompile isInTryCompile = BuildTryCompile::No);
|
||||
|
||||
virtual void PrintBuildCommandAdvice(std::ostream& os, int jobs) const;
|
||||
|
||||
|
||||
@ -469,7 +469,8 @@ cmGlobalGhsMultiGenerator::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*/, std::vector<std::string> const& makeOptions)
|
||||
cmBuildOptions /*buildOptions*/, std::vector<std::string> const& makeOptions,
|
||||
BuildTryCompile /*isInTryCompile*/)
|
||||
{
|
||||
GeneratedMakeCommand makeCommand;
|
||||
|
||||
|
||||
@ -87,8 +87,8 @@ protected:
|
||||
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::vector<std::string> const& makeOptions = std::vector<std::string>(),
|
||||
BuildTryCompile isInTryCompile = BuildTryCompile::No) override;
|
||||
void AddExtraIDETargets() override;
|
||||
|
||||
private:
|
||||
|
||||
@ -63,7 +63,8 @@ cmGlobalJOMMakefileGenerator::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, std::vector<std::string> const& makeOptions)
|
||||
cmBuildOptions buildOptions, std::vector<std::string> const& makeOptions,
|
||||
BuildTryCompile /*isInTryCompile*/)
|
||||
{
|
||||
std::vector<std::string> jomMakeOptions;
|
||||
|
||||
|
||||
@ -55,8 +55,8 @@ protected:
|
||||
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::vector<std::string> const& makeOptions = std::vector<std::string>(),
|
||||
BuildTryCompile isInTryCompile = BuildTryCompile::No) override;
|
||||
|
||||
private:
|
||||
void PrintCompilerAdvice(std::ostream& os, std::string const& lang,
|
||||
|
||||
@ -106,7 +106,8 @@ cmGlobalNMakeMakefileGenerator::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, std::vector<std::string> const& makeOptions)
|
||||
cmBuildOptions buildOptions, std::vector<std::string> const& makeOptions,
|
||||
BuildTryCompile /*isInTryCompile*/)
|
||||
{
|
||||
std::vector<std::string> nmakeMakeOptions;
|
||||
|
||||
|
||||
@ -62,8 +62,8 @@ protected:
|
||||
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::vector<std::string> const& makeOptions = std::vector<std::string>(),
|
||||
BuildTryCompile isInTryCompile = BuildTryCompile::No) override;
|
||||
|
||||
void PrintBuildCommandAdvice(std::ostream& os, int jobs) const override;
|
||||
|
||||
|
||||
@ -1010,7 +1010,8 @@ cmGlobalNinjaGenerator::GenerateBuildCommand(
|
||||
std::string const& /*projectDir*/,
|
||||
std::vector<std::string> const& targetNames, std::string const& config,
|
||||
int jobs, bool verbose, cmBuildOptions /*buildOptions*/,
|
||||
std::vector<std::string> const& makeOptions)
|
||||
std::vector<std::string> const& makeOptions,
|
||||
BuildTryCompile /*isInTryCompile*/)
|
||||
{
|
||||
GeneratedMakeCommand makeCommand;
|
||||
makeCommand.Add(this->SelectMakeProgram(makeProgram));
|
||||
|
||||
@ -202,8 +202,8 @@ public:
|
||||
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::vector<std::string> const& makeOptions = std::vector<std::string>(),
|
||||
BuildTryCompile isInTryCompile = BuildTryCompile::No) override;
|
||||
|
||||
// Setup target names
|
||||
char const* GetAllTargetName() const override { return "all"; }
|
||||
|
||||
@ -537,7 +537,8 @@ cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
|
||||
std::string const& /*projectDir*/,
|
||||
std::vector<std::string> const& targetNames, std::string const& /*config*/,
|
||||
int jobs, bool verbose, cmBuildOptions buildOptions,
|
||||
std::vector<std::string> const& makeOptions)
|
||||
std::vector<std::string> const& makeOptions,
|
||||
BuildTryCompile /*isInTryCompile*/)
|
||||
{
|
||||
GeneratedMakeCommand makeCommand;
|
||||
|
||||
|
||||
@ -173,8 +173,8 @@ public:
|
||||
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::vector<std::string> const& makeOptions = std::vector<std::string>(),
|
||||
BuildTryCompile isInTryCompile = BuildTryCompile::No) override;
|
||||
|
||||
/** Record per-target progress information. */
|
||||
void RecordTargetProgress(cmMakefileTargetGenerator* tg);
|
||||
|
||||
@ -1078,7 +1078,8 @@ cmGlobalVisualStudio10Generator::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, std::vector<std::string> const& makeOptions)
|
||||
cmBuildOptions buildOptions, std::vector<std::string> const& makeOptions,
|
||||
BuildTryCompile /*isInTryCompile*/)
|
||||
{
|
||||
std::vector<GeneratedMakeCommand> makeCommands;
|
||||
// Select the caller- or user-preferred make program, else MSBuild.
|
||||
|
||||
@ -39,8 +39,8 @@ public:
|
||||
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::vector<std::string> const& makeOptions = std::vector<std::string>(),
|
||||
BuildTryCompile isInTryCompile = BuildTryCompile::No) override;
|
||||
|
||||
//! create the correct local generator
|
||||
std::unique_ptr<cmLocalGenerator> CreateLocalGenerator(
|
||||
|
||||
@ -180,7 +180,8 @@ cmGlobalVisualStudio7Generator::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*/, std::vector<std::string> const& makeOptions)
|
||||
cmBuildOptions /*buildOptions*/, std::vector<std::string> const& makeOptions,
|
||||
BuildTryCompile /*isInTryCompile*/)
|
||||
{
|
||||
// Select the caller- or user-preferred make program, else devenv.
|
||||
std::string makeProgramSelected =
|
||||
|
||||
@ -73,8 +73,8 @@ public:
|
||||
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::vector<std::string> const& makeOptions = std::vector<std::string>(),
|
||||
BuildTryCompile isInTryCompile = BuildTryCompile::No) override;
|
||||
|
||||
/** Append the subdirectory for the given configuration. */
|
||||
void AppendDirectoryForConfig(std::string const& prefix,
|
||||
|
||||
@ -67,7 +67,8 @@ cmGlobalWatcomWMakeGenerator::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, std::vector<std::string> const& makeOptions)
|
||||
cmBuildOptions buildOptions, std::vector<std::string> const& makeOptions,
|
||||
BuildTryCompile /*isInTryCompile */)
|
||||
{
|
||||
return this->cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
|
||||
makeProgram, projectName, projectDir, targetNames, config,
|
||||
|
||||
@ -63,8 +63,8 @@ protected:
|
||||
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::vector<std::string> const& makeOptions = std::vector<std::string>(),
|
||||
BuildTryCompile isInTryCompile = BuildTryCompile::No) override;
|
||||
|
||||
void PrintBuildCommandAdvice(std::ostream& os, int jobs) const override;
|
||||
};
|
||||
|
||||
@ -546,7 +546,8 @@ cmGlobalXCodeGenerator::GenerateBuildCommand(
|
||||
std::string const& /*projectDir*/,
|
||||
std::vector<std::string> const& targetNames, std::string const& config,
|
||||
int jobs, bool /*verbose*/, cmBuildOptions /*buildOptions*/,
|
||||
std::vector<std::string> const& makeOptions)
|
||||
std::vector<std::string> const& makeOptions,
|
||||
BuildTryCompile /*isInTryCompile */)
|
||||
{
|
||||
std::string const xcodebuild =
|
||||
this->SelectMakeProgram(makeProgram, this->GetXcodeBuildCommand());
|
||||
|
||||
@ -82,8 +82,8 @@ public:
|
||||
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::vector<std::string> const& makeOptions = std::vector<std::string>(),
|
||||
BuildTryCompile isInTryCompile = BuildTryCompile::No) override;
|
||||
|
||||
/** Append the subdirectory for the given configuration. */
|
||||
void AppendDirectoryForConfig(std::string const& prefix,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user