@@ -72,6 +72,7 @@ HostTargets.TERMS = {
72
72
Android : T . ANDROID ,
73
73
Linux : T . LINUX ,
74
74
MINGW : T . LINUX ,
75
+ CYGWIN : T . LINUX ,
75
76
Darwin : T . DARWIN ,
76
77
Windows : T . WINDOWS ,
77
78
DragonFly : { os : 'dragonfly' , vendor : 'unknown' } ,
@@ -94,6 +95,7 @@ HostTargets.TERMS = {
94
95
evbarm : { } ,
95
96
i86pc : { arch : 'x86' } ,
96
97
i386 : { arch : 'x86' } ,
98
+ i686 : { arch : 'x86' } ,
97
99
// libc
98
100
gnu : { libc : 'gnu' } ,
99
101
GNU : { libc : 'gnu' } ,
@@ -112,6 +114,8 @@ HostTargets._MATCHERS = {
112
114
// el = enterprise linux
113
115
// fc = fedora core
114
116
// amzn = amazon
117
+ // ex: CYGWIN_NT-10.0-WOW/3.3.5(0.341/5/3)
118
+ cygwin : / ^ C Y G W I N ( _ N T ) ? / ,
115
119
distroRelease : / ^ ( a n d r o i d | a m z n | e l | f c ) \d + $ / ,
116
120
// ex: MINGW64_NT-10.0-19045/3.3.6-341.x86_64
117
121
mingw : / ^ M I N G W ( 6 4 _ N T ) ? / ,
@@ -146,6 +150,11 @@ HostTargets.termsToTarget = function (target, terms) {
146
150
continue ;
147
151
}
148
152
153
+ if ( term . includes ( 'CYGWIN' ) ) {
154
+ Object . assign ( target , HostTargets . TERMS . CYGWIN ) ;
155
+ continue ;
156
+ }
157
+
149
158
let m = term . match ( HostTargets . _MATCHERS . distroRelease ) ;
150
159
if ( m ) {
151
160
// ex: android12 => android, fc39 => fc
@@ -185,8 +194,26 @@ function upsertHints(target, ua, terms, hints) {
185
194
}
186
195
if ( target [ key ] !== hints [ key ] ) {
187
196
let msg = `'${ key } ' already set to '${ target [ key ] } ', not updated to '${ hints [ key ] } '` ;
188
- target . errors . push ( { [ key ] : hints [ key ] , message : msg , terms : terms } ) ;
189
- throw new Error ( `${ msg } for '${ ua } ' / '${ terms } '` ) ;
197
+ let ignore = false ;
198
+ let targetIsLinuxy =
199
+ target [ key ] === 'gnu' ||
200
+ target [ key ] === 'bionic' ||
201
+ target [ key ] === 'musl' ;
202
+ if ( targetIsLinuxy ) {
203
+ if ( hints [ key ] === 'libc' ) {
204
+ // likely an old webi script with bad generic categorization
205
+ ignore = true ;
206
+ } else if ( hints [ key ] === 'musl' ) {
207
+ // musl can be installed on a GNU system
208
+ target . libs = [ target . libc , 'musl' ] ;
209
+ ignore = true ;
210
+ }
211
+ }
212
+ if ( ! ignore ) {
213
+ target . errors . push ( { [ key ] : hints [ key ] , message : msg , terms : terms } ) ;
214
+ throw new Error ( `${ msg } for '${ terms } '` ) ;
215
+ throw new Error ( `${ msg } for '${ ua } ' / '${ terms } '` ) ;
216
+ }
190
217
}
191
218
}
192
219
}
@@ -214,8 +241,14 @@ function upsertAndroidTerms(target, terms) {
214
241
target . libc = 'bionic' ;
215
242
}
216
243
if ( target . libc !== 'bionic' ) {
217
- let msg = `Android 'libc' already set to '${ target . libc } ', but should be 'bionic'` ;
218
- target . errors . push ( { libc : 'bionic' , message : msg , terms : terms } ) ;
219
- throw new Error ( `${ msg } for '${ terms } '` ) ;
244
+ if ( target . libc === 'musl' ) {
245
+ // musl can be installed on Android
246
+ target . libcs = [ 'bionic' , 'musl' ] ;
247
+ target . libc = 'musl' ;
248
+ } else {
249
+ let msg = `Android 'libc' already set to '${ target . libc } ', but should be 'bionic'` ;
250
+ target . errors . push ( { libc : 'bionic' , message : msg , terms : terms } ) ;
251
+ throw new Error ( `${ msg } for '${ terms } '` ) ;
252
+ }
220
253
}
221
254
}
0 commit comments