refactored build system to eliminate platform-specific scripts

This commit is contained in:
Youen Toupin 2021-10-05 18:47:40 +02:00
parent fd385fd76d
commit d16e8412a2
6 changed files with 37 additions and 18 deletions

View File

@ -6,7 +6,7 @@ Vehicle energy consumption and production simulator. This tool has been created
The easiest way is to use the [online simulator](https://vhelio.org/simulateur-vhelio/).
You can also download the latest pre-built stand-alone version and open `www/vhelio-simulator.html` in your web browser. The program will run in your browser, but won't communicate with any server, this is a purely local application.
You can also download the latest pre-built stand-alone version and open `vhelio-simulator.html` in your web browser. The program will run in your browser, but won't communicate with any server, this is a purely local application.
## Building from source
@ -20,6 +20,6 @@ Then go in the `simulator` folder and run this command: `npm install`. This will
### Build
Execute `build.sh` on Linux, or `build.bat` on Windows.
Execute `npm run build` from the `simulator` directory.
That's it, you can now open `www/vhelio-simulator.html` in your browser.
That's it, you can now open `simulator/www/vhelio-simulator.html` in your browser.

View File

@ -1,7 +0,0 @@
@echo off
pushd src
node ../tools/embed.js
node ../node_modules/typescript/lib/tsc.js
node ../tools/purify.js
popd

View File

@ -1,6 +0,0 @@
#!/bin/bash
cd src
node ../tools/embed.js
../node_modules/typescript/bin/tsc
node ../tools/purify.js

View File

@ -7,6 +7,9 @@
"url": "https://gitea.youb.fr/youen/vhelio-simulator.git",
"directory": "simulator"
},
"scripts": {
"build": "node tools/build.js"
},
"dependencies": {},
"devDependencies": {
"purify-css": "^1.2.5",

25
simulator/tools/build.js Normal file
View File

@ -0,0 +1,25 @@
let child_process = require('child_process');
let toolsDir = __dirname;
let srcDir = toolsDir + "/../src";
let nodeModulesDir = toolsDir + "/../node_modules";
let commands = [
() => child_process.fork(toolsDir + '/embed.js'),
() => child_process.fork(nodeModulesDir + '/typescript/lib/tsc.js', {'cwd': srcDir}),
() => child_process.fork(toolsDir + '/purify.js', {'cwd': srcDir})
];
let commandIdx = 0;
function executeCommand(commandIdx) {
let process = commands[commandIdx]();
process.on('close', (exitCode) => {
if(exitCode != 0) throw "Command " + commands[commandIdx] + " failed with code " + exitCode;
commandIdx += 1;
if(commandIdx == commands.length) return;
executeCommand(commandIdx);
});
}
executeCommand(commandIdx);

View File

@ -47,5 +47,9 @@ function embedCsv(src, dst) {
});
}
embedSvg('../data/climate-zones-map.svg', 'climate-zones-map.svg.ts');
embedCsv('../data/climate-zones-data.csv', 'climate-zones-data.ts');
let toolsDir = __dirname;
let dataDir = toolsDir + "/../data";
let srcDir = toolsDir + "/../src";
embedSvg(dataDir+'/climate-zones-map.svg', srcDir+'/climate-zones-map.svg.ts');
embedCsv(dataDir+'/climate-zones-data.csv', srcDir+'/climate-zones-data.ts');