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

Add support for .dune-fs files #750

Closed
wants to merge 11 commits into from
Closed
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: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ next
- Fix a crash when using c files from another directory (#758, fixes
#734, @diml)

- Add support for .dune-fs files (#750, @diml)

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

Expand Down
57 changes: 45 additions & 12 deletions doc/project-layout-specification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -221,20 +221,53 @@ Note that this includes files present in the source tree as well as
generated files. So for instance a changelog generated by a user rule
will be automatically installed as well.

jbuild-ignore
=============
.dune-fs
========

By default Jbuilder traverses the whole source tree, ignoring the
following files and directories:
``.dune-fs`` files allows to control how Dune interprets the file
system. They can be used to make Dune completely ignore certain files
or directories or to make a sub-tree appear as plain raw data.

- any file that start with ``.#``
- any directory that start with either ``.`` or ``_``
They consist of a list of entries of the form:

To ignore a subtree, simply write a ``jbuild-ignore`` file in the
parent directory containing the name of the sub-directories to ignore.
.. code:: scheme

(<kind> <glob> <status>)

Where ``<kind>`` is one of ``file``, ``directory`` or ``_`` and
indicate whether the entry matches files, directories or both. See
:ref:`glob <glob>` ford details about what globs are
available. ``<status>`` gives the status of files and/or directories
matched by this entry and can be one of:

- ``standard``
- ``raw_data`` meaning that Dune will not try to interpret ``Dune``
or other special files for this file or sub-tree. This also prevents
Dune from eagerly scanning a sub-tree
- ``ignore`` meaning that Dune will completely ignore this file or
sub-tree. It is the same as removing it before running Dune

The status of a given file or sub-directory is given by the last entry
that matches. The following default is assumed in any directory that
doesn't have a ``.dune-fs`` file:

.. code:: scheme

(dir [._]* ignore)
(_ .#* ignore)

So for instance ``.git`` directories are completely ignored. If you
wanted to write an action that would read files inside the ``.git``
directory, you could override this default by adding the following
``.dune-fs`` file:

.. code:: scheme

(dir .git raw_data)

So for instance, if you write ``foo`` in ``src/jbuild-ignore``, then
``src/foo`` won't be traversed and any ``jbuild`` file it contains will
be ignored.
jbuild-ignore (deprecated)
==========================

``jbuild-ignore`` files contain a list of directory names, one per line.
``jbuild-ignore`` files are deprecated. Each line of a
``jbuild-ignore`` file is interpreted in the same way as a ``(dir
<dirname> raw_data)`` entry in a ``.dune-fs`` file.
3 changes: 3 additions & 0 deletions example/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
(jbuild_version 1)

(fs
(dir sample-projects raw_data))

(alias
((name runtest)
(deps ((package dune)
Expand Down
1 change: 0 additions & 1 deletion example/jbuild-ignore

This file was deleted.

6 changes: 3 additions & 3 deletions src/build_system.ml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ let rule_loc ~file_tree ~loc ~dir =
Option.bind (File_tree.find_dir file_tree dir)
~f:File_tree.Dir.dune_file
with
| Some file -> file
| Some file -> File_tree.Dune_file.path file
| None -> Path.relative dir "_unknown_"
in
Loc.in_file (Path.to_string file)
Expand Down Expand Up @@ -263,7 +263,7 @@ module Alias0 = struct
open Build.O

let dep_rec_internal ~name ~dir ~ctx_dir =
File_tree.Dir.fold dir ~traverse_ignored_dirs:false ~init:(Build.return true)
File_tree.Dir.fold dir ~traverse_raw_data_dirs:false ~init:(Build.return true)
~f:(fun dir acc ->
let path = Path.append ctx_dir (File_tree.Dir.path dir) in
let fn = stamp_file (make ~dir:path name) in
Expand Down Expand Up @@ -1168,7 +1168,7 @@ end

let all_targets t =
String.Map.iter t.contexts ~f:(fun ctx ->
File_tree.fold t.file_tree ~traverse_ignored_dirs:true ~init:()
File_tree.fold t.file_tree ~traverse_raw_data_dirs:true ~init:()
~f:(fun dir () ->
load_dir t
~dir:(Path.append ctx.Context.build_dir (File_tree.Dir.path dir))));
Expand Down
Loading