News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Pre-build Squirrel scripting question

Started by ironhead, December 01, 2009, 04:25:25 PM

Previous topic - Next topic

ironhead

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!

MortenMacFly

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...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

ironhead

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

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

ironhead

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

ironhead

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?

MortenMacFly

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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

ironhead

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.