Commit Graph

42 Commits

Author SHA1 Message Date
Jeremie Dimino f46de28e8d Simplify the code with Option.value
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-07-09 10:20:04 +01:00
Jeremie Dimino e05fcb7631 Do not parse dune-project files in ignored directories
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-07-09 10:20:04 +01:00
Rudi Grinberg 2257a2057b Add templates to Usexp.t directly
Templates are now directly in dune's sexp language. The syntax is change to %{}
from ${} and $(). Old templates are still supported in jbuild files.

Other changes in this PR:

* Removal of ! patterns in variables
* Strict expansion for templates in dune files. Missing vars are now an error
* Using the correct syntax to parse included files in dune
* Improvements to the tests
* Syntax aware pretty printing of sexps. Now you must pass Dune vs. Jbuild to
  print sexps

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-06-28 09:46:10 +06:30
Jeremie Dimino 0c6edde131 Add a user context to Of_sexp.t
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-06-19 16:26:00 +01:00
Jeremie Dimino 14e6b1e038 Reduce the number of of_sexp_error... functions
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-06-19 11:29:27 +01:00
Jeremie Dimino 30d20d6143 Use a single S-expression parser monad
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-06-19 11:29:27 +01:00
Rudi Grinberg 065e2bb26f Make Sexp.Of_sexp.t abstract
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-06-19 11:29:27 +01:00
Jérémie Dimino 3c74bf07e8
Use the same monad to parse all list of S-expressions (#882)
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-06-14 08:51:27 +01:00
Jeremie Dimino 250b940c32 Start of support for languages and extensions
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-06-12 12:09:11 +01:00
Jeremie Dimino b5dfb826ef Restore old ppx behavior for directories with jbuild files
Signed-off-by: Jeremie Dimino <jdimino@janestreet.com>
2018-06-05 19:19:10 +01:00
Jeremie Dimino b7afc006ee Drop support block and sexp comments in Dune files
They are almost never used and they complicate the language. The
parsing of jbuild files in unchanged.

Signed-off-by: Jeremie Dimino <jdimino@janestreet.com>
2018-06-04 13:57:27 +01:00
Rudi Grinberg be7e3d6dfc Implement --build-dir and change Path.t to use symbolic paths
The motivation for this change is implement the --build-dir feature. This
feature lets us control the build directory which previously always defaulted to
_build. To accomplish this, Path.t had to be modified to be:

External of External.t | In_source_tree of Local.t | In_build_dir of Local.t

To represent the 3 kinds of paths dune is dealing with. The In_build_dir
constructor in particular, is relative to Path.root or some external path.

A few other refactorings had to be done to support this transition:

* The workspace is now "settable". This means that we no longer have to pass it
  explicitly when converting local to absolute paths.

* Path.is_local no longer makes sense and is renamed to Path.is_managed.
  Roughly, is_managed identifies paths in the build and source directories.

* Path.absoulte has been renamed of_filename_relative_to_initial_cwd

* Path.Local.root is now "." (as opposed to "")

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-06-02 18:14:44 +07:00
Jeremie Dimino 39e74826f4 Simplify the parser
Replace the current generated parser by an ocamllex lexer + a simple
parser.

The new code is:
- much simpler and smaller
- shouldn't cause ocamlopt to stack overflow anymore on BSD systems
- slightly slower but not that much

Signed-off-by: Jeremie Dimino <jdimino@janestreet.com>
2018-06-01 08:42:45 +01:00
Etienne Millon e97d0c5ad6 Rename Path.readdir to Path.readdir_unsorted (#828)
As `Sys.readdir`, it returns entries in an nondeterministic order.
This can cause problems if caller relies on the list being sorted.

See #820.

Signed-off-by: Etienne Millon <etienne@cryptosense.com>
2018-05-31 14:52:10 +01:00
Etienne Millon 29f711985d Make "path already scanned" message deterministic (#820)
When a symlink loop is detected, the following message is printed:

> Path X has already been scanned. Cannot scan it again through symlink Y

However, the actual symlink that is displayed depends on the order in
with `readdir` outputs the contents (which depends on FS internals).

This sorts the directory list so that the message is deterministic.

It can be tested by adding for example a `List.rev` call after
`Path.readdir`: the affected version will return a different version in
the `github764` test.

Signed-off-by: Etienne Millon <etienne@cryptosense.com>
2018-05-30 12:57:23 +01:00
Jeremie Dimino 2192a549f4 Use dev/inode to detect loops 2018-05-16 14:23:01 +01:00
Rudi Grinberg ac078fcdbb add cycle and max depth to symlink following 2018-05-15 19:29:20 +07:00
Rudi Grinberg 540a22315b Refactor symlink following
Correctly resolve relative symlinks and add better error handling. Also move the
logic to the path module.
2018-05-15 17:33:51 +07:00
Rudi Grinberg 7580b8e16f Detect circular sym links
Fix #764
2018-05-15 17:33:27 +07:00
Jérémie Dimino 60c7f6fde4
Collect projects in the file tree directly (#774) 2018-05-15 09:46:07 +01:00
Jérémie Dimino bc19e14b35
Add ignored_subdirs stanza (#767) 2018-05-12 15:38:22 +02:00
Rudi Grinberg f7f22cbf52 Make Path.parent return option
Use _exn whenever we know the parent exists
2018-05-09 17:56:50 +07:00
Jérémie Dimino 5ac3acf195
Add File_tree.Dir.dune_file (#749) 2018-05-09 09:18:01 +01:00
Jérémie Dimino b54c438fda
Scan the file-system lazily (#732)
Fix #228
Fix #718
2018-05-01 16:55:31 +01:00
Rudi Grinberg 7820e29d28 Port Io to use Path.t 2018-04-25 03:25:27 +07:00
Rudi Grinberg 98b2ea795c Move String_map to stdune 2018-04-23 12:43:20 +07:00
Rudi Grinberg 530dbfeb81 Move String_set to stdune 2018-04-23 12:08:09 +07:00
Jérémie Dimino 3fd3eb8a12
Split src/import.ml into a new library src/stdune (#548)
- make sure type t always come first
- Map.map, Map.fold, ... never pass the key to the callback while Map.mapi, Map.foldi, ... do
- removed the ~key and ~data labels, I find them useless and annoying
- Set.elements --> Set.to_list
- Map.bindings --> Map.to_list
- Map.of_alist --> Map.of_list
- added Ordering.t for comparison functions
- renamed Inl/Inr to Left/Right. The latter seems clearer
- moved List.longest to String.longest
- added a Pp module with a nicer API than Format
2018-02-25 16:35:25 +00:00
David Allsopp 6873478307 Display a warning for bad jbuild-ignore lines (#389)
jbuild-ignore should only refer to directories in the current directory
(unlike .gitignore): referring to subdirectories doesn't work.

Signed-off-by: David Allsopp <david.allsopp@metastack.com>
2018-01-23 09:14:22 +00:00
Jérémie Dimino 9dd5ab74e4
[WIP] Load rules lazily (#370)
* Change jbuilder to load rules lazily

Rules are now loaded on a per directory basis as needed. This speed up
the start up time on large workspaces.

Does various refactoring as well.

* Simplify the handling of META files

We no longer generate a META.foo.from-jbuilder file. Nobody is using
this feature and it's making the new code more complicated.
2018-01-19 08:50:06 +00:00
Rudi Grinberg 1a8c328b2d Make is_directory work when dir doesn't exist 2018-01-01 21:48:25 +08:00
Jeremie Dimino 3e13492b7a Get rid of Alias.tree 2017-10-14 10:37:36 +08:00
Jeremie Dimino 7a5698c7b1 Interpret jbuild-ignore files sooner
Interpret then while loading the file tree.
2017-10-14 10:37:36 +08:00
Jeremie Dimino c6dac87ee9 Ignore all directories starting with '.' pr '_' 2017-05-19 12:36:06 +01:00
Rudi Grinberg 5adfe2d668 Ignore local switch directory (#77)
This makes jbuilder usable for building projects that use a local switch
2017-05-15 10:30:02 +01:00
Jeremie Dimino 0dd24399ca Ignore opam files in ignored sub-trees 2017-03-15 11:41:44 +00:00
Jeremie Dimino e7b543e7cb Don't scan the tree a second time for files_recursively_in 2017-03-15 09:10:22 +00:00
Jeremie Dimino 3aef1d6f3c Revert "Rename _build to _jbuild (#13)"
This reverts commit 89c15ca2c5.

Keep _build as the build directory until we get a better consensus.
2017-03-01 16:09:02 +00:00
Rudi Grinberg 89c15ca2c5 Rename _build to _jbuild (#13)
_build is already quite overloaded.
2017-03-01 13:37:05 +00:00
Jeremie Dimino fe929a07d7 Don't require packages to be defined at the root
To match the manual
2017-02-23 15:59:44 +00:00
Jeremie Dimino 9e4a83bf48 add support for c_library_flags 2017-01-06 17:18:36 +00:00
Jeremie Dimino 614dbc6f6b Setup copy rules for all source files
This is cleaner and allow dependencies on files that do not
appear in static deps or targets.

With this patch, one can now build all JS packages at once.
2016-12-31 15:12:39 +00:00