chore: use newest node-gyp for SDL pipeline (#199820)

* chore: use latest upstream node-gyp

* fix: use node-gyp.js file directly

* apply PR feedback

* chore: delete patch file

* Apply PR feedback

* Update cache salt
This commit is contained in:
Raymond Zhao 2024-01-29 19:24:14 -08:00 committed by GitHub
parent c95fb565ba
commit e284396074
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 14 additions and 94 deletions

View file

@ -1 +1 @@
2023-12-07T16:21:36.646Z
2024-01-29T19:26:27.993Z

View file

@ -95,29 +95,16 @@ stages:
displayName: CodeQL Initialize
condition: eq(variables['Codeql.enabled'], 'True')
- powershell: |
mkdir -Force .build/node-gyp
displayName: Create custom node-gyp directory
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
- powershell: |
. ../../build/azure-pipelines/win32/exec.ps1
$ErrorActionPreference = "Stop"
# TODO: Should be replaced with upstream URL once https://github.com/nodejs/node-gyp/pull/2825
# gets merged.
exec { git clone https://github.com/rzhao271/node-gyp.git . } "Cloning rzhao271/node-gyp failed"
exec { git checkout 102b347da0c92c29f9c67df22e864e70249cf086 } "Checking out 102b347 failed"
exec { npm install } "Building rzhao271/node-gyp failed"
exec { python3 -m pip install setuptools } "Installing setuptools failed"
displayName: Install custom node-gyp
workingDirectory: .build/node-gyp
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
- powershell: |
. build/azure-pipelines/win32/exec.ps1
. build/azure-pipelines/win32/retry.ps1
$ErrorActionPreference = "Stop"
$env:npm_config_node_gyp = "$(Join-Path $pwd.Path '.build/node-gyp/bin/node-gyp.js')"
# TODO: remove custom node-gyp when updating to Node v20,
# refs https://github.com/npm/cli/releases/tag/v10.2.3 which is available with Node >= 20.10.0
$nodeGypDir = "$(Agent.TempDirectory)/custom-packages"
mkdir "$nodeGypDir"
npm install node-gyp@10.0.1 -g --prefix "$nodeGypDir"
$env:npm_config_node_gyp = "${nodeGypDir}/node_modules/node-gyp/bin/node-gyp.js"
$env:npm_config_arch = "$(NPM_ARCH)"
retry { exec { yarn --frozen-lockfile --check-files } }
env:

View file

@ -89,33 +89,17 @@ steps:
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Authentication
- powershell: |
mkdir -Force .build/node-gyp
displayName: Create custom node-gyp directory
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
- powershell: |
. ../../build/azure-pipelines/win32/exec.ps1
$ErrorActionPreference = "Stop"
# TODO: Should be replaced with upstream URL once https://github.com/nodejs/node-gyp/pull/2825
# gets merged.
exec { git config --global user.email "vscode@microsoft.com" } "git config user.email failed"
exec { git config --global user.name "VSCode" } "git config user.name failed"
exec { git clone https://github.com/nodejs/node-gyp.git . } "Cloning nodejs/node-gyp failed"
exec { git checkout v9.4.0 } "Checking out v9.4.0 failed"
exec { git am --3way --whitespace=fix ../../build/npm/gyp/patches/gyp_spectre_mitigation_support.patch } "Apply spectre patch failed"
exec { npm install } "Building node-gyp failed"
exec { python3 -m pip install setuptools } "Installing setuptools failed"
displayName: Install custom node-gyp
workingDirectory: .build/node-gyp
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
- powershell: |
. build/azure-pipelines/win32/exec.ps1
. build/azure-pipelines/win32/retry.ps1
$ErrorActionPreference = "Stop"
$env:npm_config_node_gyp="$(Join-Path $pwd.Path '.build/node-gyp/bin/node-gyp.js')"
$env:npm_config_arch="$(VSCODE_ARCH)"
# TODO: remove custom node-gyp when updating to Node v20,
# refs https://github.com/npm/cli/releases/tag/v10.2.3 which is available with Node >= 20.10.0
$nodeGypDir = "$(Agent.TempDirectory)/custom-packages"
mkdir "$nodeGypDir"
npm install node-gyp@10.0.1 -g --prefix "$nodeGypDir"
$env:npm_config_node_gyp = "${nodeGypDir}/node_modules/node-gyp/bin/node-gyp.js"
$env:npm_config_arch = "$(VSCODE_ARCH)"
$env:CHILD_CONCURRENCY="1"
retry { exec { yarn --frozen-lockfile --check-files } }
env:

View file

@ -1,51 +0,0 @@
From 853e4643b6737224a5aa0720a4108461a0230991 Mon Sep 17 00:00:00 2001
From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com>
Date: Thu, 30 Mar 2023 05:23:36 -0700
Subject: [PATCH] feat(msvs): add SpectreMitigation attribute (#190)
Backports https://github.com/nodejs/gyp-next/commit/853e4643b6737224a5aa0720a4108461a0230991
diff --git a/gyp/pylib/gyp/easy_xml_test.py b/gyp/pylib/gyp/easy_xml_test.py
index 342f693..c5808b8 100755
--- a/gyp/pylib/gyp/easy_xml_test.py
+++ b/gyp/pylib/gyp/easy_xml_test.py
@@ -76,6 +76,7 @@ def test_EasyXml_complex(self):
'\'Debug|Win32\'" Label="Configuration">'
"<ConfigurationType>Application</ConfigurationType>"
"<CharacterSet>Unicode</CharacterSet>"
+ "<SpectreMitigation>SpectreLoadCF</SpectreMitigation>"
"</PropertyGroup>"
"</Project>"
)
@@ -99,6 +100,7 @@ def test_EasyXml_complex(self):
},
["ConfigurationType", "Application"],
["CharacterSet", "Unicode"],
+ ["SpectreMitigation", "SpectreLoadCF"]
],
]
)
diff --git a/gyp/pylib/gyp/generator/msvs.py b/gyp/pylib/gyp/generator/msvs.py
index 72269bd..85c354f 100644
--- a/gyp/pylib/gyp/generator/msvs.py
+++ b/gyp/pylib/gyp/generator/msvs.py
@@ -3006,6 +3006,10 @@ def _GetMSBuildConfigurationDetails(spec, build_file):
character_set = msbuild_attributes.get("CharacterSet")
config_type = msbuild_attributes.get("ConfigurationType")
_AddConditionalProperty(properties, condition, "ConfigurationType", config_type)
+ spectre_mitigation = msbuild_attributes.get('SpectreMitigation')
+ if spectre_mitigation:
+ _AddConditionalProperty(properties, condition, "SpectreMitigation",
+ spectre_mitigation)
if config_type == "Driver":
_AddConditionalProperty(properties, condition, "DriverType", "WDM")
_AddConditionalProperty(
@@ -3094,6 +3098,8 @@ def _ConvertMSVSBuildAttributes(spec, config, build_file):
msbuild_attributes[a] = _ConvertMSVSCharacterSet(msvs_attributes[a])
elif a == "ConfigurationType":
msbuild_attributes[a] = _ConvertMSVSConfigurationType(msvs_attributes[a])
+ elif a == "SpectreMitigation":
+ msbuild_attributes[a] = msvs_attributes[a]
else:
print("Warning: Do not know how to convert MSVS attribute " + a)
return msbuild_attributes