-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Muhammad Awawdi <[email protected]>
- Loading branch information
1 parent
5f0a3fc
commit 3ed65fe
Showing
12 changed files
with
177 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { GLIBC, MUSL, familySync } from "detect-libc"; | ||
import { arch, platform } from "process"; | ||
|
||
/* eslint-disable @typescript-eslint/no-require-imports */ | ||
function loadNativeBinding() { | ||
let nativeBinding = null; | ||
|
||
switch (platform) { | ||
case "linux": | ||
switch (arch) { | ||
case "x64": | ||
switch (familySync()) { | ||
case GLIBC: | ||
nativeBinding = require("@scope/glide-rs-linux-x64"); | ||
break; | ||
case MUSL: | ||
nativeBinding = require("@scope/glide-rs-linux-musl-x64"); | ||
break; | ||
default: | ||
nativeBinding = require("@scope/glide-rs-linux-x64"); | ||
break; | ||
} | ||
|
||
break; | ||
case "arm64": | ||
switch (familySync()) { | ||
case GLIBC: | ||
nativeBinding = require("@scope/glide-rs-linux-arm64"); | ||
break; | ||
case MUSL: | ||
nativeBinding = require("@scope/glide-rs-linux-musl-arm64"); | ||
break; | ||
default: | ||
nativeBinding = require("@scope/glide-rs-linux-arm64"); | ||
break; | ||
} | ||
|
||
break; | ||
default: | ||
throw new Error( | ||
`Unsupported OS: ${platform}, architecture: ${arch}`, | ||
); | ||
} | ||
|
||
break; | ||
case "darwin": | ||
switch (arch) { | ||
case "arm64": | ||
nativeBinding = require("@scope/glide-rs-darwin-arm64"); | ||
break; | ||
default: | ||
throw new Error( | ||
`Unsupported OS: ${platform}, architecture: ${arch}`, | ||
); | ||
} | ||
|
||
break; | ||
default: | ||
throw new Error( | ||
`Unsupported OS: ${platform}, architecture: ${arch}`, | ||
); | ||
} | ||
|
||
if (!nativeBinding) { | ||
throw new Error(`Failed to load native binding`); | ||
} | ||
|
||
return nativeBinding; | ||
} | ||
|
||
const nativeBinding = loadNativeBinding(); | ||
|
||
export = nativeBinding; |
Oops, something went wrong.