diff --git a/lib/edge.js b/lib/edge.js index 5d440cc2..36db3e18 100644 --- a/lib/edge.js +++ b/lib/edge.js @@ -1,25 +1,22 @@ -var fs = require('fs') - , path = require('path') - , builtEdge = path.resolve(__dirname, '../build/Release/' + (process.env.EDGE_USE_CORECLR || !fs.existsSync(path.resolve(__dirname, '../build/Release/edge_nativeclr.node')) ? 'edge_coreclr.node' : 'edge_nativeclr.node')) - , edge; +const fs = require('fs'); +const path = require('path'); +const builtEdge = path.resolve(__dirname, '../build/Release/' + (process.env.EDGE_USE_CORECLR || !fs.existsSync(path.resolve(__dirname, '../build/Release/edge_nativeclr.node')) ? 'edge_coreclr.node' : 'edge_nativeclr.node')); -function determineVersion() { - var source = path.resolve(__dirname, `native/${process.platform}/${process.arch}`) - const version = `${process.versions.node.split(".")[0]}`; - - const getDirectories = source => - fs.readdirSync(source, { withFileTypes: true }) - .filter(dir => dir.isDirectory() && dir.name.startsWith(version)) - .map(dir => dir.name) +const nodeVersion = process.versions.node.split(".")[0] - var nativeModulePath = getDirectories(source).shift() +var edge; - if(nativeModulePath) return nativeModulePath; +function determineVersion() { + var nativePath = path.resolve(__dirname, `native/${process.platform}/${process.arch}/${nodeVersion}`); + if(fs.existsSync(nativePath)){ + return nodeVersion; + } throw new Error('The edge module has not been pre-compiled for node.js version ' + process.version + '. You must build a custom version of edge.node. Please refer to https://github.com/agracio/edge-js ' + 'for building instructions.'); } + var edgeNative; if (process.env.EDGE_NATIVE) { edgeNative = process.env.EDGE_NATIVE; diff --git a/lib/native/win32/arm64/20.14.0/edge_coreclr.node b/lib/native/win32/arm64/20/edge_coreclr.node similarity index 100% rename from lib/native/win32/arm64/20.14.0/edge_coreclr.node rename to lib/native/win32/arm64/20/edge_coreclr.node diff --git a/lib/native/win32/arm64/20.14.0/edge_nativeclr.node b/lib/native/win32/arm64/20/edge_nativeclr.node similarity index 100% rename from lib/native/win32/arm64/20.14.0/edge_nativeclr.node rename to lib/native/win32/arm64/20/edge_nativeclr.node diff --git a/lib/native/win32/arm64/20/v20.14.0 b/lib/native/win32/arm64/20/v20.14.0 new file mode 100644 index 00000000..e69de29b diff --git a/lib/native/win32/arm64/22.2.0/edge_coreclr.node b/lib/native/win32/arm64/22/edge_coreclr.node similarity index 100% rename from lib/native/win32/arm64/22.2.0/edge_coreclr.node rename to lib/native/win32/arm64/22/edge_coreclr.node diff --git a/lib/native/win32/arm64/22.2.0/edge_nativeclr.node b/lib/native/win32/arm64/22/edge_nativeclr.node similarity index 100% rename from lib/native/win32/arm64/22.2.0/edge_nativeclr.node rename to lib/native/win32/arm64/22/edge_nativeclr.node diff --git a/lib/native/win32/arm64/22/v22.2.0 b/lib/native/win32/arm64/22/v22.2.0 new file mode 100644 index 00000000..e69de29b diff --git a/lib/native/win32/ia32/16.20.2/edge_coreclr.node b/lib/native/win32/ia32/16/edge_coreclr.node similarity index 100% rename from lib/native/win32/ia32/16.20.2/edge_coreclr.node rename to lib/native/win32/ia32/16/edge_coreclr.node diff --git a/lib/native/win32/ia32/16.20.2/edge_nativeclr.node b/lib/native/win32/ia32/16/edge_nativeclr.node similarity index 100% rename from lib/native/win32/ia32/16.20.2/edge_nativeclr.node rename to lib/native/win32/ia32/16/edge_nativeclr.node diff --git a/lib/native/win32/ia32/16/v16.20.2 b/lib/native/win32/ia32/16/v16.20.2 new file mode 100644 index 00000000..e69de29b diff --git a/lib/native/win32/ia32/18.19.1/edge_coreclr.node b/lib/native/win32/ia32/18/edge_coreclr.node similarity index 100% rename from lib/native/win32/ia32/18.19.1/edge_coreclr.node rename to lib/native/win32/ia32/18/edge_coreclr.node diff --git a/lib/native/win32/ia32/18.19.1/edge_nativeclr.node b/lib/native/win32/ia32/18/edge_nativeclr.node similarity index 100% rename from lib/native/win32/ia32/18.19.1/edge_nativeclr.node rename to lib/native/win32/ia32/18/edge_nativeclr.node diff --git a/lib/native/win32/ia32/18/v18.19.1 b/lib/native/win32/ia32/18/v18.19.1 new file mode 100644 index 00000000..e69de29b diff --git a/lib/native/win32/ia32/20.14.0/edge_coreclr.node b/lib/native/win32/ia32/20/edge_coreclr.node similarity index 100% rename from lib/native/win32/ia32/20.14.0/edge_coreclr.node rename to lib/native/win32/ia32/20/edge_coreclr.node diff --git a/lib/native/win32/ia32/20.14.0/edge_nativeclr.node b/lib/native/win32/ia32/20/edge_nativeclr.node similarity index 100% rename from lib/native/win32/ia32/20.14.0/edge_nativeclr.node rename to lib/native/win32/ia32/20/edge_nativeclr.node diff --git a/lib/native/win32/ia32/20/v20.14.0 b/lib/native/win32/ia32/20/v20.14.0 new file mode 100644 index 00000000..e69de29b diff --git a/lib/native/win32/ia32/22.2.0/edge_coreclr.node b/lib/native/win32/ia32/22/edge_coreclr.node similarity index 100% rename from lib/native/win32/ia32/22.2.0/edge_coreclr.node rename to lib/native/win32/ia32/22/edge_coreclr.node diff --git a/lib/native/win32/ia32/22.2.0/edge_nativeclr.node b/lib/native/win32/ia32/22/edge_nativeclr.node similarity index 100% rename from lib/native/win32/ia32/22.2.0/edge_nativeclr.node rename to lib/native/win32/ia32/22/edge_nativeclr.node diff --git a/lib/native/win32/ia32/22/v22.2.0 b/lib/native/win32/ia32/22/v22.2.0 new file mode 100644 index 00000000..e69de29b diff --git a/lib/native/win32/x64/16.20.2/edge_coreclr.node b/lib/native/win32/x64/16/edge_coreclr.node similarity index 100% rename from lib/native/win32/x64/16.20.2/edge_coreclr.node rename to lib/native/win32/x64/16/edge_coreclr.node diff --git a/lib/native/win32/x64/16.20.2/edge_nativeclr.node b/lib/native/win32/x64/16/edge_nativeclr.node similarity index 100% rename from lib/native/win32/x64/16.20.2/edge_nativeclr.node rename to lib/native/win32/x64/16/edge_nativeclr.node diff --git a/lib/native/win32/x64/16/v16.20.2 b/lib/native/win32/x64/16/v16.20.2 new file mode 100644 index 00000000..e69de29b diff --git a/lib/native/win32/x64/18.19.1/edge_coreclr.node b/lib/native/win32/x64/18/edge_coreclr.node similarity index 100% rename from lib/native/win32/x64/18.19.1/edge_coreclr.node rename to lib/native/win32/x64/18/edge_coreclr.node diff --git a/lib/native/win32/x64/18.19.1/edge_nativeclr.node b/lib/native/win32/x64/18/edge_nativeclr.node similarity index 100% rename from lib/native/win32/x64/18.19.1/edge_nativeclr.node rename to lib/native/win32/x64/18/edge_nativeclr.node diff --git a/lib/native/win32/x64/18/v18.19.1 b/lib/native/win32/x64/18/v18.19.1 new file mode 100644 index 00000000..e69de29b diff --git a/lib/native/win32/x64/20.14.0/edge_coreclr.node b/lib/native/win32/x64/20/edge_coreclr.node similarity index 100% rename from lib/native/win32/x64/20.14.0/edge_coreclr.node rename to lib/native/win32/x64/20/edge_coreclr.node diff --git a/lib/native/win32/x64/20.14.0/edge_nativeclr.node b/lib/native/win32/x64/20/edge_nativeclr.node similarity index 100% rename from lib/native/win32/x64/20.14.0/edge_nativeclr.node rename to lib/native/win32/x64/20/edge_nativeclr.node diff --git a/lib/native/win32/x64/20/v20.14.0 b/lib/native/win32/x64/20/v20.14.0 new file mode 100644 index 00000000..e69de29b diff --git a/lib/native/win32/x64/22.2.0/edge_coreclr.node b/lib/native/win32/x64/22/edge_coreclr.node similarity index 100% rename from lib/native/win32/x64/22.2.0/edge_coreclr.node rename to lib/native/win32/x64/22/edge_coreclr.node diff --git a/lib/native/win32/x64/22.2.0/edge_nativeclr.node b/lib/native/win32/x64/22/edge_nativeclr.node similarity index 100% rename from lib/native/win32/x64/22.2.0/edge_nativeclr.node rename to lib/native/win32/x64/22/edge_nativeclr.node diff --git a/lib/native/win32/x64/22/v22.2.0 b/lib/native/win32/x64/22/v22.2.0 new file mode 100644 index 00000000..e69de29b diff --git a/tools/build.bat b/tools/build.bat index 8a714530..77ead806 100644 --- a/tools/build.bat +++ b/tools/build.bat @@ -6,6 +6,8 @@ if "%1" equ "" ( exit /b -1 ) FOR /F "tokens=* USEBACKQ" %%F IN (`node -p process.arch`) DO (SET ARCH=%%F) +for /F "delims=." %%a in ("%2") do set MAJORVERSION=%%a +set MAJORVERSION=%MAJORVERSION: =% SET FLAVOR=%1 shift @@ -18,22 +20,14 @@ if not exist "%NODEEXE%" ( ) for %%i in ("%NODEEXE%") do set NODEDIR=%%~dpi SET DESTDIRROOT=%SELF%\..\lib\native\win32 -set VERSIONS= -:harvestVersions -if "%1" neq "" ( - set VERSIONS=%VERSIONS% %1 - shift - goto :harvestVersions -) -if "%VERSIONS%" equ "" set VERSIONS=20.14.0 +set VERSION=%1 pushd %SELF%\.. if "%ARCH%" == "arm64" ( - for %%V in (%VERSIONS%) do call :build arm64 arm64 %%V + call :build arm64 arm64 %VERSION% ) else ( - for %%V in (%VERSIONS%) do call :build ia32 x86 %%V - for %%V in (%VERSIONS%) do call :build x64 x64 %%V - + call :build ia32 x86 %VERSION% + call :build x64 x64 %VERSION% ) popd @@ -41,10 +35,11 @@ exit /b 0 :build -set DESTDIR=%DESTDIRROOT%\%1\%3 +set DESTDIR=%DESTDIRROOT%\%1\%MAJORVERSION% +if not exist "%DESTDIR%" mkdir "%DESTDIR%" +type NUL > %DESTDIR%\v%VERSION% if exist "%DESTDIR%\node.exe" goto gyp -if not exist "%DESTDIR%\NUL" mkdir "%DESTDIR%" echo Downloading node.exe %2 %3... node "%SELF%\download.js" %2 %3 "%DESTDIR%" if %ERRORLEVEL% neq 0 (