From cdbec08f5a967220ba0375dbc6e683134d73f95f Mon Sep 17 00:00:00 2001 From: Vijay A Date: Fri, 9 Dec 2022 09:29:23 +0530 Subject: Add 'python' dependency for compiling native libs --- scripts/build-unix.sh | 2 +- scripts/build-windows.ps1 | 35 ++++++++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 8 deletions(-) (limited to 'scripts') diff --git a/scripts/build-unix.sh b/scripts/build-unix.sh index ff1ce0f..24ab0f7 100755 --- a/scripts/build-unix.sh +++ b/scripts/build-unix.sh @@ -75,7 +75,7 @@ fi # ----------------------------------------------------------------------------- # Ensure that the system dependencies are at the correct version - fail if not # Check python version -EXPECTED_PYTHON_VERSION="3.10.4" +EXPECTED_PYTHON_VERSION=$(node -p 'require("./package.json").engines.python') ACTUAL_PYTHON_VERSION=$(python --version | sed -e "s/Python //") if [[ "$ACTUAL_PYTHON_VERSION" != "$EXPECTED_PYTHON_VERSION" ]]; then fail_with_docs "You are not running the expected version of Python! diff --git a/scripts/build-windows.ps1 b/scripts/build-windows.ps1 index 81187c6..4026aa5 100644 --- a/scripts/build-windows.ps1 +++ b/scripts/build-windows.ps1 @@ -93,7 +93,7 @@ if ($env:CLEAN -eq "true") # ----------------------------------------------------------------------------- # Ensure that the system dependencies are at the correct version - fail if not # Check python version -$EXPECTED_PYTHON_VERSION = "3.10.4" +$EXPECTED_PYTHON_VERSION = (Get-Content package.json | ConvertFrom-Json).engines.python $ACTUAL_PYTHON_VERSION = (python --version).trim("Python ") if ([System.Version]$ACTUAL_PYTHON_VERSION -ne [System.Version]$EXPECTED_PYTHON_VERSION) { fail_with_docs "You are not running the expected version of Python! @@ -101,14 +101,35 @@ if ([System.Version]$ACTUAL_PYTHON_VERSION -ne [System.Version]$EXPECTED_PYTHON_ actual : [$ACTUAL_PYTHON_VERSION]" } -# TODO: Needs proper way to check MSVS Tools # Check MSVS Tools through MSVS_VERSION -$EXPECTED_MSVST_VERSION = "2015" -$ACTUAL_MSVST_VERSION = (npm config get msvs_version) -if ([double]$ACTUAL_MSVST_VERSION -ne [double]$EXPECTED_MSVST_VERSION) { - fail_with_docs "You are not running the expected version of MSVS Tools! +$EXPECTED_MSVST_VERSION = @("2019","2022") +$NPM_CONFIG_MSVS_VERSION = npm config get msvs_version +if((-not $NPM_CONFIG_MSVS_VERSION) -or -not ($EXPECTED_MSVST_VERSION -contains $NPM_CONFIG_MSVS_VERSION)){ + Write-Host "Your Microsoft Visual Studio Tools isn't set properly or it's not the right version! + Checking your version..." + + # TODO: Implement path for ARM machines + $MSVS_REG_PATH = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\X64" + + if(-not (Test-Path -Path $MSVS_REG_PATH)){ + fail_with_docs "You don't have the Microsoft Visual Studio Tools installed!" + } + + $MSVS_VERSION = [int]((Get-ItemProperty -Path $MSVS_REG_PATH).Version.substring(4, 2)) + switch($MSVS_VERSION) { + { $MSVS_VERSION -ge 30 } {$ACTUAL_MSVST_VERSION = "2022"} + { ($MSVS_VERSION -ge 20) -and ($MSVS_VERSION -le 29) } {$ACTUAL_MSVST_VERSION = "2019"} + { $MSVS_VERSION -lt 20 } {$ACTUAL_MSVST_VERSION = "2017 or lower"} + } + + if (-not ($EXPECTED_MSVST_VERSION -contains $ACTUAL_MSVST_VERSION)) { + fail_with_docs "You are not running the expected version of MSVS Tools! expected: [$EXPECTED_MSVST_VERSION] actual : [$ACTUAL_MSVST_VERSION]" + } + + Write-Host "Changing your msvs_version on npm to [$ACTUAL_MSVST_VERSION]" + npm config set msvs_version $ACTUAL_MSVST_VERSION } # ----------------------------------------------------------------------------- @@ -125,7 +146,7 @@ if ($EXPECTED_NPM_VERSION -ne $ACTUAL_NPM_VERSION) { } # Check pnpm version -$EXPECTED_PNPM_VERSION = (Get-Content recipes\package.json | ConvertFrom-Json).engines.pnpm +$EXPECTED_PNPM_VERSION = (Get-Content .\recipes\package.json | ConvertFrom-Json).engines.pnpm $ACTUAL_PNPM_VERSION = Get-Command pnpm --version -ErrorAction SilentlyContinue # in case the pnpm executable itself is not present if ($ACTUAL_PNPM_VERSION -ne $EXPECTED_PNPM_VERSION) { npm i -gf pnpm@$EXPECTED_PNPM_VERSION -- cgit v1.2.3-54-g00ecf