1 //===- ConfigManager.h ----------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_TOOLS_LLVM_OBJCOPY_CONFIGMANAGER_H
10 #define LLVM_TOOLS_LLVM_OBJCOPY_CONFIGMANAGER_H
12 #include "COFF/COFFConfig.h"
13 #include "CommonConfig.h"
14 #include "ELF/ELFConfig.h"
15 #include "MachO/MachOConfig.h"
16 #include "MultiFormatConfig.h"
17 #include "wasm/WasmConfig.h"
18 #include "llvm/Support/Allocator.h"
24 // ConfigManager keeps all configurations and prepare
25 // format-specific options.
26 struct ConfigManager
: public MultiFormatConfig
{
27 virtual ~ConfigManager() {}
29 const CommonConfig
&getCommonConfig() const override
{ return Common
; }
30 Expected
<const ELFConfig
&> getELFConfig() const override
;
31 Expected
<const COFFConfig
&> getCOFFConfig() const override
;
32 Expected
<const MachOConfig
&> getMachOConfig() const override
;
33 Expected
<const WasmConfig
&> getWasmConfig() const override
;
43 // Configuration for the overall invocation of this tool. When invoked as
44 // objcopy, will always contain exactly one CopyConfig. When invoked as strip,
45 // will contain one or more CopyConfigs.
47 SmallVector
<ConfigManager
, 1> CopyConfigs
;
48 BumpPtrAllocator Alloc
;
51 // ParseObjcopyOptions returns the config and sets the input arguments. If a
52 // help flag is set then ParseObjcopyOptions will print the help messege and
53 // exit. ErrorCallback is used to handle recoverable errors. An Error returned
54 // by the callback aborts the parsing and is then returned by this function.
55 Expected
<DriverConfig
>
56 parseObjcopyOptions(ArrayRef
<const char *> ArgsArr
,
57 llvm::function_ref
<Error(Error
)> ErrorCallback
);
59 // ParseInstallNameToolOptions returns the config and sets the input arguments.
60 // If a help flag is set then ParseInstallNameToolOptions will print the help
62 Expected
<DriverConfig
>
63 parseInstallNameToolOptions(ArrayRef
<const char *> ArgsArr
);
65 // ParseBitcodeStripOptions returns the config and sets the input arguments.
66 // If a help flag is set then ParseBitcodeStripOptions will print the help
68 Expected
<DriverConfig
> parseBitcodeStripOptions(ArrayRef
<const char *> ArgsArr
);
70 // ParseStripOptions returns the config and sets the input arguments. If a
71 // help flag is set then ParseStripOptions will print the help messege and
72 // exit. ErrorCallback is used to handle recoverable errors. An Error returned
73 // by the callback aborts the parsing and is then returned by this function.
74 Expected
<DriverConfig
>
75 parseStripOptions(ArrayRef
<const char *> ArgsArr
,
76 llvm::function_ref
<Error(Error
)> ErrorCallback
);
77 } // namespace objcopy
80 #endif // LLVM_TOOLS_LLVM_OBJCOPY_CONFIGMANAGER_H