Skip to content

Commit

Permalink
Make the default build profile be dev
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
  • Loading branch information
jeremiedimino committed Jun 28, 2018
1 parent 16d34f4 commit 2982567
Show file tree
Hide file tree
Showing 25 changed files with 79 additions and 50 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ next
- Make `(diff a b)` ignore trailing cr on Windows and add `(cmp a b)` for
comparing binary files (#904, fix #844, @diml)

- Make `dev` the default build profile (#920, @diml)

1.0+beta20 (10/04/2018)
-----------------------

Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ BIN := ./_build/default/bin/main_dune.exe
-include Makefile.dev

default: boot.exe
./boot.exe --dev
./boot.exe

release: boot.exe
./boot.exe
./boot.exe --release

boot.exe: bootstrap.ml
ocaml bootstrap.ml
Expand All @@ -21,21 +21,21 @@ uninstall:
reinstall: uninstall reinstall

test:
$(BIN) runtest --dev
$(BIN) runtest

test-js:
$(BIN) build @runtest-js --dev
$(BIN) build @runtest-js

test-all:
$(BIN) build @runtest @runtest-js --dev
$(BIN) build @runtest @runtest-js

promote:
$(BIN) promote

accept-corrections: promote

all-supported-ocaml-versions:
$(BIN) build --dev @install @runtest --workspace dune-workspace.dev --root .
$(BIN) build @install @runtest --workspace dune-workspace.dev --root .

clean:
$(BIN) clean
Expand All @@ -52,7 +52,7 @@ livedoc:
-p 8888 -q --host $(shell hostname) -r '\.#.*'

update-jbuilds: $(BIN)
$(BIN) build --dev @doc/runtest --auto-promote
$(BIN) build @doc/runtest --auto-promote

.PHONY: default install uninstall reinstall clean test doc
.PHONY: promote accept-corrections opam-release
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ install:
build_script:
- cd "%APPVEYOR_BUILD_FOLDER%"
- ocaml bootstrap.ml
- boot.exe --dev
- boot.exe
- copy _build\install\default\bin\dune.exe dune.exe
- dune.exe build @test\blackbox-tests\windows-diff

Expand Down
20 changes: 17 additions & 3 deletions bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,26 @@ let common =
& info ["dev"] ~docs
~doc:{|Same as $(b,--profile dev)|})
in
let dev =
match Which_program.t with
| Jbuilder -> dev
| Dune ->
let check = function
| false -> `Ok false
| true ->
`Error (true, "--dev is no longer accepted as it is now the default.")
in
Term.(ret (const check $ dev))
in
let profile =
Arg.(value
& opt (some string) None
& info ["profile"] ~docs
~doc:{|Select the build profile, for instance $(b,dev) or $(b,release).
The default is $(b,default).|})
~doc:
(sprintf
{|Select the build profile, for instance $(b,dev) or
$(b,release). The default is $(b,%s).|}
Config.default_build_profile))
in
let profile =
let merge dev profile =
Expand Down Expand Up @@ -567,7 +581,7 @@ let installed_libraries =
Scheduler.go ~log:(Log.create common) ~common
(Context.create
(Default { targets = [Native]
; profile = "default" })
; profile = Config.default_build_profile })
~env
>>= fun ctxs ->
let ctx = List.hd ctxs in
Expand Down
5 changes: 3 additions & 2 deletions doc/jbuild.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1159,8 +1159,9 @@ using ``(js_of_ocaml (<js_of_ocaml-options>))``.

``<flags>`` is specified in the `Ordered set language`_.

The default value for ``(flags ...)`` depends on whether ``--dev`` is passed to
Jbuilder. ``--dev`` will enable sourcemap and the pretty JavaScript output.
The default value for ``(flags ...)`` depends on the selected build
profile. The build profile ``dev`` (the default) will enable sourcemap
and the pretty JavaScript output.

.. _user-actions:

Expand Down
6 changes: 3 additions & 3 deletions doc/terminology.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ Terminology

- **build profile**: a global setting that influence various
defaults. It can be set from the command line using ``--profile
<profile>`` or from ``jbuild-workspace`` files. The following
<profile>`` or from ``dune-workspace`` files. The following
profiles are standard:

- ``default`` which is the default profile when none is set explicitely
- ``release`` which is the profile used for opam releases
- ``dev`` which has stricter warnings
- ``dev`` which is the default profile when none is set explicitely, it
has stricter warnings that the ``release`` one
9 changes: 5 additions & 4 deletions doc/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ follows:

::

build: [["jbuilder" "build" "-p" name "-j" jobs]]
build: [["dune" "build" "-p" name "-j" jobs]]

``-p pkg`` is a shorthand for ``--root . --only-packages pkg --profile
release``. ``-p`` is the short version of
Expand Down Expand Up @@ -364,7 +364,7 @@ write a ``(profile ...)`` stanza. For instance:

