[Omake] Newbie: removing quotes for command
Hugo Ferreira
hmf at inescporto.pt
Wed Mar 21 10:09:19 PDT 2007
Hello,
Aleksey Nogin wrote:
> On 21.03.2007 07:00, Hugo Ferreira wrote:
>
>> I have used:
>> INCLUDE = $(addprefix -I , $(INCLUDES))
>> and
>> INCLUDE = $(mapprefix -I , $(INCLUDES))
>>
>> But when the target executes I get:
>>
>> ocamlc "-I " . "-I " ../res_stck "-I " ../qalist "-I " ../term "-I "
>> ../symbl_tbl "-I " ../compile -dtypes -g -c parser.mli
>>
>> ...which breaks. How do I get rid of the quotes to obtain:
>>
>> ocamlc -I . -I ../res_stck -I ../qalist -I ../term -I ../symbl_tbl -I
>> ../compile -dtypes -g -c parser.mli
>
> The issue here is that in OMake the spaces are, in general, significant.
> Your addprefix call had a space before the "," and that is where the
> "extra" spaces came from. The quotes is just something that the
> pretty-printer added to emphasize that the arguments contain spaces,
> they are not a part of the actual value.
>
Ok. Easy enough to understand.
> In general, for figuring out things like that, I would recommend using
> OMake's interactive shell osh that makes it easy to see what's going on.
>
> E.g. consider the following in osh
>
> % 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).
> 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).
>> I have even attempted to use my own function:
>>
>> F(X, Y) =
>> T =
>> foreach (Z, $(X))
>> T = $(T)$(Y)$(Z)
>>
>> #INCLUDE = $( F $(INCLUDES), -I )
>
> Same here - you left a space before the ")"!
>
>> Can anyone also explain how/why/when values are converted to/from a
>> string?
>
> This is a really good question. Unfortunately, this is not as systematic
> as it probably should be and is not much documented yet.
>
> In general:
> - An explicit quotation ($"..." or $'...') would give you a string.
>
> - A significant number of built-in functions turn (some of) their
> arguments into a string or a list of strings (breaking over the unquoted
> whitespace and array boundaries). For example,
> - String:
> case, match (the argument being matched)
> getenv, setvar, concat, removeprefix (first argument)
> setenv, get-registry, getvar (all arguments)
> split (separator argument, when given)
> - List of strings:
> string, string-escaped, quote, defined, defined-env, unsetenv
> (the first and only argument)
> equal (both arguments)
> split, concat, removeprefix (last argument)
> addsuffixes (first argument)
>
> Usually, the functions only do that "when they need to do a string-like
> operation on its argument". For example, the split function has to
> manipulate a string representation of its argument, and the same is true
> for the removesuffix. On the other hand, addsuffix is not really a
> string operation (any two values can be concatenated, they do not really
> have to be strings for that), so it does not stringify its argument.
> Some functions, however, do stringify their arguments a bit
> inappropriately - for example, addsuffixes currently does, although it
> probably should not.
>
> At the moment, the only way to figure this out for sure (other than
> manually testing) is to find the code for a built-in function in the
> src/builtin directory of the source tree -
> http://svn.metaprl.org/viewvc/mojave/omake-branches/0.9.8.x/src/builtin/
> - and look for instances of the string_of_value and strings_of_value
> calls :-(
>
So if I want to place the prefix -I to the path, but separated by a
space so that "ocamlc" may function, how should I go about it.
TIA,
Hugo Ferreira.
> Aleksey
>
More information about the Omake
mailing list