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

xapi-idl: jbuilderize #174

Merged
merged 20 commits into from
Oct 9, 2017
Merged

xapi-idl: jbuilderize #174

merged 20 commits into from
Oct 9, 2017

Conversation

edwintorok
Copy link
Contributor

This has actually been useful for @jjd27 during the clustering work: you can just drop the jbuilderized xapi-idl in a subdirectory and build everything together in planex when you are making changes to the interface.

Caveats: xcp vs xapi-idl differences in project name and library name, I had to create opam packages for both and have them depend on eachother, but maybe there is a better way.

Some libraries still use camlp4 which requires splitting the lib internally
into 3 parts: ppx-modules-needed-by-camlp4-module, camlp4-interface, rest of ppx
modules.

Signed-off-by: Edwin Török <[email protected]>
Signed-off-by: Edwin Török <[email protected]>
These functions/types are declared but not exposed through the mli

Signed-off-by: Edwin Török <[email protected]>
%s does not accept a precision

Signed-off-by: Edwin Török <[email protected]>
The tests pass either way, but partition2=partition2 looks like a typo.

Signed-off-by: Edwin Török <[email protected]>
these warnings can't easily be fixed

Signed-off-by: Edwin Török <[email protected]>
The first bind could actually use bind_1 but that is deprecated too,
just use the non-deprecated version in both places.

Signed-off-by: Edwin Török <[email protected]>
Slight problem with how ocamlfind libraries are all called xcp,  but the opam
package is xapi-idl.
Jbuilder expects the two of them to match though.

Signed-off-by: Edwin Török <[email protected]>
Based on xapi-project/nbd#bugfix-v2.x

Signed-off-by: Edwin Török <[email protected]>
Signed-off-by: Edwin Török <[email protected]>
This should be replaced by String.lowercase_ascii,
but that wouldn't compile with 4.02.3 anymore.
Asking everyone to upgrade to 4.04.2 might be too early for now.

Signed-off-by: Edwin Török <[email protected]>
@coveralls
Copy link

coveralls commented Sep 29, 2017

Coverage Status

Changes Unknown when pulling 254f58e on edwintorok:jbuilderize into ** on xapi-project:master**.

Copy link
Collaborator

@mseri mseri left a comment

Choose a reason for hiding this comment

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

Did you use something particular for b80d419, like a dead code tool, or you followed warnings?

This was a massive work, I had only some minor pedantic comments. Once those are resolved I am happy to approve it

lib/syslog.ml Outdated
@@ -49,7 +49,7 @@ let facility_of_string s =

exception Unknown_level of string
let level_of_string s =
match String.lowercase s with
match (String.lowercase s)[@ocaml.warning "-3"] with
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't silence these, it is a constant reminder of necessary changes once we drop support for 4.02

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, I'll try to make the warning non-fatal for jbuilder build --dev instead, so you can still see other warnings and doesn't stop the whole build on this one.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you can make it, it would be great! However, afaik, the set of dev flags is hardcoded for the moment.

I'd leave that fail (we can always silence it by hand while fixing the dev build) and make the release build the default one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like jbuilder --dev expands the flags into :standard and then I can turn some errors back into warnings with -warn-error -N: (flags (:standard -w -39 %s -warn-error -3)).
Not sure whether we want --dev to be the default or not though.

@@ -11,6 +11,7 @@ services:
env:
global:
- OCAML_VERSION=4.04.2
- PINS="xcp:."
Copy link
Collaborator

Choose a reason for hiding this comment

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

I did a similar thing for stdext and I already start regretting it... Should we instead update all the package references and use xapi-idl once and for all? For the rrd-stuff port I decided to go and update all the packages, it's annoing and invasive but it's a cleanup afterall. I'd like to know @robhoes and @lindig point of view as well.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've been giving a few thoughts about this. I think for the time being, for libraries like this or stdext that are pervasive across the whole product, we should value backward compatibility over coherence. After we are done with the ports, we can go an kill the backward compatibility hacks all at once.

@ocamlbuild -clean
@rm -f setup.data setup.log setup.bin
reindent:
git ls-files '*.ml' '*.mli' | xargs ocp-indent --syntax cstruct -i
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am going to update the internal documentation using this: it's much cleaner than our default Makefile

example/jbuild Outdated
(executable
((name example)
(flags (:standard -w -39 %s))
(libraries (lwt lwt.unix xcp rpclib))))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please sort the libraries names

