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

Attempt at implementing aliases #7

Merged
6 commits merged into from
Feb 21, 2017
Merged

Attempt at implementing aliases #7

6 commits merged into from
Feb 21, 2017

Conversation

rgrinberg
Copy link
Member

I didn't attempt at tackle any of the usability questions. Because my current
implementation is looking very shake.

Looking forward to a lot of feedback.

src/gen_rules.ml Outdated
let source =
match alias_conf.action with
| None -> ""
| Some a -> Sexp.to_string (User_action.Unexpanded.sexp_of_t a) in
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have:

| None -> "none"
| Some a -> "some" ^ ...

otherwise no action and "" would produce the same digest. "" would fail anyway since it is not a valid bash command, but you could get an error about multiple rules generated for a weird target, which is not great. Thinking about it, we should probably include the dependencies in the digest, otherwise we would get a clash in this case:

(alias
  ((name runtest)
   (deps (prog.exe file1)
   (action "./${*}")))

(alias
  ((name runtest)
   (deps (prog.exe file2)
   (action "./${*}")))

src/gen_rules.ml Outdated
| None -> ""
| Some a -> Sexp.to_string (User_action.Unexpanded.sexp_of_t a) in
Digest.to_hex (Digest.string source) in
let digest_path = Path.of_string (alias_conf.name ^ digest) in
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be Path.relative ~dir (alias_conf.name ^ digest).

For the basename we should use the same file prefix as Alias.make, so we could have: Path.basename (Alias.file alias) ^ "-" ^ digest

@ghost
Copy link

ghost commented Feb 20, 2017

Thanks, except for the two comments I left, it seems to me that this should work

| File t ->
List [Atom "file" ; String_with_vars.sexp_of_t t]
| Alias t ->
List [Atom "file" ; String_with_vars.sexp_of_t t]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this supposed to be "alias" ?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed

| File t ->
List [Atom "file" ; String_with_vars.sexp_of_t t]
| Alias t ->
List [Atom "file" ; String_with_vars.sexp_of_t t]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed

* Properly include option
* Add dependencies to the digest
@rgrinberg
Copy link
Member Author

Fixed that typo.

@ghost ghost merged commit 428c0b5 into ocaml:master Feb 21, 2017
@ghost
Copy link

ghost commented Feb 21, 2017

thanks. Now we just need a runtest command to be able to use this

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.

2 participants