I have a Ruby gem with a native extension that I am building with a Rake compiler ExtensionTask. I would like to take some action after the extension is built based on information calculated in extconf.rb
. I tried writing the information to global variables in extconf.rb
and then accessing those globals in the Rakefile, but they were empty. Is there any way to transfer that information to the Rakefile?
Asked
Active
Viewed 43 times
2

murgatroid99
- 19,007
- 10
- 60
- 95
1 Answers
0
Rake compiler calls extconf.rb
in a subprocess (here), so you cannot access data from variables (constants for instance) from the Rakefile
afterwards, at least not directly.
Basically, you want to communicate between two distinct processes. There are many tools for this, unix or Ruby. Here are some options:
- write to a temporary file serialized data (I'd go for
JSON
), and read it afterward. Less involved option, but more than enough for most use cases - Use a FIFO special file with
File.mkfifo
, and read from it in another thread. - Use
DRb
, you will still need toThread.fork
.
P.S: I see now it was asked so long ago, if you found a solution, I'd be glad to see it!

Ulysse BN
- 10,116
- 7
- 54
- 82