LLVM 17.0.0git
MSVCPaths.h
Go to the documentation of this file.
1//===-- MSVCPaths.h - MSVC path-parsing helpers -----------------*- 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 LLVM_WINDOWSDRIVER_MSVCPATHS_H
10#define LLVM_WINDOWSDRIVER_MSVCPATHS_H
11
13#include "llvm/ADT/StringRef.h"
14#include "llvm/ADT/Triple.h"
15#include <optional>
16#include <string>
17
18namespace llvm {
19
20namespace vfs {
21class FileSystem;
22}
23
24enum class SubDirectoryType {
25 Bin,
26 Include,
27 Lib,
28};
29
30enum class ToolsetLayout {
31 OlderVS,
34};
35
36// Windows SDKs and VC Toolchains group their contents into subdirectories based
37// on the target architecture. This function converts an llvm::Triple::ArchType
38// to the corresponding subdirectory name.
40
41// Similar to the above function, but for Visual Studios before VS2017.
43
44// Similar to the above function, but for DevDiv internal builds.
46
49 std::string &path);
50
51// Get the path to a specific subdirectory in the current toolchain for
52// a given target architecture.
53// VS2017 changed the VC toolchain layout, so this should be used instead
54// of hardcoding paths.
56 const std::string &VCToolChainPath,
57 llvm::Triple::ArchType TargetArch,
58 llvm::StringRef SubdirParent = "");
59
60// Check if the Include path of a specified version of Visual Studio contains
61// specific header files. If not, they are probably shipped with Universal CRT.
62bool useUniversalCRT(ToolsetLayout VSLayout, const std::string &VCToolChainPath,
63 llvm::Triple::ArchType TargetArch,
65
66/// Get Windows SDK installation directory.
67bool getWindowsSDKDir(vfs::FileSystem &VFS,
68 std::optional<llvm::StringRef> WinSdkDir,
69 std::optional<llvm::StringRef> WinSdkVersion,
70 std::optional<llvm::StringRef> WinSysRoot,
71 std::string &Path, int &Major,
72 std::string &WindowsSDKIncludeVersion,
73 std::string &WindowsSDKLibVersion);
74
75bool getUniversalCRTSdkDir(vfs::FileSystem &VFS,
76 std::optional<llvm::StringRef> WinSdkDir,
77 std::optional<llvm::StringRef> WinSdkVersion,
78 std::optional<llvm::StringRef> WinSysRoot,
79 std::string &Path, std::string &UCRTVersion);
80
81// Check command line arguments to try and find a toolchain.
83 vfs::FileSystem &VFS, std::optional<llvm::StringRef> VCToolsDir,
84 std::optional<llvm::StringRef> VCToolsVersion,
85 std::optional<llvm::StringRef> WinSysRoot, std::string &Path,
86 ToolsetLayout &VSLayout);
87
88// Check various environment variables to try and find a toolchain.
89bool findVCToolChainViaEnvironment(vfs::FileSystem &VFS, std::string &Path,
90 ToolsetLayout &VSLayout);
91
92// Query the Setup Config server for installs, then pick the newest version
93// and find its default VC toolchain.
94// This is the preferred way to discover new Visual Studios, as they're no
95// longer listed in the registry.
96bool findVCToolChainViaSetupConfig(vfs::FileSystem &VFS, std::string &Path,
97 ToolsetLayout &VSLayout);
98
99// Look in the registry for Visual Studio installs, and use that to get
100// a toolchain path. VS2017 and newer don't get added to the registry.
101// So if we find something here, we know that it's an older version.
102bool findVCToolChainViaRegistry(std::string &Path, ToolsetLayout &VSLayout);
103
104} // namespace llvm
105
106#endif
This header is deprecated in favour of llvm/TargetParser/Triple.h.
RelocType Type
Definition: COFFYAML.cpp:390
This file defines the SmallString class.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
The virtual file system interface.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
const char * archToWindowsSDKArch(llvm::Triple::ArchType Arch)
Definition: MSVCPaths.cpp:263
bool findVCToolChainViaCommandLine(vfs::FileSystem &VFS, std::optional< llvm::StringRef > VCToolsDir, std::optional< llvm::StringRef > VCToolsVersion, std::optional< llvm::StringRef > WinSysRoot, std::string &Path, ToolsetLayout &VSLayout)
Definition: MSVCPaths.cpp:476
SubDirectoryType
Definition: MSVCPaths.h:24
bool getWindowsSDKDir(vfs::FileSystem &VFS, std::optional< llvm::StringRef > WinSdkDir, std::optional< llvm::StringRef > WinSdkVersion, std::optional< llvm::StringRef > WinSysRoot, std::string &Path, int &Major, std::string &WindowsSDKIncludeVersion, std::string &WindowsSDKLibVersion)
Get Windows SDK installation directory.
Definition: MSVCPaths.cpp:396
bool useUniversalCRT(ToolsetLayout VSLayout, const std::string &VCToolChainPath, llvm::Triple::ArchType TargetArch, llvm::vfs::FileSystem &VFS)
Definition: MSVCPaths.cpp:388
bool findVCToolChainViaEnvironment(vfs::FileSystem &VFS, std::string &Path, ToolsetLayout &VSLayout)
Definition: MSVCPaths.cpp:503
const char * archToLegacyVCArch(llvm::Triple::ArchType Arch)
Definition: MSVCPaths.cpp:278
bool findVCToolChainViaSetupConfig(vfs::FileSystem &VFS, std::string &Path, ToolsetLayout &VSLayout)
Definition: MSVCPaths.cpp:612
ToolsetLayout
Definition: MSVCPaths.h:30
const char * archToDevDivInternalArch(llvm::Triple::ArchType Arch)
Definition: MSVCPaths.cpp:295
std::string getSubDirectoryPath(SubDirectoryType Type, ToolsetLayout VSLayout, const std::string &VCToolChainPath, llvm::Triple::ArchType TargetArch, llvm::StringRef SubdirParent="")
Definition: MSVCPaths.cpp:334
bool appendArchToWindowsSDKLibPath(int SDKMajor, llvm::SmallString< 128 > LibPath, llvm::Triple::ArchType Arch, std::string &path)
Definition: MSVCPaths.cpp:310
bool findVCToolChainViaRegistry(std::string &Path, ToolsetLayout &VSLayout)
Definition: MSVCPaths.cpp:701
bool getUniversalCRTSdkDir(vfs::FileSystem &VFS, std::optional< llvm::StringRef > WinSdkDir, std::optional< llvm::StringRef > WinSdkVersion, std::optional< llvm::StringRef > WinSysRoot, std::string &Path, std::string &UCRTVersion)
Definition: MSVCPaths.cpp:451