1

The nice thing about Rust and generated code, is that it can live in the target directory and rust-analyzer makes it easy to go and see what's there. But in OCaml, with dune, if I have a rule to generate some code, for example:

(rule
 (target kimchi.ml)
 (deps
  Cargo.toml
  rust-toolchain.toml
  ../../../../.ocamlformat
  (source_tree src)
  (source_tree binding_generation)
  (source_tree ../../proof-systems))
 (action
  (chdir
   binding_generation
   (progn
    (run rm -rf ./target)
    (run rm -f ./Cargo.lock)
    (run cargo run ../kimchi.ml)
    (run ocamlformat --impl -i ../kimchi.ml)))))

The file it generates seems to be inaccessible from ocaml-lsp in vscode without knowing the exact path. So what I can do is add:

 (mode promote)

but now, I run the risk of manually overwriting a generated file. Does building overwrites my manual changes again?

David 天宇 Wong
  • 3,724
  • 4
  • 35
  • 47

0 Answers0