Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better behavior when the targets of a rule already exist in the source tree #218

Merged
5 commits merged into from
Aug 15, 2017

Conversation

ghost
Copy link

@ghost ghost commented Aug 14, 2017

At the moment, if the targets of a rule are already present in the source tree, jbuilder ignores the rule. This is convenient for configure scripts: one can have the configure script generate a configuration file based on command line arguments supplied by the user and a rule to generate a default one. However, it is error prone in other cases. Especially when they are left-over files from a previous build system in the source tree.

This PR changes Jbuilder to emit a warning when such a case happens. The user now has to add (fallback) to the rule to specify that the rule only applies when the targets do not already exist in the source tree. For instance:

;; generate an empty lwt_config if it doesn't exist.
;; the discover script will generate defaults as appropriate.
(rule
 ((targets (lwt_config))
  (fallback)
  (action (with-stdout-to lwt_config (echo "")))))

Additionally, it is an error if only a subset of the targets are present.

This PR fixes #187 and #148.

@ghost
Copy link
Author

ghost commented Aug 15, 2017

One limitation of the current design is that one cannot turn a (ocamllex ...) stanza into a fallback rule. One way to make this more generic would be to add a fallback stanza that would act as a modifier for other stanzas:

(fallback
  (rule (...))
  (ocamllex (...))
  ...
)

However, it seems that the only use of fallback rules is for default configuration files. So it seems better to keep things simple for now.

@ghost ghost merged commit 6bed864 into master Aug 15, 2017
@ghost ghost mentioned this pull request Aug 15, 2017
@ghost ghost deleted the fallback-rules branch February 7, 2018 14:48
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parser generators and dependencies with .ml{,y,i} files.
0 participants