86 lines
1.5 KiB
JavaScript
86 lines
1.5 KiB
JavaScript
/*
|
|
|
|
Copyright (c) 2020, 2023, The Unified Company.
|
|
|
|
This code is part of Unify.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the ESA Software Community License - Strong Copyleft,
|
|
|
|
https://unifyjs.org
|
|
|
|
*/
|
|
|
|
|
|
const fs = require('fs');
|
|
|
|
const util = require('util');
|
|
|
|
const exec = util.promisify( require('child_process').exec );
|
|
|
|
|
|
exports.gpp = class gpp{
|
|
|
|
batchSize = 70;
|
|
|
|
execPromises = new Array();
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
}
|
|
|
|
async initialise() {
|
|
|
|
this.instance = await new factory();
|
|
|
|
}
|
|
|
|
createBatchesDirectory() {
|
|
|
|
if( !fs.existsSync( "./framework/cache/platforms/batches/" ) ) {
|
|
|
|
fs.mkdirSync("./framework/cache/platforms/batches/");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
async convert( inputFiles, i ) {
|
|
|
|
this.createBatchesDirectory();
|
|
|
|
|
|
var file = path.resolve( "./framework/cache/platforms/batches/" + i + ".json");
|
|
|
|
var n = i * this.batchSize;
|
|
|
|
var inputFilesSliced = inputFiles.slice( n, this.batchSize + n );
|
|
|
|
var inputFilesJoined = inputFilesSliced.join("\n");
|
|
|
|
|
|
fs.writeFileSync( file, JSON.stringify( inputFilesJoined ) );
|
|
|
|
await this.spawnBatch( file, i );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
async spawnBatch( file, i ) {
|
|
|
|
var cWrapper = path.resolve("./framework/node_modules/node-gpp/instanceChild.js");
|
|
|
|
var args = new Array( cWrapper, "file=" + file, "index=" + i );
|
|
|
|
var defaults = { file:file, env: process.env };
|
|
|
|
var execPromise = exec("node " + cWrapper + " file=" + file + " index=" + i );
|
|
|
|
this.execPromises.push(execPromise);
|
|
|
|
}
|
|
|
|
} |