mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
MRI scripts: Add addlib support.
llvm-svn: 220346
This commit is contained in:
parent
be14e0d9dd
commit
2cfc7cef2c
17
test/Object/mri-addlib.test
Normal file
17
test/Object/mri-addlib.test
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
; RUN: echo create %t.a > %t.mri
|
||||||
|
; RUN: echo addlib %p/Inputs/GNU.a >> %t.mri
|
||||||
|
; RUN: echo addlib %p/Inputs/archive-test.a-gnu-minimal >> %t.mri
|
||||||
|
; RUN: echo save >> %t.mri
|
||||||
|
; RUN: echo end >> %t.mri
|
||||||
|
|
||||||
|
; RUN: llvm-ar -M < %t.mri
|
||||||
|
; RUN: llvm-ar t %t.a | FileCheck %s
|
||||||
|
|
||||||
|
; CHECK: evenlen
|
||||||
|
; CHECK-NEXT: oddlen
|
||||||
|
; CHECK-NEXT: very_long_bytecode_file_name.bc
|
||||||
|
; CHECK-NEXT: IsNAN.o
|
||||||
|
; CHECK-NEXT: test
|
||||||
|
|
||||||
|
; line_iterator is incompatible to CRLF.
|
||||||
|
; REQUIRES: shell
|
@ -947,19 +947,22 @@ static int performOperation(ArchiveOperation Operation,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void runMRIScript() {
|
static void runMRIScript() {
|
||||||
enum class MRICommand { AddMod, Create, Save, End, Invalid };
|
enum class MRICommand { AddLib, AddMod, Create, Save, End, Invalid };
|
||||||
|
|
||||||
ErrorOr<std::unique_ptr<MemoryBuffer>> Buf = MemoryBuffer::getSTDIN();
|
ErrorOr<std::unique_ptr<MemoryBuffer>> Buf = MemoryBuffer::getSTDIN();
|
||||||
failIfError(Buf.getError());
|
failIfError(Buf.getError());
|
||||||
const MemoryBuffer &Ref = *Buf.get();
|
const MemoryBuffer &Ref = *Buf.get();
|
||||||
bool Saved = false;
|
bool Saved = false;
|
||||||
std::vector<NewArchiveIterator> NewMembers;
|
std::vector<NewArchiveIterator> NewMembers;
|
||||||
|
std::vector<std::unique_ptr<MemoryBuffer>> ArchiveBuffers;
|
||||||
|
std::vector<std::unique_ptr<object::Archive>> Archives;
|
||||||
|
|
||||||
for (line_iterator I(Ref, /*SkipBlanks*/ true, ';'), E; I != E; ++I) {
|
for (line_iterator I(Ref, /*SkipBlanks*/ true, ';'), E; I != E; ++I) {
|
||||||
StringRef Line = *I;
|
StringRef Line = *I;
|
||||||
StringRef CommandStr, Rest;
|
StringRef CommandStr, Rest;
|
||||||
std::tie(CommandStr, Rest) = Line.split(' ');
|
std::tie(CommandStr, Rest) = Line.split(' ');
|
||||||
auto Command = StringSwitch<MRICommand>(CommandStr.lower())
|
auto Command = StringSwitch<MRICommand>(CommandStr.lower())
|
||||||
|
.Case("addlib", MRICommand::AddLib)
|
||||||
.Case("addmod", MRICommand::AddMod)
|
.Case("addmod", MRICommand::AddMod)
|
||||||
.Case("create", MRICommand::Create)
|
.Case("create", MRICommand::Create)
|
||||||
.Case("save", MRICommand::Save)
|
.Case("save", MRICommand::Save)
|
||||||
@ -967,6 +970,22 @@ static void runMRIScript() {
|
|||||||
.Default(MRICommand::Invalid);
|
.Default(MRICommand::Invalid);
|
||||||
|
|
||||||
switch (Command) {
|
switch (Command) {
|
||||||
|
case MRICommand::AddLib: {
|
||||||
|
auto BufOrErr = MemoryBuffer::getFile(Rest, -1, false);
|
||||||
|
failIfError(BufOrErr.getError(), "Could not open library");
|
||||||
|
ArchiveBuffers.push_back(std::move(*BufOrErr));
|
||||||
|
auto LibOrErr =
|
||||||
|
object::Archive::create(ArchiveBuffers.back()->getMemBufferRef());
|
||||||
|
failIfError(LibOrErr.getError(), "Could not parse library");
|
||||||
|
Archives.push_back(std::move(*LibOrErr));
|
||||||
|
object::Archive &Lib = *Archives.back();
|
||||||
|
for (auto &Member : Lib.children()) {
|
||||||
|
ErrorOr<StringRef> NameOrErr = Member.getName();
|
||||||
|
failIfError(NameOrErr.getError());
|
||||||
|
addMember(NewMembers, Member, *NameOrErr);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case MRICommand::AddMod:
|
case MRICommand::AddMod:
|
||||||
addMember(NewMembers, Rest, sys::path::filename(Rest));
|
addMember(NewMembers, Rest, sys::path::filename(Rest));
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user