Closed Bug 1491104 Opened 8 years ago Closed 8 years ago

Add a script to (re)generate all binjs files in tree at once

Categories

(Core :: JavaScript Engine, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
mozilla64
Tracking Status
firefox64 --- fixed

People

(Reporter: arai, Assigned: arai)

References

Details

Attachments

(3 files)

We have multiple binjs files in tree. those files are supposed to be updated every time the spec or format changes. we should put a script that automates the step in tree.
Blocks: 1495611
testing/web-platform/mozilla/tests/binast/{small,large}.js are slightly different from the source of testing/web-platform/mozilla/tests/binast/{small,large}.binjs, that binASTLoaded is true vs false. added the source with binASTLoaded=true to use it from script.
Assignee: nobody → arai.unmht
Status: NEW → ASSIGNED
Attachment #9014001 - Flags: review?(dteller)
This script encodes all in-tree binjs files (let me know if I overlook something) the script also supports babel, which is not yet used. I'll add more testcases from jstests/jit-test, with babel, to convert all ES6+ feature into ES5 syntax.
Attachment #9014002 - Flags: review?(dteller)
and the result of the script.
Attachment #9014003 - Flags: review?(dteller)
Comment on attachment 9014003 [details] [diff] [review] Part 3: Update in-tree binjs files. Review of attachment 9014003 [details] [diff] [review]: ----------------------------------------------------------------- r=me
Attachment #9014003 - Flags: review?(dteller) → review+
Attachment #9014001 - Flags: review?(dteller) → review+
Comment on attachment 9014002 [details] [diff] [review] Part 2: Add a script to regenerate all binjs files in tree. Review of attachment 9014002 [details] [diff] [review]: ----------------------------------------------------------------- So, Python code to drive a Rust application that's going to call into Node? Why not :) ::: js/src/jsapi-tests/binast/README.md @@ +4,5 @@ > +./encode.py \ > + --topsrcdir={path to mozilla-unified} \ > + --binjsdir={path to binjs-ref clone} \ > + --binjs_encode={path to binjs_encode} \ > + --babel={path to babel command} \ That would deserve some explanation about what babel is used for. ::: js/src/jsapi-tests/binast/encode.py @@ +14,5 @@ > + help='cwd when running binjs_encode') > +parser.add_option('--binjs_encode', dest='binjs_encode', > + help='path to binjs_encode commad') > +parser.add_option('--babel', dest='babel', > + help='path to babel command') Here, too, an explanation of what babel is used for would be useful. @@ +20,5 @@ > + help='path to babel-preset-env') > +(options, args) = parser.parse_args() > + > +if not os.path.isdir(options.topsrcdir): > + print('topsrcdir directory {} does not exit'.format(options.topsrcdir), s/exit/exists/g In the entire file :) @@ +40,5 @@ > + print('babel-preset-env directory {} does not exit'.format(options.babel_preset_env), > + file=sys.stderr) > + sys.exit(1) > + > +def encode(infile_path, outfile_path, use_babel=False, binjs_encode_args=[]): It's probably faster if we can use a single call to `binjs_encode`, especially once we start reusing processes, but we don't have to do it now. Follow bug? @@ +50,5 @@ > + if use_babel: > + cmd = [options.babel, > + '--presets={}'.format(options.babel_preset_env)] > + babel_proc = subprocess.Popen(cmd, stdin=infile, stdout=subprocess.PIPE) > + binjs_stdin = babel_proc.stdout An alternative would be to babel everything (if needed) then call binjs_encode a single time. Your call.
Attachment #9014002 - Flags: review?(dteller) → review+
thank you for reviewing :D about babel part, I need to fix the .babelrc issue anyway (which will change the required arguments) I'll remove that parts for now. (In reply to David Teller [:Yoric] (please use "needinfo") from comment #6) > @@ +40,5 @@ > > + print('babel-preset-env directory {} does not exit'.format(options.babel_preset_env), > > + file=sys.stderr) > > + sys.exit(1) > > + > > +def encode(infile_path, outfile_path, use_babel=False, binjs_encode_args=[]): > > It's probably faster if we can use a single call to `binjs_encode`, > especially once we start reusing processes, but we don't have to do it now. > Follow bug? Yeah, if babel is not used, switching to binjs_encode with --outdir mode should be better. > @@ +50,5 @@ > > + if use_babel: > > + cmd = [options.babel, > > + '--presets={}'.format(options.babel_preset_env)] > > + babel_proc = subprocess.Popen(cmd, stdin=infile, stdout=subprocess.PIPE) > > + binjs_stdin = babel_proc.stdout > > An alternative would be to babel everything (if needed) then call > binjs_encode a single time. Your call. I'm not going to add babel's output in tree, so I have to think about how to handle multiple temporary files. anyway, will file a bug for it.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: