Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Script hooks added to build system
mandrav:
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:
--- Code: ---void SetBuildOptions(CompileOptionsBase@ base);
void UnsetBuildOptions(CompileOptionsBase@ base)
--- End code ---
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:
--- Code: (cpp) ---// 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);
}
--- End code ---
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]
takeshimiya:
<- :o :o Amazing! I've thinking something like that for a long time. If C::B was powerful, now it's more! :D
I'll try it when I conclude something on another build system I'm trying.
PS: Yiannis, can you update AngelScript to 2.5.0 (latest stable), so I can diff the patch to fix 64 bits compilation?
mandrav:
--- Quote from: Takeshi Miya on January 21, 2006, 10:47:55 pm ---PS: Yiannis, can you update AngelScript to 2.5.0 (latest stable), so I can diff the patch to fix 64 bits compilation?
--- End quote ---
Sure, I already planned to. I will do it tomorrow.
duncanka:
I haven't yet played around with this feature (don't have the build yet), but I have 2 questions about its usage:
1. Doesn't this risk a CB project version of DLL hell, with build settings located in far-flung files unlinked to the project? Should there be some sort of management system to prevent you from going crazy trying to figure out where in your build process the build options you've set are being altered?
2. Might it be possible to set up a special dialog to create a build options dialog specifically for generating scripts? Like, instead of clicking "OK" on the dialog to set the options for the project, you would click "Generate script" and it would save the settings you entered as a script?
Anyway, kudos on a really cool feature! :D
rickg22:
Uk not understand scripting hooks... Uk thinks spooky magic. Uk stays away :lol:
(Translation: Can somebody explain a little further please? :) thanks! )
Navigation
[0] Message Index
[#] Next page
Go to full version