This repository was archived by the owner on Oct 18, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ const opencvBuild = require ( `@nut-tree/opencv-build-${ process . platform } ` )
2+ const { resolvePath } = require ( '../lib/commons' )
3+ const fs = require ( 'fs' )
4+
5+ const libDir = resolvePath ( opencvBuild . opencvLibDir ) ;
6+
7+ if ( ! fs . existsSync ( libDir ) ) {
8+ throw new Error ( "library dir does not exist: " + libDir ) ;
9+ }
10+
11+ const libsFoundInDir = opencvBuild . getLibs ( libDir ) . filter ( lib => lib . libPath ) ;
12+
13+ if ( ! libsFoundInDir . length ) {
14+ throw new Error ( "No OpenCV libraries found in lib dir: " + libDir ) ;
15+ }
16+
17+ const defines = libsFoundInDir . map (
18+ lib => `OPENCV4NODEJS_FOUND_LIBRARY_${ lib . opencvModule . toUpperCase ( ) } `
19+ ) ;
20+
21+ const inc = [
22+ resolvePath ( opencvBuild . opencvInclude ) ,
23+ resolvePath ( opencvBuild . opencv4Include )
24+ ] ;
25+
26+ const libs = opencvBuild . isWin ( )
27+ ? libsFoundInDir . map ( lib => resolvePath ( lib . libPath ) )
28+ : // dynamically link libs if not on windows
29+ [ "-L" + libDir ]
30+ . concat ( libsFoundInDir . map ( lib => "-lopencv_" + lib . opencvModule ) )
31+ . concat ( "-Wl,-rpath," + libDir ) ;
32+
33+ module . exports = {
34+ OPENCV4NODEJS_LIBRARIES : ( ) => libs . join ( "\n" ) ,
35+ OPENCV4NODEJS_INCLUDES : ( ) => inc . join ( "\n" ) ,
36+ OPENCV4NODEJS_DEFINES : ( ) => defines . join ( "\n" )
37+ }
You can’t perform that action at this time.
0 commit comments