Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO_NOT_MERGE] Added optional gen swift to genjava.js #4448

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"lint": "jshint -c .jshintrc ./src/ && jscs -c .jscsrc ./src/"
},
"dependencies": {
"ace-builds": "^1.4.3"
"ace-builds": "^1.4.3",
"yargs": "^16.0.0"
}
}
2 changes: 1 addition & 1 deletion src/gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ if [ ${CLEAN_BUILD} -eq 1 ]; then
rm -r ../build/
fi

node ../tools/genjava.js ../tools/classes.js ../build/
node ../tools/genjava.js -i ../tools/classes.js -o ../build/
node ../tools/build.js web
62 changes: 39 additions & 23 deletions tools/genjava.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,34 @@ process.on('unhandledRejection', function(e) {
process.exit(1);
});

const yargs = require("yargs/yargs")
const { hideBin } = require('yargs/helpers')
const argv = yargs(hideBin(process.argv))
.option("i", {
alias: "input",
demandOption: "The input file is required.",
type: "string"
})
.option("o", {
alias: "output",
demandOption: "The input dir is required.",
type: "string"
})
.option("s", {
alias: "source",
type: "string"
})
.option("f", {
alias: "increment",
type: "string"
})
.option("genswift", {
type: "boolean"
})
.argv

// enable FOAM java support.
global.FOAM_FLAGS = { 'java': true, 'debug': true, 'js': false, 'swift': true };
global.FOAM_FLAGS = { 'java': true, 'debug': true, 'js': false, 'swift': argv.genswift };

// Enable FOAMLink mode but only if FOAMLINK_DATA is set in environment
var foamlinkMode = process.env.hasOwnProperty('FOAMLINK_DATA');
Expand All @@ -39,34 +65,27 @@ require('../src/foam.js');
require('../src/foam/nanos/nanos.js');
require('../src/foam/support/support.js');

var srcPath = __dirname + "/../src/";

if ( ! (
process.argv.length == 4 ||
process.argv.length == 5 ||
process.argv.length == 6 ) ) {
console.log("USAGE: genjava.js input-path output-path src-path(optional) files-to-update (optional)");
process.exit(1);
var incrementalMeta = null;
if ( argv.f ) {
incrementalMeta = JSON.parse(argv.f);
logger.debug('INCREMENTAL', argv.f);
}

if ( process.argv.length > 4 && process.argv[4] !== '--' ) {
srcPath = process.argv[4];
if ( argv.s ) {
srcPath = argv.s;
if ( ! srcPath.endsWith('/') ) {
srcPath = srcPath + '/';
}
}

var incrementalMeta = null;
if ( process.argv.length > 5 &&
process.argv[5] !== '--' &&
process.argv[5] != '' ) {
incrementalMeta = JSON.parse(process.argv[5]);
logger.debug('INCREMENTAL', process.argv[5]);
}

var indir = process.argv[2];
var indir = argv.i
indir = path_.resolve(path_.normalize(indir));

var outdir = argv.o
outdir = path_.resolve(path_.normalize(outdir));

var srcPath = __dirname + "/../src/";

var externalFile = require(indir);
var classes = externalFile.classes;
var abstractClasses = externalFile.abstractClasses;
Expand Down Expand Up @@ -139,9 +158,6 @@ logger.debug('fileWhitelist', fileWhitelist);
blacklist[cls] = true;
});

var outdir = process.argv[3];
outdir = path_.resolve(path_.normalize(outdir));

function ensurePath(p) {
var i = 1 ;
var parts = p.split(path_.sep);
Expand Down