Author Topic: Pre-build Squirrel scripting question  (Read 8726 times)

Offline ironhead

  • Almost regular
  • **
  • Posts: 210
Pre-build Squirrel scripting question
« on: December 01, 2009, 04:25:25 pm »
I'm trying to get a pre-build step to check to see if a file exists, to that end I have:

Code
[[ 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!
« Last Edit: December 01, 2009, 04:28:09 pm by ironhead »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: Pre-build Squirrel scripting question
« Reply #1 on: December 01, 2009, 05:14:09 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...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline ironhead

  • Almost regular
  • **
  • Posts: 210
Re: Pre-build Squirrel scripting question
« Reply #2 on: December 01, 2009, 05:48:50 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

Is there definitive guide as to what functions are provided in the version of squirrel used by C::B?

Offline ironhead

  • Almost regular
  • **
  • Posts: 210
Re: Pre-build Squirrel scripting question
« Reply #3 on: December 01, 2009, 07:06:21 pm »
I tried using the 'file' command:

Code
[[ 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

Offline ironhead

  • Almost regular
  • **
  • Posts: 210
Re: Pre-build Squirrel scripting question
« Reply #4 on: December 02, 2009, 12:42:50 pm »
I've got it to work:

Code
[[ 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?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: Pre-build Squirrel scripting question
« Reply #5 on: December 02, 2009, 03:26:13 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline ironhead

  • Almost regular
  • **
  • Posts: 210
Re: Pre-build Squirrel scripting question
« Reply #6 on: December 02, 2009, 03:52:45 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:

Code
[[ Include(_T("svnversion.script")); GenerateSvnVersion(); ]]

Where svnversion.script contained the GenerateSvnVersion() function.  It gave me an error when I tried this implementation.