It's true. Finally AngelScript will be used for something in C::B
Here's a little overview of the new feature.
You can attach one or more scripts to the project and/or any build targets. These scripts will be run in order just before the project/target (depending where the script is attached) gets built. Therefore it is obvious that using these scripts you can actually setup the whole build process.
Build hook scripts provide two functions:
void SetBuildOptions(CompileOptionsBase@ base);
void UnsetBuildOptions(CompileOptionsBase@ base)
Don't get confused by AngelsScript's handle symbol @. If you don't know what it is, ignore it . It's just used for reference counting.SetBuildOptions() runs before the project/target is built, while
UnsetBuildOptions() runs after the project/target has been built. The latter allows us to undo the changes
SetBuildOptions() has made
.
Here's a sample script that enables debugging symbols for GCC:
// Debug configuration
void SetBuildOptions(CompileOptionsBase@ base)
{
// remember state
bool wasModified = base.GetModified();
// compiler settings
base.AddCompilerOption("-O0");
base.AddCompilerOption("-ggdb");
// restore state
base.SetModified(wasModified);
}
void UnsetBuildOptions(CompileOptionsBase@ base)
{
// remember state
bool wasModified = base.GetModified();
// compiler settings
base.RemoveCompilerOption("-O0");
base.RemoveCompilerOption("-ggdb");
// restore state
base.SetModified(wasModified);
}
You would attach this script to any target that would produce a "Debug" output.
Simple stuff
By the way, CompileOptionsBase is a base class in C::B and the script supports it so look at sdk/compileoptionsbase.h to see what other methods you can use.
Why is this feature handy (to say the least)?
Because you do not need to setup anything in "Project->Build options". You can setup the whole project by just attaching scripts to the project/targets.
Also, because scripts are regular files, you can just copy/paste them to use them in other projects. Initial setup time becomes almost 0
, since you don't have to fiddle with all the options in "Project->Build options". Just copy some scripts from another project, attach them to your project/targets and build
.
Finally, I 've attached a sample wxWidgets project that uses build scripts so you can immediately see it in action (Project->Properties->Scripts).
Keep in mind that you will need revision 1825 for this to work.
I will be waiting for feedback
.
[attachment deleted by admin]