jbuild-ignore should only refer to directories in the current directory
(unlike .gitignore): referring to subdirectories doesn't work.
Signed-off-by: David Allsopp <david.allsopp@metastack.com>
The -o option in the Microsoft C Compiler is deprecated (and has been for
a very long time). The warning is tedious, so use /Fo instead. The only
problem with this is that "-o foo.obj" must become "/Fofoo.obj" with no
space, which requires a little support in Arg_spec.
Signed-off-by: David Allsopp <david.allsopp@metastack.com>
The legacy DOS readonly attribute is a tedious difference on Windows,
because a user may have permission to delete a file, but unlink fails
because the attribute is set.
Signed-off-by: David Allsopp <david.allsopp@metastack.com>
* 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.
* Accept correction files produced by ppx_driver so that [@@deriving_inline] works
* Change promote-if so that it doesn't promote the file when the source file doesn't exist in the source tree
* Let variables say whether they are Concat or Split
To concatenate the contents of a split variable, put it in a string:
"${var} ".
Fixes#300
See also https://github.com/janestreet/jbuilder/issues/408
* Issue a deprecation warning for ${!...}
* Treat ${CC}, ${<}, ${^} and ${read-lines:...} as split vars
* Change ${!^} into ${^} for this project jbuild rules
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
The markup emitted by Jbuilder treated module lists as inline elements
that can appear inside a line. However, neither ocamldoc nor odoc render
module lists as inline elements. They are instead block elements, that
are laid out vertically, like lists or paragraphs. Correspondingly, odoc
now rejects inline module list markup.
A side effect of the (rejected) misconception is that there was a stray
period appearing on its own line in every module list generated by
Jbuilder. This is now fixed.
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.
* docs: update some documentation in the Build module
* docs: document what [Scope.resolve] does
* docs: add a toplevel docstring to the Alias module
* docs: document (or not) the bootstrap function
* docs: lightly document the bootstrap module
* fix ignore comment
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
* 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
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.
When the docs are viewed locally, the URL ".." causes the browser to
display a listing of the parent directory, instead of "../index.html".
The "../index.html" interpretation is only provided by web servers.
This commit changes the top-level index of the docs generated by
Jbuilder so that the index lists all installed libraries (Findlib
library packages generated by Jbuilder), rather than only opam packages.
For example, current Markup.ml installs libraries
markup
markup.lwt
markup.lwt.unix
With this change, all these libraries are listed in the index. Before
this change, only markup was listed, because it happened to coincide
with the name of the opam package that contains all three libraries.
Not listing the extra libraries makes them undiscoverable, as they can
only be reached by direct URL.
When the root of the workspace is not the current directory, print:
Entering directory '<absolute path to root>'
This way editors such as emacs or vim knows how to interpret filenames
reported by the compiler.
Fixes#138
- vendored libraries are replaced by files in `vendor/boot`
- files named `XXX.boot.EXT` replace their `XXX.EXT` equivalent
For instance, to build boot.exe, we use `src/glob_lexer.boot.ml`
rather than `src/glob_lexer.ml` (which would be generated from
`src/glob_lexer.mll`).
Add (copy_files <glob>) and (copy_files# <glob>) stanzas. These
stanzas setup rules for copying files from a sub-directory to the
current directory.
This provides a reasonable way to support multi-directory
library/executables in jbuilder.
Previously, in Mode.Native, executables depended on .cmx files only.
This was fine when changes were detected by timestamp, but it is
possible to semantically alter an .ml such that only the .o/.obj file
alters. In this situation, Jbuilder would rebuild the .cmx file, but not
relink the executable.
Fixes#237.
Signed-off-by: David Allsopp <david.allsopp@metastack.com>
The form (:include $(SCOPE_ROOT)\foo) requires quoting, but the error
message was cryptic ("Error: undefined symbol include").
Signed-off-by: David Allsopp <david.allsopp@metastack.com>
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.
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.
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.
* Allow digits in library/module names
Also include the malformed module name in the error message so it's more clear what it's complaining about.
* Update jbuild.ml
Instead of passing `-I <path> file.cma` to the compiler, pass `-I
<path> <path>/file.cma`.
Fixes#118 and #177. Using the fill path should also be slightly
faster as the compiler won't have to do the lookup through all include
paths. The only drawback is that it makes linking command line
slightly longer.
This is useful, for example, if one needs to pass specific flags
by hand (due to the need to use old libraries for example). Fixes
#198
Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
The code to support it is starting to become increasingly complicated
and the number of problem found is a bit alarming.
We'll reinclude it later after a bit more testing and hopefully some
simplifications.
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.
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.
before:
- foo.re --> foo.re.ml
- foo.rei --> foo.rei.mli
after:
- foo.re --> foo.re.ml
- foo.rei --> foo.re.mli
When compiling foo.re.ml with ocamlc or ocamlopt, the compiler checks
for the existence of foo.re.mli to determine whether the file has an
explicit interface or not. With the previous naming scheme, the
compiler always thought that there was no interface and was
re-creating the .cmi, which caused a race condition.
Fixes#184
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.
Report an error when in a wrapped library, a module that is not the
toplevel module depends on the toplevel module. This doesn't make as
such a module would in theory be inaccessible from the outside
If this causes compilation failures of released packages, we'll need
to turn this into a warning.
For instance (chdir ${read:foo} ...) is not allowed. This doesn't seem
really useful since we couldn't express the targets anyway and
supporting it complicate the code.
The Microsoft C compiler doesn't recognise -g. For now, easier just not
to compile with any debugging information on MSVC.
Signed-off-by: David Allsopp <david.allsopp@metastack.com>
Currently (foreach ...) is too general and variables can be used
anywhere inside S-expressions.
We need to sort out how we are going to handle meta-programming first
as this might impact how we implement (foreach ...).
In any case, it's better not to have it in 1.0.0.
Instead make jbuilder print the rule to do the same in the warning
message. The rule is not that big. Also add a note about mli only
modules in the "Known issues" section of the README.
This avoids polluting the jbuild specification and is still a
reasonable solution until someone implements proper support for mli
only modules in the compiler.
- ${read:<filename>} -> expand to the contents of the file
- ${read-lines:<filename>} -> expand to the list of lines in the file
- ${read-strings:<filename> -> expand to the list of lines in the file,
unescaped using OCaml escaping rules
Generalize ${!...} form
This way, when an external library is reinstalled, jbuilder knows to
rebuild things.
Currently, because the library dependencies transitive closures are
computed dynamically and jbuilder doesn't yet support dynamic targets,
every single rule has to depend on all the external files.
When jbuilder support dynamic targets, we can setup one alias per
external directory.
Tested the build of 97 Jane Street repository at once. No slow down
observed for the initial build.
Then a null build goes from ~1.5s to 2s. The test case is a bit
extreme so it's bot that bad given the benefits.
- Make targets explicit b7ad08df84.
- Get rid of Vfile e73fd90b65.
Without vfile we need some new concepts to avoid parsing the requires
file multiple times and with vfile it's annoying to specify the
dependencies by hand.
Will leave that for future work. Just use memoize where it make sense,
for instance when we read the result from only the current directory
(for instance the ocamldep stuff).
Moved most of the global values computed at the beginning of
Gen_rules.Gen to Super_context.t. This will allow to split
gen_rules.ml into multiple files.
Adds the menhir stanza which desugars into a Rule.t with Support for:
* ocamlyacc like use
* modular parsers with --base
* passing extra flags
Also add tests and documentation.
Makes the output quieter by default and add a `--verbose` argument. Print a message when waiting for background jobs to finish only it it takes more than 0.5 seconds.
Before this commit, when there was more than one applicable
assignment, the one with the lowest number of formal predicates was
selected instead of the one with the biggest number of formal predicates
(executable ...) is easier to use where there is a single executable.
Also add a (package ...) and (public_name <name>)/(public_names
(<names)) to executable/executables stanzas, to make it easier to
install executables.
Closes#33
If ocamlfind is present, don't try to call `opam config var lib`. The
previous behavior was breaking Facebook builds.
Also add ocamlfind as an optional dependency, to avoid race conditions
when installing ocamlfind in parallel.