Skip to content

Commit f6b55f8

Browse files
committed
fix(host-target): ignore errant libc, handle musl on bionic and GNU
1 parent 65f5f36 commit f6b55f8

File tree

1 file changed

+38
-5
lines changed

1 file changed

+38
-5
lines changed

host-targets.js

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ HostTargets.TERMS = {
7272
Android: T.ANDROID,
7373
Linux: T.LINUX,
7474
MINGW: T.LINUX,
75+
CYGWIN: T.LINUX,
7576
Darwin: T.DARWIN,
7677
Windows: T.WINDOWS,
7778
DragonFly: { os: 'dragonfly', vendor: 'unknown' },
@@ -94,6 +95,7 @@ HostTargets.TERMS = {
9495
evbarm: {},
9596
i86pc: { arch: 'x86' },
9697
i386: { arch: 'x86' },
98+
i686: { arch: 'x86' },
9799
// libc
98100
gnu: { libc: 'gnu' },
99101
GNU: { libc: 'gnu' },
@@ -112,6 +114,8 @@ HostTargets._MATCHERS = {
112114
// el = enterprise linux
113115
// fc = fedora core
114116
// amzn = amazon
117+
// ex: CYGWIN_NT-10.0-WOW/3.3.5(0.341/5/3)
118+
cygwin: /^CYGWIN(_NT)?/,
115119
distroRelease: /^(android|amzn|el|fc)\d+$/,
116120
// ex: MINGW64_NT-10.0-19045/3.3.6-341.x86_64
117121
mingw: /^MINGW(64_NT)?/,
@@ -146,6 +150,11 @@ HostTargets.termsToTarget = function (target, terms) {
146150
continue;
147151
}
148152

153+
if (term.includes('CYGWIN')) {
154+
Object.assign(target, HostTargets.TERMS.CYGWIN);
155+
continue;
156+
}
157+
149158
let m = term.match(HostTargets._MATCHERS.distroRelease);
150159
if (m) {
151160
// ex: android12 => android, fc39 => fc
@@ -185,8 +194,26 @@ function upsertHints(target, ua, terms, hints) {
185194
}
186195
if (target[key] !== hints[key]) {
187196
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+
}
190217
}
191218
}
192219
}
@@ -214,8 +241,14 @@ function upsertAndroidTerms(target, terms) {
214241
target.libc = 'bionic';
215242
}
216243
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+
}
220253
}
221254
}

0 commit comments

Comments
 (0)