完善预编译库下载工具
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@yizhi/cv",
|
"name": "@yizhi/cv",
|
||||||
"version": "1.0.3",
|
"version": "1.0.4",
|
||||||
"releaseVersion": "1.0.3",
|
"releaseVersion": "1.0.3",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "typing/index.d.ts",
|
"types": "typing/index.d.ts",
|
||||||
|
@ -6,35 +6,31 @@ import { C } from "./common";
|
|||||||
|
|
||||||
|
|
||||||
const URLS = {
|
const URLS = {
|
||||||
GITHUB: `https://github.com/kangkang520/node-addons/releases/download/cv{{version}}/cv_{{platform}}_{{arch}}.node`,
|
GITHUB: `https://github.com/kangkang520/node-addons/releases/download/cv{{version}}/{{filename}}`,
|
||||||
URNAS: `http://git.urnas.cn:5200/yizhi-js-lib/opencv/releases/download/{{version}}/cv_{{platform}}_{{arch}}.node`,
|
URNAS: `http://git.urnas.cn:5200/yizhi-js-lib/opencv/releases/download/{{version}}/{{filename}}`,
|
||||||
}
|
}
|
||||||
|
|
||||||
function releaseVersion() { return require("../../package.json").releaseVersion }
|
function releaseVersion() { return require("../../package.json").releaseVersion }
|
||||||
|
|
||||||
function getURL(template: string) {
|
function getURL(template: string) {
|
||||||
|
const URL_CONFIG: Record<string, Record<string, string>> = {
|
||||||
|
"win32": {
|
||||||
|
"x64": "cv_windows_x64.node",
|
||||||
|
},
|
||||||
|
"linux": {
|
||||||
|
"x64": "cv_linux_x64.node",
|
||||||
|
"arm64": "cv_linux_arm64.node",
|
||||||
|
},
|
||||||
|
"darwin": {
|
||||||
|
"arm64": "cv_macos_arm64.node"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let platform = "";
|
const archConfig = URL_CONFIG[os.platform()];
|
||||||
let arch = "";
|
if (!archConfig) throw new Error(`Unsupported platform: ${os.platform()}`);
|
||||||
switch (os.platform()) {
|
const downloadName = archConfig[os.arch()];
|
||||||
case "win32":
|
if (!downloadName) throw new Error(`Unsupported architecture: ${os.arch()}`);
|
||||||
platform = "windows";
|
return template.replaceAll("{{version}}", releaseVersion()).replaceAll("{{filename}}", downloadName);
|
||||||
break;
|
|
||||||
case "linux":
|
|
||||||
platform = "linux";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error(`Unsupported platform: ${os.platform()}, Please compile the addon yourself.`);
|
|
||||||
}
|
|
||||||
switch (os.arch()) {
|
|
||||||
case "x64":
|
|
||||||
arch = "x64";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error(`Unsupported architecture: ${os.arch()}, Please compile the addon yourself.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return template.replaceAll("{{version}}", releaseVersion()).replaceAll("{{platform}}", platform).replaceAll("{{arch}}", arch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getStream() {
|
async function getStream() {
|
||||||
|
@ -140,7 +140,6 @@ async function downloadFromURL(name, url, resolver) {
|
|||||||
fs.rmSync(outputDir, { recursive: true, force: true });
|
fs.rmSync(outputDir, { recursive: true, force: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
//OpenCV
|
//OpenCV
|
||||||
if (buildOptions.withOpenCV) cmakeBuildFromSource("OpenCV", "https://github.com/opencv/opencv.git", "4.11.0", null, [
|
if (buildOptions.withOpenCV) cmakeBuildFromSource("OpenCV", "https://github.com/opencv/opencv.git", "4.11.0", null, [
|
||||||
@ -155,7 +154,12 @@ async function main() {
|
|||||||
"-DBUILD_FAT_JAVA_LIB=OFF",
|
"-DBUILD_FAT_JAVA_LIB=OFF",
|
||||||
"-DBUILD_ANDROID_SERVICE=OFF",
|
"-DBUILD_ANDROID_SERVICE=OFF",
|
||||||
"-DBUILD_JAVA=OFF",
|
"-DBUILD_JAVA=OFF",
|
||||||
"-DBUILD_PERF_TESTS=OFF"
|
"-DBUILD_PERF_TESTS=OFF",
|
||||||
|
"-DBUILD_TIFF=ON",
|
||||||
|
"-DBUILD_OPENJPEG=ON",
|
||||||
|
"-DBUILD_JPEG=ON",
|
||||||
|
"-DBUILD_PNG=ON",
|
||||||
|
"-DBUILD_WEBP=ON",
|
||||||
], (root) => [
|
], (root) => [
|
||||||
`set(OpenCV_STATIC ON)`,
|
`set(OpenCV_STATIC ON)`,
|
||||||
os.platform() == "win32" ?
|
os.platform() == "win32" ?
|
||||||
|
Reference in New Issue
Block a user