lib/jbuild Outdated
(flags (:standard -w -39 %s))
(modules (:standard \ updates task_server scheduler channel_helper))
(c_names (syslog_stubs))
(libraries (cmdliner uri re cohttp xmlm unix sexplib
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's going to become long but we are sticking to sorted columnar list of dependencies, so please separate them on different lines and sort them.

In this case, in the dependent libraries and executable you may want to first list the xapi-idl dependencies (xcp, xcp.updatex, xcp.xen, ...) and then all the others to emphasize which package libraries are needed where.

Please split them and sort them also in the rest of this file and the other jbuild files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can probably guess how I'll solve this :)
Just to clarify do you also prefer an empty line between the xcp and the rest:

(libraries
   (xcp
    xcp.updates
    xcp.xen

    lwt
    lwt.unix
    oUnit
    rpclib
    threads
   ))

Copy link
Collaborator

Choose a reason for hiding this comment

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

:) I think they are fine as they are in your new commit

xcp.opam Outdated
depends: [
"ocamlfind" {build}
"ocamlbuild" {build}
"jbuilder" {build & >= "1.0+beta11"}
"base-threads"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's sort also the dependencies here

@@ -14,7 +14,6 @@

open Xcp_service
module D = Debug.Make(struct let name = "example" end)
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we don't use it at all, lets drop this as well

lib/updates.ml Outdated
@@ -5,7 +5,6 @@ open Stdext
open Pervasiveext

module D = Debug.Make(struct let name = "updates" end)
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we don't use it at all, lets drop this as well

@@ -92,11 +90,7 @@ let finally f g =
g ();
raise e

let file_descr_of_int (x: int) : Unix.file_descr =
Obj.magic x (* Keep this in sync with ocaml's file_descr type *)
Copy link
Collaborator

Choose a reason for hiding this comment

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

🎉

Instead of silencing the deprecation warning completely just make the warning non-fatal,
even when jbuilder --dev is used.

Signed-off-by: Edwin Török <[email protected]>
Signed-off-by: Edwin Török <[email protected]>
@edwintorok
Copy link
Contributor Author

Thanks for the review, I followed jbuilder warnings for the dead code in b80d419.
Before merging I'll have to sort the dependencies like you said, and also update the spec file, which references oasis.

@coveralls
Copy link

coveralls commented Oct 2, 2017

Coverage Status

Changes Unknown when pulling f231e9b on edwintorok:jbuilderize into ** on xapi-project:master**.

lib/updates.ml Outdated
@@ -4,9 +4,6 @@
open Stdext
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is using stdext, although stdext is not listed as a dependency (it probably comes as a transitive one). Can you please remove all the open Stdext and replace the use of the library with the minimal subset of new sublibraries? In this case it would be Xapi_stdext_pervasives.Pervasiveext and I believe replacing it with let finally = Xapi_stdext_pervasives.Pervasiveext.finally should be enough in this case

Copy link
Collaborator

Choose a reason for hiding this comment

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

And there is a reference to Xapi_stdext_threads.Threadext half way through.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed, I also needed Xapi_stdext_monadic. The finally was not needed, when I added the open for Pervasiveext.

@mseri
Copy link
Collaborator

mseri commented Oct 2, 2017

Other mentions of stdext that I've seen in xcp-idl are:

I think it would be good to move from the stdext dependency to the three specific xapi-stdext-? packages only where needed as part of this port.

Use sorted columnar format for dependencies.
Reindent jbuild files

Signed-off-by: Edwin Török <[email protected]>
@coveralls
Copy link

coveralls commented Oct 3, 2017

Coverage Status

Changes Unknown when pulling 933d514 on edwintorok:jbuilderize into ** on xapi-project:master**.

Signed-off-by: Edwin Török <[email protected]>
@coveralls
Copy link

coveralls commented Oct 3, 2017

Coverage Status

Changes Unknown when pulling ebe9f3f on edwintorok:jbuilderize into ** on xapi-project:master**.

Xapi_stdext_monadic is needed for Opt

Signed-off-by: Edwin Török <[email protected]>
@edwintorok
Copy link
Contributor Author

Not sure why Travis can't find xapi-stdext-threads I see it in my opam.

@mseri
Copy link
Collaborator

mseri commented Oct 9, 2017

We found that the build issue is an issue with ocaml-docker used in the tests. @edwintorok submitted a PR to fix it ocaml/ocaml-ci-scripts#188 and should not prevent this PR to be merged. If the fix is not approved in a reasonable time, I will send a PR to move travis back to ocaml-travis.

@mseri mseri merged commit 03f01c8 into xapi-project:master Oct 9, 2017
@edwintorok edwintorok deleted the jbuilderize branch October 9, 2017 09:23
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.

3 participants