[Omake] Newbie: removing quotes for command
Aleksey Nogin
anogin at hrl.com
Wed Mar 21 11:34:33 PDT 2007
On 21.03.2007 10:09, Hugo Ferreira wrote:
>> % INCLUDES[] = a b c
>> - : <array
>> "a" : Sequence
>> "b" : Sequence
>> "c" : Sequence>
>> : Array
>> % addprefix(-I, $(INCLUDES))
>> - : <array
>> <sequence "-I" : Sequence "a" : Sequence> : Sequence
>> <sequence "-I" : Sequence "b" : Sequence> : Sequence
>> <sequence "-I" : Sequence "c" : Sequence> : Sequence>
>> : Array
>> % addprefix(-I , $(INCLUDES))
>> - : <array
>> <sequence "-I " : Sequence "a" : Sequence> : Sequence
>> <sequence "-I " : Sequence "b" : Sequence> : Sequence
>> <sequence "-I " : Sequence "c" : Sequence> : Sequence>
>> : Array
>>
>>
>
> Now I am still baffled. It seems like whether or not I use the space, I
> still get a string (addprefix does not seem to be the in the list you
> provide below).
Not quite. What you get is a sequence. The main difference between a
string and a sequence is that the string is always interpreted
literally, while all the "special" characters in a sequence retain their
meaning.
For example, running osh in a directory that contains a file named "foo":
% ls $(addprefix f, *)
foo
% ls $"$(addprefix f, *)"
/bin/ls: f*: No such file or directory
- : <exit-code 1> : Int
% ls $(addprefix f, $"*")
/bin/ls: f*: No such file or directory
- : <exit-code 1> : Int
However, what addprefix (and pretty much every other "map-like"
function) does do is packing its results into array - and any spaces
inside array elements are taken literally (which is the whole point of
arrays - and is especially handy when you want to support
files/directories with spaces in their names).
This is why, as Jason said, you need to use mapprefix - instead of
appending the prefix within the same array item (as addprefix does),
mapprefix creates a separate array element for each prefix:
% mapprefix(-I, $(INCLUDES))
- : <array
<array
"-I" : Sequence
"a" : Sequence>
: Array
<array
"-I" : Sequence
"b" : Sequence>
: Array
<array
"-I" : Sequence
"c" : Sequence>
: Array>
: Array
Or, if you want to see (the equivalent) flattened version,
% array($(mapprefix -I, $(INCLUDES)))
- : <array
"-I" : Sequence
"a" : Sequence
"-I" : Sequence
"b" : Sequence
"-I" : Sequence
"c" : Sequence>
: Array
>> BTW, is there some reason why you are implementing your own build
>> recipes for OCaml (note that at the moment you recipes are missing
>> such things as dependency scanning, which may result in all kinds of
>> problems) instead of using the existing build/OCaml.om that comes with
>> OMake?
>>
>
> I cannot use the latest and greatest version OMake which has the
> required recipes for menhir. I am therefore trying to use the files
> provided in its demos (by changing the compilation parameters).
What version of OMake are you currently using? Unless you are using
something very ancient, it might be easier to try backporting a newer
OCaml.om (at least the relevant parts of it) than to write one from
scratch. An additional benefit of backporting, of course, is that it
should then be easier to switch to a more recent version of OMake in the
future.
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