Re: How to expand environment variable in compilation command?

Thomas Leonard <[email protected]>
Newsgroups gmane.comp.file-systems.zero-install.devel
Message-ID <CAG4opy8d3kgOyTvf+-9wXVbtgvE9=pqQya_8MvjjStgQhe3OBA@mail.gmail.com>
On 9 September 2015 at 16:08, Ilja Honkonen <[email protected]> wrote:
>> Most likely, using "shell-command" will override it. Try using some
>> <arg> elements instead. The literal expansion is:
>>     <runner interface='http://repo.roscidus.com/utils/bash'>
>>       <arg>-c</arg>
>>       <arg>"$$@"</arg>
>>       <arg>-</arg>
>>     </runner>
>>     <arg>c++</arg>
>>     <arg>${SRCDIR}/test.cpp</arg>
>>     ...
>
> for-each still seems to be ignored:
>
> ...
>      <command name = 'compile'>
>        <runner interface = '../lfs/bash/bash.xml'>
>        <!--runner interface = 'http://repo.roscidus.com/utils/bash'-->
>          <arg>-c</arg>
>          <arg>"$$@"</arg>
>          <arg>-</arg>
>        </runner>
>        <arg>c++</arg>
>        <arg>${SRCDIR}/test.cpp</arg>
>        <arg>-o</arg>
>        <arg>$DISTDIR/test</arg>
>        <for-each item-from = 'CPPFLAGS'><arg>-I ${item}</arg></for-each>
>        <compile:implementation arch = '*-*'>
>          <command name = 'test' path = 'test'></command>
>          <command name = 'run' path = 'test'></command>
>        </compile:implementation>
>      </command>
>      <requires interface = '../boost/boost.xml'>
>        <environment name = 'CPPFLAGS' insert = 'include' mode = 'append'>
>        </environment>
>      </requires>
> ...
>
> Executing:
> [u'/Users/iljah/.local/share/0install.net/site-packages/file/Users__iljah__0inst-test__lfs__bash__bash.xml/4.3.30-x86_64/bin/bash',
> u'-c', u'"$@"', u'-', u'c++', u'/Users/iljah/0inst-test/test/test.cpp',
> u'-o',
> u'/private/var/folders/ff/m6cylxhd2csdz9fh62g3djtm0000gq/T/0compile-VBoSvz/test-any-any/test']

Works for me, after two minor changes (my version attached):

- I used the original bash URL, not your local path (it should work
for you now you've downloaded bash with the OCaml version).

- I used a different interface (0compile) for the dependency, since
you used a local path.

I got:

Executing: [u'/bin/bash', u'-c', u'"$@"', u'-', u'c++',
u'/tmp/test.cpp', u'-o', u'/tmp/0compile-iA0bJX/test-any-any/test',
u'-I /home/tal/Projects/zero-install/0compile/include']

(note: you should remove the space after "-I" or split it into two arguments)


-- 
Dr Thomas Leonard        http://roscidus.com/blog/
GPG: DA98 25AE CAD0 8975 7CDA  BD8E 0713 3F96 CA74 D8BA

------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140

_______________________________________________
Zero-install-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/zero-install-devel
test.xml (text/xml, 1.1 KB)
<?xml version="1.0" ?>
<interface
   xmlns = 'http://zero-install.sourceforge.net/2004/injector/interface'
   xmlns:compile = 'http://zero-install.sourceforge.net/2006/namespaces/0compile' >
   <name>test</name>
   <summary>test</summary>
   <implementation id = '.' local-path = '.' version = '0.2' arch = '*-src'>
     <command name = 'compile'>
       <runner interface = 'http://repo.roscidus.com/utils/bash'>
         <arg>-c</arg>
         <arg>"$$@"</arg>
         <arg>-</arg>
       </runner>
       <arg>c++</arg>
       <arg>${SRCDIR}/test.cpp</arg>
       <arg>-o</arg>
       <arg>$DISTDIR/test</arg>
       <for-each item-from = 'CPPFLAGS'><arg>-I ${item}</arg></for-each>
       <compile:implementation arch = '*-*'>
         <command name = 'test' path = 'test'></command>
         <command name = 'run' path = 'test'></command>
       </compile:implementation>
     </command>
     <requires interface = '/home/tal/Projects/zero-install/0compile/0compile.xml'>
       <environment name = 'CPPFLAGS' insert = 'include' mode = 'append'/>
     </requires>
   </implementation>
</interface>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.