@@ -55,22 +55,25 @@ export function buildLibmongocryptDownloadUrl(ref, platform) {
5555}
5656
5757export function getLibmongocryptPrebuildName ( ) {
58- const platformMatrix = {
59- [ 'darwin-arm64' ] : 'macos' ,
60- [ 'darwin-x64' ] : 'macos' ,
61- [ 'linux-ppc64' ] : 'rhel-71-ppc64el' ,
62- [ 'linux-s390x' ] : 'rhel72-zseries-test' ,
63- [ 'linux-arm64' ] : 'ubuntu1804-arm64' ,
64- [ 'linux-x64' ] : 'rhel-70-64-bit' ,
65- [ 'win32-x64' ] : 'windows-test'
66- } ;
67-
68- const detectedPlatform = `${ process . platform } -${ process . arch } ` ;
69- const prebuild = platformMatrix [ detectedPlatform ] ;
70-
71- if ( prebuild == null ) throw new Error ( `Unsupported: ${ detectedPlatform } ` ) ;
72-
73- return prebuild ;
58+ const prebuildIdentifierFactory = {
59+ 'darwin' : ( ) => 'macos' ,
60+ 'win32' : ( ) => 'windows-test' ,
61+ 'linux' : ( ) => {
62+ const key = `${ getLibc ( ) } -${ process . arch } ` ;
63+ return {
64+ [ 'musl-x64' ] : 'alpine-amd64-earthly' ,
65+ [ 'musl-arm64' ] : 'alpine-arm64-earthly' ,
66+ [ 'glibc-ppc64' ] : 'rhel-71-ppc64el' ,
67+ [ 'glibc-s390x' ] : 'rhel72-zseries-test' ,
68+ [ 'glibc-arm64' ] : 'ubuntu1804-arm64' ,
69+ [ 'glibc-x64' ] : 'rhel-70-64-bit' ,
70+ } [ key ]
71+ }
72+ } [ process . platform ] ?? ( ( ) => {
73+ throw new Error ( `Unsupported platform` ) ;
74+ } ) ;
75+
76+ return prebuildIdentifierFactory ( ) ;
7477}
7578
7679/** `xtrace` style command runner, uses spawn so that stdio is inherited */
@@ -91,7 +94,7 @@ export async function run(command, args = [], options = {}) {
9194/**
9295 * @returns the libc (`musl` or `glibc`), if the platform is linux, otherwise null.
9396 */
94- export function getLibc ( ) {
97+ function getLibc ( ) {
9598 if ( process . platform !== 'linux' ) return null ;
9699
97100 /**
@@ -111,29 +114,3 @@ export function getLibc() {
111114 console . error ( { ldd : lddVersion ( ) } ) ;
112115 return lddVersion ( ) . includes ( 'musl' ) ? 'musl' : 'glibc' ;
113116}
114-
115- /**
116- * @returns the name of the package inside the libmognocrypt prebuild tarball for the current platform, arch and libc (if linux).
117- */
118- export function getLibmongocryptPackageName ( ) {
119- const platformFactory = {
120- 'darwin' : ( ) => 'macos' ,
121- 'win32' : ( ) => 'windows-test' ,
122- 'linux' : ( ) => {
123- const key = `${ getLibc ( ) } -${ process . arch } ` ;
124- return {
125- [ 'musl-x64' ] : 'alpine-amd64-earthly' ,
126- [ 'musl-arm64' ] : 'alpine-arm64-earthly' ,
127- [ 'glibc-ppc64' ] : 'rhel-71-ppc64el' ,
128- [ 'glibc-s390x' ] : 'rhel72-zseries-test' ,
129- [ 'glibc-arm64' ] : 'ubuntu1804-arm64' ,
130- [ 'glibc-x64' ] : 'rhel-70-64-bit' ,
131- } [ key ]
132- }
133- } [ process . platform ] ?? ( ( ) => {
134- throw new Error ( 'unexpected platform.' )
135- } ) ;
136-
137- return platformFactory ( ) ;
138- }
139-
0 commit comments