Skip to content

opensourcedoc/ocaml-clean-compile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ocaml-clean-compile

Compile OCaml code without leaving behind temporary files.

Overview

The OCaml compiler often generates intermediate files during compilation, which developers must clean up manually.
This project provides three lightweight shell scripts — ocaml-std, ocaml-core and ocaml-js — that compile OCaml code in a system temporary directory and automatically remove all intermediate files once the build is complete.

Features

  • Clean builds: Produces native executables without leaving behind .cmi, .cmo, or other temporary artifacts.
  • Multiple targets:
    • ocaml-std → build with the OCaml standard library only
    • ocaml-core → build with Jane Street’s Base, Stdio, and Core libraries
    • ocaml-js → build JavaScript output via js_of_ocaml
  • Simple usage: Just provide your source files — the scripts take care of the rest.

Requirements

Native Executable (ocaml-std)

  • OCaml 4.14.4+ (recommended)
  • opam
  • cppo

Jane Street Enhanced Executable (ocaml-core)

Includes the native requirements, plus:

  • base
  • stdio
  • core
  • ocamlfind

In the updated ocaml-clean-compile, ocaml-core is simply a thin wrapper around ocaml-std.
If you need to include additional packages, use the following command instead:

$ ocaml-std -r requirement.txt lib1.ml ... main.ml

Remember to list all dependencies in requirement.txt again, including base, stdio, core, and any other required packages.

JavaScript (ocaml-js)

Includes the native requirements, plus:

  • js_of_ocaml
  • js_of_ocaml-ppx
  • ocamlfind

Usage

Native Executable

$ ocaml-std lib.mli lib.ml main.ml
$ ocaml-core lib.mli lib.ml main.ml

JavaScript

$ ocaml-js lib.mli lib.ml main.ml

Include Additional Packages

$ ocaml-std -r requirement.txt lib.mli lib.ml main.ml

List each dependency on a separate line in requirements.txt.
Refer to core.txt for formatting guidance.

Non-Goal

This project does not aim to replace dune.

dune remains the recommended build system for managing complex OCaml projects.
ocaml-clean-compile is intended only as a lightweight helper for quick compilation without clutter.

Note

inplace is bundled for cppo in-place editing.

License

MIT License (c) 2026 ByteBard

About

Compile OCaml code without leaving behind temporary files

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages