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

ppx_cstruct 4.04 #111

Merged
merged 3 commits into from
Aug 16, 2016
Merged

ppx_cstruct 4.04 #111

merged 3 commits into from
Aug 16, 2016

Conversation

gasche
Copy link
Contributor

@gasche gasche commented Aug 16, 2016

This PR implements support for 4.04 by just copying the 4.03 implementation which seems to work unchanged -- the local testsuite passes. This is an attempt to fix #110.

The first two commit make small changes on the select_ppx_version hack (see commit messages):

  • the first uses an invalid source file to make sure there is a compilation failure when the OCaml version is unknown
  • the second makes sure the auto-generated file is cleaned on distclean.

It would be nice if a release with this PR or a similar change to bring 4.04 could be made before the actual 4.04 release, so that we can test (and possibly fix) other software depending on cstruct during the beta/release-candidate period.

@@ -4,7 +4,7 @@ V=`ocamlc -version`
case $V in
4.02*) SRC=402 ;;
4.03*) SRC=403 ;;
*) echo Unsupported OCaml version $V ;;
*) SRC=error; echo Unsupported OCaml version $V ;;
Copy link
Member

Choose a reason for hiding this comment

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

isn't an exit 1 sufficient, rather than distributing invalid ml code for the error case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed it works fine, I'll rebase the PR. Thanks @hannesm!

Before this commit, compiling ppx_cstruct from an unsupported OCaml
version would just build ppx_cstruct.native from an empty source file,
which worked but produced an incorrect preprocessor, deferring
failures to cstruct's users.

After this commit, using an unsupported OCaml version fails at
configure time:

```
Unsupported OCaml version 4.04.0+dev7-2015-08-09
E: Failure("Command 'sh select_ppx_version.sh conf' terminated with error code 1")
Makefile:34: recipe for target 'setup.data' failed
```
Note that ppx_cstruct.404.ml is just an unchanged copy of
ppx_cstruct.403.ml. This seems to work well with the testsuite
provided. I used a plain file copy instead of a symlink as I don't know how
git symlinks are handled on Windows machines.

Having two files that are exactly the same means a fair amount of
redundancy, but I think this redundancy was chosen by the decision to
have a ppx_cstruct.$VERSION.ml file per OCaml version in the first
place. If one wants to reduce redundancy in the future, I guess that
a single file with preprocessor directives would make more sense.
V=`ocamlc -version`
case $V in
4.02*) SRC=402 ;;
4.03*) SRC=403 ;;
*) echo Unsupported OCaml version $V ;;
4.04*) SRC=404 ;;
Copy link
Member

Choose a reason for hiding this comment

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

instead of duplicating code in the repo, we could set SRC=403 here.. I'm still not sure which is less worse - pest or cholera

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I considered it, but I think that it's better to be clear (and dumb) rather than try to be cunning inside a general approach that is rather duplication-friendly anyway.

@hannesm
Copy link
Member

hannesm commented Aug 16, 2016

thx @gasche. IMHO good to merge!

@avsm
Copy link
Member

avsm commented Aug 16, 2016

ok, will cut a release shortly.

@avsm avsm merged commit 36993e0 into mirage:master Aug 16, 2016
@@ -1,10 +1,17 @@
#!/bin/sh -e

case $1 in
clean) rm -f ppx/ppx_cstruct.ml; exit 0 ;;
conf) (* continue *) ;;
Copy link
Contributor Author

@gasche gasche Aug 16, 2016

Choose a reason for hiding this comment

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

looking at the patch again, this line uses OCaml comment syntax, which provokes the following behaviour from the root of the repository:

$ (* continue *)
bash: appveyor.yml: command not found

(The first * expands to the list of files in alphabetic order and the first, appveyor.ml, gets called as a command)

It would be nice to commit a minor change to remove the comment or use proper shell comment syntax.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, fixed this up in #112

@hannesm hannesm mentioned this pull request Mar 6, 2017
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.

ppx_cstruct seems broken on 4.04
3 participants