ArchiveWriter.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- ArchiveWriter.h - ar archive file format writer ----------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // Declares the writeArchive function for writing an archive file.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_OBJECT_ARCHIVEWRITER_H
  18. #define LLVM_OBJECT_ARCHIVEWRITER_H
  19. #include "llvm/Object/Archive.h"
  20. namespace llvm {
  21. struct NewArchiveMember {
  22. std::unique_ptr<MemoryBuffer> Buf;
  23. StringRef MemberName;
  24. sys::TimePoint<std::chrono::seconds> ModTime;
  25. unsigned UID = 0, GID = 0, Perms = 0644;
  26. NewArchiveMember() = default;
  27. NewArchiveMember(MemoryBufferRef BufRef);
  28. // Detect the archive format from the object or bitcode file. This helps
  29. // assume the archive format when creating or editing archives in the case
  30. // one isn't explicitly set.
  31. object::Archive::Kind detectKindFromObject() const;
  32. static Expected<NewArchiveMember>
  33. getOldMember(const object::Archive::Child &OldMember, bool Deterministic);
  34. static Expected<NewArchiveMember> getFile(StringRef FileName,
  35. bool Deterministic);
  36. };
  37. Expected<std::string> computeArchiveRelativePath(StringRef From, StringRef To);
  38. Error writeArchive(StringRef ArcName, ArrayRef<NewArchiveMember> NewMembers,
  39. bool WriteSymtab, object::Archive::Kind Kind,
  40. bool Deterministic, bool Thin,
  41. std::unique_ptr<MemoryBuffer> OldArchiveBuf = nullptr);
  42. // writeArchiveToBuffer is similar to writeArchive but returns the Archive in a
  43. // buffer instead of writing it out to a file.
  44. Expected<std::unique_ptr<MemoryBuffer>>
  45. writeArchiveToBuffer(ArrayRef<NewArchiveMember> NewMembers, bool WriteSymtab,
  46. object::Archive::Kind Kind, bool Deterministic, bool Thin);
  47. }
  48. #endif
  49. #ifdef __GNUC__
  50. #pragma GCC diagnostic pop
  51. #endif