LLVM 24.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"
17#include <optional>
18#include <string>
19
20namespace llvm {
21
27
33
34// Windows SDKs and VC Toolchains group their contents into subdirectories based
35// on the target architecture. This function converts an llvm::Triple::ArchType
36// to the corresponding subdirectory name.
38
39// Similar to the above function, but for Visual Studios before VS2017.
41
42// Similar to the above function, but for DevDiv internal builds.
44
48 std::string &path);
49
50// Get the path to a specific subdirectory in the current toolchain for
51// a given target architecture.
52// VS2017 changed the VC toolchain layout, so this should be used instead
53// of hardcoding paths.
55 ToolsetLayout VSLayout,
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.
63 const std::string &VCToolChainPath,
64 llvm::Triple::ArchType TargetArch,
66
67/// Get Windows SDK installation directory.
68LLVM_ABI bool getWindowsSDKDir(vfs::FileSystem &VFS,
69 std::optional<llvm::StringRef> WinSdkDir,
70 std::optional<llvm::StringRef> WinSdkVersion,
71 std::optional<llvm::StringRef> WinSysRoot,
72 std::string &Path, int &Major,
73 std::string &WindowsSDKIncludeVersion,
74 std::string &WindowsSDKLibVersion);
75
76LLVM_ABI bool
77getUniversalCRTSdkDir(vfs::FileSystem &VFS,
78 std::optional<llvm::StringRef> WinSdkDir,
79 std::optional<llvm::StringRef> WinSdkVersion,
80 std::optional<llvm::StringRef> WinSysRoot,
81 std::string &Path, std::string &UCRTVersion);
82
83// Check command line arguments to try and find a toolchain.
84LLVM_ABI bool
85findVCToolChainViaCommandLine(vfs::FileSystem &VFS,
86 std::optional<llvm::StringRef> VCToolsDir,
87 std::optional<llvm::StringRef> VCToolsVersion,
88 std::optional<llvm::StringRef> WinSysRoot,
89 std::string &Path, ToolsetLayout &VSLayout);
90
91// Check various environment variables to try and find a toolchain.
92LLVM_ABI bool findVCToolChainViaEnvironment(vfs::FileSystem &VFS,
93 std::string &Path,
94 ToolsetLayout &VSLayout);
95
96// Query the Setup Config server for installs, then pick the newest version
97// and find its default VC toolchain. If `VCToolsVersion` is specified, that
98// version is preferred over the latest version.
99//
100// This is the preferred way to discover new Visual Studios, as they're no
101// longer listed in the registry.
102LLVM_ABI bool
103findVCToolChainViaSetupConfig(vfs::FileSystem &VFS,
104 std::optional<llvm::StringRef> VCToolsVersion,
105 std::string &Path, ToolsetLayout &VSLayout);
106
107// Look in the registry for Visual Studio installs, and use that to get
108// a toolchain path. VS2017 and newer don't get added to the registry.
109// So if we find something here, we know that it's an older version.
110LLVM_ABI bool findVCToolChainViaRegistry(std::string &Path,
111 ToolsetLayout &VSLayout);
112
113} // namespace llvm
114
115#endif
#define LLVM_ABI
Definition Compiler.h:215
This file defines the SmallString class.
Contains the forward declaration for vfs::FileSystem, as well as the IntrusiveRefCntPtrInfo specializ...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition SmallString.h:26
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
The virtual file system interface.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI const char * archToWindowsSDKArch(llvm::Triple::ArchType Arch)
LLVM_ABI 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)
SubDirectoryType
Definition MSVCPaths.h:22
LLVM_ABI 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.
LLVM_ABI bool useUniversalCRT(ToolsetLayout VSLayout, const std::string &VCToolChainPath, llvm::Triple::ArchType TargetArch, llvm::vfs::FileSystem &VFS)
LLVM_ABI bool findVCToolChainViaEnvironment(vfs::FileSystem &VFS, std::string &Path, ToolsetLayout &VSLayout)
LLVM_ABI bool findVCToolChainViaSetupConfig(vfs::FileSystem &VFS, std::optional< llvm::StringRef > VCToolsVersion, std::string &Path, ToolsetLayout &VSLayout)
LLVM_ABI const char * archToLegacyVCArch(llvm::Triple::ArchType Arch)
ToolsetLayout
Definition MSVCPaths.h:28
LLVM_ABI const char * archToDevDivInternalArch(llvm::Triple::ArchType Arch)
LLVM_ABI std::string getSubDirectoryPath(SubDirectoryType Type, ToolsetLayout VSLayout, const std::string &VCToolChainPath, llvm::Triple::ArchType TargetArch, llvm::StringRef SubdirParent="")
LLVM_ABI bool appendArchToWindowsSDKLibPath(int SDKMajor, llvm::SmallString< 128 > LibPath, llvm::Triple::ArchType Arch, std::string &path)
LLVM_ABI bool findVCToolChainViaRegistry(std::string &Path, ToolsetLayout &VSLayout)
LLVM_ABI 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)