"Global" or "build context" variables from sub projects

 

It would be nice to be able to mark variables in a project as "Global" or "build context", so they will be available in the parent project (after running the sub project).

I use a sub-project to do generic build steps that are needed in all my build scripts. This includes setting up build tools, validating the build environment (library versions, tools...) and setting up standard variables.

Right now if I add a variable to the sub project, it is only available during the execution of the sub project. The only work around is to use a "define variable" action, after this the variable will also be available in the parent project.
But for this to work, I have to remove the variable from the "project variable list", else the "define variable" action will not be executed (or not in a way that the variable is available in the parent project). This makes maintaining the sub project script difficult, as these "manually defined" variables are not available in the action drop downs.
 
I would suggest that you add a "build context" scope, additionally to the "Project", "User", "System" and "Environment" scopes. These variables in the "build context" scope will be shared by all scripts during a build. Additionally the script editor could run through all included build scripts when opening a script to enumerate the "build context" variables, to make them available in the script editor.
 
I hope this all makes sense, or else please do not hesitate to ask for me to elaborate on the concept.
 
Kind regards,
Christoph

 

Has there been any thoughts about supporting a "current build" variable context?

Best regards,

Christoph

Hi Christoph

I have been considering this issue, along with a bunch of other changes we would like to make to variables in general. The overriding consideration though is backwards compatibility.

As for loading the variables from included projects, that is just not practical since the included projects themselves may not be known at design time, and may change at runtime if variables are used.

I’m open to suggestions though. One thing we could do at design time is to add an option to import variable definitions from included projects… but that won’t solve the problem for everyone.

 

The global or "current build" context variables values would not be saved to the project file, only declared. And then the variables would only initialize when first found/loaded. It would be the responsibility of the developer to manage/prevent any clashes.
So the variable would be created and initialized during load of the first project which uses them. Following projects would see that the variable is already created, and therefor not initialize them.

So if you would like to use that same variable in both the parent and child projects, you would need to declare them in both projects. The variable would be instantiated in the parent project (sice it is the first project to declare it), and available in the child project. The child project would now be able to use the variable, and if it saves anything, this would also be available in the parent project.

So if the variable was not declared in the "build" context in the parent project, the variable would not be available in the parent project, only in the child projects which declared it. (Or the variable would not be available in the parent project IDE, for selection.)

I do not see any problems with backwards compatibility here (unless a 6.1 project should be able to execute in 5.x, 4.x,...)
But maybe you see some problems which might araise from this. Please let me know, and I am sure we can find a way araound

I admit this would be great, but now I'm seeing that in FB7, variables created with "Define Variable", while executing an included .fbp7 project, do not remain once that included project returns control to the parent build.

This makes it very difficult to have globally useful variables. Our build is absolutely huge and I have to have some way to allow variables to be defined anytime, either in the overriding master build process, or in any individual project. And the best way to do that is to load them with our _Global_Actions_Library.fbp7 ... only it's not working. The variables disappear when the child process that defines them has completed.

I'm not too proud to ask for help here.

How about this:

have a list of variables to set after the include project action has executed? so that you have a “Set variables before loading” and a “Set variables after running” lists.

Regards
Magni