Commit Graph

60 Commits

Author SHA1 Message Date
Jeremie Dimino 86b130560e Store the project directory in Jbuild.Library.t
There is no risk of confusion about the interpretation of the root
field anymore since it has type Path.Local.t.

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-06-12 12:09:11 +01:00
Jeremie Dimino b35fbbd7b2 Abstract the ppx driver system
- remove hard-coded knowledge of ocaml-migrate-parsetree and ppx_driver
- get the exact driver parameters directly from the driver itself

Signed-off-by: Jeremie Dimino <jdimino@janestreet.com>
2018-06-05 19:19:10 +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
Rudi Grinberg 6b130e809c Move int sets and maps to stdune
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-05-24 18:22:36 +07:00
Jérémie Dimino ac8bffc1f3
Get rid of Jbuild.Scope_info and use Dune_project instead (#776) 2018-05-16 16:21:08 +01:00
Jérémie Dimino 95d9cf0415
Refactor Jbuild.Scope_info.Name and Dune_project.name (#775) 2018-05-15 14:07:02 +01:00
Rudi Grinberg 7820e29d28 Port Io to use Path.t 2018-04-25 03:25:27 +07:00
Rudi Grinberg 24041593da Move Code_error to Stdune.Exn
This exception is useful outside of jbuilder
2018-04-23 14:04:15 +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
Jeremie Dimino 3c7672c696 Report the ppx runtime deps as external dependencies 2018-04-09 06:31:52 +08:00
Jeremie Dimino 22b024a977 More hacks for external-lib-deps
Fix #644
2018-04-09 06:31:52 +08:00
Jeremie Dimino 1215fe2f8a Remove unused Lib.Compile.make 2018-04-09 06:31:52 +08:00
Jeremie Dimino 01fab4c1c3 Add Stdune.Or_exn 2018-03-30 16:55:44 -04:00
Jeremie Dimino bdb03925d1 Add Lib.Compile.compile_and_link_flags 2018-03-18 16:22:56 -04:00
Rudi Grinberg 25d52d1e3a Add Lib.Map 2018-03-18 13:42:01 +08:00
Jérémie Dimino 69c5a4a79d Implement Lib.package
Gets the opam package of a library for a public or installed library
2018-03-16 11:11:48 +08:00
Jérémie Dimino b59dab57da Include the package in the public status of libraries 2018-03-16 11:11:18 +08:00
Jeremie Dimino e57a706960 Use the use-site location for errors from pps 2018-03-12 18:07:05 +00:00
Jeremie Dimino 7e361d596e Let Report_error print the location for Private_deps_not_allowed 2018-03-12 17:58:54 +00:00
Jeremie Dimino 178e26cfd9 Use a more informative name 2018-03-12 17:56:24 +00:00
Jeremie Dimino 69209d7243 Remove extra parentheses 2018-03-12 17:53:00 +00:00
Rudi Grinberg 753badd481 Fix private deps check for ppx runtime dependencies 2018-03-13 00:11:12 +07:00
Rudi Grinberg 0823f9d803 allow_private_deps flag
Flag to guard public dependencies from acquiring private ones
2018-03-12 23:38:48 +07:00
Jeremie Dimino b219f28a8a Format fix 2018-03-09 20:43:57 +00:00
Jeremie Dimino a5f9a9e063 Detect overlapping libraries 2018-03-06 12:59:01 +00:00
Jeremie Dimino 6eace337bc typo 2018-03-05 18:06:41 +00:00
Jeremie Dimino 3edc029bf4 ws 2018-03-05 15:05:24 +00:00
Rudi Grinberg 7790d6bd4c Fix DB.all returning non unique libs (#565)
DB.all will return duplicate libraries in cases when it has 2 names for the same
library. This fix changes all to return a set of values. This is to indicate and
guarantee the uniqueness.
2018-03-01 11:53:27 +00:00
Jeremie Dimino d5ebd0e9be Allow to capture the library a backend is attached to 2018-02-28 19:08:03 +00:00
Jeremie Dimino 17f4567014 Still build a Lib.t value for hidden libraries
This makes everything else simpler
2018-02-28 19:08:03 +00:00
Jérémie Dimino 138c920069 Add support for sub-systems
- Add a Sub_system module that allows to register sub-systems
  that are implemented in a single file
- Add a Syntax module to deal with versioned syntaxes

Other changes:
- Add location to all library dependencies in jbuild files, to report
  properly located errors
- Change the type of functions in Lib to return (_, exn) result
  rather than (_, Lib.Error.t With_required_by.t) result, which was
  hard to use
- Remove With_required_by.t as it was unused
- Rename With_required_by to Dep_path
- Cleanup a bit the Exe module, move a lot of stuff that was specific to
  executable stanzas in gen_rules.ml
- Add String_with_vars.Unexpanded.sexp_of_t
- Rework a bit the code in Lib, in particular factorize the code
  for taking the transitive closure of libraries
- Add an ?extra_vars argument to functions that expand variables
  in Super_context
- Fix the printing of dependency path
- Merge the handling of dependency path between the build system and
  the Lib module
2018-02-26 16:05:48 +00: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
Christophe Troestler fbafb3d47a Make Atom.t private and consequences (#524) 2018-02-24 23:33:26 +00:00
Jeremie Dimino db345be90b Trivial fix 2018-02-20 18:55:52 +00:00
Jérémie Dimino 9e4cc84370
Refactor library management (#516)
Lib module
----------

We have a new module Lib that replaces Lib, parts of Lib_db and parts
of Findlib. It is used to manage all libraries (internal and
extrernal). Lib.t represent a completely resolved library, i.e. where
all the dependencies have been resolved. Lib.Compile is used to
provide what is necessary to build the library itself. Lib.Meta
provides what is necessary to generate the META file for the library.

We also have library databases represented as Lib.DB.t. A library
database is simply a mapping from names to Lib.t values and and
created from a resolve function that looks up a name and return a
Lib.Info.t. A Lib.Info.t is the same as a Lib.t except that
dependencies are not resolved.

A library database can have a parent database that is used to lookup
names that are not found in the current database. In practice we have
the following hierarchy:

1. For every scope, we have a library database that holds all the
   libraries of this scope. In this DB, a library can be referred by
   either it's name or public name

2. the parent of each of these databases is a database that holds all
   the public libraries of the workspace. In this DB libraries must be
   referred by their public name

3. the parent of this DB is for installed libraries

(1) databases are accessible via Scope.libs
    (Super_context.find_scope_by_{name,dir} sctx xxx)
(2) is accessible via Super_context.public_libs sctx
(3) is accessible via Super_context.installed_libs sctx

The dependencies of a library are always resolved inside the DB it is
part of. When we compute a transitive closure, we check that we don't
have two libraries from two different DB with the same name. So for
instance linting Base should now supported.

Jbuild.Scope_info
-----------------

Jbuild.Scope was renamed Jbuild.Scope_info

Scope module
------------

This replaces Lib_db. A Scope.t is now just a pair of a
Jbuild.Scope_info.t and a Lib.DB.t. Scope.DB.t is an object used to
lookup scopes by either name or directory.

We no longer have an external scope or special anonymous
scope. Instead one should use Super_context.installed_libs or
Super_context.public_libs depending on the context.
2018-02-20 11:46:10 +00:00
Jérémie Dimino dfb8afb46e
Compute the transitive closure of findlib packages lazily (#507)
We are now computing the transitive closure of findlib packages
lazily. This simplify the code and prepare for subsequent changes to
library management.

Fix #484 at the same time
2018-02-13 17:49:07 +00:00
Rudi Grinberg 0d62c34e42
Make Lib.t abstract (#498)
* Make Lib.t abstract

This requires removing the external/internal separation in most places in the
source code. Briefly, these are:

* Special casing of external libs for incremental compilation in jsoo
* .merlin generation
* stamp file generation
* transitive closure having a flag for walking external libs
* checking if a lib is a driver (checking various names)

These cases are fixed by introducing an src_dir, obj_dir abstractions, and the
ability to check if a library is local.
2018-02-13 18:36:15 +08:00
Jérémie Dimino 763feda683 Move the addition of <lib>.a dependencies to Lib.archive_files (#493)
Move the addition of <lib>.a dependencies to Lib.archive_files

And refactor a bit the code
2018-02-08 03:21:11 +08:00
Jeremie Dimino b46cef533a Make Findlib.package abstract 2018-02-07 18:10:05 +00:00
Grégoire Henry fda3c7f680 Implement #427 2018-02-07 12:33:52 +00:00
Jérémie Dimino d4c9eb6ba0
Do not pass -I <stdlib-dir> (#488) 2018-02-06 11:49:44 +00:00
Rudi Grinberg 1013db83b5 Add Lib.public_name 2018-01-31 00:48:58 +08:00
Jeremie Dimino 18d8cb847d Fix the test added in the previous commit 2017-12-18 13:30:49 +00:00
Jérémie Dimino c7e67d49b8 Use the full path of archives when linking (#197)
Instead of passing `-I <path> file.cma` to the compiler, pass `-I
<path> <path>/file.cma`.

Fixes #118 and #177. Using the fill path should also be slightly
faster as the compiler won't have to do the lookup through all include
paths. The only drawback is that it makes linking command line
slightly longer.
2017-07-25 14:08:39 +01:00
Jeremie Dimino 4b40cad247 Revert public_interfaces for now
The code to support it is starting to become increasingly complicated
and the number of problem found is a bit alarming.

We'll reinclude it later after a bit more testing and hopefully some
simplifications.
2017-07-21 17:32:39 +01:00
Jeremie Dimino 9893c14500 Fix some problems related to public_interfaces
The dependencies on library artifacts are now properly setup to point
to the files in _build/install/...

Moreorver, private interfaces are now only visible inside the library
itself and are only allowed for private libraries. When a project
defines multiple packages, this ensures that the visibility when all
packages are built simultaneously and when they are installed one by
one.

We can relax these restrictions later with a bit more work and a clear
definition of where private modules should be visible.
2017-07-21 16:52:28 +01:00
Jeremie Dimino 45e04010c5 style 2017-07-19 15:35:05 +01:00
François Bobot a3933a2c18 Add public_interfaces selection for libraries (#106)
Add a field "public_interfaces" to library stanza listing which modules are public.

Private modules won't be accessible outside the scope where the library is defined.
2017-07-19 15:26:48 +01:00
Jeremie Dimino b74544919a jbuild_types.ml --> jbuild.ml 2017-06-02 14:32:05 +01:00