Commit Graph

65 Commits

Author SHA1 Message Date
Rudi Grinberg 530dbfeb81 Move String_set to stdune 2018-04-23 12:08:09 +07:00
Rudi Grinberg 9acf617563 Remove ~has_dot_merlin flag
it was introduced to avoid generaitng a needless .merlin file for utop levels.
But now that we have a better mechanism for that, it serves no purpose.
2018-04-10 02:01:33 +07:00
Jeremie Dimino 22b024a977 More hacks for external-lib-deps
Fix #644
2018-04-09 06:31:52 +08:00
Jeremie Dimino 0104309f25 Use Arg_spec.Hidden_deps 2018-04-09 06:31:52 +08:00
Jeremie Dimino 606ad1b10f Pass around library dependencies as static values
This way we know more of the compilation DAG statically. This helps
for parallelism as well as for `jbuilder external-lib-deps`
2018-04-09 06:31:52 +08:00
Jeremie Dimino 9b1adee13c Record library dependencies using Build.prefix_rules 2018-04-09 05:59:12 +08:00
Jeremie Dimino 950a37b1ad Generate select rules explicitely in gen_rules 2018-04-09 05:59:12 +08:00
Jeremie Dimino 75269117cd Use static requires in merlin 2018-04-09 05:59:12 +08:00
Jeremie Dimino b5fad14f16 Less Path.Set.t -> Path.t list conversions 2018-03-19 01:19:41 +08:00
Jeremie Dimino 9043280160 Allow dynamic dependencies for aliases 2018-03-19 01:19:20 +08:00
Jeremie Dimino a55cde2969 fix 2018-03-19 01:19:09 +08:00
Jeremie Dimino 73873b31bc Recursive package deps 2018-03-19 01:18:55 +08:00
Rudi Grinberg 9b5ac4060f Add a map from package names to libraries to super context
Will be used for odoc and installation
2018-03-16 13:49:33 +08:00
Rudi Grinberg a62e92a0ee Move they '@' scope encoding to common module
This encoding will also be used by odoc so it's best to share it
2018-03-15 14:50:34 +08:00
Rudi Grinberg ff05369868 Introduce package name private type 2018-03-03 01:44:03 +07:00
Jérémie Dimino 45535f7afd
Extracted SC.PP as Preprocessing (#560) 2018-02-28 12:26:34 +00:00
Rudi Grinberg d01a684f71 Move SC.Doc to Odoc module
It longer has a rason to exist in super context.
2018-02-28 17:24:37 +07: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
Rudi Grinberg 31ea39949b Make prefix_rules accessible through Super_context 2018-02-26 15:54:15 +07:00
Jérémie Dimino 19f1c6f6b3
Add an Exe module to build and link executables (#533) 2018-02-20 16:38:22 +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
Rudi Grinberg fd6e8ad91f Remove {anonymous,external}_scope from Super_context
These were re-exported to avoid access libs directly, but there's already an
accessor to do that, so these functions weren't used consistently anyway.
2018-02-10 00:15:26 +08:00
Jérémie Dimino 4e4f651b37
Don't stop on the first error (#477)
Before, jbuilder used to stop its execution after an error was
encountered. Now it continues until all branches have been explored.

To implement this feature, Future was rewritten as a Fiber module with
a simpler semantic.

This patch contains various other refactorings.
2018-02-06 14:39:03 +00:00
Rudi Grinberg a29f144bc1 Use correct scopes for generating ppx preprocessors
Use the intenral scope whenever there's an internal lib in the preprocessors.
Otherwise use the external scope.
2018-01-31 00:48:58 +08:00
Rudi Grinberg 672120b3b8 Introduce explicit scopes for Lib_db
This commit introduces explicit scopes in Lib_db and refactors dune to use these
scopes where appropriate. Briefly, they are appropriate whenever we previously
used a directory to resolve the scope with Lib_db.find ~dir and friends. So a
Lib_db.Scope.t replaces a (dir, Lib_db.t) pair.

This allows to be explicit about the anonymous and external scope. Which is
important when building ppx drivers.

We also harmonize the error handling with the Findlib module. In both cases
we use a flat string list of errors. Rather than the more specific type we had
before in Findlib.
2018-01-30 19:21:40 +08:00
Jérémie Dimino c066efd196
Add the transitive dependencies of used ppx rewriters (#450) 2018-01-25 11:22:50 +00:00
Jérémie Dimino ba5ffbc414
Fix meta generation for ppx runtime deps (#441)
Use the transitive closure for the deprecated ppx method
2018-01-23 16:03:59 +00:00
Rudi Grinberg 6cce747141 Make odoc work with multiple libraries defined in the same dir 2018-01-23 02:56:23 +08:00
Jérémie Dimino 5651eb80b5
Better behavior when aliases have targets (#426)
Ignore the targets and report a warning.
2018-01-19 22:17:11 +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
Jérémie Dimino e28344a24b
Do not use the transitive closure in generated META files (#405) 2018-01-12 16:41:23 +00:00
Rudi Grinberg 1fc0ef0ab1 Add lint rules 2018-01-10 22:45:50 +08:00
Rudi Grinberg 1ff8a7989c Cross compilation support
In a host/target setup, all binaries that are built (including preprocessors)
are ran using the host *for* building targets. Final target artifacts are
compiled using the target toolchain
2018-01-01 22:34:41 +08:00
Jeremie Dimino 18d8cb847d Fix the test added in the previous commit 2017-12-18 13:30:49 +00:00
Rudi Grinberg a57c488dd7
Fix jbuilder rule in case of missing binaries (#292)
Make jbuilder rules work even when binaries are missing

* Proper error messages for missing binaries

* Unify Prog_spec and Maybe_prog

both can simply be unified into a path type that has a hint for the error

* Remove scarcely useful in_the_tree parameter

It's always true except for the C compiler. In which case, there's no harm in
making it true.

* Make Artifacts return Action.Prog

The old return value was simply converted to this anyway. It's simpler to just
return the proper error straight up.

* Remove remains of in_the_tree
2017-11-07 21:42:55 +08:00
Jeremie Dimino 5de73ca740 Add support for locks in rules
This is to allow users define more complicated tests without having
to resort to -j1.
2017-09-29 12:20:08 +01:00
Jeremie Dimino b965c66af5 Avoid generating useless .utop/.merlin files 2017-09-22 02:16:26 +01:00
Jérémie Dimino 6bed864057 Better behavior when the targets of a rule already exist in the source tree (#218)
Warn when a file is both present in the source tree and generated by
a rule. Before, jbuilder would silently ignore the rule. One now has
to add a field `(fallback)` to custom rules to keep the current
behavior.
2017-08-15 11:16:11 +01:00
David Allsopp 3a64432d04 Expand variables in flags
Extend Ordered_set_lang.Unexpanded.expand to include a mapping function
for the S-expression for each atom. The previous behaviour can be
achieved with ~f:Sexp.Of_sexp.string, but this allows the S-expression
to be parsed using String_with_vars.t, thus allowing variable expansion.
2017-08-03 17:28:32 +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
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
François Bobot 52afe84c83 Fix some warning 50 for 4.02.3 (#161)
Warning 50: unattached documentation comment (ignored)
2017-06-26 10:28:37 +01:00
Jeremie Dimino daeb40b087 Add SCOPE_ROOT
While analysing packages using jbuilder, I found that some packages
use ${ROOT} to refer to the root of the project. However, this doesn't
work as ${ROOT} depends on the workspace configuration.

Add ${SCOPE_ROOT} to make this easier for projects with a lot of
nested sub-directories.
2017-06-09 12:45:05 +01:00
Jeremie Dimino 11985e3948 Update the code to talk about scopes 2017-06-05 13:42:13 +01:00
Jeremie Dimino b74544919a jbuild_types.ml --> jbuild.ml 2017-06-02 14:32:05 +01:00
Jeremie Dimino 5e06daa5b2 Rename (do ...) to (rule ...) 2017-06-01 16:53:55 +01:00
Jeremie Dimino 373e6c2524 Allow ${...:...} for in (do ...) and add more checks
Check that targets written by the user are a superset of inferred
targets.
2017-05-31 10:15:32 +01:00
Jeremie Dimino 116769724f Allow to use ${^} in actions in conjunction with (glob_files ...) and (file_recursively_in ...) 2017-05-29 18:53:54 +01:00
Jérémie Dimino 1e41feaf8a Add simplified version of rules 2017-05-29 07:51:52 +01:00
Jérémie Dimino 73a4cef9f8 Move the context out of Action.t
And add it to the rule. It is never dynamic, so it is simpler this
way, we just set it in Super_context.add_rule.
2017-05-29 07:51:52 +01:00