Revert "win: Remove special check for 10.0.22621.2428 Win SDK version"
This reverts commit c05affe022794ad95bf28445501e10b27ff4debd.
Reason for revert: We need this check again after the upgrade to 26100 was rolled back, https://chromium-review.googlesource.com/c/chromium/src/+/5972668
Original change's description:
> win: Remove special check for 10.0.22621.2428 Win SDK version
>
> We added this check in crrev.com/c/5738088 since we needed a specific
> patch version of 22621 with no simple way to check for it. We've now
> updated past 22621 to 26100 in crrev.com/c/5898835, so we can remove
> this check entirely.
>
> Bug: 40150597
> Bug: 325004812
> Change-Id: I3de129feaeb2dc0392508604260c9361995521bf
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5949425
> Reviewed-by: Alan Zhao <ayzhao@google.com>
> Commit-Queue: Michael Tang <tangm@microsoft.com>
> Reviewed-by: Rafael Cintron <rafael.cintron@microsoft.com>
> Cr-Commit-Position: refs/heads/main@{#1371682}
Bug: 40150597
Bug: 325004812
Change-Id: I804f039ebf715c474f8e471ae55a7a3762100d32
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5989717
Reviewed-by: Alan Zhao <ayzhao@google.com>
Auto-Submit: Michael Tang <tangm@microsoft.com>
Commit-Queue: Michael Tang <tangm@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1378013}
NOKEYCHECK=True
GitOrigin-RevId: 5d984f21325a0e66d659b89163cffd650aa7f339
diff --git a/vs_toolchain.py b/vs_toolchain.py
index 6cefd48..f0b8bac 100755
--- a/vs_toolchain.py
+++ b/vs_toolchain.py
@@ -576,6 +576,42 @@
return NormalizePath(os.environ['WINDOWSSDKDIR'])
+def SDKIncludesIDCompositionDevice4():
+ """Returns true if the selected Windows SDK includes the declaration for the
+ IDCompositionDevice4 interface. This is essentially the equivalent checking
+ if a (non-preview) SDK version >=10.0.22621.2428.
+
+ We cannot check for this SDK version directly since it installs to a folder
+ with the minor version set to 0 (i.e. 10.0.22621.0) and the
+ IDCompositionDevice4 interface was added in a servicing release which did
+ not increment the major version.
+
+ There doesn't seem to be a straightforward and cross-platform way to get the
+ minor version of an installed SDK directory. To work around this, we look
+ for the GUID declaring the interface which implies the SDK version and
+ ensures the interface itself is present."""
+ win_sdk_dir = SetEnvironmentAndGetSDKDir()
+ if not win_sdk_dir:
+ return False
+
+ # Skip this check if we know the major version definitely includes
+ # IDCompositionDevice4.
+ if int(SDK_VERSION.split('.')[2]) > 22621:
+ return True
+
+ dcomp_header_path = os.path.join(win_sdk_dir, 'Include', SDK_VERSION, 'um',
+ 'dcomp.h')
+ DECLARE_DEVICE4_LINE = ('DECLARE_INTERFACE_IID_('
+ 'IDCompositionDevice4, IDCompositionDevice3, '
+ '"85FC5CCA-2DA6-494C-86B6-4A775C049B8A")')
+ with open(dcomp_header_path) as f:
+ for line in f.readlines():
+ if line.rstrip() == DECLARE_DEVICE4_LINE:
+ return True
+
+ return False
+
+
def GetToolchainDir():
"""Gets location information about the current toolchain (must have been
previously updated by 'update'). This is used for the GN build."""
@@ -583,6 +619,14 @@
win_sdk_dir = SetEnvironmentAndGetSDKDir()
version_as_year = GetVisualStudioVersion()
+ if not SDKIncludesIDCompositionDevice4():
+ print(
+ 'Windows SDK >= 10.0.22621.2428 required. You can get it by updating '
+ f'Visual Studio {version_as_year} using the Visual Studio Installer.',
+ file=sys.stderr,
+ )
+ return 1
+
print('''vs_path = %s
sdk_version = %s
sdk_path = %s