[Omake] Extending scanner rules

Aleksey Nogin anogin at hrl.com
Wed Apr 4 10:36:23 PDT 2007


On 04.04.2007 00:25, Jonathan Roewen wrote:

> Is it possible to extend a scanner rule?
> 
> I have a problem where I have modules that _should_ have a depenency
> on my custom stdlib/pervasives, but ocamldep doesn't know how to do
> that properly (at the very least pervasives), and so it tries to build
> those modules too early.
> 
> Basically, I'd like to simply add something like
> $(ROOT)/kernel/stdlib/pervasives.cmi as a dependency to every module
> in selected subdirs automagically.

Jonathan,

You do not need to extend the scanner rules here - those are only needed 
when you want to discover dependencies at run time. Here, on the other 
hand, the "missing" dependency is known in advance, so you can simply 
specify it as an implicit dependency.

E.g.

#------- Root OMakefile ----------------------------

PERV = $(file kernel/stdlib/pervasives)
PERV_CMI = $(file $(PERV).cmi)
PERV_CMX = $(file $(PERV).cmx)

#------ OMakefile in the part of the project -------
#------ that needs a custom Pervasives -------------

%.cmx %(EXT_OBJ): $(PERV_CMI) $(PERV_CMX)
%.cmi: $(PERV_CMI)
%.cmo: $(PERV_CMI)

#---------------------------------------------------

Note that the implicit dependencies are inherited through .SUBDIRS and 
scoped in the same way as everything else (variables, phonies, implicit 
rules, etc), so you may do something like in, say, kernel (here I am 
"randomly" guessing what the structure of your code might be):

section
   # stdlib does not use the default pervasives
   OCAMLFLAGS += -nopervasives
   .SUBDIRS: stdlib

# Everything else depends on the custom pervasives
PERV = $(file stdlib/pervasives)
PERV_CMI = $(file $(PERV).cmi)
PERV_CMX = $(file $(PERV).cmx)

%.cmx %(EXT_OBJ): $(PERV_CMI) $(PERV_CMX)
%.cmi: $(PERV_CMI)
%.cmo: $(PERV_CMI)

Aleksey

-- 
Aleksey Nogin, Research Staff Member
Advanced Technologies Department, Information & System Sciences Lab
HRL Laboratories, LLC, Malibu, CA


More information about the Omake mailing list