Skip to content

Commit

Permalink
refactor: move dune.exe binary to _boot (#6308)
Browse files Browse the repository at this point in the history
* removes yet another generated file from the source repo
* we leave dune.exe as a shell script for user convenience

Signed-off-by: Rudi Grinberg <[email protected]>
  • Loading branch information
rgrinberg authored Nov 12, 2022
1 parent 8c27958 commit d14624c
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ jobs:

# dune doesn't have any additional dependencies so we can build it right
# away this makes it possible to see build errors as soon as possible
- run: opam exec -- make dune.exe
- run: opam exec -- make _boot/dune.exe

# Ensure Dune can build itself
- run: opam exec -- ./dune.exe build @install -p dune --profile dune-bootstrap
- run: opam exec -- make bootstrap

- name: Install deps on Unix
run: |
Expand Down
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ _build
/_boot
_perf
*.install
.merlin
*.corrected

# vim swap files
*.swp
Expand All @@ -20,8 +18,6 @@ _perf
.git-ps

.duneboot.*
/boot/*.cm*
dune.exe
Makefile.dev
src/dune_rules/setup.ml
result
Expand Down
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PREFIX_ARG := $(if $(PREFIX),--prefix $(PREFIX),)
LIBDIR_ARG := $(if $(LIBDIR),--libdir $(LIBDIR),)
DESTDIR_ARG := $(if $(DESTDIR),--destdir $(DESTDIR),)
INSTALL_ARGS := $(PREFIX_ARG) $(LIBDIR_ARG) $(DESTDIR_ARG)
BIN := ./dune.exe
BIN := ./_boot/dune.exe

# Dependencies used for testing dune, when developed locally and
# when tested in CI
Expand All @@ -26,7 +26,7 @@ ppxlib \
result \
ctypes \
"utop>=2.6.0" \
"melange>=0.3.0"
"melange>=0.3.0"

# Dependencies recommended for developing dune locally,
# but not wanted in CI
Expand All @@ -43,7 +43,7 @@ help:

.PHONY: release
release: $(BIN)
@$(BIN) build -p dune --profile dune-bootstrap
@$(BIN) build @install -p dune --profile dune-bootstrap

$(BIN):
@ocaml boot/bootstrap.ml
Expand Down Expand Up @@ -146,8 +146,8 @@ ifeq (dune,$(firstword $(MAKECMDGOALS)))
endif

.PHONY: bench
bench: release
@$(BIN) exec -- ./bench/bench.exe _build/default/dune.exe
bench: $(BIN)
@$(BIN) exec -- ./bench/bench.exe $(BIN)

.PHONY: dune
dune: $(BIN)
Expand All @@ -174,3 +174,7 @@ docker-build-image:
.PHONY: docker-compose
docker-compose:
docker compose -f docker/dev.yml run dune bash

.PHONY: bootstrap
bootstrap:
$(BIN) build @install -p dune --profile dune-bootstrap
2 changes: 1 addition & 1 deletion bench/bench.ml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ let () =
]
}
; { Output.name = "Misc"
; metrics = [ ("Size of dune.exe", `Int size, "bytes") ]
; metrics = [ ("Size of _boot/dune.exe", `Int size, "bytes") ]
}
]
in
Expand Down
2 changes: 1 addition & 1 deletion bin/dune
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

(rule
(action
(copy ../dune.exe dune.exe))
(copy ../_boot/dune.exe dune.exe))
(enabled_if
(= %{profile} dune-bootstrap)))

Expand Down
2 changes: 1 addition & 1 deletion boot/duneboot.ml
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ let sort_files dependencies ~main =

let common_build_args name ~external_includes ~external_libraries =
List.concat
[ [ "-o"; Filename.concat ".." (name ^ ".exe"); "-g" ]
[ [ "-o"; Filename.concat "../_boot" (name ^ ".exe"); "-g" ]
; (match Config.mode with
| Byte -> [ Config.output_complete_obj_arg ]
| Native -> [])
Expand Down
2 changes: 1 addition & 1 deletion doc/hacking.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ run the bootstrapping step itself, build the ``dune.exe`` target with

.. code:: sh
make dune.exe
make dev
Once you've bootstrapped dune, you should be using it to develop dune itself.
Here are the most common commands you'll be running:
Expand Down
4 changes: 3 additions & 1 deletion dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
(dirs :standard \ result)
(dirs _boot :standard \ result)

(data_only_dirs _boot)

(rule
(copy dune-private-libs.opam.template dune-configurator.opam.template))
Expand Down
2 changes: 2 additions & 0 deletions dune.exe
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
exec "$(dirname $0)/_boot/dune.exe" $@
2 changes: 1 addition & 1 deletion dune.opam
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ conflicts: [
dev-repo: "git+https://github.com/ocaml/dune.git"
build: [
["ocaml" "boot/bootstrap.ml" "-j" jobs]
["./dune.exe" "build" "dune.install" "--release" "--profile" "dune-bootstrap" "-j" jobs]
["./_boot/dune.exe" "build" "dune.install" "--release" "--profile" "dune-bootstrap" "-j" jobs]
]
depends: [
# Please keep the lower bound in sync with .github/workflows/workflow.yml,
Expand Down
2 changes: 1 addition & 1 deletion dune.opam.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
build: [
["ocaml" "boot/bootstrap.ml" "-j" jobs]
["./dune.exe" "build" "dune.install" "--release" "--profile" "dune-bootstrap" "-j" jobs]
["./_boot/dune.exe" "build" "dune.install" "--release" "--profile" "dune-bootstrap" "-j" jobs]
]
depends: [
# Please keep the lower bound in sync with .github/workflows/workflow.yml,
Expand Down

0 comments on commit d14624c

Please sign in to comment.