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

Switch to the Dune build system and ppxlib #40

Merged
merged 15 commits into from
Mar 19, 2021
Merged

Conversation

MisterDA
Copy link
Collaborator

Hi!
This PR switches extunix to the Dune build system, and updates the code onto OCaml 4.11.
Dune prefers libraries and executable to live in different directories, so I had to move ppx_have and discover out of src. There were a few updates needed to account for the changes to the language and the standard library. The switch to odoc also requires some changes to the documentation, and to move the default AST in ppx_have to a recent OCaml.
Prefixing module names with the name of the library is also deprecated, so ExtUnixAll, ExtUnixSpecific, and ExtUnixConfig only exist as ExtUnix.All, ExtUnix.Specific, and ExtUnix.Config now.
Dune now generate extunix.opam automatically, and the release process is done with dune-release which reads CHANGES.txt, tags the git repo, creates then publishes a tarball.

@MisterDA MisterDA force-pushed the dune branch 5 times, most recently from f94266f to 6767420 Compare December 19, 2020 15:19
@MisterDA MisterDA force-pushed the dune branch 2 times, most recently from 740506c to 13d1ebc Compare January 8, 2021 17:26
@MisterDA
Copy link
Collaborator Author

Hello @ygrek,
I believe that I have converged and that the PR is ready for review.
One thing that I haven't done is to port ppx_have to the newer ppxlib.

@MisterDA MisterDA changed the title Switch to the Dune build system Switch to the Dune build system and ppxlib Feb 16, 2021
@ygrek
Copy link
Owner

ygrek commented Feb 16, 2021

(I didn't forget about this)

@MisterDA
Copy link
Collaborator Author

Yay! I think this is it.
The first batch of commits fixes compilation issues, the second batch removes oasis and migrates to dune. I've also ported the ad-hoc discover exe to dune-configurator. There's a workaround for a bug in configurator that's fixed now, but we have to wait for a new release of dune to remove the workaround. And finally, I've ported the ppx to ppxlib. It has a number of improvements over ocaml-migrate-parsetree.
Let me know what you think!

I also have some patches to make more functions work on Windows, but I intend to rebase them on this branch once it's merged.

@@ -5,6 +5,19 @@ environment:
FORK_USER: ocaml
FORK_BRANCH: master
CYG_ROOT: C:\cygwin64

Choose a reason for hiding this comment

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

Suggested change
CYG_ROOT: C:\cygwin64
CYG_ROOT: C:\cygwin64
OPAM_VERSION: 2.0.8

Could you try this? it might help the doubling of output in opam

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can reproduce in local with Opam 2.0.8, so this won't change it.

Choose a reason for hiding this comment

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

ah, I see. That sounds like an opam-on-windows™ bug indeed then :/ Have you tried with opam 2.1.0~beta4?

dune-project Outdated Show resolved Hide resolved
MisterDA added 2 commits March 1, 2021 13:39
- remove all Oasis configuration and generated files;
- add Dune build files;
- move discover and ppx_have to their separate directories;
- rename extUnix.mlpp to extUnix.pp.ml;
- generate the opam file using Dune;
- use dune-release for release process;
- update README documentation.
Ppxlib allows inserting a (possibly empty) list of structure_items, so
this has the nice side-effect of removing the `include module ___ end`
and have all the functions in the top-level of the generated modules.
@kit-ty-kate
Copy link

ping @ygrek if you have some time to review this

Copy link
Owner

@ygrek ygrek left a comment

Choose a reason for hiding this comment

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

thanks, this looks neat

#define UNUSED(x) (void)(x)

#include <caml/version.h>
#if OCAML_VERSION < 41200
Copy link
Owner

Choose a reason for hiding this comment

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

maybe better check for symbol itself
#ifndef Some_val

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, the end-result is the same, but we know these macros were introduced in 4.12.
I applied the same patch for the same issue here: ocaml-opam/ocaml-mccs#30.

@@ -16,7 +16,7 @@ array_of_value(value v)
size = Wosize_val(v);
arr = caml_stat_alloc((size + 1) * sizeof(char *));
for (i = 0; i < size; i++)
arr[i] = String_val(Field(v, i));
arr[i] = caml_stat_strdup(String_val(Field(v, i)));
Copy link
Owner

Choose a reason for hiding this comment

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

unrelated change
original code looks correct, why?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because of this warning: a const string pointer is written into the non-const array.

dune build @install
         gcc src/fexecve.o
fexecve.c: In function ‘array_of_value’:
fexecve.c:19:12: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
     arr[i] = String_val(Field(v, i));
            ^

However you're right, the copy isn't necessary and I believe a cast removing the const is enough to remove the warning, as the string isn't written into.

Makefile Show resolved Hide resolved
@ygrek ygrek merged commit 5ec9f12 into ygrek:master Mar 19, 2021
@kit-ty-kate
Copy link

@ygrek is there a release planned by any chance? Having a release with this PR in would help us immensely switch away from OMP1 and/or camlp4 (given some projects use OMP2 + extunix and only extunix < 0.2.0 is available with this configuration)

@MisterDA MisterDA deleted the dune branch March 24, 2021 16:23
@avsm
Copy link

avsm commented Apr 5, 2021

@ygrek would you have time to cut a release with this PR included? Not having this is causing problems with the ocaml/opam base image builders (as they need newer ppxlib and extlib). Thanks!

@ygrek
Copy link
Owner

ygrek commented Apr 10, 2021

MisterDA added a commit that referenced this pull request Apr 13, 2021
Fixes for suggestions in #40 and #41
Enable libexecinfo on Alpine
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.

4 participants