| 26 | }; |
| 27 | |
| 28 | void cmVariableWatchCommandVariableAccessed(std::string const& variable, |
| 29 | int access_type, void* client_data, |
| 30 | char const* newValue, |
| 31 | cmMakefile const* mf) |
| 32 | { |
| 33 | cmVariableWatchCallbackData* data = |
| 34 | static_cast<cmVariableWatchCallbackData*>(client_data); |
| 35 | |
| 36 | if (data->InCallback) { |
| 37 | return; |
| 38 | } |
| 39 | data->InCallback = true; |
| 40 | |
| 41 | auto accessString = cmVariableWatch::GetAccessAsString(access_type); |
| 42 | |
| 43 | /// Ultra bad!! |
| 44 | cmMakefile* makefile = const_cast<cmMakefile*>(mf); |
| 45 | |
| 46 | std::string stack = *mf->GetProperty("LISTFILE_STACK"); |
| 47 | if (!data->Command.empty()) { |
| 48 | cmValue const currentListFile = |
| 49 | mf->GetDefinition("CMAKE_CURRENT_LIST_FILE"); |
| 50 | auto const fakeLineNo = |
| 51 | std::numeric_limits<decltype(cmListFileArgument::Line)>::max(); |
| 52 | |
| 53 | std::vector<cmListFileArgument> newLFFArgs{ |
| 54 | { variable, cmListFileArgument::Quoted, fakeLineNo }, |
| 55 | { accessString, cmListFileArgument::Quoted, fakeLineNo }, |
| 56 | { newValue ? newValue : "", cmListFileArgument::Quoted, fakeLineNo }, |
| 57 | { *currentListFile, cmListFileArgument::Quoted, fakeLineNo }, |
| 58 | { stack, cmListFileArgument::Quoted, fakeLineNo } |
| 59 | }; |
| 60 | |
| 61 | cmListFileFunction newLFF{ data->Command, fakeLineNo, fakeLineNo, |
| 62 | std::move(newLFFArgs) }; |
| 63 | cmExecutionStatus status(*makefile); |
| 64 | if (!makefile->ExecuteCommand(newLFF, status)) { |
| 65 | cmSystemTools::Error( |
| 66 | cmStrCat("Error in cmake code at\nUnknown:0:\nA command failed " |
| 67 | "during the invocation of callback \"", |
| 68 | data->Command, "\".")); |
| 69 | } |
| 70 | } else { |
| 71 | makefile->IssueMessage( |
| 72 | MessageType::LOG, |
| 73 | cmStrCat("Variable \"", variable, "\" was accessed using ", accessString, |
| 74 | " with value \"", (newValue ? newValue : ""), "\".")); |
| 75 | } |
| 76 | |
| 77 | data->InCallback = false; |
| 78 | } |
| 79 | |
| 80 | void deleteVariableWatchCallbackData(void* client_data) |
| 81 | { |
nothing calls this directly
no test coverage detected
searching dependent graphs…