mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-01-26 19:09:06 +00:00
FASTBuild: optimize generated file
List of changes: 1. Remove unneeded aliases 2. Don't write VS Solution on Apple 3. Use external script to perform clean 4. Fix small bug when empty environment was resulting in invalid file. It greatly reduces the size of .fdb file and makes FASTBuild run much faster in different cases.
This commit is contained in:
parent
d5d02f80c0
commit
4387c965a6
@ -812,8 +812,6 @@ void cmFastbuildNormalTargetGenerator::Generate()
|
||||
FastbuildTargetDep targetDep{ tname };
|
||||
if (dep->GetType() == cmStateEnums::OBJECT_LIBRARY) {
|
||||
targetDep.Type = FastbuildTargetDepType::ORDER_ONLY;
|
||||
} else {
|
||||
targetDep.Type = FastbuildTargetDepType::ALL;
|
||||
}
|
||||
fastbuildTarget.PreBuildDependencies.emplace(std::move(targetDep));
|
||||
}
|
||||
@ -908,6 +906,15 @@ void cmFastbuildNormalTargetGenerator::Generate()
|
||||
|
||||
AddStampExeIfApplicable(fastbuildTarget);
|
||||
|
||||
// size 1 means that it's not a multi-arch lib (which can only be the case on
|
||||
// Darwin).
|
||||
if (fastbuildTarget.LinkerNode.size() == 1 &&
|
||||
fastbuildTarget.LinkerNode[0].Type ==
|
||||
FastbuildLinkerNode::STATIC_LIBRARY &&
|
||||
!fastbuildTarget.PostBuildExecNodes.Nodes.empty()) {
|
||||
ProcessPostBuildForStaticLib(fastbuildTarget);
|
||||
}
|
||||
|
||||
AdditionalCleanFiles();
|
||||
|
||||
this->GetGlobalGenerator()->AddTarget(std::move(fastbuildTarget));
|
||||
@ -979,6 +986,25 @@ void cmFastbuildNormalTargetGenerator::AddStampExeIfApplicable(
|
||||
}
|
||||
}
|
||||
|
||||
void cmFastbuildNormalTargetGenerator::ProcessPostBuildForStaticLib(
|
||||
FastbuildTarget& fastbuildTarget) const
|
||||
{
|
||||
// "Library" nodes do not have "LinkerStampExe" property, so we need to be
|
||||
// clever here: create an alias that will refer to the binary as well as to
|
||||
// all post-build steps. Also, make sure that post-build steps depend on the
|
||||
// binary itself.
|
||||
LogMessage("ProcessPostBuildForStaticLib(...)");
|
||||
FastbuildAliasNode alias;
|
||||
alias.Name = std::move(fastbuildTarget.LinkerNode[0].Name);
|
||||
for (FastbuildExecNode& postBuildExec :
|
||||
fastbuildTarget.PostBuildExecNodes.Nodes) {
|
||||
postBuildExec.PreBuildDependencies.emplace(
|
||||
fastbuildTarget.LinkerNode[0].LinkerOutput);
|
||||
alias.PreBuildDependencies.emplace(postBuildExec.Name);
|
||||
}
|
||||
fastbuildTarget.AliasNodes.emplace_back(std::move(alias));
|
||||
}
|
||||
|
||||
void cmFastbuildNormalTargetGenerator::CollapseAllExecsIntoOneScriptfile(
|
||||
std::string const& scriptFileName,
|
||||
std::vector<FastbuildExecNode> const& execs) const
|
||||
@ -1203,6 +1229,9 @@ cmFastbuildNormalTargetGenerator::GenerateObjects()
|
||||
|
||||
cmSourceFile const& srcFile = *source;
|
||||
|
||||
this->GetGlobalGenerator()->AddFileToClean(cmStrCat(
|
||||
ObjectOutDir, '/', this->GeneratorTarget->GetObjectName(source)));
|
||||
|
||||
// Do not generate separate node for PCH source file.
|
||||
if (this->GeneratorTarget->GetPchSource(Config, srcFile.GetLanguage()) ==
|
||||
srcFile.GetFullPath()) {
|
||||
@ -1540,8 +1569,10 @@ void cmFastbuildNormalTargetGenerator::AppendPrebuildDeps(
|
||||
LogMessage("Adding dep to " + fastbuildTargetName);
|
||||
linkerNode.PreBuildDependencies.insert(std::move(fastbuildTargetName));
|
||||
} else {
|
||||
LogMessage("Adding dep " + linkDep + " for sorting");
|
||||
linkerNode.PreBuildDependencies.insert(linkDep);
|
||||
if (!cmIsNOTFOUND(linkDep)) {
|
||||
LogMessage("Adding dep " + linkDep + " for sorting");
|
||||
linkerNode.PreBuildDependencies.insert(linkDep);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1753,6 +1784,9 @@ void cmFastbuildNormalTargetGenerator::AddLipoCommand(FastbuildTarget& target)
|
||||
FastbuildExecNode exec;
|
||||
exec.ExecExecutable = lipo;
|
||||
exec.ExecOutput = target.RealOutput;
|
||||
if (exec.ExecOutput != target.Name) {
|
||||
exec.Name = target.Name;
|
||||
}
|
||||
for (auto const& ArchSpecificTarget : target.LinkerNode) {
|
||||
exec.ExecInput.emplace_back(ArchSpecificTarget.LinkerOutput);
|
||||
}
|
||||
|
||||
@ -113,6 +113,7 @@ private:
|
||||
std::vector<FastbuildExecNode> GetSymlinkExecs() const;
|
||||
void ProcessManifests(FastbuildLinkerNode& linkerNode) const;
|
||||
void AddStampExeIfApplicable(FastbuildTarget& fastbuildTarget) const;
|
||||
void ProcessPostBuildForStaticLib(FastbuildTarget& fastbuildTarget) const;
|
||||
void CollapseAllExecsIntoOneScriptfile(
|
||||
std::string const& scriptFileName,
|
||||
std::vector<FastbuildExecNode> const& execs) const;
|
||||
|
||||
@ -678,8 +678,6 @@ FastbuildExecNodes cmFastbuildTargetGenerator::GenerateCommands(
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@ -108,9 +108,7 @@ void cmFastbuildUtilityTargetGenerator::Generate()
|
||||
"-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));
|
||||
exec.PreBuildDependencies.emplace(dep->GetName());
|
||||
}
|
||||
this->GetGlobalGenerator()->AddTarget(std::move(exec));
|
||||
}
|
||||
|
||||
@ -92,12 +92,6 @@ void FastbuildTarget::GenerateAliases()
|
||||
this->DependenciesAlias.PreBuildDependencies.emplace(dep);
|
||||
}
|
||||
}
|
||||
// Build.
|
||||
if (!this->LinkerNode.empty() &&
|
||||
this->LinkerNode[0].Type != FastbuildLinkerNode::NONE) {
|
||||
this->BuildAlias = generateAlias(this->Name, FASTBUILD_BUILD_ALIAS_POSTFIX,
|
||||
this->LinkerNode);
|
||||
}
|
||||
|
||||
// PRE/POST/REST
|
||||
if (!this->PreBuildExecNodes.PreBuildDependencies.empty()) {
|
||||
@ -117,73 +111,21 @@ void FastbuildTarget::GenerateAliases()
|
||||
this->ExecNodes.Name = this->Name + FASTBUILD_CUSTOM_COMMAND_ALIAS_POSTFIX;
|
||||
}
|
||||
|
||||
// -all.
|
||||
FastbuildAliasNode allAlias;
|
||||
allAlias.Name = this->Name + FASTBUILD_ALL_ALIAS_POSTFIX;
|
||||
|
||||
auto const addToAll = [&allAlias](FastbuildAliasNode const& node) {
|
||||
if (!node.PreBuildDependencies.empty()) {
|
||||
allAlias.PreBuildDependencies.emplace(node.Name);
|
||||
}
|
||||
};
|
||||
// Add "-pre" nodes first, so we wait for all generations when building
|
||||
// "-all".
|
||||
for (FastbuildAliasNode const& execs : {
|
||||
PreBuildExecNodes,
|
||||
PreLinkExecNodes.Alias,
|
||||
}) {
|
||||
addToAll(execs);
|
||||
}
|
||||
|
||||
// -build.
|
||||
addToAll(this->BuildAlias);
|
||||
for (FastbuildAliasNode const& node : AliasNodes) {
|
||||
addToAll(node);
|
||||
}
|
||||
|
||||
for (FastbuildAliasNode const& execs : { ExecNodes }) {
|
||||
addToAll(execs);
|
||||
}
|
||||
|
||||
bool const hasStampExeProperty = !this->LinkerNode.empty() &&
|
||||
(this->LinkerNode[0].Type == FastbuildLinkerNode::EXECUTABLE ||
|
||||
this->LinkerNode[0].Type == FastbuildLinkerNode::SHARED_LIBRARY);
|
||||
// If we have .LinkerStampExe - we will use it to execute POST_BUILD steps,
|
||||
// so don't add them to "-all".
|
||||
if (!hasStampExeProperty) {
|
||||
addToAll(this->PostBuildExecNodes.Alias);
|
||||
}
|
||||
|
||||
// Tested in "RunCMake.VerifyHeaderSets" test.
|
||||
if (allAlias.PreBuildDependencies.empty()) {
|
||||
addToAll(DependenciesAlias);
|
||||
}
|
||||
|
||||
for (auto const& objectList : this->ObjectListNodes) {
|
||||
allAlias.PreBuildDependencies.emplace(objectList.Name);
|
||||
}
|
||||
|
||||
for (auto const& linkerNode : this->LinkerNode) {
|
||||
allAlias.PreBuildDependencies.emplace(linkerNode.Name);
|
||||
}
|
||||
|
||||
// Absolutely empty target. But we still should be able to "build" it.
|
||||
if (allAlias.PreBuildDependencies.empty()) {
|
||||
allAlias.PreBuildDependencies.emplace(FASTBUILD_NOOP_FILE_NAME);
|
||||
}
|
||||
|
||||
AliasNodes.emplace_back(std::move(allAlias));
|
||||
// In case we want to build the target by name, but we don't have any output.
|
||||
// OR we have two arches and real output does not match target name (it can
|
||||
// match if lipo produces such file).
|
||||
// RunCMake.CMakePackage / RunCMake.XcFramework
|
||||
if ((this->LinkerNode.size() > 1 && this->RealOutput != this->Name) ||
|
||||
this->RealOutput.empty()) {
|
||||
// If we don't have any node that we can build by name (e.g. no static /
|
||||
// dynamic lib or executable) -> create an alias so that we can build this
|
||||
// target by name.
|
||||
if (LinkerNode.empty()) {
|
||||
FastbuildAliasNode alias;
|
||||
alias.Name = this->Name;
|
||||
FastbuildTargetDep dep{ this->Name };
|
||||
dep.Type = FastbuildTargetDepType::ALL;
|
||||
alias.PreBuildDependencies = { std::move(dep) };
|
||||
if (LinkerNode.empty()) {
|
||||
for (FastbuildObjectListNode const& objListNode : ObjectListNodes) {
|
||||
alias.PreBuildDependencies.emplace(objListNode.Name);
|
||||
}
|
||||
} else {
|
||||
for (FastbuildLinkerNode const& linkerNode : LinkerNode) {
|
||||
alias.PreBuildDependencies.emplace(linkerNode.Name);
|
||||
}
|
||||
}
|
||||
AliasNodes.emplace_back(std::move(alias));
|
||||
}
|
||||
|
||||
@ -197,9 +139,9 @@ void FastbuildTarget::GenerateAliases()
|
||||
if (linkerNode.Type == FastbuildLinkerNode::SHARED_LIBRARY ||
|
||||
linkerNode.Type == FastbuildLinkerNode::STATIC_LIBRARY ||
|
||||
linkerNode.Type == FastbuildLinkerNode::EXECUTABLE) {
|
||||
std::string name = FASTBUILD_LINK_ARTIFACTS_ALIAS_POSTFIX;
|
||||
std::string postfix = FASTBUILD_LINK_ARTIFACTS_ALIAS_POSTFIX;
|
||||
if (!linkerNode.Arch.empty()) {
|
||||
name += cmStrCat('-', linkerNode.Arch);
|
||||
postfix += cmStrCat('-', linkerNode.Arch);
|
||||
}
|
||||
#ifdef _WIN32
|
||||
// On Windows DLL and Executables must be linked via Import Lib file
|
||||
@ -214,9 +156,10 @@ void FastbuildTarget::GenerateAliases()
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
AliasNodes.emplace_back(
|
||||
generateAlias(this->Name, name.c_str(),
|
||||
std::vector<FastbuildLinkerNode>{ linkerNode }));
|
||||
FastbuildAliasNode alias;
|
||||
alias.Name = this->Name + postfix;
|
||||
alias.PreBuildDependencies.emplace(linkerNode.LinkerOutput);
|
||||
AliasNodes.emplace_back(std::move(alias));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -714,14 +657,7 @@ struct WrapHelper
|
||||
}
|
||||
std::string operator()(FastbuildTargetDep const& in)
|
||||
{
|
||||
std::string res = in.Name;
|
||||
if (in.Type == FastbuildTargetDepType::ALL) {
|
||||
res += FASTBUILD_ALL_ALIAS_POSTFIX;
|
||||
} else if (in.Type == FastbuildTargetDepType::BUILD) {
|
||||
res += FASTBUILD_BUILD_ALIAS_POSTFIX;
|
||||
}
|
||||
|
||||
return (*this)(std::move(res));
|
||||
return (*this)(in.Name);
|
||||
}
|
||||
};
|
||||
template <class T>
|
||||
@ -916,7 +852,9 @@ void cmGlobalFastbuildGenerator::WriteCompilers()
|
||||
if (compilerDef.DontUseEnv) {
|
||||
LogMessage("Not using system environment");
|
||||
} else {
|
||||
WriteVariable("Environment", "." FASTBUILD_ENV_VAR_NAME, 1);
|
||||
if (!LocalEnvironment.empty()) {
|
||||
WriteVariable("Environment", "." FASTBUILD_ENV_VAR_NAME, 1);
|
||||
}
|
||||
}
|
||||
if (!compilerDef.ExtraFiles.empty()) {
|
||||
// Do not escape '$' sign, CMAKE_${LANG}_FASTBUILD_EXTRA_FILES might
|
||||
@ -1196,7 +1134,9 @@ void cmGlobalFastbuildGenerator::WriteLinker(
|
||||
LinkerNode.Type == FastbuildLinkerNode::EXECUTABLE ? "Executable"
|
||||
: LinkerNode.Type == FastbuildLinkerNode::SHARED_LIBRARY ? "DLL"
|
||||
: "Library",
|
||||
LinkerNode.Name != LinkerNode.LinkerOutput ? Quote(LinkerNode.Name) : "",
|
||||
(!LinkerNode.Name.empty() && LinkerNode.Name != LinkerNode.LinkerOutput)
|
||||
? Quote(LinkerNode.Name)
|
||||
: "",
|
||||
1);
|
||||
Indent(1);
|
||||
*BuildFileStream << "{\n";
|
||||
@ -1347,9 +1287,6 @@ void cmGlobalFastbuildGenerator::WriteTarget(FastbuildTarget const& target)
|
||||
}
|
||||
}
|
||||
|
||||
// -build.
|
||||
this->WriteAlias(target.BuildAlias);
|
||||
|
||||
if (!target.PostBuildExecNodes.Nodes.empty()) {
|
||||
for (auto const& exec : target.PostBuildExecNodes.Nodes) {
|
||||
this->WriteExec(exec);
|
||||
@ -1365,11 +1302,12 @@ void cmGlobalFastbuildGenerator::WriteTarget(FastbuildTarget const& target)
|
||||
void cmGlobalFastbuildGenerator::WriteIDEProjects()
|
||||
{
|
||||
for (auto const& proj : IDEProjects) {
|
||||
(void)proj;
|
||||
// VS
|
||||
#if defined(_WIN32)
|
||||
auto const& VSProj = proj.second.first;
|
||||
WriteCommand("VCXProject", Quote(VSProj.Alias));
|
||||
*this->BuildFileStream << "{\n";
|
||||
|
||||
WriteVariable("ProjectOutput", Quote(VSProj.ProjectOutput), 1);
|
||||
WriteIDEProjectConfig(VSProj.ProjectConfigs);
|
||||
WriteVSBuildCommands();
|
||||
@ -1377,22 +1315,21 @@ void cmGlobalFastbuildGenerator::WriteIDEProjects()
|
||||
*this->BuildFileStream << "}\n\n";
|
||||
|
||||
// XCode
|
||||
// On Windows Xcode project's nested paths can become too long.
|
||||
#if !defined(_WIN32)
|
||||
#elif defined(__APPLE__)
|
||||
auto const& XCodeProj = proj.second.second;
|
||||
WriteCommand("XCodeProject", Quote(XCodeProj.Alias), 0);
|
||||
*this->BuildFileStream << "{\n";
|
||||
WriteVariable("ProjectOutput", Quote(XCodeProj.ProjectOutput), 1);
|
||||
WriteIDEProjectConfig(XCodeProj.ProjectConfigs);
|
||||
WriteXCodeBuildCommands();
|
||||
|
||||
WriteIDEProjectCommon(XCodeProj);
|
||||
*this->BuildFileStream << "}\n\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
this->WriteSolution();
|
||||
#if !defined(_WIN32)
|
||||
#elif defined(__APPLE__)
|
||||
this->WriteXCodeTopLevelProject();
|
||||
#endif
|
||||
}
|
||||
@ -1459,18 +1396,12 @@ void cmGlobalFastbuildGenerator::AddTargetAll()
|
||||
FastbuildAliasNode allAliasNode;
|
||||
allAliasNode.Name = FASTBUILD_ALL_TARGET_NAME;
|
||||
|
||||
FastbuildTarget allTarget;
|
||||
allTarget.Name = allTarget.Name = FASTBUILD_ALL_TARGET_NAME;
|
||||
allTarget.IsGlobal = true;
|
||||
|
||||
for (auto const& targetBase : FastbuildTargets) {
|
||||
if (targetBase->Type == FastbuildTargetType::LINK) {
|
||||
auto const& target = static_cast<FastbuildTarget const&>(*targetBase);
|
||||
// Add non-global and non-excluded targets to "all"
|
||||
if (!target.IsGlobal && !target.ExcludeFromAll) {
|
||||
allAliasNode.PreBuildDependencies.emplace(target.Name +
|
||||
FASTBUILD_ALL_ALIAS_POSTFIX);
|
||||
allTarget.PreBuildDependencies.emplace(target.Name);
|
||||
allAliasNode.PreBuildDependencies.emplace(target.Name);
|
||||
}
|
||||
} else if (targetBase->Type == FastbuildTargetType::ALIAS) {
|
||||
auto const& target = static_cast<FastbuildAliasNode const&>(*targetBase);
|
||||
@ -1482,8 +1413,7 @@ void cmGlobalFastbuildGenerator::AddTargetAll()
|
||||
if (allAliasNode.PreBuildDependencies.empty()) {
|
||||
allAliasNode.PreBuildDependencies.emplace(FASTBUILD_NOOP_FILE_NAME);
|
||||
}
|
||||
allTarget.AliasNodes.emplace_back(std::move(allAliasNode));
|
||||
this->AddTarget(std::move(allTarget));
|
||||
this->AddTarget(std::move(allAliasNode));
|
||||
}
|
||||
|
||||
void cmGlobalFastbuildGenerator::AddGlobCheckExec()
|
||||
@ -1639,63 +1569,47 @@ void cmGlobalFastbuildGenerator::WriteTargetRebuildBFF()
|
||||
this->WriteExec(rebuildBFF, 0);
|
||||
}
|
||||
|
||||
void cmGlobalFastbuildGenerator::WriteCleanScript()
|
||||
{
|
||||
std::string const path =
|
||||
cmStrCat(this->GetCMakeInstance()->GetHomeOutputDirectory(), '/',
|
||||
FASTBUILD_CLEAN_SCRIPT_NAME);
|
||||
cmsys::ofstream scriptFile(path.c_str(), std::ios::out | std::ios::binary);
|
||||
if (!scriptFile.is_open()) {
|
||||
cmSystemTools::Error("Failed to open: " FASTBUILD_CLEAN_SCRIPT_NAME);
|
||||
return;
|
||||
}
|
||||
for (std::string const& file : AllFilesToClean) {
|
||||
#if defined(_WIN32)
|
||||
scriptFile << "del /f /q "
|
||||
<< cmSystemTools::ConvertToWindowsOutputPath(file) << "\n";
|
||||
#else
|
||||
scriptFile << "rm -f " << file << '\n';
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void cmGlobalFastbuildGenerator::WriteTargetClean()
|
||||
{
|
||||
WriteCommand("RemoveDir", Quote(FASTBUILD_CLEAN_TARGET_NAME));
|
||||
*BuildFileStream << "{\n";
|
||||
|
||||
WriteVariable("RemoveDirs", "false", 1);
|
||||
WriteVariable("RemovePathsRecurse", "false", 1);
|
||||
|
||||
std::vector<std::string> removePatterns{
|
||||
"*" FASTBUILD_DUMMY_OUTPUT_EXTENSION
|
||||
};
|
||||
std::vector<std::string> langs;
|
||||
this->GetEnabledLanguages(langs);
|
||||
for (auto const& lang : langs) {
|
||||
auto const extension = this->GetSafeGlobalSetting(
|
||||
cmStrCat("CMAKE_", lang, "_OUTPUT_EXTENSION"));
|
||||
if (!extension.empty() &&
|
||||
std::find(removePatterns.begin(), removePatterns.end(),
|
||||
'*' + extension) == removePatterns.end()) {
|
||||
removePatterns.emplace_back('*' + extension);
|
||||
}
|
||||
if (AllFilesToClean.empty()) {
|
||||
FastbuildAliasNode clean;
|
||||
clean.Name = FASTBUILD_CLEAN_TARGET_NAME;
|
||||
clean.PreBuildDependencies.emplace(FASTBUILD_CLEAN_FILE_NAME);
|
||||
WriteAlias(clean, 0);
|
||||
return;
|
||||
}
|
||||
auto const PchExtension = this->GetSafeGlobalSetting("CMAKE_PCH_EXTENSION");
|
||||
if (!PchExtension.empty()) {
|
||||
removePatterns.emplace_back('*' + PchExtension);
|
||||
}
|
||||
auto const buildDir = this->GetCMakeInstance()->GetHomeOutputDirectory();
|
||||
if (!AllFilesToClean.empty()) {
|
||||
for (auto const& file : AllFilesToClean) {
|
||||
auto const path = cmSystemTools::GetFilenamePath(file);
|
||||
// Since we don't recurse (to not delete unrelated .obj), need to add
|
||||
// full path to the file.
|
||||
// Tested in "ExternalOBJ" test.
|
||||
if (!path.empty()) {
|
||||
AllFoldersToClean.emplace(cmStrCat(buildDir, '/', path));
|
||||
}
|
||||
removePatterns.emplace_back('*' + cmSystemTools::GetFilenameName(file));
|
||||
}
|
||||
}
|
||||
|
||||
WriteArray("RemovePatterns", Wrap(removePatterns), 1);
|
||||
|
||||
std::vector<std::string> tmp;
|
||||
|
||||
std::move(AllFilesToKeep.begin(), AllFilesToKeep.end(),
|
||||
std::back_inserter(tmp));
|
||||
if (!tmp.empty()) {
|
||||
WriteArray("RemoveExcludeFiles", Wrap(tmp), 1);
|
||||
tmp.clear();
|
||||
}
|
||||
|
||||
tmp.emplace_back(buildDir);
|
||||
std::move(AllFoldersToClean.begin(), AllFoldersToClean.end(),
|
||||
std::back_inserter(tmp));
|
||||
WriteArray("RemovePaths", Wrap(tmp), 1);
|
||||
|
||||
*BuildFileStream << "}\n";
|
||||
WriteCleanScript();
|
||||
FastbuildExecNode clean;
|
||||
clean.Name = FASTBUILD_CLEAN_TARGET_NAME;
|
||||
clean.ExecExecutable = GetExternalShellExecutable();
|
||||
clean.ExecArguments =
|
||||
FASTBUILD_SCRIPT_FILE_ARG FASTBUILD_1_INPUT_PLACEHOLDER;
|
||||
clean.ExecInput = { FASTBUILD_CLEAN_SCRIPT_NAME };
|
||||
clean.ExecAlways = true;
|
||||
clean.ExecUseStdOutAsOutput = true;
|
||||
clean.ExecOutput = FASTBUILD_CLEAN_FILE_NAME;
|
||||
clean.ExecWorkingDir = this->GetCMakeInstance()->GetHomeOutputDirectory();
|
||||
WriteExec(clean, 0);
|
||||
}
|
||||
|
||||
void cmGlobalFastbuildGenerator::WriteTargets()
|
||||
@ -1708,6 +1622,9 @@ void cmGlobalFastbuildGenerator::WriteTargets()
|
||||
cmSystemTools::Touch(cmStrCat(this->CMakeInstance->GetHomeOutputDirectory(),
|
||||
'/', FASTBUILD_NOOP_FILE_NAME),
|
||||
true);
|
||||
cmSystemTools::Touch(cmStrCat(this->CMakeInstance->GetHomeOutputDirectory(),
|
||||
'/', FASTBUILD_CLEAN_FILE_NAME),
|
||||
true);
|
||||
// Add "all" utility target before sorting, so we can correctly sort
|
||||
// targets that depend on it
|
||||
AddTargetAll();
|
||||
@ -1724,11 +1641,6 @@ void cmGlobalFastbuildGenerator::WriteTargets()
|
||||
this->WriteExec(static_cast<FastbuildExecNode const&>(*targetBase));
|
||||
} else if (targetBase->Type == FastbuildTargetType::ALIAS) {
|
||||
this->WriteAlias(static_cast<FastbuildAliasNode const&>(*targetBase));
|
||||
// CustomCommandByproducts test.
|
||||
FastbuildAliasNode alias;
|
||||
alias.Name = targetBase->Name + FASTBUILD_ALL_ALIAS_POSTFIX;
|
||||
alias.PreBuildDependencies.emplace(targetBase->Name);
|
||||
this->WriteAlias(alias);
|
||||
} else if (targetBase->Type == FastbuildTargetType::LINK) {
|
||||
auto const& target = static_cast<FastbuildTarget const&>(*targetBase);
|
||||
this->WriteTarget(target);
|
||||
|
||||
@ -53,8 +53,6 @@ struct cmDocumentationEntry;
|
||||
#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"
|
||||
@ -66,8 +64,6 @@ struct cmDocumentationEntry;
|
||||
// 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_"
|
||||
@ -81,6 +77,7 @@ struct cmDocumentationEntry;
|
||||
#define FASTBUILD_CLEAN_TARGET_NAME "clean"
|
||||
|
||||
#define FASTBUILD_NOOP_FILE_NAME "fbuild_noop"
|
||||
#define FASTBUILD_CLEAN_FILE_NAME "fbuild_clean-out"
|
||||
|
||||
#define FASTBUILD_BUILD_FILE "fbuild.bff"
|
||||
|
||||
@ -90,23 +87,25 @@ struct cmDocumentationEntry;
|
||||
# define FASTBUILD_SCRIPT_FILE_EXTENSION ".bat"
|
||||
# define FASTBUILD_SCRIPT_FILE_ARG "/C "
|
||||
# define FASTBUILD_SCRIPT_CD "cd /D "
|
||||
# define FASTBUILD_CLEAN_SCRIPT_NAME "clean" FASTBUILD_SCRIPT_FILE_EXTENSION
|
||||
#else
|
||||
# define FASTBUILD_SCRIPT_FILE_EXTENSION ".sh"
|
||||
# define FASTBUILD_SCRIPT_FILE_ARG ""
|
||||
# define FASTBUILD_SCRIPT_CD "cd "
|
||||
# define FASTBUILD_CLEAN_SCRIPT_NAME "clean" FASTBUILD_SCRIPT_FILE_EXTENSION
|
||||
#endif
|
||||
|
||||
enum class FastbuildTargetDepType
|
||||
{
|
||||
ALL,
|
||||
BUILD,
|
||||
// Order-only dependency that is not going to appear in the generated file.
|
||||
ORDER_ONLY,
|
||||
NONE,
|
||||
// Regular target dep.
|
||||
REGULAR,
|
||||
};
|
||||
struct FastbuildTargetDep
|
||||
{
|
||||
std::string Name;
|
||||
FastbuildTargetDepType Type = FastbuildTargetDepType::NONE;
|
||||
FastbuildTargetDepType Type = FastbuildTargetDepType::REGULAR;
|
||||
FastbuildTargetDep(std::string n)
|
||||
: Name(std::move(n))
|
||||
{
|
||||
@ -308,9 +307,6 @@ struct FastbuildTarget : public FastbuildTargetBase
|
||||
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;
|
||||
@ -517,6 +513,7 @@ public:
|
||||
void WriteSolution();
|
||||
void WriteXCodeTopLevelProject();
|
||||
void WriteTargetRebuildBFF();
|
||||
void WriteCleanScript();
|
||||
void WriteTargetClean();
|
||||
|
||||
void AddTargetAll();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user