refactored build system to eliminate platform-specific scripts
This commit is contained in:
parent
fd385fd76d
commit
d16e8412a2
@ -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/).
|
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
|
## Building from source
|
||||||
|
|
||||||
@ -20,6 +20,6 @@ Then go in the `simulator` folder and run this command: `npm install`. This will
|
|||||||
|
|
||||||
### Build
|
### 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.
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
@echo off
|
|
||||||
|
|
||||||
pushd src
|
|
||||||
node ../tools/embed.js
|
|
||||||
node ../node_modules/typescript/lib/tsc.js
|
|
||||||
node ../tools/purify.js
|
|
||||||
popd
|
|
@ -1,6 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
cd src
|
|
||||||
node ../tools/embed.js
|
|
||||||
../node_modules/typescript/bin/tsc
|
|
||||||
node ../tools/purify.js
|
|
@ -7,6 +7,9 @@
|
|||||||
"url": "https://gitea.youb.fr/youen/vhelio-simulator.git",
|
"url": "https://gitea.youb.fr/youen/vhelio-simulator.git",
|
||||||
"directory": "simulator"
|
"directory": "simulator"
|
||||||
},
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "node tools/build.js"
|
||||||
|
},
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"purify-css": "^1.2.5",
|
"purify-css": "^1.2.5",
|
||||||
|
25
simulator/tools/build.js
Normal file
25
simulator/tools/build.js
Normal 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);
|
@ -47,5 +47,9 @@ function embedCsv(src, dst) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
embedSvg('../data/climate-zones-map.svg', 'climate-zones-map.svg.ts');
|
let toolsDir = __dirname;
|
||||||
embedCsv('../data/climate-zones-data.csv', 'climate-zones-data.ts');
|
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');
|
||||||
|
Loading…
Reference in New Issue
Block a user