1010const https = require ( 'https' ) ;
1111const fs = require ( 'fs' ) ;
1212const path = require ( 'path' ) ;
13+ const os = require ( 'os' ) ;
1314
1415const root = process . cwd ( ) ;
1516const pkg = require ( path . join ( root , 'package.json' ) ) ;
@@ -29,14 +30,22 @@ function detectLibc() {
2930}
3031
3132function platformTriple ( ) {
32- const { platform, arch } = process ;
33+ // Allow explicit overrides for debugging or special environments
34+ const forceTriple = process . env . SQLITE3_VEC_TRIPLE ;
35+ if ( forceTriple ) return forceTriple ;
36+ const forcePlatform = process . env . SQLITE3_VEC_PLATFORM ;
37+ const forceArch = process . env . SQLITE3_VEC_ARCH ;
38+ const platform = ( forcePlatform || process . platform ) ;
39+ const arch = ( forceArch || process . arch ) ;
3340 if ( platform === 'darwin' ) return `darwin-${ arch } ` ;
3441 if ( platform === 'win32' ) return `win32-${ arch } ` ;
3542 if ( platform === 'linux' ) return `linux-${ arch } -${ detectLibc ( ) } ` ;
3643 return `${ platform } -${ arch } ` ;
3744}
3845
3946function fileExt ( ) {
47+ const forceExt = process . env . SQLITE3_VEC_EXT ;
48+ if ( forceExt ) return forceExt ;
4049 if ( process . platform === 'darwin' ) return 'dylib' ;
4150 if ( process . platform === 'win32' ) return 'dll' ;
4251 return 'so' ;
@@ -75,6 +84,20 @@ async function download(url, dest) {
7584async function main ( ) {
7685 const triple = platformTriple ( ) ;
7786 const ext = fileExt ( ) ;
87+ // Helpful diagnostics
88+ const diag = {
89+ platform : process . platform ,
90+ arch : process . arch ,
91+ osRelease : os . release ?. ( ) || undefined ,
92+ force : {
93+ triple : process . env . SQLITE3_VEC_TRIPLE || undefined ,
94+ platform : process . env . SQLITE3_VEC_PLATFORM || undefined ,
95+ arch : process . env . SQLITE3_VEC_ARCH || undefined ,
96+ ext : process . env . SQLITE3_VEC_EXT || undefined ,
97+ } ,
98+ resolved : { triple, ext } ,
99+ } ;
100+ console . log ( '[sqlite3-vec] Platform detection:' , JSON . stringify ( diag ) ) ;
78101 const verWithV = pkg . version . startsWith ( 'v' ) ? pkg . version : `v${ pkg . version } ` ;
79102 const verNoV = verWithV . replace ( / ^ v / , '' ) ;
80103 const resolved = repoFromPackage ( ) ;
0 commit comments