From b091237162d866b283093b8231dd4ebbaa32f430 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 11 Oct 2019 13:20:16 +0200 Subject: [PATCH] build: fix version checks in gyp files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make `distutils.version.StrictVersion` available as a helper to gyp expressions so they can do proper version checks and update the gyp files accordingly. Caveat emptor: `StrictVersion` does *not* like empty strings so this commit adds truthiness guards. The helper could deal with those but I felt it better to make it explicit. Fixes: https://github.com/nodejs/node/issues/29927 PR-URL: https://github.com/nodejs/node/pull/29931 Reviewed-By: Michaƫl Zasso Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig (cherry picked from commit 6f814013f45698a9178203331b62e3fe07fdb7d5) --- deps/openssl/openssl.gypi | 4 +++- tools/gyp/pylib/gyp/input.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/deps/openssl/openssl.gypi b/deps/openssl/openssl.gypi index 21e1058aa28406..7ab578b25a7b14 100644 --- a/deps/openssl/openssl.gypi +++ b/deps/openssl/openssl.gypi @@ -1037,7 +1037,9 @@ # 'conditions': [ ['(OS=="win" and MSVS_VERSION>="2012") or ' - 'llvm_version>="3.3" or xcode_version>="5.0" or gas_version>="2.23"', { + 'llvm_version and v(llvm_version) >= v("3.3") or ' + 'gas_version and v(gas_version) >= v("2.23") or ' + 'xcode_version and v(xcode_version) >= v("5.0")', { 'openssl_sources_x64_win_masm': [ '<@(openssl_sources_asm_latest_x64_win_masm)', '<@(openssl_sources_common_x64_win_masm)', diff --git a/tools/gyp/pylib/gyp/input.py b/tools/gyp/pylib/gyp/input.py index a571b071567576..dcb7555fc55865 100644 --- a/tools/gyp/pylib/gyp/input.py +++ b/tools/gyp/pylib/gyp/input.py @@ -19,6 +19,7 @@ import threading import time import traceback +from distutils.version import StrictVersion from gyp.common import GypError from gyp.common import OrderedSet @@ -1086,7 +1087,8 @@ def EvalSingleCondition( else: ast_code = compile(cond_expr_expanded, '', 'eval') cached_conditions_asts[cond_expr_expanded] = ast_code - if eval(ast_code, {'__builtins__': None}, variables): + env = {'__builtins__': None, 'v': StrictVersion} + if eval(ast_code, env, variables): return true_dict return false_dict except SyntaxError as e: