Skip to content

Commit

Permalink
Merge branch 'master' into warn_unused_prepro_deps_later
Browse files Browse the repository at this point in the history
  • Loading branch information
nojb authored Sep 25, 2019
2 parents 1595ddf + faed6db commit 56861af
Show file tree
Hide file tree
Showing 87 changed files with 1,510 additions and 1,125 deletions.
14 changes: 10 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,27 @@ cache:
install: bash -ex .travis-ci.sh prepare
script: bash -ex .travis-ci.sh build

# Please keep the list in sync with the minimal version of OCaml in
# dune-project and bootstrap.ml

matrix:
include:
- os: linux
env: OCAML_VERSION=4.08 OCAML_RELEASE=0 WITH_OPAM=0
env: OCAML_VERSION=4.06 OCAML_RELEASE=1 WITH_OPAM=0
stage: Build
- os: linux
env: OCAML_VERSION=4.07 OCAML_RELEASE=1 WITH_OPAM=0
stage: Build
- os: linux
env: OCAML_VERSION=4.08 OCAML_RELEASE=0 WITH_OPAM=1
env: OCAML_VERSION=4.08 OCAML_RELEASE=1 WITH_OPAM=0
stage: Build
- os: linux
env: OCAML_VERSION=4.08 OCAML_RELEASE=0 WITH_OPAM=1
env: OCAML_VERSION=4.08 OCAML_RELEASE=1 WITH_OPAM=1
stage: Test
addons:
apt:
packages:
- aspcud
- os: osx
env: OCAML_VERSION=4.08 OCAML_RELEASE=0 WITH_OPAM=0
env: OCAML_VERSION=4.08 OCAML_RELEASE=1 WITH_OPAM=0
stage: Build_macOS
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@
are marked with`re_export` and will automatically be provided to
users of a library (#2605, @rgrinberg)

- Add a `deprecated_library_name` stanza to redirect old names after a
library has been renamed (#2528, @diml)

1.11.3 (23/08/2019)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion bin/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
(public_name dune)
(package dune)
(libraries memo dune_lang fiber stdune unix dune_manager dune cmdliner
build_info)
threads.posix build_info)
(preprocess future_syntax))
8 changes: 6 additions & 2 deletions bin/import.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ module Cached_digest = Dune.Cached_digest
module Profile = Dune.Profile
include Common.Let_syntax

(* FIXME: leverage fibers to actually connect in the background *)
let make_memory () =
let handle = function
| Dune_manager.Client.Dedup (target, source, digest) ->
Scheduler.send_dedup target source digest
in
match Sys.getenv_opt "DUNE_CACHE" with
| Some _ -> Fiber.return (Some (Result.ok_exn (Dune_manager.Client.make ())))
| Some _ ->
Fiber.return (Some (Result.ok_exn (Dune_manager.Client.make handle)))
| _ -> Fiber.return None

module Main = struct
Expand Down
15 changes: 6 additions & 9 deletions bin/installed_libraries.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,18 @@ let term =
) else
let pkgs = Findlib.all_packages findlib in
let max_len =
String.longest_map pkgs ~f:(fun (n : Dune_package.Lib.t) ->
let info = Dune_package.Lib.info n in
let name = Dune.Lib_info.name info in
Lib_name.to_string name)
String.longest_map pkgs ~f:(fun e ->
Lib_name.to_string (Dune_package.Entry.name e))
in
List.iter pkgs ~f:(fun (pkg : Dune_package.Lib.t) ->
let info = Dune_package.Lib.info pkg in
List.iter pkgs ~f:(fun e ->
let ver =
match Dune.Lib_info.version info with
match Dune_package.Entry.version e with
| Some v -> v
| _ -> "n/a"
in
let name = Dune.Lib_info.name info in
Printf.printf "%-*s (version: %s)\n" max_len
(Lib_name.to_string name) ver);
(Lib_name.to_string (Dune_package.Entry.name e))
ver);
Fiber.return ())

let command = (term, info)
8 changes: 7 additions & 1 deletion bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ let run_build_command ~common ~targets =
in
Scheduler.poll ~common ~once ~finally:Hooks.End_of_build.run ()
else
Scheduler.go ~common once
Scheduler.go ~common once;
Option.iter (Build_system.get_memory ()) ~f:(fun memory ->
(* Synchronously wait for the end of the connection with the cache
daemon, ensuring all dedup messages have been queued. *)
Dune_manager.Client.teardown memory;
(* Hande all remaining dedup mesages. *)
Scheduler.wait_for_dune_cache ())

let build_targets =
let doc =
Expand Down
18 changes: 16 additions & 2 deletions bootstrap.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[@@@ocaml.warning "-40"]

(* Please keep this value in sync with .travis.yml and dune-project *)
let min_ocaml_version = (4, 06)

