forked from OSchip/llvm-project
[libc++] Reimplement platform detection features without running on the test host
It's sufficient to sniff the platform we're running on using the compiler macros -- we don't need to run any code.
This commit is contained in:
parent
e81c05777d
commit
2be4014fe6
|
@ -110,22 +110,10 @@ for locale, alts in locales.items():
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
# Add a feature representing the platform name: darwin, linux, windows, etc...
|
# Add features representing the platform name: darwin, linux, windows, etc...
|
||||||
features += [
|
features += [
|
||||||
Feature(name=lambda cfg: programOutput(cfg, """
|
Feature(name='darwin', when=lambda cfg: '__APPLE__' in compilerMacros(cfg)),
|
||||||
#include <cstdio>
|
Feature(name='windows', when=lambda cfg: '_WIN32' in compilerMacros(cfg)),
|
||||||
int main() {
|
Feature(name='linux', when=lambda cfg: '__linux__' in compilerMacros(cfg)),
|
||||||
#if defined(__APPLE__)
|
Feature(name='netbsd', when=lambda cfg: '__NetBSD__' in compilerMacros(cfg))
|
||||||
std::printf("darwin");
|
|
||||||
#elif defined(_WIN32)
|
|
||||||
std::printf("windows");
|
|
||||||
#elif defined(__NetBSD__)
|
|
||||||
std::printf("netbsd");
|
|
||||||
#elif defined(__linux__)
|
|
||||||
std::printf("linux");
|
|
||||||
#else
|
|
||||||
std::printf("unknown-platform");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
"""))
|
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue