mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 10:58:56 +00:00
Fix detect-libc
This commit is contained in:
34
src/bun.js/bindings/BunDetectLibcModule.cpp
Normal file
34
src/bun.js/bindings/BunDetectLibcModule.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "root.h"
|
||||
|
||||
#include "JavaScriptCore/JavaScript.h"
|
||||
#include "wtf/text/WTFString.h"
|
||||
#include "JavaScriptCore/ObjectConstructor.h"
|
||||
|
||||
#if defined(__LINUX__)
|
||||
#include <gnu/libc-version.h>
|
||||
#endif
|
||||
|
||||
using namespace JSC;
|
||||
using namespace WTF;
|
||||
|
||||
JSC::JSObject* createDetectLibcModule(JSC::JSGlobalObject* globalObject)
|
||||
{
|
||||
VM& vm = globalObject->vm();
|
||||
JSC::JSObject* object = nullptr;
|
||||
|
||||
{
|
||||
JSC::ObjectInitializationScope initializationScope(vm);
|
||||
object = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), 2);
|
||||
#if defined(__LINUX__)
|
||||
auto version = JSC::jsString(vm, makeAtomString(gnu_get_libc_version()));
|
||||
auto family = JSC::jsString(vm, makeAtomString("glibc"));
|
||||
#else
|
||||
auto version = JSC::jsNull();
|
||||
auto family = JSC::jsNull();
|
||||
#endif
|
||||
object->putDirect(vm, JSC::Identifier::fromString(vm, "version"_s), version, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
|
||||
object->putDirect(vm, JSC::Identifier::fromString(vm, "family"_s), family, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
Reference in New Issue
Block a user