Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

Commit f327735

Browse files
author
Simon Hofmann
committed
Updated linking process to use local libs from node_modules
1 parent c3e3b5c commit f327735

File tree

5 files changed

+35
-16
lines changed

5 files changed

+35
-16
lines changed

lib/dirs.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const { join } = require("path");
2+
3+
const isWin = () => process.platform == 'win32'
4+
5+
const isOSX = () => process.platform == 'darwin'
6+
7+
const isUnix = () => !isWin() && !isOSX();
8+
9+
const rootDir = `../node_modules/@nut-tree/opencv-build-${process.platform}`
10+
const opencvRoot = join(rootDir, 'opencv');
11+
const opencvBuild = join(opencvRoot, 'build');
12+
const opencvInclude = join(opencvBuild, 'include');
13+
const opencvLibDir = isWin() ? join(opencvBuild, 'lib/Release') : join(opencvBuild, 'lib');
14+
const opencvBinDir = isWin() ? join(opencvBuild, 'bin/Release') : join(opencvBuild, 'bin');
15+
16+
module.exports = {
17+
rootDir,
18+
opencvRoot,
19+
opencvBuild,
20+
opencvInclude,
21+
opencvLibDir,
22+
opencvBinDir
23+
}

lib/includes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const opencvBuild = require(`@nut-tree/opencv-build-${process.platform}`);
1+
const { opencvInclude } = require("./dirs");
22
const { resolvePath, defaultDir, linkSystemLibs } = require('./commons');
33

44
if (linkSystemLibs()) {
@@ -7,4 +7,4 @@ if (linkSystemLibs()) {
77
}
88

99
// set include dir from auto build
10-
console.log(resolvePath(opencvBuild.opencvInclude));
10+
console.log(opencvInclude);

lib/libs.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const opencvBuild = require(`@nut-tree/opencv-build-${process.platform}`);
22
const { resolvePath, getLibDir, linkSystemLibs } = require('./commons');
3+
const { opencvLibDir } = require("./dirs");
34

45
function linkLibs(libs) {
56
libs
@@ -13,13 +14,7 @@ if (linkSystemLibs()) {
1314
return;
1415
}
1516

16-
// get libs from auto build
17-
if (process.platform === 'win32') {
18-
linkLibs(opencvBuild.getLibs(resolvePath(opencvBuild.opencvLibDir)));
19-
return;
20-
}
21-
2217
// if not windows, link libs dynamically
23-
console.log('-L' + resolvePath(opencvBuild.opencvLibDir));
18+
console.log('-L' + opencvLibDir);
2419
opencvBuild.opencvModules.forEach(lib => console.log(`-lopencv_${lib}`));
25-
console.log('-Wl,-rpath,' + resolvePath(opencvBuild.opencvLibDir));
20+
console.log('-Wl,-rpath,' + opencvLibDir);

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "opencv4nodejs-prebuilt",
3-
"version": "4.15.0-minimal",
3+
"version": "4.15.0-slim",
44
"description": "This is a fork of opencv4nodejs which provides pre-built binaries",
55
"keywords": [
66
"opencv",
@@ -44,6 +44,7 @@
4444
},
4545
"gypfile": true,
4646
"dependencies": {
47+
"@nut-tree/opencv-build-darwin": "^3.4.6",
4748
"macro-inferno": "^0.2.3",
4849
"nan": "^2.12.1",
4950
"native-node-utils": "^0.1.5",
@@ -55,5 +56,5 @@
5556
"devDependencies": {
5657
"prebuild": "^8.2.0"
5758
},
58-
"opencv": "3.4.6-home"
59+
"opencv": "3.4.6"
5960
}

0 commit comments

Comments
 (0)