.. code:: scheme
(profile dev)
(profile release)
Note that the command line option ``--profile`` has precedence over
this stanza.
Expand Down Expand Up @@ -436,8 +436,9 @@ It supports two modes of compilation:
separately and then linked together. This mode is useful during development as
it builds more quickly.

The separate compilation mode will be selected when passing ``--dev`` to
jbuilder. There is currently no other way to control this behaviour.
The separate compilation mode will be selected when the build profile
is ``dev``, which is the default. There is currently no other way to
control this behaviour.

See the section about :ref:`jbuild-jsoo` for passing custom flags to the
js_of_ocaml compiler
Expand Down
4 changes: 2 additions & 2 deletions dune.opam
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ license: "MIT"
build: [
["ocaml" "configure.ml" "--libdir" lib]
["ocaml" "bootstrap.ml"]
["./boot.exe" "--subst"] {pinned}
["./boot.exe" "-j" jobs]
["./boot.exe" "--release" "--subst"] {pinned}
["./boot.exe" "--release" "-j" jobs]
]
available: [ ocaml-version >= "4.02.3" ]
conflicts: [
Expand Down
5 changes: 5 additions & 0 deletions src/config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ let jbuilder_keep_fname = ".jbuilder-keep"
let inside_emacs = Option.is_some (Env.get Env.initial "INSIDE_EMACS")
let inside_dune = Option.is_some (Env.get Env.initial "INSIDE_DUNE")

let default_build_profile =
match Which_program.t with
| Dune -> "dev"
| Jbuilder -> "release"

open Sexp.Of_sexp

module Display = struct
Expand Down
2 changes: 2 additions & 0 deletions src/config.mli
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ val inside_emacs : bool
(** Are we running insinde Dune? *)
val inside_dune : bool

val default_build_profile : string

(** Jbuilder configuration *)

module Display : sig
Expand Down
3 changes: 2 additions & 1 deletion src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
re
opam_file_format
usexp
ocaml_config)
ocaml_config
which_program)
(synopsis "Internal Dune library, do not use!"))

