The "root" command doesn't currently provide for an easy way to specify a search path for header files. For example, many of my ROOT macros reference header files using the "#include" directive, but these header files often reside in other directories. I needed an easy way, similar to the "-I" flag of compilers, to specify such a search path, so I wrote the "root_wrap" utility to provide this functionality. There are, of course, other mechanisms to adjust ROOT's "include path" (and as a matter of fact, "root_wrap" uses one of these mechanisms), but I have found that none are as easy to use or familiar as throwing "-I" flags at "root". The "root_wrap" utility is a wrapper around the "root" command that makes multiple occurrences of the "-I" flag work the way you would expect it to. To use "root_wrap", simply invoke it in the same way as you would normally invoke the "root" command. It will look for occurrences of the "-I" flag and make "root" Do The Right Thing w.r.t. the include path. All other flags are simply passed through to the real "root" command. I have attached the "root_wrap" utility to this e-mail, since it is so tiny. However, it is also available in its own package at ftp://ftp.slac.stanford.edu/users/langston/root/root_wrap-0.1.2.tar.gz Enjoy :-) -- Matthew D. Langston SLD, Stanford Linear Accelerator Center langston@SLAC.Stanford.EDU NAME root_wrap - a wrapper for the root command that makes multiple occurrences of -I work properly. SYNOPSIS root_wrap [-I<path1> -I<path2> ...] [standard ROOT options] DESCRIPTION This script is a wrapper for the root command that makes multiple occurrences of the -I flag work properly. Simply invoke this script in the same way as you would normally execute the root command. This script will look for occurences of the -I flag and make root *Do The Right Thing* w.r.t. the include path. All other flags passed to this script are mostly ignored and simply passed through to the root command. EXAMPLE $ root_wrap -Iproj1 -Iproj2 main.cxx $ ls -R main.cxx proj1/ proj2/ proj1: Foo.hxx proj2: Bar.hxx $ cat main.cxx #include "Foo.hxx" #include "Bar.hxx" int main( int argc, char* argv[] ) { Foo foo; Bar bar; } BUGS None that I am aware of at this time. AUTHOR Matthew D. Langston langston@SLAC.Stanford.EDU COPYRIGHT Copyright (C) 1999 Matthew D. Langston <langston@SLAC.Stanford.EDU> LICENSE This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. For a copy of the GNU General Public License, write to: Free Software Foundation, Inc. Suite 330 59 Temple Place Boston, MA 02111-1307, USA. #! /usr/bin/perl -w =head1 NAME B<root_wrap> - a wrapper for the B<root> command that makes multiple occurrences of B<-I> work properly. =head1 SYNOPSIS root_wrap [-I<path1> -I<path2> ...] [standard ROOT options] =head1 DESCRIPTION This script is a wrapper for the B<root> command that makes multiple occurrences of the B<-I> flag work properly. Simply invoke this script in the same way as you would normally execute the B<root> command. This script will look for occurences of the B<-I> flag and make B<root> I<Do The Right Thing> w.r.t. the include path. All other flags passed to this script are mostly ignored and simply passed through to the B<root> command. =head1 EXAMPLE $ root_wrap -Iproj1 -Iproj2 main.cxx $ ls -R main.cxx proj1/ proj2/ proj1: Foo.hxx proj2: Bar.hxx $ cat main.cxx #include "Foo.hxx" #include "Bar.hxx" int main( int argc, char* argv[] ) { Foo foo; Bar bar; } =head1 BUGS None that I am aware of at this time. =head1 AUTHOR Matthew D. Langston B<langston@SLAC.Stanford.EDU> =head1 COPYRIGHT Copyright (C) 1999 Matthew D. Langston <langston@SLAC.Stanford.EDU> =head1 LICENSE This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. For a copy of the GNU General Public License, write to: Free Software Foundation, Inc. Suite 330 59 Temple Place Boston, MA 02111-1307, USA. =cut use strict; use vars qw( $VERSION ); $VERSION = "0.1.2"; use IO::File; use POSIX qw( tmpnam ); # Scan the command line for things we want to massage. my @includes; my @flags; my @macros; foreach ( @ARGV ) { SWITCH: { # Look for "-I" options. /^-I(.+)/ && do { push( @includes, $1 ); last SWITCH; }; # Look for all other flags. /^-/ && do { push( @flags, $_ ); last SWITCH; }; # Everything else must be a macro file that the user wants to # execute. push( @macros, $_ ); } } # Look for the "help" or "usage" options(s) so that we can print our own # custom usage message in addition to ROOT's build-in usage message. foreach ( @flags ) { usage() and last if /^-(?:h|\?)$/; } # $tmp_file_name is a temporary file of cint pragmas which adds # directories to the search list for "#include" statements. This # temporary file is deleted when root exits. my $tmp_file_name = ""; if ( @includes ) { my $fh; # Try new temporary file names until we get one that didn't already # exist. do { $tmp_file_name = tmpnam() . ".C" } until $fh = new IO::File( $tmp_file_name, O_RDWR | O_CREAT | O_EXCL ); # Install atexit-style handler so that when we exit or die, we # automatically delete this temporary file. END { if ( length( $tmp_file_name ) > 0 ) { unlink( $tmp_file_name ) or die "Couldn't unlink $tmp_file_name: $!"; } } print $fh "{"; print $fh "#ifdef __CINT__$/"; foreach ( @includes ) { print $fh "#pragma includepath \"$_\"$/"; } foreach ( @macros ) { print $fh "gROOT->ProcessLine( \".x $_\" );$/"; } print $fh "#endif$/"; print $fh "}"; @ARGV = @flags; } my $rc = system( "root @ARGV $tmp_file_name" ); exit( $rc ); sub usage() { my $fh = *STDERR; print $fh <<\EOF; Usage: root_wrap [-I<path>] [standard ROOT options] -I<path> Add the directory <path> to the head of the list of directories to be searched for header files. If you use more than one "-I" option, the directories are scanned in left-to-right order. standard ROOT options All of ROOTs standard options are passed to ROOT unmodified: EOF } __END__
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:39 MET