From: Berke Durak <berke.durak@exalead.com>
To: Caml-list List <caml-list@inria.fr>
Cc: Nicolas Pouillard <nicolas.pouillard@gmail.com>
Subject: Using dynlink (native code and byte code) for the build system
Date: Thu, 31 Jan 2008 11:02:10 +0100 [thread overview]
Message-ID: <47A19CA2.9010303@exalead.com> (raw)
Hello all,
Thank to Alain Frisch's natdynlink, it is now possible to dynamically load native code plugins.
We were thinking with Nicolas of dynamically of using this to loading all plugins dynamically, instead of linking them
with ocamlbuild and re-running the resulting executable as is done currently. This would allow to load any number of
plugins during the course of the compilation.
It has been recently suggested on this list that instead of forcing everyone to use the same build system, we could ask
them to have a common build API.
One proposition was a makefile with a fixed number of targets (byte, native, clean...)
I think that we should minimize the set of different languages used per the ``you shall not unnecessarily multiply
entities'' principle. Also, Makefiles are not very portable, because:
* There are different implementations of make (BSD make vs GNU make)
* Makefiles embed shell commands and filenames, which cause huge portability problems
So why not require projects to have a buld API in an Ocaml file? The API would be distinct from ocamlbuild but would
be designed to be extensible, to permit dynamic loading and to be callable from ocamlbuild.
I have started a toy system. Every project includes in its root a file named plugin.ml, which contanis something such as:
open Interface
class entry env =
object
inherit default_builder
method hello =
env.env_say "Hello, world!"
method build =
env.env_say "Building";
Sys.command "make linux"
method clean =
env.env_say "Cleaning";
Sys.command "make clean"
end
let _ = register (fun env -> new entry env)
Interface is the API we are talking of. The plugin registers an object of class entry.
The entry object has a #build method which is called to build and install the project,
according to options and target directories defined in the environment env.
The environment contains a registry-like configuration dictionary whose interpretation
is project-dependent.
The entry object can also have a #prerequisites method which returns a description of
the dependencies of the project.
I've made a toy API and a toy builder which compiles and loads native plugins,
and written a plugin for a C project which is built using make. You can browse
the source at
http://aurochs.fr/hg/opkg/
or clone it using Mercurial with the command:
hg clone http://aurochs.fr/hg/opkg/
You then run ./make and then ./builder
So this is a request for experimenting and developing a plugin system around these ides.
Feel absolutely free to do anything based on the opkg sample code. I hope a nice plugin system will
evolve from it.
PS. You can commit in your own repository; if you want to have push access
just send me a mail with the result of htpasswd -nd yourlogin
PPS. I put the code in the public domain.
--
Berke DURAK
next reply other threads:[~2008-01-31 10:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-31 10:02 Berke Durak [this message]
2008-01-31 14:49 ` [Caml-list] " Alain Frisch
2008-01-31 14:48 ` Jon Harrop
2008-01-31 14:59 ` Berke Durak
2008-01-31 14:58 ` Jon Harrop
2008-01-31 16:46 ` Alain Frisch
2008-02-01 16:21 ` Jon Harrop
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47A19CA2.9010303@exalead.com \
--to=berke.durak@exalead.com \
--cc=caml-list@inria.fr \
--cc=nicolas.pouillard@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox