Files
nixpkgs/pkgs/by-name/vo/voicevox/hardcode-paths.patch
2025-11-09 19:52:26 +01:00

86 lines
3.3 KiB
Diff

diff --git a/.env.production b/.env.production
index cc5e2b9..29140f8 100644
--- a/.env.production
+++ b/.env.production
@@ -4,7 +4,7 @@ VITE_DEFAULT_ENGINE_INFOS=`[
"uuid": "074fc39e-678b-4c13-8916-ffca8d505d1d",
"name": "VOICEVOX Engine",
"executionEnabled": true,
- "executionFilePath": "vv-engine/run.exe",
+ "executionFilePath": "@voicevox_engine_path@",
"executionArgs": [],
"host": "http://127.0.0.1:50021"
}
diff --git a/build/electronBuilderConfig.ts b/build/electronBuilderConfig.ts
index 83dcc10..114fb9d 100644
--- a/build/electronBuilderConfig.ts
+++ b/build/electronBuilderConfig.ts
@@ -45,17 +45,6 @@ const isArm64 = process.arch === "arm64";
// cf: https://k-hyoda.hatenablog.com/entry/2021/10/23/000349#%E8%BF%BD%E5%8A%A0%E5%B1%95%E9%96%8B%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E5%85%88%E3%81%AE%E8%A8%AD%E5%AE%9A
const extraFilePrefix = isMac ? "MacOS/" : "";
-const sevenZipFile = readdirSync(path.join(rootDir, "vendored", "7z")).find(
- // Windows: 7za.exe, Linux: 7zzs, macOS: 7zz
- (fileName) => ["7za.exe", "7zzs", "7zz"].includes(fileName),
-);
-
-if (!sevenZipFile) {
- throw new Error(
- "7z binary file not found. Run `node ./tools/download7z.ts` first.",
- );
-}
-
const builderOptions: ElectronBuilderConfiguration = {
beforeBuild: async () => {
if (existsSync(path.join(rootDir, "dist_electron"))) {
@@ -97,14 +86,6 @@ const builderOptions: ElectronBuilderConfiguration = {
from: "build/README.txt",
to: extraFilePrefix + "README.txt",
},
- {
- from: VOICEVOX_ENGINE_DIR,
- to: path.join(extraFilePrefix, "vv-engine"),
- },
- {
- from: path.join(rootDir, "vendored", "7z", sevenZipFile),
- to: extraFilePrefix + sevenZipFile,
- },
],
// electron-builder installer
productName: "VOICEVOX",
diff --git a/src/backend/electron/vvppFile.ts b/src/backend/electron/vvppFile.ts
index f649bf8..de2f3fa 100644
--- a/src/backend/electron/vvppFile.ts
+++ b/src/backend/electron/vvppFile.ts
@@ -224,6 +224,7 @@ export class VvppFileExtractor {
}
private getSevenZipPath(): string {
+ return "@sevenzip_path@";
let sevenZipPath = import.meta.env.VITE_7Z_BIN_NAME;
if (!sevenZipPath) {
throw new Error("7z path is not defined");
diff --git a/vite.config.ts b/vite.config.ts
index 3c9e029..c253a6a 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -5,7 +5,6 @@ import { rm } from "node:fs/promises";
import electronPlugin from "vite-plugin-electron/simple";
import tsconfigPaths from "vite-tsconfig-paths";
import vue from "@vitejs/plugin-vue";
-import electronDefaultImport from "electron";
import checker from "vite-plugin-checker";
import { BuildOptions, defineConfig, loadEnv, Plugin } from "vite";
import { quasar } from "@quasar/vite-plugin";
@@ -17,9 +16,7 @@ import {
SourceFile,
} from "./tools/checkSuspiciousImports.js";
-// @ts-expect-error electronをelectron環境外からimportするとelectronのファイルパスが得られる。
-// https://github.com/electron/electron/blob/a95180e0806f4adba8009f46124b6bb4853ac0a6/npm/index.js
-const electronPath = electronDefaultImport as string;
+const electronPath = "@electron_path@";
const nodeTestPaths = ["../tests/unit/**/*.node.{test,spec}.ts"];
const browserTestPaths = ["../tests/unit/**/*.browser.{test,spec}.ts"];