learn-ocaml icon indicating copy to clipboard operation
learn-ocaml copied to clipboard

[build] Generate `given_exo.{cmi,cmo,cmt}` files

Open erikmd opened this issue 4 years ago • 0 comments

  • Kind: feature

  • Address #414 first (disabling broken option learn-ocaml build --jobs=2)

Description

  • Add option learn-ocaml build --enable-cmo-build
  • This new experimental option is on by default (implicit mode) and generates given_exo.{cmi,cmo,cmt} in the www folder for each prelude ^ " ;;\n" ^ prepare.
  • This is a key feature for learn-ocaml.el (the Tuareg/Merlin frontend for Learn-OCaml); it can be disabled using the flag:
    $ learn-ocaml build --disable-cmo-build
    
  • If the www/exo.json file is up-to-date, the exo.cm* are not built.
  • But we can force the exo.cm* build (explicit mode) even for un-changed exercises using the flag:
    $ learn-ocaml build --enable-cmo-build
    
  • This option may later become mandatory if/when the js_of_ocaml front-end also fetches similar *.cmo files.
  • Regarding the ocamlc naming convention:
    require that the input exercise id basename exo-name matches [0-9A-Za-z_-]+, otherwise raise a warning,
    then bijectively replace __0 and -_1 in exo, then yield the output filename dir/given_exo_1name.cmo.

Checklist

  • [x] Read the CONTRIBUTING.md guide.
  • [x] Add/update tests
  • [ ] Implement the learn-ocaml-client counterpart of this feature within this PR

Note to maintainers

  • Read this wiki page
  • Make sure the PR has a milestone
  • Assign yourself before merging (using a regular Merge for this one)

erikmd avatar Nov 06 '21 18:11 erikmd