Skip to content

Commit fcb6a47

Browse files
author
Shigeki Ohtsu
committed
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
1 parent 8ed3053 commit fcb6a47

File tree

2 files changed

+220
-190
lines changed

2 files changed

+220
-190
lines changed

deps/openssl/openssl.gyp

+78-190
Original file line numberDiff line numberDiff line change
@@ -13,93 +13,74 @@
1313
{
1414
'target_name': 'openssl',
1515
'type': '<(library)',
16-
'sources': [
17-
'<@(openssl_sources)',
18-
],
16+
'sources': ['<@(openssl_sources)'],
1917
'sources/': [
2018
['exclude', 'md2/.*$'],
2119
['exclude', 'store/.*$']
2220
],
2321
'conditions': [
24-
['target_arch!="ia32" and target_arch!="x64" and target_arch!="arm" or openssl_no_asm!=0', {
22+
['openssl_no_asm!=0', {
2523
# Disable asm
2624
'defines': [
27-
'OPENSSL_NO_ASM'
28-
],
29-
'sources': [
30-
'<@(openssl_sources_no_asm)',
25+
'OPENSSL_NO_ASM',
3126
],
27+
'sources': ['<@(openssl_sources_no_asm)'],
3228
}, {
33-
# Enable asm
34-
'defines': [
35-
'AES_ASM',
36-
'CPUID_ASM',
37-
'OPENSSL_BN_ASM_MONT',
38-
'OPENSSL_CPUID_OBJ',
39-
'SHA1_ASM',
40-
'SHA256_ASM',
41-
'SHA512_ASM',
42-
'GHASH_ASM',
43-
],
29+
# "else if" was supported in https://codereview.chromium.org/601353002
4430
'conditions': [
45-
# Extended assembly on non-arm platforms
46-
['target_arch!="arm"', {
31+
['target_arch=="arm"', {
32+
'defines': ['<@(openssl_defines_asm)'],
33+
'sources': ['<@(openssl_sources_arm_elf_gas)'],
34+
}, 'target_arch=="ia32" and OS=="mac"', {
4735
'defines': [
48-
'VPAES_ASM',
49-
'BN_ASM',
50-
'BF_ASM',
51-
'BNCO_ASM',
52-
'DES_ASM',
53-
'LIB_BN_ASM',
54-
'MD5_ASM',
55-
'OPENSSL_BN_ASM',
56-
'RIP_ASM',
57-
'RMD160_ASM',
58-
'WHIRLPOOL_ASM',
59-
'WP_ASM',
36+
'<@(openssl_defines_asm)',
37+
'<@(openssl_defines_x86_mac)',
6038
],
61-
}],
62-
['OS!="win" and OS!="mac" and target_arch=="ia32"', {
63-
'sources': [
64-
'<@(openssl_sources_x86_elf_gas)',
65-
]
66-
}],
67-
['OS!="win" and OS!="mac" and target_arch=="x64"', {
39+
'sources': ['<@(openssl_sources_x86_macosx_gas)'],
40+
}, 'target_arch=="ia32" and OS=="win"', {
6841
'defines': [
69-
'OPENSSL_BN_ASM_MONT5',
70-
'OPENSSL_BN_ASM_GF2m',
71-
'OPENSSL_IA32_SSE2',
72-
'BSAES_ASM',
42+
'<@(openssl_defines_asm)',
43+
'<@(openssl_defines_x86_win)',
7344
],
74-
'sources': [
75-
'<@(openssl_sources_x64_elf_gas)',
76-
]
77-
}],
78-
['OS=="mac" and target_arch=="ia32"', {
79-
'sources': [
80-
'<@(openssl_sources_x86_macosx_gas)',
81-
]
82-
}],
83-
['OS=="mac" and target_arch=="x64"', {
45+
'sources': ['<@(openssl_sources_x86_win32_masm)'],
46+
}, 'target_arch=="ia32"', {
47+
# Linux or others
8448
'defines': [
85-
'OPENSSL_BN_ASM_MONT5',
86-
'OPENSSL_BN_ASM_GF2m',
87-
'OPENSSL_IA32_SSE2',
88-
'BSAES_ASM',
49+
'<@(openssl_defines_asm)',
50+
'<@(openssl_defines_x86_elf)',
8951
],
90-
'sources': [
91-
'<@(openssl_sources_x64_macosx_gas)',
92-
]
93-
}],
94-
['target_arch=="arm"', {
95-
'sources': [
96-
'<@(openssl_sources_arm_elf_gas)',
97-
]
98-
}],
99-
['OS=="win" and target_arch=="ia32"', {
100-
'sources': [
101-
'<@(openssl_sources_x86_win32_masm)',
52+
'sources': ['<@(openssl_sources_x86_elf_gas)'],
53+
}, 'target_arch=="x64" and OS=="mac"', {
54+
'defines': [
55+
'<@(openssl_defines_asm)',
56+
'<@(openssl_defines_x64_mac)',
57+
],
58+
'sources': ['<@(openssl_sources_x64_macosx_gas)'],
59+
}, 'target_arch=="x64" and OS=="win"', {
60+
'defines': [
61+
'<@(openssl_defines_asm)',
62+
'<@(openssl_defines_x64_win)',
10263
],
64+
'sources': ['<@(openssl_sources_x64_win32_masm)'],
65+
}, 'target_arch=="x64"', {
66+
# Linux or others
67+
'defines': [
68+
'<@(openssl_defines_asm)',
69+
'<@(openssl_defines_x64_elf)',
70+
],
71+
'sources': ['<@(openssl_sources_x64_elf_gas)'],
72+
}, { # else other archtectures does not use asm
73+
'defines': [
74+
'OPENSSL_NO_ASM',
75+
],
76+
'sources': ['<@(openssl_sources_no_asm)'],
77+
}],
78+
],
79+
}], # end of conditions of openssl_no_asm
80+
['OS=="win"', {
81+
'defines' : ['<@(openssl_defines_all_win)'],
82+
'conditions': [
83+
['target_arch=="ia32"', {
10384
'rules': [
10485
{
10586
'rule_name': 'Assemble',
@@ -118,18 +99,8 @@
11899
'process_outputs_as_sources': 0,
119100
'message': 'Assembling <(RULE_INPUT_PATH) to <(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).obj.',
120101
}
121-
]
122-
}],
123-
['OS=="win" and target_arch=="x64"', {
124-
'defines': [
125-
'OPENSSL_BN_ASM_MONT5',
126-
'OPENSSL_BN_ASM_GF2m',
127-
'OPENSSL_IA32_SSE2',
128-
'BSAES_ASM',
129-
],
130-
'sources': [
131-
'<@(openssl_sources_x64_win32_masm)',
132102
],
103+
}, 'target_arch=="x64"', {
133104
'rules': [
134105
{
135106
'rule_name': 'Assemble',
@@ -147,73 +118,36 @@
147118
'process_outputs_as_sources': 0,
148119
'message': 'Assembling <(RULE_INPUT_PATH) to <(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).obj.',
149120
}
150-
]
151-
}]
152-
]
153-
}],
154-
['OS=="win"', {
155-
'link_settings': {
156-
'libraries': [
157-
'-lgdi32.lib',
158-
'-luser32.lib',
159-
]
160-
},
161-
'defines': [
162-
'DSO_WIN32',
121+
],
122+
}],
163123
],
164124
}, {
165-
'defines': [
166-
'DSO_DLFCN',
167-
'HAVE_DLFCN_H'
168-
],
169-
}],
170-
],
171-
'include_dirs': [
172-
'.',
173-
'openssl',
174-
'openssl/crypto',
175-
'openssl/crypto/asn1',
176-
'openssl/crypto/evp',
177-
'openssl/crypto/md2',
178-
'openssl/crypto/modes',
179-
'openssl/crypto/store',
180-
'openssl/include',
125+
'defines' : ['<@(openssl_defines_all_non_win)']
126+
}]
181127
],
128+
'include_dirs': ['<@(openssl_include_dirs)'],
182129
'direct_dependent_settings': {
183-
'include_dirs': ['openssl/include'],
130+
'include_dirs': [
131+
'openssl/include'
132+
],
184133
},
185134
},
186135
{
187136
'target_name': 'openssl-cli',
188137
'type': 'executable',
189-
'dependencies': [
190-
'openssl',
191-
],
138+
'dependencies': ['openssl'],
192139
'defines': [
193-
'MONOLITH',
194-
],
195-
'sources': [
196-
'<@(openssl_cli_sources)',
140+
'MONOLITH'
197141
],
142+
'sources': ['<@(openssl_cli_sources)'],
198143
'conditions': [
199144
['OS=="solaris"', {
200-
'libraries': [
201-
'-lsocket',
202-
'-lnsl',
203-
]
204-
}],
205-
['OS=="win"', {
145+
'libraries': ['<@(openssl_cli_libraries_solaris)']
146+
}, 'OS=="win"', {
206147
'link_settings': {
207-
'libraries': [
208-
'-lws2_32.lib',
209-
'-lgdi32.lib',
210-
'-ladvapi32.lib',
211-
'-lcrypt32.lib',
212-
'-luser32.lib',
213-
],
148+
'libraries': ['<@(openssl_cli_libraries_win)'],
214149
},
215-
}],
216-
[ 'OS in "linux android"', {
150+
}, 'OS in "linux android"', {
217151
'link_settings': {
218152
'libraries': [
219153
'-ldl',
@@ -224,70 +158,24 @@
224158
}
225159
],
226160
'target_defaults': {
227-
'include_dirs': [
228-
'.',
229-
'openssl',
230-
'openssl/crypto',
231-
'openssl/crypto/asn1',
232-
'openssl/crypto/evp',
233-
'openssl/crypto/md2',
234-
'openssl/crypto/modes',
235-
'openssl/crypto/store',
236-
'openssl/include',
237-
],
238-
'defines': [
239-
# No clue what these are for.
240-
'L_ENDIAN',
241-
'PURIFY',
242-
'_REENTRANT',
243-
244-
# SSLv2 is known broken and has been superseded by SSLv3 for almost
245-
# twenty years now.
246-
'OPENSSL_NO_SSL2',
247-
248-
# SSLv3 is susceptible to downgrade attacks (POODLE.)
249-
'OPENSSL_NO_SSL3',
250-
251-
# Heartbeat is a TLS extension, that couldn't be turned off or
252-
# asked to be not advertised. Unfortunately this is unacceptable for
253-
# Microsoft's IIS, which seems to be ignoring whole ClientHello after
254-
# seeing this extension.
255-
'OPENSSL_NO_HEARTBEATS',
256-
],
161+
'include_dirs': ['<@(openssl_default_include_dirs)'],
162+
'defines': ['<@(openssl_default_defines_all)'],
257163
'conditions': [
258164
['OS=="win"', {
259-
'defines': [
260-
'MK1MF_BUILD',
261-
'WIN32_LEAN_AND_MEAN',
262-
'OPENSSL_SYSNAME_WIN32',
263-
],
264-
'msvs_disabled_warnings': [
265-
4244, # conversion from 'signed type', possible loss of data
266-
4267, # conversion from 'unsigned type', possible loss of data
267-
4996, # 'GetVersionExA': was declared deprecated
268-
],
165+
'defines': ['<@(openssl_default_defines_win)'],
166+
'link_settings': {
167+
'libraries': ['<@(openssl_default_libraries_win)'],
168+
},
269169
}, {
270-
'defines': [
271-
# ENGINESDIR must be defined if OPENSSLDIR is.
272-
'ENGINESDIR="/dev/null"',
273-
'TERMIOS',
170+
'defines': ['<@(openssl_default_defines_not_win)'],
171+
'cflags': [
172+
'-Wno-missing-field-initializers',
274173
],
275-
'cflags': ['-Wno-missing-field-initializers'],
276174
'conditions': [
277175
['OS=="mac"', {
278-
'defines': [
279-
# Set to ubuntu default path for convenience. If necessary,
280-
# override this at runtime with the SSL_CERT_DIR environment
281-
# variable.
282-
'OPENSSLDIR="/System/Library/OpenSSL/"',
283-
],
176+
'defines': ['<@(openssl_default_defines_mac)'],
284177
}, {
285-
'defines': [
286-
# Set to ubuntu default path for convenience. If necessary,
287-
# override this at runtime with the SSL_CERT_DIR environment
288-
# variable.
289-
'OPENSSLDIR="/etc/ssl"',
290-
],
178+
'defines': ['<@(openssl_default_defines_linux_others)'],
291179
}],
292180
]
293181
}],

0 commit comments

Comments
 (0)