xref: /freebsd/contrib/llvm-project/llvm/tools/llvm-objcopy/ObjcopyOptions.h (revision ebacd8013fe5f7fdf9f6a5b286f6680dd2891036)
1 //===- ObjcopyOptions.h ---------------------------------------------------===//
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 #ifndef LLVM_TOOLS_LLVM_OBJCOPY_OBJCOPYOPTIONS_H
10 #define LLVM_TOOLS_LLVM_OBJCOPY_OBJCOPYOPTIONS_H
11 
12 #include "llvm/ObjCopy/ConfigManager.h"
13 #include "llvm/Support/Allocator.h"
14 #include <vector>
15 
16 namespace llvm {
17 namespace objcopy {
18 
19 // Configuration for the overall invocation of this tool. When invoked as
20 // objcopy, will always contain exactly one CopyConfig. When invoked as strip,
21 // will contain one or more CopyConfigs.
22 struct DriverConfig {
23   SmallVector<ConfigManager, 1> CopyConfigs;
24   BumpPtrAllocator Alloc;
25 };
26 
27 // ParseObjcopyOptions returns the config and sets the input arguments. If a
28 // help flag is set then ParseObjcopyOptions will print the help messege and
29 // exit. ErrorCallback is used to handle recoverable errors. An Error returned
30 // by the callback aborts the parsing and is then returned by this function.
31 Expected<DriverConfig>
32 parseObjcopyOptions(ArrayRef<const char *> ArgsArr,
33                     llvm::function_ref<Error(Error)> ErrorCallback);
34 
35 // ParseInstallNameToolOptions returns the config and sets the input arguments.
36 // If a help flag is set then ParseInstallNameToolOptions will print the help
37 // messege and exit.
38 Expected<DriverConfig>
39 parseInstallNameToolOptions(ArrayRef<const char *> ArgsArr);
40 
41 // ParseBitcodeStripOptions returns the config and sets the input arguments.
42 // If a help flag is set then ParseBitcodeStripOptions will print the help
43 // messege and exit.
44 Expected<DriverConfig>
45 parseBitcodeStripOptions(ArrayRef<const char *> ArgsArr,
46                          llvm::function_ref<Error(Error)> ErrorCallback);
47 
48 // ParseStripOptions returns the config and sets the input arguments. If a
49 // help flag is set then ParseStripOptions will print the help messege and
50 // exit. ErrorCallback is used to handle recoverable errors. An Error returned
51 // by the callback aborts the parsing and is then returned by this function.
52 Expected<DriverConfig>
53 parseStripOptions(ArrayRef<const char *> ArgsArr,
54                   llvm::function_ref<Error(Error)> ErrorCallback);
55 } // namespace objcopy
56 } // namespace llvm
57 
58 #endif // LLVM_TOOLS_LLVM_OBJCOPY_OBJCOPYOPTIONS_H
59