xref: /aosp_15_r20/external/protobuf/benchmarks/protobuf.js/generate_pbjs_files.js (revision 1b3f573f81763fcece89efc2b6a5209149e44ab8)
1var pbjs = require("./protobuf.js/cli").pbjs
2
3var argv = [];
4var protoFiles = [];
5var prefix = "";
6process.argv.forEach(function(val, index) {
7  var arg = val;
8  if (arg.length > 6 && arg.substring(arg.length - 6) == ".proto") {
9    protoFiles.push(arg);
10  } else if (arg.length > 15 && arg.substring(0, 15) ==  "--include_path=") {
11    prefix = arg.substring(15);
12  } else if (index >= 2) {
13    argv.push(arg);
14  }
15});
16protoFiles.forEach(function(val) {
17  argv.push(prefix + "/" + val);
18});
19
20pbjs.main(argv, function(err, output){
21  if (err) {
22    console.log(err);
23  }
24});
25
26