From aa3f986093c0a8038a5aa539bfc680635e2d27db Mon Sep 17 00:00:00 2001 From: Shigeki Ohtsu Date: Wed, 4 Feb 2015 09:05:49 +0900 Subject: [PATCH] deps: refactor openssl.gyp Updated gyp has "else if" syntax in condition. Use this for target_arch and OS switches. Several defines, rules and libraries variables moved to openssl.gypi --- deps/openssl/openssl.gyp | 268 +++++++++++--------------------------- deps/openssl/openssl.gypi | 142 ++++++++++++++++++++ 2 files changed, 220 insertions(+), 190 deletions(-) diff --git a/deps/openssl/openssl.gyp b/deps/openssl/openssl.gyp index 5a6d5f2f4af023..e61359de4fa29f 100644 --- a/deps/openssl/openssl.gyp +++ b/deps/openssl/openssl.gyp @@ -13,93 +13,74 @@ { 'target_name': 'openssl', 'type': '<(library)', - 'sources': [ - '<@(openssl_sources)', - ], + 'sources': ['<@(openssl_sources)'], 'sources/': [ ['exclude', 'md2/.*$'], ['exclude', 'store/.*$'] ], 'conditions': [ - ['target_arch!="ia32" and target_arch!="x64" and target_arch!="arm" or openssl_no_asm!=0', { + ['openssl_no_asm!=0', { # Disable asm 'defines': [ - 'OPENSSL_NO_ASM' - ], - 'sources': [ - '<@(openssl_sources_no_asm)', + 'OPENSSL_NO_ASM', ], + 'sources': ['<@(openssl_sources_no_asm)'], }, { - # Enable asm - 'defines': [ - 'AES_ASM', - 'CPUID_ASM', - 'OPENSSL_BN_ASM_MONT', - 'OPENSSL_CPUID_OBJ', - 'SHA1_ASM', - 'SHA256_ASM', - 'SHA512_ASM', - 'GHASH_ASM', - ], + # "else if" was supported in https://codereview.chromium.org/601353002 'conditions': [ - # Extended assembly on non-arm platforms - ['target_arch!="arm"', { + ['target_arch=="arm"', { + 'defines': ['<@(openssl_defines_asm)'], + 'sources': ['<@(openssl_sources_arm_elf_gas)'], + }, 'target_arch=="ia32" and OS=="mac"', { 'defines': [ - 'VPAES_ASM', - 'BN_ASM', - 'BF_ASM', - 'BNCO_ASM', - 'DES_ASM', - 'LIB_BN_ASM', - 'MD5_ASM', - 'OPENSSL_BN_ASM', - 'RIP_ASM', - 'RMD160_ASM', - 'WHIRLPOOL_ASM', - 'WP_ASM', + '<@(openssl_defines_asm)', + '<@(openssl_defines_x86_mac)', ], - }], - ['OS!="win" and OS!="mac" and target_arch=="ia32"', { - 'sources': [ - '<@(openssl_sources_x86_elf_gas)', - ] - }], - ['OS!="win" and OS!="mac" and target_arch=="x64"', { + 'sources': ['<@(openssl_sources_x86_macosx_gas)'], + }, 'target_arch=="ia32" and OS=="win"', { 'defines': [ - 'OPENSSL_BN_ASM_MONT5', - 'OPENSSL_BN_ASM_GF2m', - 'OPENSSL_IA32_SSE2', - 'BSAES_ASM', + '<@(openssl_defines_asm)', + '<@(openssl_defines_x86_win)', ], - 'sources': [ - '<@(openssl_sources_x64_elf_gas)', - ] - }], - ['OS=="mac" and target_arch=="ia32"', { - 'sources': [ - '<@(openssl_sources_x86_macosx_gas)', - ] - }], - ['OS=="mac" and target_arch=="x64"', { + 'sources': ['<@(openssl_sources_x86_win32_masm)'], + }, 'target_arch=="ia32"', { + # Linux or others 'defines': [ - 'OPENSSL_BN_ASM_MONT5', - 'OPENSSL_BN_ASM_GF2m', - 'OPENSSL_IA32_SSE2', - 'BSAES_ASM', + '<@(openssl_defines_asm)', + '<@(openssl_defines_x86_elf)', ], - 'sources': [ - '<@(openssl_sources_x64_macosx_gas)', - ] - }], - ['target_arch=="arm"', { - 'sources': [ - '<@(openssl_sources_arm_elf_gas)', - ] - }], - ['OS=="win" and target_arch=="ia32"', { - 'sources': [ - '<@(openssl_sources_x86_win32_masm)', + 'sources': ['<@(openssl_sources_x86_elf_gas)'], + }, 'target_arch=="x64" and OS=="mac"', { + 'defines': [ + '<@(openssl_defines_asm)', + '<@(openssl_defines_x64_mac)', + ], + 'sources': ['<@(openssl_sources_x64_macosx_gas)'], + }, 'target_arch=="x64" and OS=="win"', { + 'defines': [ + '<@(openssl_defines_asm)', + '<@(openssl_defines_x64_win)', ], + 'sources': ['<@(openssl_sources_x64_win32_masm)'], + }, 'target_arch=="x64"', { + # Linux or others + 'defines': [ + '<@(openssl_defines_asm)', + '<@(openssl_defines_x64_elf)', + ], + 'sources': ['<@(openssl_sources_x64_elf_gas)'], + }, { # else other archtectures does not use asm + 'defines': [ + 'OPENSSL_NO_ASM', + ], + 'sources': ['<@(openssl_sources_no_asm)'], + }], + ], + }], # end of conditions of openssl_no_asm + ['OS=="win"', { + 'defines' : ['<@(openssl_defines_all_win)'], + 'conditions': [ + ['target_arch=="ia32"', { 'rules': [ { 'rule_name': 'Assemble', @@ -118,18 +99,8 @@ 'process_outputs_as_sources': 0, 'message': 'Assembling <(RULE_INPUT_PATH) to <(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).obj.', } - ] - }], - ['OS=="win" and target_arch=="x64"', { - 'defines': [ - 'OPENSSL_BN_ASM_MONT5', - 'OPENSSL_BN_ASM_GF2m', - 'OPENSSL_IA32_SSE2', - 'BSAES_ASM', - ], - 'sources': [ - '<@(openssl_sources_x64_win32_masm)', ], + }, 'target_arch=="x64"', { 'rules': [ { 'rule_name': 'Assemble', @@ -147,73 +118,36 @@ 'process_outputs_as_sources': 0, 'message': 'Assembling <(RULE_INPUT_PATH) to <(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).obj.', } - ] - }] - ] - }], - ['OS=="win"', { - 'link_settings': { - 'libraries': [ - '-lgdi32.lib', - '-luser32.lib', - ] - }, - 'defines': [ - 'DSO_WIN32', + ], + }], ], }, { - 'defines': [ - 'DSO_DLFCN', - 'HAVE_DLFCN_H' - ], - }], - ], - 'include_dirs': [ - '.', - 'openssl', - 'openssl/crypto', - 'openssl/crypto/asn1', - 'openssl/crypto/evp', - 'openssl/crypto/md2', - 'openssl/crypto/modes', - 'openssl/crypto/store', - 'openssl/include', + 'defines' : ['<@(openssl_defines_all_non_win)'] + }] ], + 'include_dirs': ['<@(openssl_include_dirs)'], 'direct_dependent_settings': { - 'include_dirs': ['openssl/include'], + 'include_dirs': [ + 'openssl/include' + ], }, }, { 'target_name': 'openssl-cli', 'type': 'executable', - 'dependencies': [ - 'openssl', - ], + 'dependencies': ['openssl'], 'defines': [ - 'MONOLITH', - ], - 'sources': [ - '<@(openssl_cli_sources)', + 'MONOLITH' ], + 'sources': ['<@(openssl_cli_sources)'], 'conditions': [ ['OS=="solaris"', { - 'libraries': [ - '-lsocket', - '-lnsl', - ] - }], - ['OS=="win"', { + 'libraries': ['<@(openssl_cli_libraries_solaris)'] + }, 'OS=="win"', { 'link_settings': { - 'libraries': [ - '-lws2_32.lib', - '-lgdi32.lib', - '-ladvapi32.lib', - '-lcrypt32.lib', - '-luser32.lib', - ], + 'libraries': ['<@(openssl_cli_libraries_win)'], }, - }], - [ 'OS in "linux android"', { + }, 'OS in "linux android"', { 'link_settings': { 'libraries': [ '-ldl', @@ -224,70 +158,24 @@ } ], 'target_defaults': { - 'include_dirs': [ - '.', - 'openssl', - 'openssl/crypto', - 'openssl/crypto/asn1', - 'openssl/crypto/evp', - 'openssl/crypto/md2', - 'openssl/crypto/modes', - 'openssl/crypto/store', - 'openssl/include', - ], - 'defines': [ - # No clue what these are for. - 'L_ENDIAN', - 'PURIFY', - '_REENTRANT', - - # SSLv2 is known broken and has been superseded by SSLv3 for almost - # twenty years now. - 'OPENSSL_NO_SSL2', - - # SSLv3 is susceptible to downgrade attacks (POODLE.) - 'OPENSSL_NO_SSL3', - - # Heartbeat is a TLS extension, that couldn't be turned off or - # asked to be not advertised. Unfortunately this is unacceptable for - # Microsoft's IIS, which seems to be ignoring whole ClientHello after - # seeing this extension. - 'OPENSSL_NO_HEARTBEATS', - ], + 'include_dirs': ['<@(openssl_default_include_dirs)'], + 'defines': ['<@(openssl_default_defines_all)'], 'conditions': [ ['OS=="win"', { - 'defines': [ - 'MK1MF_BUILD', - 'WIN32_LEAN_AND_MEAN', - 'OPENSSL_SYSNAME_WIN32', - ], - 'msvs_disabled_warnings': [ - 4244, # conversion from 'signed type', possible loss of data - 4267, # conversion from 'unsigned type', possible loss of data - 4996, # 'GetVersionExA': was declared deprecated - ], + 'defines': ['<@(openssl_default_defines_win)'], + 'link_settings': { + 'libraries': ['<@(openssl_default_libraries_win)'], + }, }, { - 'defines': [ - # ENGINESDIR must be defined if OPENSSLDIR is. - 'ENGINESDIR="/dev/null"', - 'TERMIOS', + 'defines': ['<@(openssl_default_defines_not_win)'], + 'cflags': [ + '-Wno-missing-field-initializers', ], - 'cflags': ['-Wno-missing-field-initializers'], 'conditions': [ ['OS=="mac"', { - 'defines': [ - # Set to ubuntu default path for convenience. If necessary, - # override this at runtime with the SSL_CERT_DIR environment - # variable. - 'OPENSSLDIR="/System/Library/OpenSSL/"', - ], + 'defines': ['<@(openssl_default_defines_mac)'], }, { - 'defines': [ - # Set to ubuntu default path for convenience. If necessary, - # override this at runtime with the SSL_CERT_DIR environment - # variable. - 'OPENSSLDIR="/etc/ssl"', - ], + 'defines': ['<@(openssl_default_defines_linux_others)'], }], ] }], diff --git a/deps/openssl/openssl.gypi b/deps/openssl/openssl.gypi index 05bbcf62fe6cac..8b668437943cd2 100644 --- a/deps/openssl/openssl.gypi +++ b/deps/openssl/openssl.gypi @@ -883,5 +883,147 @@ 'openssl/apps/version.c', 'openssl/apps/x509.c', ], + 'openssl_defines_asm': [ + 'AES_ASM', + 'CPUID_ASM', + 'OPENSSL_BN_ASM_MONT', + 'OPENSSL_CPUID_OBJ', + 'SHA1_ASM', + 'SHA256_ASM', + 'SHA512_ASM', + 'GHASH_ASM', + ], + 'openssl_defines_non_arm': [ + 'VPAES_ASM', + 'BN_ASM', + 'BF_ASM', + 'BNCO_ASM', + 'DES_ASM', + 'LIB_BN_ASM', + 'MD5_ASM', + 'OPENSSL_BN_ASM', + 'RIP_ASM', + 'RMD160_ASM', + 'WHIRLPOOL_ASM', + 'WP_ASM', + ], + 'openssl_defines_all_win': [ + 'DSO_WIN32', + ], + 'openssl_defines_all_non_win': [ + 'DSO_DLFCN', + 'HAVE_DLFCN_H', + ], + 'openssl_defines_x86_elf': [ + '<@(openssl_defines_non_arm)', + + ], + 'openssl_defines_x86_mac': [ + '<@(openssl_defines_non_arm)', + ], + 'openssl_defines_x86_win': [ + '<@(openssl_defines_non_arm)', + ], + 'openssl_defines_x64_elf': [ + '<@(openssl_defines_non_arm)', + 'OPENSSL_BN_ASM_MONT5', + 'OPENSSL_BN_ASM_GF2m', + 'OPENSSL_IA32_SSE2', + 'BSAES_ASM', + ], + 'openssl_defines_x64_mac': [ + '<@(openssl_defines_non_arm)', + 'OPENSSL_BN_ASM_MONT5', + 'OPENSSL_BN_ASM_GF2m', + 'OPENSSL_IA32_SSE2', + 'BSAES_ASM', + ], + 'openssl_defines_x64_win': [ + '<@(openssl_defines_non_arm)', + 'OPENSSL_BN_ASM_MONT5', + 'OPENSSL_BN_ASM_GF2m', + 'OPENSSL_IA32_SSE2', + 'BSAES_ASM', + ], + 'openssl_include_dirs': [ + '.', + 'openssl', + 'openssl/crypto', + 'openssl/crypto/asn1', + 'openssl/crypto/evp', + 'openssl/crypto/md2', + 'openssl/crypto/modes', + 'openssl/crypto/store', + 'openssl/include', + ], +#### Variables for openssl-cli #### + 'openssl_cli_libraries_solaris': [ + '-lsocket', + '-lnsl', + ], + 'openssl_cli_libraries_win': [ + '-lws2_32.lib', + '-lgdi32.lib', + '-ladvapi32.lib', + '-lcrypt32.lib', + '-luser32.lib', + ], +#### Variables for Target Defaults #### + 'openssl_default_include_dirs': [ + '.', + 'openssl', + 'openssl/crypto', + 'openssl/crypto/asn1', + 'openssl/crypto/evp', + 'openssl/crypto/md2', + 'openssl/crypto/modes', + 'openssl/crypto/store', + 'openssl/include', + ], + 'openssl_default_defines_all': [ + # No clue what these are for. + 'L_ENDIAN', + 'PURIFY', + '_REENTRANT', + + # SSLv2 is known broken and has been superseded by SSLv3 for almost + # twenty years now. + 'OPENSSL_NO_SSL2', + + # SSLv3 is susceptible to downgrade attacks (POODLE.) + 'OPENSSL_NO_SSL3', + + # Heartbeat is a TLS extension, that couldn't be turned off or + # asked to be not advertised. Unfortunately this is unacceptable for + # Microsoft's IIS, which seems to be ignoring whole ClientHello after + # seeing this extension. + 'OPENSSL_NO_HEARTBEATS', + ], + 'openssl_default_defines_win': [ + 'MK1MF_BUILD', + 'WIN32_LEAN_AND_MEAN', + 'OPENSSL_SYSNAME_WIN32', + ], + 'openssl_default_libraries_win': [ + '-lgdi32.lib', + '-luser32.lib', + ], + 'openssl_default_defines_not_win': [ + # ENGINESDIR must be defined if OPENSSLDIR is. + 'ENGINESDIR="/dev/null"', + 'TERMIOS', + ], + 'openssl_default_defines_mac': [ + # Set to ubuntu default path for convenience. If necessary, + # override this at runtime with the SSL_CERT_DIR environment + # variable. + 'OPENSSLDIR="/System/Library/OpenSSL/"', + ], + 'openssl_default_defines_linux_others': [ + # Set to ubuntu default path for convenience. If necessary, + # override this at runtime with the SSL_CERT_DIR environment + # variable. + 'OPENSSLDIR="/etc/ssl"', + ] } }