|
Boost-Build : |
From: Craig Rodrigues (rodrigc_at_[hidden])
Date: 2005-06-24 11:28:39
On Sun, Jun 19, 2005 at 02:36:56PM -0500, Rene Rivera wrote:
> Or perhaps you meant the command to be: rule SHELL ( shellcmd ) ?
Yes, that is what I meant.
> Also the builtin doesn't compile when "popen" is not available in the
> runtime library, for example in the case of the MSL.
Can you define NO_POPEN in jam.h for platforms which do not support popen()?
My suggestion is to put the SHELL stuff inside a "#ifndef NO_POPEN"
block.
> And to add more
> work for you, documentation for the new builtin should be added to
> boost-root/tools/build/jam_src/index.html.
I didn't add documentation yet.
Index: builtins.c
===================================================================
RCS file: /cvsroot/boost/boost/tools/build/jam_src/builtins.c,v
retrieving revision 1.41
diff -u -u -r1.41 builtins.c
--- builtins.c 24 May 2005 07:57:55 -0000 1.41
+++ builtins.c 24 Jun 2005 16:23:37 -0000
@@ -317,6 +317,10 @@
builtin_flags, T_FLAG_NOUPDATE, 0 );
}
+# ifndef NO_POPEN
+ bind_builtin( "SHELL", builtin_shellcmd, 0, 0 );
+# endif
+
/* Initialize builtin modules */
init_set();
init_path();
@@ -1604,3 +1608,43 @@
}
#endif
+
+
+#ifndef NO_POPEN
+
+LIST *builtin_shellcmd( PARSE *parse, FRAME *frame )
+{
+#if defined(_MSC_VER) || defined(__BORLANDC__)
+ #define popen _popen
+ #define pclose _pclose
+#endif
+int i;
+ LIST* arg = lol_get( frame->args, 0 );
+ LIST* result = 0;
+ string s[1];
+ char buffer[1024];
+ int ret;
+ FILE *p = NULL;
+
+ fflush(NULL);
+
+ p = popen(arg->string, "r");
+ if ( p == NULL )
+ return L0;
+
+ string_new( s );
+
+ while ( (ret = fread(buffer, sizeof(char), sizeof(buffer)-1, p)) > 0) {
+ buffer[ret+1] = 0;
+ string_append( s, buffer );
+ }
+
+ result = list_new( L0, newstr(s->value) );
+
+ pclose(p);
+ string_free(s);
+ return result;
+}
+
+#endif
+
Index: builtins.h
===================================================================
RCS file: /cvsroot/boost/boost/tools/build/jam_src/builtins.h,v
retrieving revision 1.19
diff -u -u -r1.19 builtins.h
--- builtins.h 24 May 2005 07:57:55 -0000 1.19
+++ builtins.h 24 Jun 2005 16:23:37 -0000
@@ -47,6 +47,10 @@
LIST *builtin_check_if_file( PARSE *parse, FRAME *frame );
LIST *builtin_python_import_rule( PARSE *parse, FRAME *frame );
+#ifndef NO_POPEN
+LIST *builtin_shellcmd( PARSE *parse, FRAME *frame );
+#endif
+
void backtrace( FRAME *frame );
#endif
-- Craig Rodrigues rodrigc_at_[hidden]
Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk