Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to declare executables with hyphens in a OCaml dune?

I'm setting up a demo project using dune, and want to name the executable "hello-world.exe" instead of "hello_world". If I try to build the project I get an compiler error. How can I declare an executable with hyphens in the filename?

I'm using dune 1.9.3 and OCaml 4.05.0.

dune:

(executable
 (name hello-world))

hello-world.ml

let () = print_endline "Hello, World!"

build error

$ dune build hello-world.exe
Info: creating file dune-project with this contents:
| (lang dune 1.9)

      ocamlc .hello-world.eobjs/byte/hello-world.{cmi,cmo,cmt} (exit 2)
(cd _build/default && /usr/bin/ocamlc.opt -w @a-4-29-40-41-42-44-45-48-58-59-60-40 -strict-sequence -strict-formats -short-paths -keep-locs -g -bin-annot -I .hello-world.eobjs/byte -no-alias-deps -opaque -o .hello-world.eobjs/byte/hello-world.cmo -c -impl hello-world.ml)
File "hello-world.ml", line 1:
Warning 24: bad source file name: "Hello-world" is not a valid module name.
File "hello-world.ml", line 1:
Error: Some fatal warnings were triggered (1 occurrences)
like image 642
Niko W. Avatar asked Jun 11 '19 13:06

Niko W.


1 Answers

You need to disable the warning 24:

(executable (name hello-world) (flags (:standard -w -24)))

or just

(executable (name hello-world) (flags (:standard -warn-error -24)))

if you prefer to keep the warning

like image 142
octachron Avatar answered Nov 10 '22 14:11

octachron