Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make --dev the default #920

Merged
2 commits merged into from Jun 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ case "$TARGET" in
echo -en "travis_fold:end:dune.bootstrap\r"
./boot.exe --subst
echo -en "travis_fold:start:dune.boot\r"
./boot.exe --dev
./boot.exe
echo -en "travis_fold:end:dune.boot\r"
if [ $WITH_OPAM -eq 1 ] ; then
_build/install/default/bin/dune runtest && \
Expand Down
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
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
INSTALL_ARGS := $(if $(PREFIX),--prefix $(PREFIX),)
BIN := ./_build/default/bin/main.exe
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
21 changes: 15 additions & 6 deletions bin/dune
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
(library
(name main)
(modules (main))
(libraries unix dune cmdliner))

(executable
(name main)
(name main_dune)
(public_name dune)
(package dune)
(libraries unix dune cmdliner)
(modules (main_dune))
(libraries which_program_dune main)
(preprocess no_preprocessing))

(install
(section bin)
(package dune)
(files (main.exe as jbuilder)))
(executable
(name main_jbuilder)
(public_name jbuilder)
(package dune)
(modules (main_jbuilder))
(libraries which_program_jbuilder main)
(preprocess no_preprocessing))
22 changes: 18 additions & 4 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 Expand Up @@ -1538,7 +1552,7 @@ let default =
]
)

let () =
let main () =
Colors.setup_err_formatter_colors ();
try
match Term.eval_choice default all ~catch:false with
Expand Down
2 changes: 1 addition & 1 deletion bin/main.mli
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(* empty *)
val main : unit -> unit
1 change: 1 addition & 0 deletions bin/main_dune.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let () = Main.main ()
1 change: 1 addition & 0 deletions bin/main_dune.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(* empty *)
1 change: 1 addition & 0 deletions bin/main_jbuilder.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let () = Main.main ()
1 change: 1 addition & 0 deletions bin/main_jbuilder.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(* empty *)
3 changes: 2 additions & 1 deletion bootstrap.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ end

(* Directories with library names *)
let dirs =
[ "src/stdune/caml" , Some "Caml"
[ "src/which_program" , Some "Which_program"
; "src/stdune/caml" , Some "Caml"
; "src/stdune" , Some "Stdune"
; "src/fiber" , Some "Fiber"
; "src/xdg" , Some "Xdg"
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
14 changes: 14 additions & 0 deletions src/which_program/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(library
(name which_program)
(public_name dune.which-program)
(synopsis "[Internal] Standard library of Dune")
(wrapped false)
(flags (:standard (:include no-keep-locs)))
(modules_without_implementation which_program))

; To avoid issues on Windows and OSX
(rule (with-stdout-to which_program_dummy.ml (echo "")))

(rule
(with-stdout-to no-keep-locs
(run %{OCAML} %{path:gen-no-keep-locs} %{ocaml_version})))
7 changes: 7 additions & 0 deletions src/which_program/dune-impl/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(library
(name which_program_dune)
(public_name dune.which-program.dune)
(wrapped false)
(flags (:standard (:include ../no-keep-locs))))

(rule (copy# ../which_program.mli which_program.mli))
2 changes: 2 additions & 0 deletions src/which_program/dune-impl/which_program.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type t = Dune | Jbuilder
let t = Dune
8 changes: 8 additions & 0 deletions src/which_program/gen-no-keep-locs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(* -*- tuared -*- *)

let () =
let ver = Scanf.sscanf Sys.argv.(1) "%u.%u" (fun a b -> a, b) in
if ver >= (4, 03) then
print_endline "(-no-keep-locs)"
else
print_endline "()"
7 changes: 7 additions & 0 deletions src/which_program/jbuilder-impl/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(library
(name which_program_jbuilder)
(public_name dune.which-program.jbuilder)
(wrapped false)
(flags (:standard (:include ../no-keep-locs))))

(rule (copy# ../which_program.mli which_program.mli))
2 changes: 2 additions & 0 deletions src/which_program/jbuilder-impl/which_program.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type t = Dune | Jbuilder
let t = Jbuilder
2 changes: 2 additions & 0 deletions src/which_program/which_program.boot.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type t = Dune | Jbuilder
let t = Dune
5 changes: 5 additions & 0 deletions src/which_program/which_program.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(** Whether we are 'dune' or 'jbuilder' *)

type t = Dune | Jbuilder

val t : t
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
Loading