(ocamllex meta_lexer glob_lexer dune_lexer)
Expand Down
10 changes: 6 additions & 4 deletions src/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ let setup ?(log=Log.no_log)
| None -> Native
| Some x -> Named x
]
; profile = Option.value profile ~default:"default"
; profile =
Option.value profile
~default:Config.default_build_profile
}]
}
in
Expand Down Expand Up @@ -229,8 +231,8 @@ let bootstrap () =
let profile = ref None in
Arg.parse
[ "-j" , String concurrency_arg, "JOBS concurrency"
; "--dev" , Unit (fun () -> profile := Some "dev"),
" set development mode"
; "--release" , Unit (fun () -> profile := Some "release"),
" set release mode"
; "--display" , display_mode , " set the display mode"
; "--subst" , Unit subst ,
" substitute watermarks in source files"
Expand All @@ -242,7 +244,7 @@ let bootstrap () =
Clflags.debug_dep_path := true;
let config =
(* Only load the configuration with --dev *)
if !profile = Some "dev" then
if !profile <> Some "release" then
Config.load_user_config_file ()
else
Config.default
Expand Down
2 changes: 1 addition & 1 deletion src/workspace.ml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ let t ?x ?profile:cmdline_profile sexps =
| _ :: (loc, _) :: _, _ ->
Loc.fail loc "profile defined too many times"
| _, Some p -> p
| [], None -> "default"
| [], None -> Config.default_build_profile
| [(_, p)], None -> p
in
let { merlin_context; contexts } =
Expand Down
12 changes: 6 additions & 6 deletions test/blackbox-tests/test-cases/env/run.t
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
$ dune printenv .
$ dune printenv --profile default .
(
(flags (-w -40 -plop))
(ocamlc_flags (-g))
(ocamlopt_flags (-g))
)
$ dune printenv src
$ dune printenv --profile default src
(
(flags (-w -40 -plop -truc))
(ocamlc_flags (-g))
(ocamlopt_flags (-g))
)
$ dune printenv bin
$ dune printenv --profile default bin
(
(flags (-machin))
(ocamlc_flags (-g))
(ocamlopt_flags (-g))
)
$ dune printenv vendor
$ dune printenv --profile default vendor
(
(flags (-w -40 -plop))
(ocamlc_flags (-g))
(ocamlopt_flags (-g))
)
$ dune printenv vendor/a
$ dune printenv --profile default vendor/a
(
(flags (-w -40 -bidule))
(ocamlc_flags (-g))
(ocamlopt_flags (-g))
)
$ dune printenv vendor/a/src
$ dune printenv --profile default vendor/a/src
(
(flags (-w -40 -bidule -pouet))
(ocamlc_flags (-g))
Expand Down
2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/exec-cmd/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
ocamlopt .foo.eobjs/foo.{cmx,o}
ocamlopt foo.exe
Foo
$ dune exec --dev ./foo.exe --display short
$ dune exec --profile release ./foo.exe --display short
ocamlc .foo.eobjs/foo.{cmi,cmo,cmt}
ocamlopt .foo.eobjs/foo.{cmx,o}
ocamlopt foo.exe
Expand Down

This file was deleted.

This file was deleted.

7 changes: 5 additions & 2 deletions test/blackbox-tests/test-cases/github660/run.t
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
$ echo 'let hello = "hello"' > explicit-interfaces/lib_sub.ml
$ echo 'let hello = "hello"' > no-interfaces/lib_sub.ml

When there are explicit interfaces, modules must be rebuilt.

$ dune runtest --root explicit-interfaces
Entering directory 'explicit-interfaces'
main alias runtest
hello
$ echo 'let x = 1' >> explicit-interfaces/lib_sub.ml
$ echo 'let _x = 1' >> explicit-interfaces/lib_sub.ml
$ dune runtest --root explicit-interfaces
Entering directory 'explicit-interfaces'
main alias runtest
Expand All @@ -17,7 +20,7 @@ to rely on these.
Entering directory 'no-interfaces'
main alias runtest
hello
$ echo 'let x = 1' >> no-interfaces/lib_sub.ml
$ echo 'let _x = 1' >> no-interfaces/lib_sub.ml
$ dune runtest --root no-interfaces
Entering directory 'no-interfaces'
main alias runtest
Expand Down
4 changes: 2 additions & 2 deletions test/blackbox-tests/test-cases/js_of_ocaml/run.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$ dune build --display short --dev bin/technologic.bc.js @install lib/x.cma.js lib/x__Y.cmo.js bin/z.cmo.js
$ dune build --display short bin/technologic.bc.js @install lib/x.cma.js lib/x__Y.cmo.js bin/z.cmo.js
ocamlc lib/stubs$ext_obj
ocamlmklib lib/dllx_stubs$ext_dll,lib/libx_stubs$ext_lib
ocamlopt .ppx/js_of_ocaml-ppx/ppx.exe
Expand Down Expand Up @@ -34,7 +34,7 @@
use it
break it
fix it
$ dune build --display short bin/technologic.bc.js @install
$ dune build --display short bin/technologic.bc.js @install --profile release
ocamlc lib/.x.objs/x__.{cmi,cmo,cmt}
ocamlc lib/.x.objs/x__Y.{cmi,cmo,cmt}
ocamlc lib/.x.objs/x.{cmi,cmo,cmt}
Expand Down
2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/merlin-tests/run.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$ dune build @print-merlins --display short
$ dune build @print-merlins --display short --profile release
ocamldep sanitize-dot-merlin/.sanitize_dot_merlin.eobjs/sanitize_dot_merlin.ml.d
ocamlc sanitize-dot-merlin/.sanitize_dot_merlin.eobjs/sanitize_dot_merlin.{cmi,cmo,cmt}
ocamlopt sanitize-dot-merlin/.sanitize_dot_merlin.eobjs/sanitize_dot_merlin.{cmx,o}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$ dune exec ./test.exe --debug-dep --display short --root jbuild
$ dune exec ./test.exe --debug-dep --display short --root jbuild --profile release
Entering directory 'jbuild'
File "jbuild", line 1, characters 0-0:
Warning: Module "Lib" is used in several stanzas:
Expand Down
2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/ppx-rewriter/ppx/fooppx.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let () =
; "-arg", Arg.Set_string arg, ""
])
Migrate_parsetree.Versions.ocaml_405
(fun _ cookies ->
(fun _ _cookies ->
if not !flag then (
Format.eprintf "pass -flag to fooppx@.%!";
exit 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open Str
open! Str

let foo () =
print_endline "foobarlib"
8 changes: 4 additions & 4 deletions test/bulk-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
# the current test succeeds. It uses inotifywait to detect changes to
# the test.

DUNE=_build/default/bin/main.exe
DUNE=_build/default/bin/main_dune.exe

LIST=$(mktemp)
trap "rm -f $LIST" EXIT

echo "Computing the list of failing tests..."
$DUNE runtest test/blackbox-tests \
--diff-command "echo >> $LIST" --dev &> /dev/null
TESTS=$(cat /tmp/list |cut -d/ -f4 |sed 's/^//')
--diff-command "echo >> $LIST" &> /dev/null
TESTS=$(cat $LIST |cut -d/ -f4 |sed 's/^//')
rm -f $LIST

count=0
Expand All @@ -32,7 +32,7 @@ for t in $TESTS; do
echo "$title"
echo "${title//?/=}"
echo
$DUNE build --dev @test/blackbox-tests/$t && break
$DUNE build @test/blackbox-tests/$t && break
inotifywait $(find test/blackbox-tests/test-cases/$t -type d) \
-e modify,attrib,close_write,move,create,delete
done
Expand Down
2 changes: 1 addition & 1 deletion test/unit-tests/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
(modules expect_test)
(link_flags (-linkall))
(modes byte)
(libraries unix dune compiler-libs.toplevel test_common))
(libraries which_program_dune unix dune compiler-libs.toplevel test_common))

(ocamllex expect_test)

Expand Down

0 comments on commit 2982567

Please sign in to comment.