[Module-build-general] redirecting system() to a file, or ways to avoid it
Status: Beta
Brought to you by:
kwilliams
From: Ken W. <ke...@ma...> - 2002-11-26 23:23:40
|
Hey, In Module::Build, very little is done by the external system, but some things still are. One little thorn in its side is ExtUtils::xsubpp - which, despite living in @INC and having two colons in its name, is a script, not a module. In order to parse .xs files, this script needs to be called and its output redirected to a file. That's not usually a very hard task, but I've decided to use the multi-arg form of system() whenever possible, so that I don't have to handle argument quoting issues on all the platforms of the world. But the multi-arg form of system() doesn't let me do output redirects (which probably weren't portable across platforms anyway with single-arg system()). So I'm trying to think of the best alternative. Choices include: 1) Wrap all of the xsubpp code into a subroutine, set @ARGV, open STDOUT to a file, and call the subroutine. 2) Same as 1), but just do() the xsubpp file instead of making it a subroutine. 3) Write some function to convert multi-arg system() calls to safely-quoted single-arg system() calls, in a cross-platform way, with cross-platform support for output redirection. 4) Go back in time and re-implement ExtUtils::xsubpp as a bare-bones wrapper around an ExtUtils::ParseXS module. Module::Build can just call functions in ExtUtils::ParseXS, then. 5) Don't go back in time, but create an ExtUtils::ParseXS module nonetheless, which *future* versions of xsubpp could use as guts. Create a Module::Build dependency on ExtUtils::ParseXS and don't call xsubpp. 6) Borg all the xsubpp code into Module::Build where I can control it. Even though 1) and 2) are pretty ugly, I'm leaning toward doing one of them, if they'd work. 3) looks non-fun, and the further away I can get Module::Build and system() from each other, the better. 4) and 5) would be a lot of work, but probably the best from an architectural point of view. 4) would be really cool, actually. Note that 5) would create the first non-5.6-core dependency in Module::Build, though. And 6) seems like a bad idea. There's also: 7) Just write it as a single-arg, ad hoc system() call, don't worry about cross-platform issues, make those MacOS bastards live without XS compilation a little while longer, and only fix the quoting when someone tells me it's broken on VMS and Amiga, and Win95. Any thoughts before I act? -Ken |