1//===- ArchiveWriter.h - ar archive file format writer ----------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Declares the writeArchive function for writing an archive file.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_OBJECT_ARCHIVEWRITER_H
14#define LLVM_OBJECT_ARCHIVEWRITER_H
15
16#include "llvm/Object/Archive.h"
17
18namespace llvm {
19
20struct NewArchiveMember {
21 std::unique_ptr<MemoryBuffer> Buf;
22 StringRef MemberName;
23 sys::TimePoint<std::chrono::seconds> ModTime;
24 unsigned UID = 0, GID = 0, Perms = 0644;
25
26 NewArchiveMember() = default;
27 NewArchiveMember(MemoryBufferRef BufRef);
28
29 static Expected<NewArchiveMember>
30 getOldMember(const object::Archive::Child &OldMember, bool Deterministic);
31
32 static Expected<NewArchiveMember> getFile(StringRef FileName,
33 bool Deterministic);
34};
35
36Expected<std::string> computeArchiveRelativePath(StringRef From, StringRef To);
37
38Error 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
43// writeArchiveToBuffer is similar to writeArchive but returns the Archive in a
44// buffer instead of writing it out to a file.
45Expected<std::unique_ptr<MemoryBuffer>>
46writeArchiveToBuffer(ArrayRef<NewArchiveMember> NewMembers, bool WriteSymtab,
47 object::Archive::Kind Kind, bool Deterministic, bool Thin);
48}
49
50#endif
51