Skip to content

Commit

Permalink
simplifying pre-built libraries structure and resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
agracio committed Jun 8, 2024
1 parent 023b5eb commit 2f8134b
Show file tree
Hide file tree
Showing 32 changed files with 20 additions and 28 deletions.
25 changes: 11 additions & 14 deletions lib/edge.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
File renamed without changes.
Empty file.
File renamed without changes.
Empty file.
File renamed without changes.
Empty file.
File renamed without changes.
Empty file.
File renamed without changes.
Empty file.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
Empty file added lib/native/win32/x64/22/v22.2.0
Empty file.
23 changes: 9 additions & 14 deletions tools/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -18,33 +20,26 @@ 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

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 (
Expand Down

0 comments on commit 2f8134b

Please sign in to comment.