This repository was archived by the owner on Oct 18, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +28
-21
lines changed Expand file tree Collapse file tree 5 files changed +28
-21
lines changed Original file line number Diff line number Diff line change 1- const fs = require ( 'fs' ) ;
2- const path = require ( 'path' ) ;
1+ const path = require ( "path" ) ;
32
43function resolvePath ( filePath , file ) {
54 if ( ! filePath ) {
65 return undefined ;
76 }
8- return ( file ? path . resolve ( filePath , file ) : path . resolve ( filePath ) ) . replace ( / \\ / g, '/' ) ;
7+ return ( file ? path . resolve ( filePath , file ) : path . resolve ( filePath ) ) . replace (
8+ / \\ / g,
9+ "/"
10+ ) ;
911}
1012
11- const defaultDir = ' /usr/local' ;
13+ const defaultDir = " /usr/local" ;
1214
1315function getLibDir ( ) {
14- const libPath = resolvePath ( process . env . OPENCV_LIB_DIR )
15- if ( process . platform === ' win32' && ! libPath ) {
16- throw new Error ( ' OPENCV_LIB_DIR is not defined' )
16+ const libPath = resolvePath ( process . env . OPENCV_LIB_DIR ) ;
17+ if ( process . platform === " win32" && ! libPath ) {
18+ throw new Error ( " OPENCV_LIB_DIR is not defined" ) ;
1719 }
1820 return libPath || `${ defaultDir } /lib` ;
1921}
2022
23+ function linkSystemLibs ( ) {
24+ return ! ! process . env . OPENCV_LINK_SYSTEM_LIBS ;
25+ }
26+
2127module . exports = {
2228 resolvePath,
2329 defaultDir,
24- getLibDir
30+ getLibDir,
31+ linkSystemLibs
2532} ;
Original file line number Diff line number Diff line change 11const path = require ( 'path' ) ;
2- const opencvBuild = require ( ' opencv-build' ) ;
3- const { resolvePath } = require ( './commons' ) ;
2+ const opencvBuild = require ( `@nut-tree/ opencv-build- ${ process . platform } ` ) ;
3+ const { resolvePath, linkSystemLibs } = require ( './commons' ) ;
44
55// ensure binaries are added to path on windows
6- if ( opencvBuild . isAutoBuildEnabled ( ) && process . platform === 'win32' ) {
6+ if ( ! linkSystemLibs ( ) && process . platform === 'win32' ) {
77 // append opencv binary path to node process
88 if ( ! process . env . path . includes ( opencvBuild . opencvBinDir ) ) {
99 process . env . path = `${ process . env . path } ;${ opencvBuild . opencvBinDir } ;`
Original file line number Diff line number Diff line change 1- const opencvBuild = require ( ' opencv-build' ) ;
2- const { getLibDir } = require ( './commons' ) ;
1+ const opencvBuild = require ( `@nut-tree/ opencv-build- ${ process . platform } ` ) ;
2+ const { getLibDir, linkSystemLibs } = require ( './commons' ) ;
33
4- if ( ! opencvBuild . isAutoBuildEnabled ( ) ) {
4+ if ( linkSystemLibs ( ) ) {
55 opencvBuild . getLibs ( getLibDir ( ) )
66 . filter ( lib => lib . libPath )
77 . map ( lib => lib . opencvModule )
Original file line number Diff line number Diff line change 1- const opencvBuild = require ( ' opencv-build' ) ;
2- const { resolvePath, defaultDir } = require ( './commons' ) ;
1+ const opencvBuild = require ( `@nut-tree/ opencv-build- ${ process . platform } ` ) ;
2+ const { resolvePath, defaultDir, linkSystemLibs } = require ( './commons' ) ;
33
4- if ( opencvBuild . isAutoBuildEnabled ( ) ) {
4+ if ( linkSystemLibs ( ) ) {
55 console . log ( resolvePath ( process . env . OPENCV_INCLUDE_DIR ) || `${ defaultDir } /include` ) ;
66 return ;
77}
Original file line number Diff line number Diff line change 1- const opencvBuild = require ( ' opencv-build' ) ;
2- const { resolvePath, getLibDir } = require ( './commons' ) ;
1+ const opencvBuild = require ( `@nut-tree/ opencv-build- ${ process . platform } ` ) ;
2+ const { resolvePath, getLibDir, linkSystemLibs } = require ( './commons' ) ;
33
44function linkLibs ( libs ) {
55 libs
@@ -8,7 +8,7 @@ function linkLibs(libs) {
88 . forEach ( libPath => console . log ( resolvePath ( libPath ) ) ) ;
99}
1010
11- if ( ! opencvBuild . isAutoBuildEnabled ( ) ) {
11+ if ( linkSystemLibs ( ) ) {
1212 linkLibs ( opencvBuild . getLibs ( getLibDir ( ) ) ) ;
1313 return ;
1414}
@@ -21,5 +21,5 @@ if (process.platform === 'win32') {
2121
2222// if not windows, link libs dynamically
2323console . log ( '-L' + resolvePath ( opencvBuild . opencvLibDir ) ) ;
24- opencvBuild . opencvModules . forEach ( lib => console . log ( ' -lopencv_' + lib ) ) ;
24+ opencvBuild . opencvModules . forEach ( lib => console . log ( ` -lopencv_${ lib } ` ) ) ;
2525console . log ( '-Wl,-rpath,' + resolvePath ( opencvBuild . opencvLibDir ) ) ;
You can’t perform that action at this time.
0 commit comments