[Omake] Scoping
Jason Hickey
jyh at cs.caltech.edu
Wed Nov 8 21:11:25 PST 2006
It may be just that you are assuming that OCamlProgram(foo, files) is
transitive. In other words, not only should foo be built with the
flags you define in the function body, but also each file in files
should use the same flags as well. However, this isn't the way it
works--it wouldn't be a good idea.
How is the environment for a target xxx/yyy determined?
1. If there is a rule that has xxx/yyy as an explicit target,
then the environment of that rule is used.
2. Otherwise, the environment at the end of xxx/OMakefile is used.
The OCamlProgram(foo, files) defines an explicit target for foo, not
for each file in files.
I'm guessing that you are defining your function so that you can call
it more than once. So probably we need some clarification. Why not
this?
LocalOCamlGeneratedFiles(...)
...
OCAMLINCLUDES[] += ...
...
test-a = $(OCamlProgram $(name), $(files)
Is it because you have multiple program targets in the same
directory, and the source files have to be compiled differently for
each target? This kind of design doesn't work, because it specifies
multiple different ways to compile the same source files. For example:
# This kind of thing doesn't work
# DEBUG section
section
OCAMLFLAGS += -g
foo.cmo:
OCamlProgram(boo, foo)
# OPTIMIZING section
section
OCAMLFLAGS += -inline 10000
foo.cmo:
OCamlProgram(boo, foo)
In any case, the way to write your spec is pretty simple. A rule
specifies the environment for the target, not the sources.
CFLAGS = -O1
a.exe: b.o
$(CC) $(CFLAGS) -o $@ $<
CFLAGS = -g
b.o: b.c
$(CC) $(CFLAGS) -c $<
b.o is compiled with -g, and a.exe is compiled with -O1.
Jason
On Nov 8, 2006, at 8:40 PM, Nathaniel Gray wrote:
>
> Didn't seem to help. Here's what I'm actually working on:
>
> SFProgram(name, files, sfFiles) =
> LocalOCamlGeneratedFiles($(sfFiles))
> public.OCAMLFLAGS += -thread
> public.OCAML_OTHER_LIBS += unix threads lm gc view_change \
> mcast_lib reliable_multicast
> public.OCAML_LINK_FLAGS += $(mojavecomm)/lib/gc_clib_impl.a \
> $(mojavecomm)/lib/mcast_clib.a
> public.OCAMLINCLUDES += $(libmojave) $(mojavecomm)/lib \
> $(dir ../mcomm-lib)
> public.OCAML_LIBS += $(sfgrouplib)
> files += $(sfFiles)
> return $(OCamlProgram $(name), $(files))
> test-a = $(SFProgram test-a, FakeSpec, test1-a)
>
> OMake fails to build FakeSpec.cmi because the includes aren't all
> there:
> - build test FakeSpec.cmi
> + ocamlopt.opt -warn-error A -I . -c FakeSpec.ml
> File "FakeSpec.ml", line 1, characters 0-10:
> Unbound module SFLog
>
--
Jason Hickey http://www.cs.caltech.edu/~jyh
Caltech Computer Science Tel: 626-395-6568 FAX: 626-792-4257
More information about the Omake
mailing list