1//===-- OptionGroupPlatform.h -----------------------------------*- 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#ifndef liblldb_OptionGroupPlatform_h_
10#define liblldb_OptionGroupPlatform_h_
11
12#include "lldb/Interpreter/Options.h"
13#include "lldb/Utility/ConstString.h"
14#include "llvm/Support/VersionTuple.h"
15
16namespace lldb_private {
17
18// PlatformOptionGroup
19//
20// Make platform options available to any commands that need the settings.
21class OptionGroupPlatform : public OptionGroup {
22public:
23  OptionGroupPlatform(bool include_platform_option)
24      : OptionGroup(), m_platform_name(), m_sdk_sysroot(),
25        m_include_platform_option(include_platform_option) {}
26
27  ~OptionGroupPlatform() override = default;
28
29  llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
30
31  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
32                        ExecutionContext *execution_context) override;
33  Status SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
34
35  void OptionParsingStarting(ExecutionContext *execution_context) override;
36
37  lldb::PlatformSP CreatePlatformWithOptions(CommandInterpreter &interpreter,
38                                             const ArchSpec &arch,
39                                             bool make_selected, Status &error,
40                                             ArchSpec &platform_arch) const;
41
42  bool PlatformWasSpecified() const { return !m_platform_name.empty(); }
43
44  void SetPlatformName(const char *platform_name) {
45    if (platform_name && platform_name[0])
46      m_platform_name.assign(platform_name);
47    else
48      m_platform_name.clear();
49  }
50
51  ConstString GetSDKRootDirectory() const { return m_sdk_sysroot; }
52
53  void SetSDKRootDirectory(ConstString sdk_root_directory) {
54    m_sdk_sysroot = sdk_root_directory;
55  }
56
57  ConstString GetSDKBuild() const { return m_sdk_build; }
58
59  void SetSDKBuild(ConstString sdk_build) { m_sdk_build = sdk_build; }
60
61  bool PlatformMatches(const lldb::PlatformSP &platform_sp) const;
62
63protected:
64  std::string m_platform_name;
65  ConstString m_sdk_sysroot;
66  ConstString m_sdk_build;
67  llvm::VersionTuple m_os_version;
68  bool m_include_platform_option;
69};
70
71} // namespace lldb_private
72
73#endif // liblldb_OptionGroupPlatform_h_
74