Commit Graph

1274 Commits

Author SHA1 Message Date
Rudi Grinberg 5f783be1b2 Use maps instead of hash tables for variable lookup
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-08 16:33:18 +07:00
Rudi Grinberg 7b05fc34b6 Add String_with_vars.Var.name
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-08 16:33:18 +07:00
Rudi Grinberg 9750f84b76 Remove String_with_var.Loc.fail
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-08 16:33:18 +07:00
Rudi Grinberg 843792ad5d Switch from maps to tables for variables
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-08 16:33:18 +07:00
Rudi Grinberg 43b15bf944 Add Var module to Super_context
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-08 16:33:18 +07:00
Rudi Grinberg 2f86a4d857 Rename the expand family of functions
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-08 16:33:18 +07:00
Rudi Grinberg 73cc3b1e7c Simplify Var.t definition
Remove all gatd's and the extra record type

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-08 16:33:18 +07:00
Rudi Grinberg 972406a0dc Fix static dependencies
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-08 16:33:18 +07:00
Rudi Grinberg 2a71439c3e Toyish gadtization to remove a few assert falses
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-08 16:33:18 +07:00
Rudi Grinberg 6159a2909c Remove one off function
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-08 16:33:18 +07:00
Rudi Grinberg 3a7b62a57d Use the variable for dynamic expansions as well
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-08 16:33:18 +07:00
Rudi Grinberg 3f7ad78512 Replace more code with the variable system
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-08 16:33:18 +07:00
Rudi Grinberg 9811031899 Implement a more elaborate variable expansion mechanism
That embeds changes across versions

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-08 16:33:18 +07:00
Rudi Grinberg 8ef6af2675 Add some helpers to String_with_loc
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-08 16:33:18 +07:00
Rudi Grinberg 54ff98b36d Rename ROOT to root
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-08 16:33:18 +07:00
Rudi Grinberg a0a92d9adb Introduce a Dir primitive to Value
This is like Path but users will know not to infer dependencies from it

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-08 16:33:18 +07:00
Rudi Grinberg 1a37977f62 Fix error message
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-08 16:33:18 +07:00
Rudi Grinberg 90cde684e6 Remove uppercase vars in dune files
While maintaing them in jbuild files (with proper error messages)

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-08 16:33:18 +07:00
Jérémie Dimino 3348b6a913
Adapt the behavior of dune subst for dune projects (#960)
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-07-08 09:51:16 +01:00
Rudi Grinberg b8f11b1f04 Make variable rename errors more consistent
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-06 18:48:30 +07:00
Rudi Grinberg c4545fce18 Get rid of indexed lookups for deps
Have %{first-dep} to replace %{<}

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-06 18:46:10 +07:00
Rudi Grinberg ca342fd840 Fix inverted conditionals for version check
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-06 18:46:09 +07:00
Rudi Grinberg 204b21f4fb Rename %{<} to %{deps[0]} and implement %{deps[i]}
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-06 18:46:09 +07:00
Rudi Grinberg 97fba5537d Write lexer to parse %{deps[i]}
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-06 18:46:09 +07:00
Rudi Grinberg 0195b4bd03 Add some helpers to impldement %{deps[i]}
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-06 18:46:09 +07:00
Rudi Grinberg 13c12e9def Rename %{^} to %{deps}
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-06 18:45:43 +07:00
Rudi Grinberg a317fb0606 Rename %{@} to %{targets}
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-06 18:45:43 +07:00
Rudi Grinberg c290ad288f Rename scope_root to project_root
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-06 18:45:43 +07:00
Rudi Grinberg 7707872e54
Test Stanza Proposal (#822)
Add tests and test stanza

These stanzas are used to easily define tests. If a test has a corresponding .expect file, it will be immediately considered as an expect test.
2018-07-06 18:43:31 +07:00
Rudi Grinberg a8bd8ffa44 Rename JBUILDER_GEN to DUNE_GEN
Technically, we still support JBUILDER_GEN

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-06 15:10:13 +07:00
Etienne Millon 35ff6466de Remove path-no-dep syntax
See #944

Signed-off-by: Etienne Millon <etienne@cryptosense.com>
2018-07-04 10:39:57 +02:00
Etienne Millon 628914fe28 Rename path to dep in dune files
See #842

Signed-off-by: Etienne Millon <etienne@cryptosense.com>
2018-07-03 15:59:52 +02:00
Rudi Grinberg 63eb0f2312
Merge branch 'master' into subsystem-versioned 2018-07-03 18:59:02 +07:00
Jérémie Dimino e6a5ef9508
Add the lib_root and libexec_root install sections (#947)
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-07-03 10:49:18 +01:00
Rudi Grinberg 7a91a2b23b
Merge branch 'master' into subsystem-versioned 2018-07-03 16:49:05 +07:00
Rudi Grinberg e09695e116 Relax versions for subsystems
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-03 16:36:11 +07:00
Rudi Grinberg 8e09749f12 Add missing words to syntax error message
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-03 16:12:01 +07:00
Rudi Grinberg aee019577b Change fallback check to use ?check param
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-03 16:12:01 +07:00
Rudi Grinberg dee6c9aa96 Disable fallback in dune files
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-03 16:12:01 +07:00
Jérémie Dimino e56fba9a57
Do not use opam-installer to copy files (#941)
Instead of calling opam-installer, manually parse .install files and copy the files.

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-07-03 10:10:09 +01:00
Jeremie Dimino 6589464f21 Rewrite lexing of installed dune files
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-07-03 09:22:57 +01:00
Rudi Grinberg 04ee6b0b2d Set M.syntax when reading subsystems generated by dune
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-03 01:01:06 +07:00
Rudi Grinberg 044c78281d Use parsing context when parsing name, version, raw triple of sub systems
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-03 01:01:06 +07:00
Rudi Grinberg 0051aeca29 Do not read .dune files twice
Reuse the same lexer by pushing back some tokens manually

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-03 01:01:06 +07:00
Rudi Grinberg 4af1f189f0 Using Syntax.Verison.t to decide how to generate sub system files
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-03 01:01:06 +07:00
Rudi Grinberg 22cf958b0c Add dune_version field for libraries
This field is necessary to know how to generate .dune files for a particular
library.

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-03 01:01:06 +07:00
Rudi Grinberg 9005ca8998 Simplify error handling
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-03 01:01:06 +07:00
Rudi Grinberg 01163776ad s/Dune/lang/
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-03 01:01:06 +07:00
Rudi Grinberg f6fe5d20bb Generate dune file version correctly
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-03 01:01:06 +07:00
Rudi Grinberg 9c0daa24de Don't hard code parsing_context for sub systems
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-03 01:01:06 +07:00
Rudi Grinberg ba9335badf Simplify dump_config with Option.map
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-03 01:01:06 +07:00
Rudi Grinberg 7b12e12571 Share loc variable
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-03 01:01:06 +07:00
Rudi Grinberg bedad1f689 Set version when parsing dune files
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-03 01:01:06 +07:00
Rudi Grinberg 8390af90e4 Simplify versioning matching
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-03 01:01:06 +07:00
Rudi Grinberg a4bc260241 Loc.of_lexbuf
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-03 01:01:06 +07:00
Rudi Grinberg c906801c69 Parse dune files in a versioned way.
We read the first 3 tokens of a dune file and use it recognize if the file was
generated using jbuilder or dune

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-03 01:01:06 +07:00
Rudi Grinberg 179d23ee38 Expose the type of tokens and lexers
This will be necessary for some manual parsing

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-03 01:01:06 +07:00
Rudi Grinberg 67edb7f89e Move make_loc to Loc module and rename it to of_lexbuf
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-03 01:01:06 +07:00
Jérémie Dimino 438fef915f
Forbid #require in dune files in OCaml syntax (#938)
And add run_and_read_lines to replace old use cases of Unix.open_process_in

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-07-02 08:17:53 +01:00
Rudi Grinberg f163f6197a
Merge branch 'master' into rename-build-profile 2018-07-02 13:45:00 +07:00
Rudi Grinberg d19e55bd4d Rename %{build_profile} to %{profile}
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-02 12:52:48 +07:00
Jeremie Dimino fc9f3357ab Allow some part of a Build.t to be lazy
This is useful for (alias_rec ...) since at definition site we recurse
through all sub-directories. This is especially relevant now that we
have the default alias which defaults to (alias_rec install).

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-07-01 21:50:44 +01:00
Jeremie Dimino 81bcd0f3e1 Add a "default" alias defined as follow:
- if "default" is specified by the user explicitely, use this
  definition
- otherwise assume the following definition:

  (alias
   (name default)
   (deps (alias_rec install)))

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-07-01 21:50:44 +01:00
Jeremie Dimino 0a970aba35 Improve error message for undefined aliases
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-07-01 21:50:44 +01:00
Jeremie Dimino 30db63ef71 Support @@alias to build an alias non-recursively
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-07-01 21:50:44 +01:00
Jeremie Dimino 79f3506922 Add String_with_vars.text_only
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-07-01 21:36:26 +01:00
Jeremie Dimino b4dd6565b2 Add Ordered_set_lang.Unexpanded.fold_strings
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-07-01 21:36:26 +01:00
Rudi Grinberg aa981b3206 Fix error message when workspace file doesn't exist
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-01 01:46:32 +07:00
Rudi Grinberg 989a1c0058 don't use wildcard match where not necessary
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-01 01:46:32 +07:00
Rudi Grinberg 2b307bfe99 Use Option.some_if when checking for workspace file
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-01 01:46:32 +07:00
Rudi Grinberg db4aed42d6 Add %{build_profile} variable
Added for testing but could come in handy elsewhere

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-01 01:46:32 +07:00
Jeremie Dimino 80c2d61416 Factorize construction of default workspace configuration
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-07-01 01:46:32 +07:00
Jeremie Dimino 9ffa579dbf Restore rule about empty dune-workspace file
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-07-01 01:46:32 +07:00
Jeremie Dimino 757400a6a6 Fix error message about unsupported versions
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-07-01 01:46:32 +07:00
Jeremie Dimino 3d65c4e378 Version the user configuration file
- dune requires the (lang ...) line
- jbuilder accepts it but fallback to the jbuild syntax if it's not
  present

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-07-01 01:46:32 +07:00
Jeremie Dimino cdcc520430 Disable old syntax for opam contexts in dune-workspace files
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-07-01 01:46:32 +07:00
Jeremie Dimino d5ae6dede0 Make dune require a (lang ...) line in dune-workspace files
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-07-01 01:46:32 +07:00
Jeremie Dimino 7c6ecc821f Reimplement workspace.ml with the new parsing API
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-07-01 01:46:32 +07:00
Jeremie Dimino 19532a8c3d Generalizes handling of files starting with (lang LANG VER)
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-07-01 01:46:32 +07:00
Jérémie Dimino 6823fb0d43 Restore eof_reached
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-01 01:46:32 +07:00
Jeremie Dimino d6c35e01df Split xxx-workspace file between jbuilder and dune
- jbuilder only looks for jbuild-workspace files
- dune only looks for dune-workspace files

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-07-01 01:45:02 +07:00
Jérémie Dimino e706421893 Add function to parse version header from sexp files
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-07-01 01:34:33 +07:00
Nathan Rebours 23717d1fd6 Drop findlib:x syntax in dune and display an error (#887)
Signed-off-by: Nathan Rebours <nathan@cryptosense.com>
2018-06-29 21:35:41 +01:00
Jérémie Dimino 7e79e2870d
Make the set language more future proof (#930)
- forbid list starting by an atom not starting with - or :
- allow to avoid the toplevel parentheses in dune files

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-06-29 21:11:47 +01:00
Jérémie Dimino 793a0b7c17
Fix the build on 4.02 by emulating -no-keep-locs (#927)
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-06-29 07:40:02 +01:00
Rudi Grinberg 8185337876
Merge branch 'master' into persistent-build-files 2018-06-29 11:07:22 +06:30
Rudi Grinberg 79224ff194 Add name to Vfile_kind functor
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-06-28 22:42:55 +06:30
Rudi Grinberg ef5a2144dd Add magic to to_out_string
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-06-28 22:40:00 +06:30
Jeremie Dimino 473dd9b440 Change the default build profile to dev during bootstrap
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-06-28 12:40:27 +01:00
Rudi Grinberg 3177404741 Remove extra module from Vfile_kind functor
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-06-28 18:02:50 +06:30
Rudi Grinberg 2071ac1072 Implement Vfile_kind in term of Persistent
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-06-28 18:01:06 +06:30
Rudi Grinberg aa22671b2f Remove Make_full from file_kind signature since it's unused
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-06-28 17:15:34 +06:30
Rudi Grinberg bc09b8fc81 Change Action.Promotion to use Utils.Persistent
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-06-28 17:15:34 +06:30
Rudi Grinberg 4738b6df89 Make promoted files a set
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-06-28 17:15:34 +06:30
Rudi Grinberg 2a80d034fa Use Util.Persistent to reimplemented promoted files store
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2018-06-28 17:15:34 +06:30
Jeremie Dimino af6f003d13 Refactor ordered_set_lang.ml
- use the new s-expression parsing API
- simplify the types and the parsing

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-06-28 11:26:42 +01:00
Jeremie Dimino f9f5503e81 Change the signature of Of_peek.peek
It is always used the same way: `peek raw`, and sometimes preceded by
a `eos`. Remove the old `peek` and add:

- `peek_exn` which is the same the old `peek raw`
- `peek` which returns `None` if the end of sequence is reached

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-06-28 11:26:42 +01:00
Jeremie Dimino 2982567639 Make the default build profile be dev
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-06-28 11:23:10 +01:00
Jeremie Dimino 16d34f4a07 Add Which_program to know whether we are dune or jbuilder
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-06-28 11:23:10 +01:00
Jérémie Dimino 9585c8f79d
Move ocamldep output files to the object directory (#918)
- this avoid the need for the "already_used" business
- this will make it easier to support multi-dir libraries without copy_files

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2018-06-28 09:46:20 +01:00