Commit Graph

863 Commits

Author SHA1 Message Date
Rudi Grinberg 5a5ba64503 Fix 4.02.3 compat in usexp
Do not use Char.equal
2018-03-17 14:23:43 +00:00
Rudi Grinberg f39b302a8d Fix Atom definition of Usexp
Fix the is_valid function to only validate atoms that don't contain spaces,
parens, comment characters.
2018-03-17 14:23:43 +00: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
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
Rudi Grinberg 07385a15ed Remove double extending the env with context's env 2018-03-16 01:45:52 +08:00
Rudi Grinberg 68cf393c5f Use Bin.path_sep 2018-03-16 01:45:39 +08:00
Rudi Grinberg 2634477def Change Action to include the context's exec env 2018-03-16 00:44:23 +08:00
Rudi Grinberg 3c7e6adc73
Merge pull request #619 from rgrinberg/install-run-fixes
Tweaks to Actions
2018-03-15 19:10:13 +08:00
Rudi Grinberg db55b4e880
Merge pull request #618 from rgrinberg/scope-encode
Move they '@' scope encoding to common module
2018-03-15 19:09:56 +08:00
Rudi Grinberg 9a1910cf6f Add context for alias actions 2018-03-15 18:25:21 +08:00
Rudi Grinberg bd457ea549 Use Env.t over string array in another place 2018-03-15 18:24:41 +08:00
Rudi Grinberg dea2ac77ca No optional args for context 2018-03-15 18:24:36 +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 25158fc702 Share Ordered_set_lang.Make(String)(String) 2018-03-15 14:25:04 +08:00
Rudi Grinberg 286f93a963 indentation 2018-03-15 14:24:55 +08:00
Jeremie Dimino 3b1bef8b9c ocamlX_flags --> ocamlX_cflags 2018-03-14 12:02:56 +00:00
Rudi Grinberg 521a36dcef
Merge pull request #603 from diml/universe
Allow to depend on the universe
2018-03-14 13:02:23 +07:00
Rudi Grinberg 28208a1c12
Merge pull request #612 from rgrinberg/rename-result-private-lib
Rename the result private library
2018-03-14 12:59:36 +07:00
Rudi Grinberg 48ca91e013 Move the results lib into Caml
The result name is taken by other libs hence it breaks `jbuilder utop`. Hence we
simply move it our stdlib overlay. The -open flag is used to avoid having to
modify vendored code.
2018-03-14 12:09:20 +08:00
Jeremie Dimino 6fc1e0659a Workaround non-precise mtime on OSX 2018-03-13 19:15:06 +00:00
Jeremie Dimino e2adf9d44a Allow to depend on the universe
Fix #255
2018-03-13 19:12:57 +00:00
Jérémie Dimino 8e4c9fce4c
Import the Sexp parser generator (#608) 2018-03-13 19:06:34 +00:00
Rudi Grinberg d6a6a817f7 Move Io to stdune
This allows configurator to drop the dependency on jbuilder itself
2018-03-13 20:27:07 +07:00
Rudi Grinberg 12511a68ea
Merge pull request #607 from rgrinberg/private-public-overlap-take2
Disallow public/private overlap
2018-03-13 03:39:55 +07:00
Jérémie Dimino ca5c383b3b
Fix locations reported by the parser (#609)
The start position of atoms wasn't saved by the parser.
2018-03-12 18:41:49 +00: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
Rudi Grinberg 2f7db648ed
Merge pull request #601 from rgrinberg/env-context
Move env var handling outside of Context.t
2018-03-12 19:13:33 +07:00
Jeremie Dimino f74817e00d Fill the loc field of rules 2018-03-12 12:02:55 +00:00
Jeremie Dimino eef3633d9a Tweak error messages 2018-03-12 18:45:47 +07:00
Rudi Grinberg 4a68db622d Change representation to map from assoc list 2018-03-12 18:45:47 +07:00
Rudi Grinberg 161be3af1c Stage Var.compare 2018-03-12 18:45:47 +07:00
Rudi Grinberg 1f99d0fb70 Simplify Env.get
we already have Var.equal now
2018-03-12 18:45:47 +07:00
Rudi Grinberg f4955cdc22 Remove env_extra from Context.t
Rely on diffing
2018-03-12 18:45:47 +07:00
Rudi Grinberg 79d47ab68e Simplify Env.t
Use assoc list
2018-03-12 18:45:47 +07:00
Rudi Grinberg 26d6b03c66 Make unix representation more efficient
By not allocation a closure on every update
2018-03-12 18:45:47 +07:00
Rudi Grinberg e604c69510 Remove env_extra in Action
It's simply to just use Env.t everywhere. Also, there's no need to have the env
in the execution context since it's not used for anything. Only the env that is
passed directly is used.
2018-03-12 18:45:47 +07:00
Rudi Grinberg f1baaa23a8 Add Env.add
Just add 1 binding to Env
2018-03-12 18:45:47 +07:00
Rudi Grinberg 3193e4902d Make Process.run take Env.t directly 2018-03-12 18:45:47 +07:00
Rudi Grinberg 4b191b2b03 s/Env.get_var/Env.get/ 2018-03-12 18:45:47 +07:00
Rudi Grinberg 206cc69fd9 Simplify Context.create
There's no need for a base_env parameter as it's always Env.initial
2018-03-12 18:45:47 +07:00
Rudi Grinberg 35d4153641 Make Env.t abstract 2018-03-12 18:43:02 +07:00
Rudi Grinberg 8458bf3b15 Move env related functions to Env module 2018-03-12 18:43:02 +07:00
François Bobot feba0827b8 Allow to link executables as static or shared objects (#23)
- Setup the rules to use the `-output-complete-obj` option of OCaml
- Introduce a `best` mode in addition to `byte` and `native`
- Extend the `modes` field of executables to mean "linking modes", and add linking modes for static and shared objects
2018-03-12 11:40:53 +00:00
Jeremie Dimino 5286b42f58 Fix #597 2018-03-10 08:25:45 +07:00
Jeremie Dimino b219f28a8a Format fix 2018-03-09 20:43:57 +00:00
Jérémie Dimino 1feab6b2a6
Allow to specify additional libraries for the test runner (#600) 2018-03-09 19:51:02 +00:00
David Allsopp b604871aab Limit number of simultaneously opened fds (#578)
Non-optimal solution: only handles the common case.
2018-03-08 18:28:14 +00:00
Jérémie Dimino b029d32dfb
fix String_with_vars.sexp_of_t (#595) 2018-03-07 15:01:46 +00:00
Jeremie Dimino 0f0b154de6 Remove ranlib, doesn't seem to be available on Windows 2018-03-07 09:40:08 +00:00
Jeremie Dimino 98bb8adf83 fix 2018-03-07 09:40:08 +00:00
Jeremie Dimino cc845e5fdb Make all variables accessible in jbuild files 2018-03-07 09:40:08 +00:00
Jeremie Dimino 21a980a5d1 Update configurator 2018-03-07 09:40:08 +00:00
Jeremie Dimino 6ee6ed35d2 Ocamlc_config --> Ocaml_config 2018-03-07 09:40:08 +00:00
Jeremie Dimino 3bc21617b2 Refactor ocamlc_config 2018-03-07 09:40:08 +00:00
Jeremie Dimino 0b6a7eee2f Recent versions of ocaml expose 'ext_exe' 2018-03-07 09:40:08 +00:00
Jeremie Dimino 9c178480ea Update configurator 2018-03-07 09:40:08 +00:00
Jeremie Dimino d415ed5f6c Expose a few more variables 2018-03-07 09:40:08 +00:00
Jeremie Dimino 1ff05d52e2 Refactor a bit the variables in super_context.ml 2018-03-07 09:40:08 +00:00
Jeremie Dimino a95fd29dba Move Ocamlc_config to its own library and refactor it a bit 2018-03-07 09:40:08 +00:00
Jérémie Dimino dfdb6c09f4
Allow to set the library path at configure time (#575)
This allow to drop the dependency on ocamlfind
2018-03-06 14:56:24 +00:00
Jeremie Dimino 232acdd92f Libraries and executables can allow overlapping dependencies 2018-03-06 12:59:01 +00:00
Jeremie Dimino a5f9a9e063 Detect overlapping libraries 2018-03-06 12:59:01 +00:00
Rudi Grinberg c8355b454c Generalize Ordered_set_lang to return a custom map
This simplifes all the conversion from and to Module.Name.Map.t
2018-03-06 18:45:38 +07:00
Rudi Grinberg ddefafa58b Introduce private type for module name 2018-03-06 18:45:38 +07:00
Jeremie Dimino 6eace337bc typo 2018-03-05 18:06:41 +00:00
Jérémie Dimino cd6812f269
Accept and ignore ppx.driver fields (#588) 2018-03-05 17:59:56 +00:00
Jérémie Dimino 4857ed444a
Reduce interleaving in the scheduler (#586) 2018-03-05 17:52:21 +00:00
Rudi Grinberg 5ded45faf0
Merge pull request #584 from rgrinberg/improve-error-modules
Improve error in modules partition
2018-03-05 23:47:19 +07:00
Jeremie Dimino 348d2b1a1e display tweaks 2018-03-05 16:24:24 +00:00
Rudi Grinberg 719cf5eea0 Improve error in modules partition
Specify how to fix the error (by writing modules fields)
2018-03-05 23:11:45 +07:00
Jeremie Dimino 3edc029bf4 ws 2018-03-05 15:05:24 +00:00
Rudi Grinberg 75fe147da9
Merge pull request #577 from rgrinberg/menhir-own-module
Move menhir rules to own module
2018-03-05 21:30:17 +07:00
Jeremie Dimino a1beb25d12 Add a bit more doc to Build 2018-03-05 14:14:09 +00:00
Jeremie Dimino 1a4362b0b1 Document Arg_spec a bit more 2018-03-05 14:00:29 +00:00
Jeremie Dimino 4c2768e805 style + doc 2018-03-05 14:00:21 +00:00
Rudi Grinberg 6d5c2de689 Change menhir flags to use ordered set language
Consistent with how flags are handled elsewhere in jbuilder
2018-03-05 20:03:16 +07:00
Rudi Grinberg f06519e231 Implement menhir rules from scrath
Rather than changing them to user_rules and then compiling those.
2018-03-05 19:56:27 +07:00
Rudi Grinberg 288de19920 Move menhir rules to own module 2018-03-05 18:32:25 +07:00
Rudi Grinberg 09aa2cd1cf
Merge pull request #574 from diml/workaround-broken-builtins
Add a simple workaround for #563
2018-03-05 16:34:34 +07:00
Rudi Grinberg 7c287a5e0a Change Package.Name.t to interned type 2018-03-03 20:41:29 +07:00
Jeremie Dimino d1feb062b6 Add a workaround for broken META file for builtin packages
Fixes #563
2018-03-03 11:33:40 +00:00
Rudi Grinberg ff05369868 Introduce package name private type 2018-03-03 01:44:03 +07:00
Rudi Grinberg e4aac2da97 Improve error message for missing scopes 2018-03-02 15:55:48 +07:00
Jeremie Dimino de99d84f73 Ignore errors while generating the .merlin file
Fix #568
Fix #51
2018-03-01 23:34:43 +00:00
Jeremie Dimino 1b279f30bf Make Merlin.t abstract 2018-03-01 23:30:06 +00:00
Jeremie Dimino 39ac04a535 Add Build.catch 2018-03-01 23:30:06 +00:00
Jeremie Dimino 2e7f881d4c Fix #567
The alias module needs an implementation for non-jbuilder users.
2018-03-01 20:47:08 +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
Rudi Grinberg 66a907be58
Merge pull request #467 from ocaml/import-configurator
Import configurator
2018-03-01 12:28:32 +07: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
Rudi Grinberg 3e73397638 Port configurator to dune 2018-02-28 23:37:20 +07:00
Rudi Grinberg 9b6abc4014 Initial import of configurator
This is the original source imported
2018-02-28 23:36:35 +07:00
Rudi Grinberg 070fd95cac Add configurator build
For now the library is private
2018-02-28 23:33:16 +07:00
Jérémie Dimino 55675598c4 Extend ocamlc_config for configurator
* Add make to create ocamlc_config.t
* Add function to get bindings
2018-02-28 23:32:24 +07:00
Rudi Grinberg 9a6d9a3aa9 Extend stdlib for configurator 2018-02-28 23:31:24 +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
Rudi Grinberg 02c5b005dd Move intallation and META rules to install_rules module 2018-02-28 12:21:25 +07:00
Rudi Grinberg 5ecf354127 Add a sub-system for inline tests (#547)
To support frameworks such as ppx_inline_test, ppx_expect and qtest
2018-02-27 19:06:12 +00:00
Xavier Clerc c324736d11 Support upcoming ppxlib (was "ppx_base") (#554) 2018-02-27 12:56:47 +00:00
Jeremie Dimino 4dc8d2456f Pass obj_dir explicitely to Exe.build_and_link and don't return it
The only place where we used the default value was gen_rules
2018-02-26 16:05:48 +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
Rudi Grinberg 95c254a6a0 Revert "Add support for upcoming ppx_base. (#541)"
This reverts commit 032cb62af6.
2018-02-26 21:07:02 +07:00
Rudi Grinberg 31ea39949b Make prefix_rules accessible through Super_context 2018-02-26 15:54:15 +07:00
Jérémie Dimino 0c30689404 Make Ocamldep.rules already_used arg optional
String_set.empty is a good default value
2018-02-26 15:53:19 +07:00
Jérémie Dimino 6e7d297ea3 Introduce short syntax for sexps 2018-02-26 15:53:19 +07:00
Jérémie Dimino 5a73753095 Extend interned module with a Table type 2018-02-26 15:53:19 +07:00
Jérémie Dimino 9943acb4dc Add utility functions to result
all and concat_map
2018-02-26 15:53:19 +07:00
Jérémie Dimino e77bd30681 prefix_rules should append rather than overwrite the prefix 2018-02-26 15:53:19 +07:00
Rudi Grinberg 3fd3d5b44c Don't pass lib_name if lib is already passed
We can easily get the library name
2018-02-26 14:55:40 +07:00
Rudi Grinberg 290bcceb17 s/capitalize_ascii/capitalize/ 2018-02-26 01:39:16 +07:00
Rudi Grinberg 1cb005bb50 Add a way to customize obj dir for executables
Use this function to simplify the obj dir for the utop runner
2018-02-26 01:30:02 +07:00
Rudi Grinberg b4e0c04368 Revert "Use _utop.ml to avoid creating a separate dir for utop rules"
This reverts commit 9ec894eda0.
2018-02-26 01:30:02 +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
Jérémie Dimino 4cf7dc558b
Fix generation of the alias module with 4.02 (#549) 2018-02-25 12:58:40 +00:00
Christophe Troestler fbafb3d47a Make Atom.t private and consequences (#524) 2018-02-24 23:33:26 +00:00
Jérémie Dimino 361773fdb6 Remove gen_dot_merlin flag
It's no longer necessary after switching to the new Exe api. The new API will
not generate a .merlin file for utop.
2018-02-24 18:25:14 +07:00
Rudi Grinberg 4c9da64290
Merge pull request #537 from rgrinberg/use-fake-module-name
Use .utop.ml to avoid creating a separate dir for utop rules
2018-02-23 12:10:28 +07:00
Xavier Clerc 032cb62af6 Add support for upcoming ppx_base. (#541) 2018-02-22 20:38:27 +00:00
Rudi Grinberg 9ec894eda0 Use _utop.ml to avoid creating a separate dir for utop rules 2018-02-22 17:34:39 +07:00
Jeremie Dimino 41b5017eb2 Fix #534 2018-02-21 13:35:47 +00:00
Rudi Grinberg 80ed205e38 Refactor utop module to use the new exe module 2018-02-21 16:44:31 +07:00
Jeremie Dimino db345be90b Trivial fix 2018-02-20 18:55:52 +00:00
Jérémie Dimino 2a531c5d24
Detect when a module is used by several stanzas (#532)
- print a warning
- don't generate several rules for the .d files
- Added tests for multiple rules for .ml.d
2018-02-20 16:44:25 +00:00
Jérémie Dimino 19f1c6f6b3
Add an Exe module to build and link executables (#533) 2018-02-20 16:38:22 +00:00
Rudi Grinberg d8e4145dba Warn instead of error on harmless fake modules
E.g. (modules (:standard \ does_not_exist)) is harmless
2018-02-20 20:23:28 +07: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
Jeremie Dimino 26dc6d2b13 Share some computations on pps when preprocessing modules 2018-02-19 16:04:47 +00:00
Rudi Grinberg a6e6136f3a
Merge pull request #521 from rgrinberg/build-only-public-docs
Change @doc to only build public docs
2018-02-19 19:00:27 +07:00
Rudi Grinberg 55e8dd99e2 Move reading/reading ocamlc -config to own module 2018-02-18 10:14:38 +07:00
Christophe Troestler 75ab3946f6
Distinguish quoted and unquoted variables
Now only quoted strings support concatenation of text and a split-variable.
2018-02-17 23:44:32 +01:00
Rudi Grinberg d28c6e4456 Change @doc to only build public docs
Private docs can still be built using the new @doc-private alias
2018-02-16 16:22:28 +07:00
Jérémie Dimino 5669f57907
Fix display when output is not a tty (#518) 2018-02-15 14:04:00 +00:00
Christophe Troestler 67c9363c7d Use more precise combinators "atom" and "quoted_string" 2018-02-15 00:45:06 +01:00
Christophe Troestler b48a9fec53 Usexp: Properly quote atoms when pretty printing 2018-02-15 00:43:08 +01:00
Christophe Troestler 8e9ec4a52a Do not accept the quoted form "->" in place of -> 2018-02-15 00:43:08 +01:00
Christophe Troestler 0cbd1c7450 Usexp: factorize pp of atoms & fix serialization 2018-02-15 00:43:08 +01:00
Christophe Troestler 453ce1eb56 String_with_vars: Use a functor to create generic expansion fun
This required to remove the labeled ~dir arguments in Action because
one would have had to use the same label for the expansion context in
String_with_vars, which would have been odd for generic expansion
functions.
2018-02-15 00:43:08 +01:00
Christophe Troestler a91cf637ae Trigger an error for unquoted concatenations with list variables
Thus x${v} where v is a variable that returns several values must
necessarily be quoted: "x${v}".
2018-02-15 00:43:08 +01:00
Christophe Troestler 754aa59cc3 String_with_vars: Distinguish quoted and unquoted strings
This implies that an atom can only contain a single variable, such as
${@}, and not something like xxx${@}xxx.  The internal representation
was changed not to be able to represent the latter.
2018-02-15 00:43:08 +01:00
Christophe Troestler cc9c71661e Fix Jérémie Dimino remarks 2018-02-15 00:43:08 +01:00
Christophe Troestler f9e17f76e0 Requires that atoms are unquoted is some contexts 2018-02-15 00:43:08 +01:00
Christophe Troestler 73f529ae82 Rename String to Quoted_string 2018-02-15 00:43:08 +01:00