opencv-build
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -1,2 +0,2 @@ | ||
export declare const OPENCV_CONTRIB_ARCHIVE = "https://github.com/opencv/opencv_contrib/archive/3.4.4.tar.gz"; | ||
export declare const OPENCV_CONTRIB_ARCHIVE = "https://github.com/opencv/opencv_contrib/archive/3.4.6.tar.gz"; | ||
export declare const opencvRepoUrl = "https://github.com/opencv/opencv.git"; | ||
@@ -3,0 +3,0 @@ export declare const opencvContribRepoUrl = "https://github.com/opencv/opencv_contrib.git"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var dirs_1 = require("./dirs"); | ||
exports.OPENCV_CONTRIB_ARCHIVE = 'https://github.com/opencv/opencv_contrib/archive/3.4.4.tar.gz'; | ||
exports.OPENCV_CONTRIB_ARCHIVE = 'https://github.com/opencv/opencv_contrib/archive/3.4.6.tar.gz'; | ||
exports.opencvRepoUrl = 'https://github.com/opencv/opencv.git'; | ||
@@ -6,0 +6,0 @@ exports.opencvContribRepoUrl = 'https://github.com/opencv/opencv_contrib.git'; |
import { AutoBuildFile } from './types'; | ||
export declare function isAutoBuildDisabled(): boolean; | ||
export declare function buildWithCuda(): boolean; | ||
export declare function isWithoutContrib(): boolean; | ||
@@ -4,0 +5,0 @@ export declare function autoBuildFlags(): string; |
@@ -11,2 +11,6 @@ "use strict"; | ||
exports.isAutoBuildDisabled = isAutoBuildDisabled; | ||
function buildWithCuda() { | ||
return !!process.env.OPENCV4NODEJS_BUILD_CUDA || false; | ||
} | ||
exports.buildWithCuda = buildWithCuda; | ||
function isWithoutContrib() { | ||
@@ -30,3 +34,3 @@ return !!process.env.OPENCV4NODEJS_AUTOBUILD_WITHOUT_CONTRIB; | ||
function opencvVersion() { | ||
return process.env.OPENCV4NODEJS_AUTOBUILD_OPENCV_VERSION || '3.4.3'; | ||
return process.env.OPENCV4NODEJS_AUTOBUILD_OPENCV_VERSION || '3.4.6'; | ||
} | ||
@@ -33,0 +37,0 @@ exports.opencvVersion = opencvVersion; |
@@ -98,2 +98,10 @@ "use strict"; | ||
} | ||
function getCudaCmakeFlags() { | ||
return [ | ||
'-DWITH_CUDA=ON', | ||
'-DBUILD_opencv_cudacodec=OFF', | ||
'-DCUDA_FAST_MATH=ON', | ||
'-DWITH_CUBLAS=ON', | ||
]; | ||
} | ||
function getSharedCmakeFlags() { | ||
@@ -106,2 +114,6 @@ var conditionalFlags = env_1.isWithoutContrib() | ||
]; | ||
if (env_1.buildWithCuda() && utils_1.isCudaAvailable()) { | ||
log.info('install', 'Adding CUDA flags...'); | ||
conditionalFlags = conditionalFlags.concat(getCudaCmakeFlags()); | ||
} | ||
return constants_1.defaultCmakeFlags | ||
@@ -155,11 +167,13 @@ .concat(conditionalFlags) | ||
return __awaiter(this, void 0, void 0, function () { | ||
var tag, msbuild; | ||
var msbuild, cMakeFlags, tag; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
case 0: return [4 /*yield*/, getMsbuildIfWin() | ||
// Get cmake flags here to check for CUDA early on instead of the start of the building process | ||
]; | ||
case 1: | ||
msbuild = _a.sent(); | ||
cMakeFlags = utils_1.isWin() ? getWinCmakeFlags(msbuild.version) : getSharedCmakeFlags(); | ||
tag = env_1.opencvVersion(); | ||
log.info('install', 'installing opencv version %s into directory: %s', tag, dirs_1.dirs.opencvRoot); | ||
return [4 /*yield*/, getMsbuildIfWin()]; | ||
case 1: | ||
msbuild = _a.sent(); | ||
return [4 /*yield*/, utils_1.exec(getMkDirCmd('opencv'), { cwd: dirs_1.dirs.rootDir })]; | ||
@@ -190,3 +204,3 @@ case 2: | ||
_a.sent(); | ||
return [4 /*yield*/, utils_1.spawn('cmake', getCmakeArgs(utils_1.isWin() ? getWinCmakeFlags(msbuild.version) : getSharedCmakeFlags()), { cwd: dirs_1.dirs.opencvBuild })]; | ||
return [4 /*yield*/, utils_1.spawn('cmake', getCmakeArgs(cMakeFlags), { cwd: dirs_1.dirs.opencvBuild })]; | ||
case 11: | ||
@@ -193,0 +207,0 @@ _a.sent(); |
@@ -11,1 +11,2 @@ /// <reference types="node" /> | ||
export declare function isUnix(): boolean; | ||
export declare function isCudaAvailable(): Promise<boolean>; |
@@ -39,2 +39,4 @@ "use strict"; | ||
var child_process = require("child_process"); | ||
var fs = require("fs"); | ||
var path = require("path"); | ||
var log = require('npmlog'); | ||
@@ -150,1 +152,37 @@ function exec(cmd, options) { | ||
exports.isUnix = isUnix; | ||
function isCudaAvailable() { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var err_2, cudaVersionFilePath, content; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
log.info('install', 'Check if CUDA is available & what version...'); | ||
if (!isWin()) return [3 /*break*/, 4]; | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, requireCmd('nvcc --version', 'CUDA availability check')]; | ||
case 2: | ||
_a.sent(); | ||
return [2 /*return*/, true]; | ||
case 3: | ||
err_2 = _a.sent(); | ||
log.info('install', 'Seems like CUDA is not installed.'); | ||
return [2 /*return*/, false]; | ||
case 4: | ||
cudaVersionFilePath = path.resolve('/usr/local/cuda/version.txt'); | ||
if (fs.existsSync(cudaVersionFilePath)) { | ||
content = fs.readFileSync(cudaVersionFilePath, 'utf8'); | ||
log.info('install', content); | ||
return [2 /*return*/, true]; | ||
} | ||
else { | ||
log.info('install', 'CUDA version file could not be found.'); | ||
return [2 /*return*/, false]; | ||
} | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
exports.isCudaAvailable = isCudaAvailable; |
{ | ||
"name": "opencv-build", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "A simple script to auto build recent OpenCV + contrib version via npm", | ||
@@ -5,0 +5,0 @@ "main": "./build/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
82367
1614
13