Commit Graph

142 Commits

Author SHA1 Message Date
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
Jérémie Dimino 1860438605
Add a jbuilder transition package (#796)
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-05-28 18:19:30 +01:00
Rudi Grinberg d600db2158 Change Build_job to be set
The elements are unique and the order isn't well defined anyway

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-05-24 10:44:47 +07: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 4d8ca489be
Add support for environment & build profiles (#419) 2018-05-04 16:49:25 +01:00
Jeremie Dimino dc0a6d4401 Rename all jbuild files 2018-05-04 12:26:26 +01:00
Rudi Grinberg 25c34c222c Remove all hard coded uses of "_build"
Always route these cases through Path.build_dir
2018-05-02 22:38:50 +07:00
Jérémie Dimino 325584adfc
Renaming to Dune (#721)
- install two identical binaries: jbuilder and dune
- rename the man pages to dune-*
- change the name in man pages
- change the name of libraries
- add support for dune-project files and add a dune-project file
- add support for dune-workspace files
- start updating the manual
- update the tests
2018-05-02 12:56:12 +01:00
Jérémie Dimino 53202d0a09
Make -j default to the number of CPUs (#726) 2018-04-26 16:10:14 +01:00
Rudi Grinberg f44b8bdb1b Unhardcode _build dir everywhere 2018-04-25 18:22:48 +07:00
Rudi Grinberg b02c61f63c Change the prog arg in Process to Path.t 2018-04-25 16:30:18 +07:00
Rudi Grinberg 7820e29d28 Port Io to use Path.t 2018-04-25 03:25:27 +07:00
Jérémie Dimino 239ff0054e
Remove jbuilder_ prefix for vendored libraries (#720)
It's not useful since we are not installing them. Also unwrap
libraries that are unwrapped upstream.
2018-04-24 14:38:30 +01: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 294d693749 Do not load the user configuration file when INSIDE_DUNE is set 2018-04-12 12:43:14 +01:00
Jeremie Dimino 22b024a977 More hacks for external-lib-deps
Fix #644
2018-04-09 06:31:52 +08:00
Jeremie Dimino a1812fccd5 Add INSIDE_DUNE to detect when we are running from unside Dune
And use the following defaults: -j 1 --root . --display quiet
2018-04-03 11:43:07 +08:00
Jeremie Dimino 31858c9680 Don't on side-effects for setting up the environment
Instead of making sure we set global variables and call Unix.putenv in
the right order, pass the environment explicitely everywhere.
2018-04-03 11:43:07 +08:00
Rudi Grinberg 2634477def Change Action to include the context's exec env 2018-03-16 00:44:23 +08:00
Rudi Grinberg bd457ea549 Use Env.t over string array in another place 2018-03-15 18:24:41 +08:00
Rudi Grinberg 7c287a5e0a Change Package.Name.t to interned type 2018-03-03 20:41:29 +07:00
Rudi Grinberg ff05369868 Introduce package name private type 2018-03-03 01:44:03 +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
Christophe Troestler fbafb3d47a Make Atom.t private and consequences (#524) 2018-02-24 23:33:26 +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 5669f57907
Fix display when output is not a tty (#518) 2018-02-15 14:04:00 +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
Jeremie Dimino b46cef533a Make Findlib.package abstract 2018-02-07 18:10:05 +00:00
Jeremie Dimino f949588742 Actions printed by "jbuilder rules" are now using relative paths
This seems more natural
2018-02-07 18:10:05 +00:00
Jeremie Dimino fae08c79be Allow to set the concurrency level from the config file 2018-02-07 12:11:27 +00:00
Jérémie Dimino 0570e09f9a
Add a configuration file and a quiet mode (#490) 2018-02-07 11:38:21 +00: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 e61142e885
Merge pull request #460 from ocaml/fix-promote-tests-on-osx
Fix bad interaction between promotion and incremental builds on OSX
2018-02-01 20:15:18 +08:00
Jeremie Dimino b9c4dd2339 Remove files from the digest cache when promoting them.
This is to avoid problems with incremental compilation on OSX.

Fix #456
2018-02-01 08:23:25 +00:00
Rudi Grinberg 56c6f3bee7 Make target_hint not fail when target is Path.root
fix #468
2018-02-01 16:22:11 +08:00
Jérémie Dimino 437211f74f
Expose the promote mode (#437) 2018-01-25 19:07:46 +00:00
Rudi Grinberg 58f9e9840c Replace janestreet/jbuilder with ocaml/dune
Update all links where necessary
2018-01-23 17:52:44 +08: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 b06aad431e
Replace promote actions by diff actions + promote command (#421)
* Remove (promote ...) and (promote-if ...)
* Remove `--promote ...`
* Add (diff ...) and (diff? ...)
* Add `jbuilder promote` and `--auto-promote`
* Fix #423
2018-01-18 11:32:20 +00:00
Jeremie Dimino d4dec9b4f5 Change the default of --promote from check to copy
As said in the PR. I forgot to push the commit.
2018-01-15 14:55:17 +00:00
Jérémie Dimino eab1ff6c7b
Add promote actions and include stanzas (#402)
Add a promote action that allows to copy over generated files as
source files and an include stanza allowing to include a file in a
jbuild file.
2018-01-15 13:24:25 +00:00
Jeremie Dimino 6e64156913 Add target support
* Create targets from findlib toolchains by reading findlib configs
* Define targets inside workspace files
* Set cross compilation targets with -x argument
2018-01-01 22:34:41 +08:00
Rudi Grinberg 058643608c
Jbuilder exec rebuilt if possible option (#345)
Make jbuilder exec build its target

Jbuilder will now attempt to rebuild the target before executing it. This option can be turned off by passing in --no-build
2017-12-11 18:23:07 +08:00
François Bobot 13fed1f1ce
Merge pull request #339 from rgrinberg/fix-jbuilder-exec-utop
Fix jbuilder exec from sub dirs & utop
2017-12-01 13:41:21 +01:00
Rudi Grinberg 785beeafac
Add option to force running tests (#320)
Option to force running tests

The mechanism allows for forcing any alias, but only forcing tests is exposed to the user. Aliases are forced by deleting all the alias files that belong to a particular alias. The option for forcing tests is called --force.
2017-11-28 19:03:22 +08:00
Jeremie Dimino ce0ecaf9e0 Restore cwd before execve 2017-11-25 23:25:13 +08:00
Rudi Grinberg 0c2228e7bc
Refactor jbuilder exec path handling (#327)
There's no need for runcwd as initial_cwd is already defined somewhere. Add
Filename.analyze_program_name function to make the clearer.
2017-11-14 15:19:58 +08:00
Rudi Grinberg 9c8ecc9fbc
Improve jbuilder exec (#286)
* Improve jbuilder exec

When the path passed contianed to exec contains a '/', it will be interpreted
relative to the path of a build context (default context when absent)

* Update man page of jbuilder exec

* Add String.drop_prefix

* Make jbuilder exec understand relative/absolute paths

jbuilder exec will now interpret absolute paths as relative to the specified
build context. While relative paths will now be intepreted relative to the cwd
appended to the specified build context.

* Fix jbuilder exec /absolute/path

When the path provided to jbuilder exec is absolute, we should ignore the build
context for looking up the binary.

* Fix exec when ran outside of root

Previously, a call like $ jbuilder exec ./xxx --root=p would raise
an exception. Now ./xxx will be intepreterd relative to --root.

* Fix relative paths when jbuilder is ran outside of --root

* Simplify documentation for jbuilder exec
2017-11-07 21:41:09 +08:00
Rudi Grinberg e23f6fe8bb Use Alias.of_path over Path operations and Alias.make 2017-10-19 08:35:08 +08:00