diff --git a/Readme.md b/Readme.md index 97956ec..537506c 100644 --- a/Readme.md +++ b/Readme.md @@ -49,11 +49,18 @@ Install the `gfortran` compiler, then: ```bash cd trimsp/fortran make -make install ``` - -This will install the `trimspNL` binary in `/usr/local/bin`, -but it can be moved to any other directory in your `PATH`. + +This creates the `trimspNL` binary in the repository root. For packaged +Electron builds, copy or rebuild it into: + +```text +resources/bin/trimspNL +``` + +The application will prefer that bundled copy when running from a packaged +install. During development it can still use a local checkout copy or a +`trimspNL` binary found in the configured path or in `PATH`. ###### Running the GUI ###### @@ -75,11 +82,14 @@ Install [Node.js] (`nodejs`, `nodejs-libs` and `npm`), then run: ```bash cd trimsp +cp trimspNL resources/bin/trimspNL npm install npm run make ``` This uses Electron Forge to build Linux packages from the current checkout. +The packaged application bundles `resources/bin/trimspNL` inside the app +resources, so make sure that file exists and is up to date before packaging. The generated files are written under: diff --git a/TrimSPelec.js b/TrimSPelec.js index 1cefe51..bf9dcce 100644 --- a/TrimSPelec.js +++ b/TrimSPelec.js @@ -73,6 +73,25 @@ function fileExists(filename) { return 0; } +function getTrimBinaryPath(configuredPath) { + const candidates = []; + if (configuredPath) { + candidates.push(path.join(configuredPath, "trimspNL")); + } + if (process.resourcesPath) { + candidates.push(path.join(process.resourcesPath, "bin", "trimspNL")); + candidates.push(path.join(process.resourcesPath, "trimspNL")); + } + candidates.push(path.join(process.cwd(), "trimspNL")); + + for (const candidate of candidates) { + if (fileExists(candidate)) { + return candidate; + } + } + return "trimspNL"; +} + function setWorkFolder(foldername) { const folder = Array.isArray(foldername) ? foldername[0] : foldername; if (folder) { diff --git a/TrimSPlib.js b/TrimSPlib.js index 62f132d..b69f8e7 100644 --- a/TrimSPlib.js +++ b/TrimSPlib.js @@ -3607,15 +3607,7 @@ async function startSequence() { let webOrApp = amIWeb(); // Only for Node.js if (!webOrApp) { - // Check if the trimspNL binary is found - if (!fileExists(trimBin)) { - // check if it is in rpm - trimBin = "/usr/lib/TrimSP/resources/app/trimspNL"; - if (!fileExists(trimBin)) { - // if not found, try in PATH and hope for the best - trimBin = "trimspNL"; - } - } + trimBin = getTrimBinaryPath(All["trimPath"]); // Check if workPath exists otherwise create it checkDir(All['workPath']); // from TrimSPelec.js, Electron/Node specific } else { diff --git a/package.json b/package.json index 592c492..01f6ebb 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,9 @@ "forge": { "packagerConfig": { "icon": "appicons/icons/png/1024x1024.png", + "extraResource": [ + "resources/bin" + ], "ignore": [ "Readme.md", "ToDo.txt", diff --git a/resources/bin/trimspNL b/resources/bin/trimspNL new file mode 100755 index 0000000..c84d1ad Binary files /dev/null and b/resources/bin/trimspNL differ