| 859 | } |
| 860 | |
| 861 | void cmMakefile::RunListFile(cmListFile const& listFile, |
| 862 | std::string const& filenametoread, |
| 863 | DeferCommands* defer) |
| 864 | { |
| 865 | // add this list file to the list of dependencies |
| 866 | this->ListFiles.push_back(filenametoread); |
| 867 | |
| 868 | // Run the parsed commands. |
| 869 | size_t const numberFunctions = listFile.Functions.size(); |
| 870 | for (size_t i = 0; i < numberFunctions; ++i) { |
| 871 | cmExecutionStatus status(*this); |
| 872 | this->ExecuteCommand(listFile.Functions[i], status); |
| 873 | if (cmSystemTools::GetFatalErrorOccurred()) { |
| 874 | break; |
| 875 | } |
| 876 | if (status.HasExitCode()) { |
| 877 | // cmake_language EXIT was requested, early break. |
| 878 | this->GetCMakeInstance()->SetScriptModeExitCode(status.GetExitCode()); |
| 879 | break; |
| 880 | } |
| 881 | if (status.GetReturnInvoked()) { |
| 882 | this->RaiseScope(status.GetReturnVariables()); |
| 883 | // Exit early due to return command. |
| 884 | break; |
| 885 | } |
| 886 | } |
| 887 | |
| 888 | // Run any deferred commands. |
| 889 | if (defer) { |
| 890 | // Add a backtrace level indicating calls are deferred. |
| 891 | DeferScope scope(this, filenametoread); |
| 892 | |
| 893 | // Iterate by index in case one deferred call schedules another. |
| 894 | // NOLINTNEXTLINE(modernize-loop-convert) |
| 895 | for (size_t i = 0; i < defer->Commands.size(); ++i) { |
| 896 | DeferCommand& d = defer->Commands[i]; |
| 897 | if (d.Id.empty()) { |
| 898 | // Canceled. |
| 899 | continue; |
| 900 | } |
| 901 | // Mark as executed. |
| 902 | std::string id = std::move(d.Id); |
| 903 | |
| 904 | // The deferred call may have come from another file. |
| 905 | DeferCallScope callScope(this, d.FilePath); |
| 906 | |
| 907 | cmExecutionStatus status(*this); |
| 908 | this->ExecuteCommand(d.Command, status, std::move(id)); |
| 909 | if (cmSystemTools::GetFatalErrorOccurred()) { |
| 910 | break; |
| 911 | } |
| 912 | } |
| 913 | } |
| 914 | } |
| 915 | |
| 916 | void cmMakefile::EnforceDirectoryLevelRules() const |
| 917 | { |
no test coverage detected