diff options
Diffstat (limited to 'contrib/llvm/utils/FileUpdate')
-rw-r--r-- | contrib/llvm/utils/FileUpdate/CMakeLists.txt | 11 | ||||
-rw-r--r-- | contrib/llvm/utils/FileUpdate/FileUpdate.cpp | 87 | ||||
-rw-r--r-- | contrib/llvm/utils/FileUpdate/Makefile | 21 |
3 files changed, 0 insertions, 119 deletions
diff --git a/contrib/llvm/utils/FileUpdate/CMakeLists.txt b/contrib/llvm/utils/FileUpdate/CMakeLists.txt deleted file mode 100644 index bacbd16..0000000 --- a/contrib/llvm/utils/FileUpdate/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -add_executable(FileUpdate - FileUpdate.cpp - ) - -target_link_libraries(FileUpdate LLVMSupport LLVMSystem) -if( MINGW ) - target_link_libraries(FileUpdate imagehlp psapi) -endif( MINGW ) -if( LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD ) - target_link_libraries(FileUpdate pthread) -endif() diff --git a/contrib/llvm/utils/FileUpdate/FileUpdate.cpp b/contrib/llvm/utils/FileUpdate/FileUpdate.cpp deleted file mode 100644 index 2cf366f..0000000 --- a/contrib/llvm/utils/FileUpdate/FileUpdate.cpp +++ /dev/null @@ -1,87 +0,0 @@ -//===- FileUpdate.cpp - Conditionally update a file -----------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// FileUpdate is a utility for conditionally updating a file from its input -// based on whether the input differs from the output. It is used to avoid -// unnecessary modifications in a build system. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/PrettyStackTrace.h" -#include "llvm/Support/raw_ostream.h" -#include "llvm/System/Signals.h" -using namespace llvm; - -static cl::opt<bool> -Quiet("quiet", cl::desc("Don't print unnecessary status information"), - cl::init(false)); - -static cl::opt<std::string> -InputFilename("input-file", cl::desc("Input file (defaults to stdin)"), - cl::init("-"), cl::value_desc("filename")); - -static cl::opt<std::string> -OutputFilename(cl::Positional, cl::desc("<output-file>"), cl::Required); - -int main(int argc, char **argv) { - sys::PrintStackTraceOnErrorSignal(); - PrettyStackTraceProgram X(argc, argv); - cl::ParseCommandLineOptions(argc, argv); - - if (OutputFilename == "-") { - errs() << argv[0] << ": error: Can't update standard output\n"; - return 1; - } - - // Get the input data. - std::string ErrorStr; - MemoryBuffer *In = - MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), &ErrorStr); - if (In == 0) { - errs() << argv[0] << ": error: Unable to get input '" - << InputFilename << "': " << ErrorStr << '\n'; - return 1; - } - - // Get the output data. - MemoryBuffer *Out = MemoryBuffer::getFile(OutputFilename.c_str(), &ErrorStr); - - // If the output exists and the contents match, we are done. - if (Out && In->getBufferSize() == Out->getBufferSize() && - memcmp(In->getBufferStart(), Out->getBufferStart(), - Out->getBufferSize()) == 0) { - if (!Quiet) - errs() << argv[0] << ": Not updating '" << OutputFilename - << "', contents match input.\n"; - return 0; - } - - delete Out; - - // Otherwise, overwrite the output. - if (!Quiet) - errs() << argv[0] << ": Updating '" << OutputFilename - << "', contents changed.\n"; - tool_output_file OutStream(OutputFilename.c_str(), ErrorStr, - raw_fd_ostream::F_Binary); - if (!ErrorStr.empty()) { - errs() << argv[0] << ": Unable to write output '" - << OutputFilename << "': " << ErrorStr << '\n'; - return 1; - } - - OutStream.os().write(In->getBufferStart(), In->getBufferSize()); - - // Declare success. - OutStream.keep(); - - return 0; -} diff --git a/contrib/llvm/utils/FileUpdate/Makefile b/contrib/llvm/utils/FileUpdate/Makefile deleted file mode 100644 index 5b545c2..0000000 --- a/contrib/llvm/utils/FileUpdate/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -##===- utils/FileUpdate/Makefile ---------------------------*- Makefile -*-===## -# -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. -# -##===----------------------------------------------------------------------===## - -LEVEL = ../.. -TOOLNAME = FileUpdate -USEDLIBS = LLVMSupport.a LLVMSystem.a - -# This tool has no plugins, optimize startup time. -TOOL_NO_EXPORTS = 1 - -# Don't install this utility -NO_INSTALL = 1 - -include $(LEVEL)/Makefile.common - |