I'm trying to get a pre-build step to check to see if a file exists, to that end I have:
[[ if ( !exist( "svnversion.h" ) ) { printl( "Hello" ); } ]]
But I get an error stating "the index 'exist' does not exist".
Can someone please point out what I'm doing wrong?
Thank you!
Quote from: ironhead on December 01, 2009, 04:25:25 PM
Can someone please point out what I'm doing wrong?
"exist" and "printl" are not valid Squirrel script functions. They are not even C++ btw...
Quote from: MortenMacFly on December 01, 2009, 05:14:09 PM
"exist" and "printl" are not valid Squirrel script functions. They are not even C++ btw...
Hrmm... interesting, I got 'exist' and 'printl' from:
http://www.ibm.com/developerworks/aix/library/au-spunix_squirrel/index.html (http://www.ibm.com/developerworks/aix/library/au-spunix_squirrel/index.html)
Is there definitive guide as to what functions are provided in the version of squirrel used by C::B?
I tried using the 'file' command:
[[ local svnfile = file("svnversion.h", "r"); if ( !svnfile ) { printl( "Hello" ); } ]]
But also received an error: "the index 'file' does not exist"
Yet, as I understand it, it should have worked (at least attempted to read the file):
http://squirrel-lang.org/doc/sqstdlib2.html#d0e159 (http://squirrel-lang.org/doc/sqstdlib2.html#d0e159)
I've got it to work:
[[ local svnfile = _T("svnversion.h"); local svncmd = _T("cmd /c svn info --revision HEAD | grep Revision | sed -f svnversion.sed > svnversion.h"); if ( !IO.FileExists(svnfile) ) { IO.Execute(svncmd); } ]]
My question is, is IO.Execute the best way to make a system call?
Quote from: ironhead on December 02, 2009, 12:42:50 PM
My question is, is IO.Execute the best way to make a system call?
Yes. Notice the C::B script security must be configured correctly to allow (system) IO calls.
Quote from: MortenMacFly on December 02, 2009, 03:26:13 PM
Quote from: ironhead on December 02, 2009, 12:42:50 PM
My question is, is IO.Execute the best way to make a system call?
Yes. Notice the C::B script security must be configured correctly to allow (system) IO calls.
Agreed... I had to allow the script to launch executables
Is it possible to have the Pre-build step call a script? I tried with:
[[ Include(_T("svnversion.script")); GenerateSvnVersion(); ]]Where svnversion.script contained the GenerateSvnVersion() function. It gave me an error when I tried this implementation.