Accessing @-variables from run scripts

Skip to first unread message

David Joaquín Shourabi Porcel

Jul 8, 2020, 7:15:46 AM7/8/20
to tup-users

What is the best way for run scripts to access @-variables?

I found out about the vardict file, whose path is passed to run scripts via the tup_vardict environment variable. However, neither its existence nor its format are documented. Is it meant to be used by run scripts?

Its format seems to be:
  1. First, a dump of the unsigned int holding the amount of @-variables. In my platform, that's 4 bytes and little endian.
  2. Then, the index, as a series of unsigned ints (again 4 bytes each and little endian on my platform). Each value represents the offset at which the corresponding variable starts (after the index).
  3. Finally, a 0-ended line for each @-variable, with the equal sign between the variable and its value.
Is my understanding right? If so, could the format be made more portable, instead of depending on the platform's type sizes and endianness? Could we perhaps switch to JSON instead? I would be happy to author the necessary changes.

Passing the value of the @-variable in the Tupfile would also work:

run ./ @(FOOBAR)

However, the vardict approach would be cleaner.

Kind regards,

Reply all
Reply to author
0 new messages