[omake] Is there a way to 'export' variable value from sub-OMakefile to parent?

Gerd Stolpmann info at gerd-stolpmann.de
Sun Feb 21 11:24:36 GMT 2016


Am Mittwoch, den 17.02.2016, 18:21 +0900 schrieb Nozomi Shibano:
> Hi,
> 
> I had a general question. Please help if someone had answer. (Also
> advise if I should ask this question in other place.)
> 
> Is there any way to 'export' variable value from sub-OMakefile to
> parent? Sometimes I want to declare 'accumulator' variable in root
> OMakefile and append to it in sub-OMakefiles using += operator, and
> then do some task with accumulated values in root OMakefile. For
> example, accumulate paths of all .o files in sub-directories and link
> them into single .exe file in the root directory.
> 
> It seems to me that, it is not possible.

Right, normal .SUBDIRS (w/o section) always starts a new environment,
and there is no way to export updated variables.

>  (Exceptionally, when
> sub-OMakefile is written as .SUBDIRS section in root OMakefile,
> 'export' command works for this purpose.) 

Based on this observation, here is an idea: maybe the combo .SUBDIRS
section with "include" works:

.SUBDIRS: dir
    include OMakefile
    export variable

This is not tested, though.

Note that a simple "include dir/OMakefile" would not work because the
rules in OMakefile wouldn't then be applied to the subdirectory.

Gerd

> Passing information from
> sub-OMakefile to parent is only possible via target file in sub
> directory and dependency to it from root OMakefile. For above example
> case, I have to link .o files into .a file in sub-OMakefile and
> declare dependency from .exe to that .a file in root OMakefile. Is
> this correct understanding?
> 
> Regards,
> Nozomi Shibano
> _______________________________________________
> Omake mailing list
> Omake at lists.ocaml.org
> http://lists.ocaml.org/listinfo/omake

-- 
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany    gerd at gerd-stolpmann.de
My OCaml site:          http://www.camlcity.org
Contact details:        http://www.camlcity.org/contact.html
Company homepage:       http://www.gerd-stolpmann.de
------------------------------------------------------------

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: This is a digitally signed message part
URL: <http://lists.ocaml.org/pipermail/omake/attachments/20160221/f672e7da/attachment.sig>


More information about the Omake mailing list