Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@u4/opencv-build

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@u4/opencv-build - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

30

lib/OpenCVBuildEnv.d.ts

@@ -41,2 +41,26 @@ /// <reference types="node" />

/**
* Find the proper root dir, this directory will contains all openCV source code and a subfolder per build
* @param opts
* @returns
*/
static getBuildDir(opts?: OpenCVBuildEnvParams): string;
/**
* list existing build in the diven directory
* @param rootDir build directory
* @returns builds list
*/
static listBuild(rootDir: string): Array<{
autobuild: string;
buildInfo: AutoBuildFile;
dir: string;
hash: string;
date: Date;
}>;
/**
* Read a parse an existing autoBuildFile
* @param autoBuildFile file path
* @returns
*/
static readAutoBuildFile(autoBuildFile: string, quiet?: boolean): AutoBuildFile | undefined;
/**
* autodetect path using common values.

@@ -83,7 +107,2 @@ * @return number of updated env variable from 0 to 3

get optHash(): string;
listBuild(): Array<{
autobuild: string;
dir: string;
date: Date;
}>;
get platform(): NodeJS.Platform;

@@ -107,3 +126,2 @@ get isWin(): boolean;

readAutoBuildFile(): AutoBuildFile | undefined;
private readAutoBuildFile2;
}

98

lib/OpenCVBuildEnv.js

@@ -71,6 +71,3 @@ "use strict";

this.packageRoot = opts.rootcwd || process.env.INIT_CWD || process.cwd();
this.buildRoot = opts.buildRoot || process.env.OPENCV_BUILD_ROOT || path_1.default.join(__dirname, '..');
if (this.buildRoot[0] === '~') {
this.buildRoot = path_1.default.join(os_1.default.homedir(), this.buildRoot.slice(1));
}
this.buildRoot = OpenCVBuildEnv.getBuildDir(opts);
// get project Root path to looks for package.json for opencv4nodejs section

@@ -92,3 +89,3 @@ try {

if (!this.no_autobuild && opts.prebuild) {
const builds = this.listBuild();
const builds = OpenCVBuildEnv.listBuild(this.rootDir);
if (!builds.length) {

@@ -114,7 +111,8 @@ throw Error(`No build found in ${this.rootDir} you should launch opencv-build-npm once`);

// load envthe prevuious build
const autoBuildFile = this.readAutoBuildFile2(builds[0].autobuild);
if (!autoBuildFile)
throw Error(`failed to read build info from ${builds[0].autobuild}`);
const autoBuildFile = builds[0].buildInfo;
//const autoBuildFile = OpenCVBuildEnv.readAutoBuildFile(builds[0].autobuild);
//if (!autoBuildFile)
// throw Error(`failed to read build info from ${builds[0].autobuild}`);
const flagStr = autoBuildFile.env.autoBuildFlags;
this.hash = builds[0].dir.replace(/^opencv-.+-/, '-');
this.hash = builds[0].hash;
// merge -DBUILD_opencv_ to internal BUILD_opencv_ manager

@@ -203,2 +201,56 @@ if (flagStr) {

/**
* Find the proper root dir, this directory will contains all openCV source code and a subfolder per build
* @param opts
* @returns
*/
static getBuildDir(opts = {}) {
let buildRoot = opts.buildRoot || process.env.OPENCV_BUILD_ROOT || path_1.default.join(__dirname, '..');
if (buildRoot[0] === '~') {
buildRoot = path_1.default.join(os_1.default.homedir(), buildRoot.slice(1));
}
return buildRoot;
}
/**
* list existing build in the diven directory
* @param rootDir build directory
* @returns builds list
*/
static listBuild(rootDir) {
const versions = fs_1.default.readdirSync(rootDir)
.filter(n => n.startsWith('opencv-'))
.map((dir) => {
const autobuild = path_1.default.join(rootDir, dir, 'auto-build.json');
const hash = dir.replace(/^opencv-.+-/, '-');
const buildInfo = OpenCVBuildEnv.readAutoBuildFile(autobuild, true);
return { autobuild, dir, hash, buildInfo, date: fs_1.default.statSync(autobuild).mtime };
})
.filter((n) => n.buildInfo);
return versions;
}
/**
* Read a parse an existing autoBuildFile
* @param autoBuildFile file path
* @returns
*/
static readAutoBuildFile(autoBuildFile, quiet) {
try {
const fileExists = fs_1.default.existsSync(autoBuildFile);
if (fileExists) {
const autoBuildFileData = JSON.parse(fs_1.default.readFileSync(autoBuildFile).toString());
if (!autoBuildFileData.opencvVersion || !('autoBuildFlags' in autoBuildFileData) || !Array.isArray(autoBuildFileData.modules)) {
// if (quiet) return undefined;
throw new Error(`auto-build.json has invalid contents, please delete the file: ${autoBuildFile}`);
}
return autoBuildFileData;
}
if (!quiet)
npmlog_1.default.info('readAutoBuildFile', 'file does not exists: %s', autoBuildFile);
}
catch (err) {
//if (!quiet)
npmlog_1.default.error('readAutoBuildFile', 'failed to read auto-build.json from: %s, with error: %s', autoBuildFile, err.toString());
}
return undefined;
}
/**
* autodetect path using common values.

@@ -531,11 +583,2 @@ * @return number of updated env variable from 0 to 3

}
listBuild() {
const rootDir = this.rootDir;
const versions = fs_1.default.readdirSync(rootDir)
.filter(n => n.startsWith('opencv-'))
.map((n) => ({ autobuild: path_1.default.join(rootDir, n, 'auto-build.json'), dir: n }))
.filter((n) => fs_1.default.existsSync(n.autobuild))
.map(({ autobuild, dir }) => ({ autobuild, dir, date: fs_1.default.statSync(autobuild).mtime }));
return versions;
}
get platform() {

@@ -609,21 +652,4 @@ return this._platform;

readAutoBuildFile() {
return this.readAutoBuildFile2(this.autoBuildFile);
return OpenCVBuildEnv.readAutoBuildFile(this.autoBuildFile);
}
readAutoBuildFile2(autoBuildFile) {
try {
const fileExists = fs_1.default.existsSync(autoBuildFile);
if (fileExists) {
const autoBuildFileData = JSON.parse(fs_1.default.readFileSync(autoBuildFile).toString());
if (!autoBuildFileData.opencvVersion || !('autoBuildFlags' in autoBuildFileData) || !Array.isArray(autoBuildFileData.modules)) {
throw new Error('auto-build.json has invalid contents');
}
return autoBuildFileData;
}
npmlog_1.default.info('readAutoBuildFile', 'file does not exists: %s', autoBuildFile);
}
catch (err) {
npmlog_1.default.error('readAutoBuildFile', 'failed to read auto-build.json from: %s, with error: %s', autoBuildFile, err.toString());
}
return undefined;
}
}

@@ -630,0 +656,0 @@ exports.default = OpenCVBuildEnv;

{
"name": "@u4/opencv-build",
"version": "0.6.0",
"version": "0.6.1",
"description": "A simple script to auto build recent OpenCV + contrib version via npm 2022 Edition",

@@ -10,2 +10,17 @@ "main": "./lib/index.js",

},
"scripts": {
"clean": "rimraf build",
"build": "tsc",
"build3x": "tsc && node lib/main.js --keepsource",
"install_macm1": "node bin/main.js --version 4.5.5 --flag=\"-DCMAKE_SYSTEM_PROCESSOR=arm64 -DCMAKE_OSX_ARCHITECTURES=arm64\"",
"install_4_5_5": "node bin/main.js --version 4.5.5",
"install_4_6_0_cuda_30XX": "tsc && cross-env OPENCV4NODEJS_DISABLE_AUTOBUILD= node bin/main.js --keepsource --version 4.6.0 --cuda --cudaArch=8.6",
"do-install": "node bin/main.js",
"cleanbuild": "rimraf lib && tsc",
"postinstallDISABLED": "npm run do-install",
"prepare": "npm run build",
"prepublishOnly": "npm run build",
"lint": "eslint src/**/*.ts",
"test": "mocha -r ts-node/register 'test/**/*.test.ts'"
},
"bin": {

@@ -57,16 +72,3 @@ "opencv-build-npm": "bin/main.js"

"lib"
],
"scripts": {
"clean": "rimraf build",
"build": "tsc",
"build3x": "tsc && node lib/main.js --keepsource",
"install_macm1": "node bin/main.js --version 4.5.5 --flag=\"-DCMAKE_SYSTEM_PROCESSOR=arm64 -DCMAKE_OSX_ARCHITECTURES=arm64\"",
"install_4_5_5": "node bin/main.js --version 4.5.5",
"install_4_6_0_cuda_30XX": "tsc && cross-env OPENCV4NODEJS_DISABLE_AUTOBUILD= node bin/main.js --keepsource --version 4.6.0 --cuda --cudaArch=8.6",
"do-install": "node bin/main.js",
"cleanbuild": "rimraf lib && tsc",
"postinstallDISABLED": "npm run do-install",
"lint": "eslint src/**/*.ts",
"test": "mocha -r ts-node/register 'test/**/*.test.ts'"
}
]
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc