ocaml port submissions

Tom Hutchinson th5 at macports.org
Wed May 19 02:02:52 PDT 2010


Thanks for the reminder.

Last weekend I made my first "serious" portfile. I added a variant to port ocaml.

The OCaml compiler team is very conservative about adding new things to the standard distribution (they are underpowered and anything they add they'll have to maintain forever). Most of the time that's fine; things can just be put in libraries. Sometimes though, that isn't feasible. There are a few tools/extensions that are patches to the compiler.

The variant I made is for the OCamlSpotter tool. It lets you save type information at compile time (so in an editor you can look up what the type of an expression is. Anyway...

To add this variant wasn't trivial. 

An extra archive needs to be downloaded (in a different format too - it seems like there's current no good way to mix gzip and bz2 in the extract phase - I ended up exacting the additional file manually in extract-post). Then some files need to be moved from one directory to the other. Then a patch that affects several files needs to be applied. This patch file is in the extra archive. There isn't a simple single build target anymore either.

While kind of a pain, this was a good experience. It really forced me to learn about the different build phases. I found myself reading the guide and the the phase sources (portbuild.tcl, etc...).

The part that is still a little bit a magic is destroot. I'll have to look more to learn how the whole staging process works. I don't have internet access at home (an experiment I would strongly encourage others to try) so I was just using the sources and a downloaded copy of the guide. Are there other resources I should read?

This weekend I'll try to clean up this portfile. Right now some parts are kind of hacks. For instance, in some places I looked how the tcl's files worked and did things manually (when I couldn't directly use the predefined phases). While this will work now, it seems much better to use the proper lookup functions.

As for the port submissions, I'll take a look. I was wondering about one thing in them:

proc ocamlfind_destdir {} {
	    # only bother calculating this darn thing once
	    variable ocamlfind_destdir {}
	    variable destroot
	    variable prefix
	    if {![string length $ocamlfind_destdir]} {
	        set ocamlfind_destdir ${destroot}[exec ${prefix}/bin/ocamlfind printconf destdir]
	    }
	    return $ocamlfind_destdir
	}


pre-destroot {
	  system "mkdir -p [ocamlfind_destdir]"
	  reinplace "s#\$(OCAMLFIND_INSTFLAGS)# -ldconf ignore -destdir '[ocamlfind_destdir]'#g" ${worksrcpath}/src/OCamlMakefile
	}

Note: Findlib (here called using the ocamlfind command) is a widely used OCaml tool for dealing with OCaml libraries. 

Style-wise, I'm wondering about setting setting this variable ($ocamlfind_destdir). I don't see any big advantage to this over just calling the command every time. I haven't seen this kind of thing in other ports (though admittedly I've only read a relatively small number in great detail).

Another thing I'll be looking into is updating the OCaml Batteries Included port (caml-batteries).

I have a question. Should I continue with the caml- prefix for port names? Some ports are named ocaml-* (which is widely used in naming packages for Linux distributions).

Yikes - I apologize for this long and rambling e-mail

Tom

On May 17, 2010, at 12:40 PM, Rainer Müller wrote:

> Hello Tom,
> 
> in your request for commit rights for MacPorts you said you are
> interested in ocaml and would like to create some new ports. In our Trac
> are ocaml port submissions which are queued for almost two years now.
> Nobody else seemed to be interested to work on these tickets yet.
> 
> Please, would you be able to take a look at these?
> 
> http://trac.macports.org/query?status=!closed&component=ports&summary=~ocaml&type=submission
> 
> Thanks in advance,
> Rainer



More information about the macports-dev mailing list