Skip to content

Commit

Permalink
build: fix version checks in gyp files
Browse files Browse the repository at this point in the history
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: nodejs#29927

PR-URL: nodejs#29931
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
(cherry picked from commit 6f81401)
  • Loading branch information
bnoordhuis authored and BaochengSu committed Oct 9, 2020
1 parent ec41091 commit b091237
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion deps/openssl/openssl.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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)',
Expand Down
4 changes: 3 additions & 1 deletion tools/gyp/pylib/gyp/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -1086,7 +1087,8 @@ def EvalSingleCondition(
else:
ast_code = compile(cond_expr_expanded, '<string>', '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:
Expand Down

0 comments on commit b091237

Please sign in to comment.