mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
05dc27715d
This commit introduces some changes to how the revng pipeline handles serializing to disk. Specificaly: * Pipeline globals (specifically model.yml) are better handled if they are in a subdirectory. They are now saved in the "context" subdirectory. * In python:revng.api the pipeline is serialized whenever there is a non-reproducible change to the state (e.g. binary upload or model change). In the case of analyses this is done conservatively by checking that the diff produced is not empty. * The logic for computing a step's subdirectory has been moved to the pipeline runner, consequently if a step is asked to serialize it will not create any subdirectories. * Functionality for saving a single step/context has been exposed in Pipeline C. * Finally, all path concatenations are now handled by llvm::sys::path::append, for extra os-agnosticism.
39 lines
1.0 KiB
C++
39 lines
1.0 KiB
C++
/// \file GlobalsMap.cpp
|
|
/// \brief GlobalsMap methods implementations
|
|
|
|
//
|
|
// This file is distributed under the MIT License. See LICENSE.md for details.
|
|
//
|
|
|
|
#include <system_error>
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
#include "llvm/Support/FileSystem.h"
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
#include "revng/Pipeline/GlobalsMap.h"
|
|
|
|
using namespace std;
|
|
using namespace pipeline;
|
|
using namespace llvm;
|
|
|
|
llvm::Error GlobalsMap::storeToDisk(llvm::StringRef Path) const {
|
|
for (const auto &Global : Map) {
|
|
llvm::SmallString<128> Filename;
|
|
llvm::sys::path::append(Filename, Path, Global.first());
|
|
if (auto E = Global.second->storeToDisk(Filename); !!E)
|
|
return E;
|
|
}
|
|
return llvm::Error::success();
|
|
}
|
|
|
|
llvm::Error GlobalsMap::loadFromDisk(llvm::StringRef Path) {
|
|
for (const auto &Global : Map) {
|
|
llvm::SmallString<128> Filename;
|
|
llvm::sys::path::append(Filename, Path, Global.first());
|
|
if (auto E = Global.second->loadFromDisk(Filename); !!E)
|
|
return E;
|
|
}
|
|
return llvm::Error::success();
|
|
}
|