Commit Graph

124 Commits

Author SHA1 Message Date
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
Jeremie Dimino 30a914278e All aliases on the command line are recursive
Calling 'jbuilder build @path/x' always request the alias `x` in
`path` and all its descendant.

To implement that, change the build system interface to take an
arbitrary request as argument.
2017-10-14 10:37:36 +08:00
David Allsopp 0e46cdd4e3 Clflags.workspace_root needs to be absolute
Since the fix for #262 in 3fb19150 it is necessary for workspace_root to
be absolute. In particular, `jbuilder build -p foo` (which implies
`--root=.`) needs to evaluate what that root is.
2017-09-29 14:14:21 +01:00
Daniel Hillerström 267ea46c4d Fixed a typo in the documentation. 2017-08-06 11:04:57 +01:00
Rudi Grinberg b668d9189f Add a utop subcommand (#183)
Add a utop subcommand that build and execute a utop where all the libraries defined in the current directory are immediately available for interactive use.
2017-08-04 08:59:35 +01:00
Jeremie Dimino 2f801cf17f typo 2017-07-27 12:08:19 +01:00
Jeremie Dimino b1e140eef3 Add --destdir + document --destdir, --prefix and --libdir
Should help #202
2017-07-27 12:06:14 +01:00
Jeremie Dimino cfd43d5282 Simplify a bit the rules for installation of library files 2017-07-25 17:07:24 +01:00
François Bobot 747cf220c6 Install by specifying libdir for opam-installer
- change default findlib directory (ocamlc -where)
2017-07-25 16:44:14 +01:00
Jeremie Dimino 241f1204cb Really fix #137 2017-06-09 15:18:27 +01:00
Jeremie Dimino fff5763a53 Fix #137: fix hint when all missing libs are optional 2017-06-09 14:49:08 +01:00
Jeremie Dimino b74544919a jbuild_types.ml --> jbuild.ml 2017-06-02 14:32:05 +01:00
Anton Bachin e3d879dbd8 Fix some typos in command option docs (#117) 2017-06-02 10:51:32 +01:00
Jeremie Dimino 543354c070 Fix #115 2017-06-01 16:34:04 +01:00
Jeremie Dimino f210b32fd0 Improve the behavior of "jbuilder exec" on Windows 2017-05-31 14:41:45 +01:00
Jeremie Dimino f18afbf8aa Fix jbuilder exec for windows 2017-05-31 11:28:39 +01:00
Jeremie Dimino 65150b4166 Add -debug-backtrace 2017-05-29 14:18:07 +01:00
Jeremie Dimino c73b1f1fe3 Add a --no-buffer option
Following #107
2017-05-29 10:57:04 +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