15460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//===- CommandLine.h ------------------------------------------------------===//
25460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//
35460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//                     The MCLinker Project
45460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//
55460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao// This file is distributed under the University of Illinois Open Source
65460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao// License. See LICENSE.TXT for details.
75460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//
85460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//===----------------------------------------------------------------------===//
987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines#ifndef MCLD_SUPPORT_COMMANDLINE_H
1087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines#define MCLD_SUPPORT_COMMANDLINE_H
11affc150dc44fab1911775a49636d0ce85333b634Zonr Chang#include <mcld/Support/FileSystem.h>
12affc150dc44fab1911775a49636d0ce85333b634Zonr Chang#include <mcld/MC/ZOption.h>
135460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
14d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao#include <llvm/ADT/StringRef.h>
15f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines#include <llvm/ADT/Triple.h>
16d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao#include <llvm/Support/CommandLine.h>
17d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao
18d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao#include <string>
19d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao
205460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaonamespace llvm {
215460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaonamespace cl {
225460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
23d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao//===----------------------------------------------------------------------===//
24d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao// SearchDirParser
25d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao//===----------------------------------------------------------------------===//
26d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liaoclass SearchDirParser : public llvm::cl::basic_parser<std::string>
27d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao{
28d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liaopublic:
29d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao  // parse - Return true on error.
30d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao  bool parse(Option &pOption,
31d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao             StringRef pArgName,
32d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao             StringRef pArg,
33d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao             std::string &pValue);
34d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao
35d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao  const char *getValueName() const { return "searchdir"; }
36d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao
37d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao  void printOptionDiff(const Option &pOption,
38d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao                       StringRef pValue,
39d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao                       OptVal pDefault,
40d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao                       size_t pGlobalWidth) const;
41d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao
42d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao  void anchor();
43d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao};
44d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao
45d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao//===----------------------------------------------------------------------===//
46f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines// FalseParser
47f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines//===----------------------------------------------------------------------===//
48f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hinesclass FalseParser : public cl::parser<bool>
49f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines{
50f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hinespublic:
51f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines  // parse - Return true on error.
52f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines  bool parse(cl::Option &O, StringRef ArgName, StringRef Arg, bool &Val) {
53f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines    if (cl::parser<bool>::parse(O, ArgName, Arg, Val))
54f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines      return false;
55f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines    Val = false;
56f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines    return false;
57f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines  }
58f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines};
59f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines
60f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines//===----------------------------------------------------------------------===//
61d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao// parser<mcld::sys::fs::Path>
62d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao//===----------------------------------------------------------------------===//
635460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaotemplate<>
645460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaoclass parser<mcld::sys::fs::Path> : public basic_parser<mcld::sys::fs::Path>
655460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao{
665460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaopublic:
675460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  bool parse(Option &O,
685460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao             StringRef ArgName,
695460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao             StringRef Arg,
705460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao             mcld::sys::fs::Path &Val);
715460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
725460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  virtual const char *getValueName() const { return "path"; }
735460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  void printOptionDiff(const Option &O,
745460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                       const mcld::sys::fs::Path &V,
755460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                       OptVal Default,
765460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                       size_t GlobalWidth) const;
775460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  virtual void anchor();
785460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao};
795460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
80d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao//===----------------------------------------------------------------------===//
81affc150dc44fab1911775a49636d0ce85333b634Zonr Chang// parser<mcld::ZOption>
82d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao//===----------------------------------------------------------------------===//
83affc150dc44fab1911775a49636d0ce85333b634Zonr Changtemplate<>
84affc150dc44fab1911775a49636d0ce85333b634Zonr Changclass parser<mcld::ZOption> : public llvm::cl::basic_parser<mcld::ZOption>
85affc150dc44fab1911775a49636d0ce85333b634Zonr Chang{
86affc150dc44fab1911775a49636d0ce85333b634Zonr Changpublic:
87affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  bool parse(Option &O, StringRef ArgName, StringRef Arg, mcld::ZOption &Val);
88affc150dc44fab1911775a49636d0ce85333b634Zonr Chang
89affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  virtual const char *getValueName() const { return "z-option"; }
90affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  void printOptionDiff(const Option &O,
91affc150dc44fab1911775a49636d0ce85333b634Zonr Chang                       const mcld::ZOption &V,
92affc150dc44fab1911775a49636d0ce85333b634Zonr Chang                       OptVal Default,
93affc150dc44fab1911775a49636d0ce85333b634Zonr Chang                       size_t GlobalWidth) const;
94affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  virtual void anchor();
95affc150dc44fab1911775a49636d0ce85333b634Zonr Chang};
96affc150dc44fab1911775a49636d0ce85333b634Zonr Chang
975460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao} // namespace of cl
985460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao} // namespace of llvm
995460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1005460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao#endif
1015460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
102