(* This module is here to build a version of Dune that is capable of
* building itself. It accomplishes this by concatenating all its source files
* into a single .ml file and simply compiling it. The source code of the
Expand All @@ -10,6 +13,18 @@
* continue to work, dune files in the Dune repository should not use
* globs. *)

;;
Scanf.sscanf Sys.ocaml_version "%u.%u" (fun x y ->
if (x, y) < min_ocaml_version then (
Printf.eprintf
"Sorry, your version of OCaml is too old to build dune.\n\
You need OCaml >= %u.%02u to build dune itself.\n\
Please use a more recent compiler.\n\
%!"
(fst min_ocaml_version) (snd min_ocaml_version);
exit 1
))

module Array = ArrayLabels
module List = ListLabels

Expand All @@ -34,8 +49,7 @@ type subdirs =

(* Directories with library names *)
let dirs =
[ ("src/stdune/result", Some "Dune_result", No)
; ("src/stdune/caml", Some "Dune_caml", No)
[ ("src/stdune/caml", Some "Dune_caml", No)
; ("src/dune_action_plugin", Some "Dune_action_plugin", No)
; ("src/stdune", Some "Stdune", No)
; ("src/fiber", Some "Fiber", No)
Expand Down
16 changes: 16 additions & 0 deletions doc/dune-files.rst
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,22 @@ JavaScript output.

See :ref:`jsoo` for more information.

deprecated_library_name
-----------------------

The ``deprecated_library_name`` stanza allows to redirect an old
deprecated name after a library has been renamed. It's syntax is as
follow:

(deprecated_library_name
(old_public_name <name>)
(new_public_name <name>))

When a developer uses the old public name in a list of library
dependencies, it will be transparently replaced by the new name. Note
that it is not necessary for the new name to exist at definition time
as it is only resolved at the point where the old name is used.

executable
----------

Expand Down
1 change: 1 addition & 0 deletions dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
;; We embed a copy of ocaml-syntax-shims until we drop support for
;; OCaml < 4.08

(env
(_
(binaries
Expand Down
1 change: 0 additions & 1 deletion dune-build-info.opam
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ homepage: "https://github.com/ocaml/dune"
doc: "https://dune.readthedocs.io/"
bug-reports: "https://github.com/ocaml/dune/issues"
depends: [
"ocaml" {>= "4.02"}
"dune" {>= "1.11"}
]
dev-repo: "git+https://github.com/ocaml/dune.git"
Expand Down
5 changes: 3 additions & 2 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
(package
(name dune)
(depends
(ocaml (>= 4.02))
;; Please keep the lower bound in sync with .travis.yml and
;; min_ocaml_version in bootstrap.ml
(ocaml (>= 4.06))
base-unix
base-threads)
(conflicts
Expand Down Expand Up @@ -42,7 +44,6 @@ for free.
(package
(name dune-build-info)
(depends
(ocaml (>= 4.02))
(dune (>= 1.11)))
(synopsis "Embed build informations inside executable")
(description "\
Expand Down
6 changes: 1 addition & 5 deletions dune-workspace.dev
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
(lang dune 1.0)

;; This file is used by `make all-supported-ocaml-versions`
(context (opam (switch 4.02.3)))
(context (opam (switch 4.03.0)))
(context (opam (switch 4.04.2)))
(context (opam (switch 4.05.0)))
(context (opam (switch 4.06.1)))
(context (opam (switch 4.07.1)))
(context (opam (switch 4.08.0+trunk)))
(context (opam (switch 4.08.0)))
2 changes: 1 addition & 1 deletion dune.opam
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ homepage: "https://github.com/ocaml/dune"
doc: "https://dune.readthedocs.io/"
bug-reports: "https://github.com/ocaml/dune/issues"
depends: [
"ocaml" {>= "4.02"}
"ocaml" {>= "4.06"}
"base-unix"
"base-threads"
]
Expand Down
2 changes: 1 addition & 1 deletion src/configurator/dune
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
(name configurator)
(public_name dune.configurator)
(preprocess future_syntax)
(libraries stdune ocaml_config dune_lang dune_caml dune._result)
(libraries stdune ocaml_config dune_lang dune_caml)
(flags
(:standard
-safe-string
Expand Down
4 changes: 1 addition & 3 deletions src/configurator/v1.mli
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
open! Dune_result

type t

val create :
Expand Down Expand Up @@ -95,7 +93,7 @@ module Pkg_config : sig
[package] should be just the name of the package. Returns [Error
error_msg] if [package] is not available *)
val query_expr_err :
t -> package:string -> expr:string -> (package_conf, string) Result.t
t -> package:string -> expr:string -> (package_conf, string) result
end
with type configurator := t

Expand Down
5 changes: 5 additions & 0 deletions src/dune/build_system.ml
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,10 @@ let set_rule_generators ~init ~gen_rules =
Fdecl.set t.init_rules init_rules;
Fdecl.set t.gen_rules gen_rules

let get_memory () =
let t = t () in
t.memory

let get_dir_triage t ~dir =
match Path.as_in_source_tree dir with
| Some dir ->
Expand Down Expand Up @@ -1472,6 +1476,7 @@ end = struct
let* () =
if rule_need_rerun then (
List.iter targets_as_list ~f:(fun target ->
Cached_digest.remove (Path.build target);
Path.unlink_no_err (Path.build target));
let from_dune_memory =
match (do_not_memoize, t.memory) with
Expand Down
2 changes: 2 additions & 0 deletions src/dune/build_system.mli
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,5 @@ end
transitive dependencies. *)
val evaluate_rules :
recursive:bool -> request:unit Build.t -> Rule.t list Fiber.t

val get_memory : unit -> Dune_manager.Client.t option
56 changes: 31 additions & 25 deletions src/dune/cached_digest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -96,34 +96,40 @@ let refresh fn =
set_with_stat fn digest stat;
digest

let file fn =
let peek_file fn =
let cache = Lazy.force cache in
match Path.Table.find cache.table fn with
| None -> refresh fn
| None -> None
| Some x ->
if x.stats_checked = cache.checked_key then
x.digest
else (
needs_dumping := true;
let stat = Path.stat fn in
let dirty = ref false in
set_max_timestamp cache stat;
if stat.st_mtime <> x.timestamp then (
dirty := true;
x.timestamp <- stat.st_mtime
);
if stat.st_perm <> x.permissions then (
dirty := true;
x.permissions <- stat.st_perm
);
if stat.st_size <> x.size then (
dirty := true;
x.size <- stat.st_size
);
if !dirty then x.digest <- Digest.file_with_stats fn stat;
x.stats_checked <- cache.checked_key;
x.digest
)
Some
( if x.stats_checked = cache.checked_key then
x.digest
else (
needs_dumping := true;
let stat = Path.stat fn in
let dirty = ref false in
set_max_timestamp cache stat;
if stat.st_mtime <> x.timestamp then (
dirty := true;
x.timestamp <- stat.st_mtime
);
if stat.st_perm <> x.permissions then (
dirty := true;
x.permissions <- stat.st_perm
);
if stat.st_size <> x.size then (
dirty := true;
x.size <- stat.st_size
);
if !dirty then x.digest <- Digest.file_with_stats fn stat;
x.stats_checked <- cache.checked_key;
x.digest
) )

let file fn =
match peek_file fn with
| None -> refresh fn
| Some v -> v

let remove fn =
let cache = Lazy.force cache in
Expand Down
3 changes: 3 additions & 0 deletions src/dune/cached_digest.mli
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ open Stdune
(** Digest the contents of the following file *)
val file : Path.t -> Digest.t

(** The digest of the following file, if cached *)
val peek_file : Path.t -> Digest.t option

(** Clear the following digest from the cache *)
val remove : Path.t -> unit

Expand Down
2 changes: 1 addition & 1 deletion src/dune/compilation_context.ml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type t =
; preprocessing : Preprocessing.t
; no_keep_locs : bool
; opaque : bool
; stdlib : Dune_file.Library.Stdlib.t option
; stdlib : Ocaml_stdlib.t option
; js_of_ocaml : Dune_file.Js_of_ocaml.t option
; dynlink : bool
; sandbox : Sandbox_config.t
Expand Down
4 changes: 2 additions & 2 deletions src/dune/compilation_context.mli
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ val create :
-> ?preprocessing:Preprocessing.t
-> ?no_keep_locs:bool
-> opaque:bool
-> ?stdlib:Dune_file.Library.Stdlib.t
-> ?stdlib:Ocaml_stdlib.t
-> js_of_ocaml:Dune_file.Js_of_ocaml.t option
-> dynlink:bool
-> package:Package.t option
Expand Down Expand Up @@ -63,7 +63,7 @@ val no_keep_locs : t -> bool

val opaque : t -> bool

val stdlib : t -> Dune_file.Library.Stdlib.t option
val stdlib : t -> Ocaml_stdlib.t option

val js_of_ocaml : t -> Dune_file.Js_of_ocaml.t option

Expand Down
7 changes: 6 additions & 1 deletion src/dune/dir_contents.ml
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,13 @@ end = struct
(Option.value ~default:Ordered_set_lang.standard
lib.private_modules)
in
let stdlib = lib.stdlib in
let implements = Option.is_some lib.implements in
let _loc, lib_name = lib.name in
Left
(lib, Modules.lib ~lib ~src_dir ~modules ~main_module_name ~wrapped)
( lib
, Modules.lib ~stdlib ~implements ~lib_name ~src_dir ~modules
~main_module_name ~wrapped )
| Executables exes
|Tests { exes; _ } ->
let modules =
Expand Down
Loading

0 comments on commit 56861af

Please sign in to comment.