User forums > Using Code::Blocks
Script C::B
Jenna:
--- Quote from: Pecan on December 07, 2011, 01:19:04 pm ---
--- Quote from: jens on December 06, 2011, 08:24:53 pm ---FilesList * ProjectBuildTarget::GetFilesList() seems not to work. It was implemented in svn r1433, but m_Files (the member-variable, that is returned) was never filled as far as I can see after a quick look.
It's only used in Export targets as project, if I see correctly, and I nevr used this option, so I do not know, if it ever worked as expected.
--- End quote ---
It looks quite confusing, but I think you'll find that m_Files in ProjectBuildTarget is filled by the project loader when the targets are built by ProjectFile.
--- End quote ---
I found this and have fixed the export_target_to_project-function (this was indeed broken after switching to wxHashSet, stupid comparison-error) in trunk in the meantime.
@LETARTARE (and of course everybody who is interested):
Can you please test the attached patch ?
It reimplements GetFile(index) for projects and implements it for (projectbuild-)targets.
To get the buildtargets of a projectfile, I use your first approach (the same way it is doen for compilerVar).
I only tested it with the make_dist.script until now (no time at the moment).
EDIT:
Patch updated: http://forums.codeblocks.org/index.php/topic,15596.msg105399.html#msg105399
LETARTARE:
thanks
I try ...
LETARTARE:
tested with /
Vista Basic Pack 2? Mingw32 with TDM-GCC 4.4/4.5 Series
Code:: Blocks SVN 7620
===> 'Int ProjectBuildTarget::GetFilesCount ()' <===
===> 'ProjectFile * ProjectBuildTarget::GetFile (int)' <===
using the script 'lisfilestarget.script' as follows:
--- Code: ---///-----------------------------------------------------------------------------
/// use new methods (patch 'reimplement_GetFile_index_20111207-1.patch')
/// ===> 'int ProjectBuildTarget::GetFilesCount()' <===
/// ===> 'ProjectFile * ProjectBuildTarget::GetFile(int)' <===
/// svn in 7887 .. 7600
///-----------------------------------------------------------------------------
///-----------------------------------------------------------------------------
/// display all files targets
// affiche tous les fichiers de chaque cible
///-----------------------------------------------------------------------------
class DisplayAllFilesTargets extends cbScriptPlugin {
/// members
// membres
VERSION = _T("0.3.0");
///-----------------------------------------------------------------------------
/// mandatory to init script plugin
// obligatoire pour initialiser le script d'extension
///-----------------------------------------------------------------------------
constructor() {
/// constructor base class
// constructeur de la classe de base
cbScriptPlugin.constructor();
/// setup the plugin's info
// les informations de l'extension
info.name = _T("DisplayAllFilesTargets");
info.title = _("Display files targets");
info.version = VERSION;
info.license = _T("GPL");
}
///-----------------------------------------------------------------------------
/// to create context menu entries
// pour créer les entrées du menu de contexte
///-----------------------------------------------------------------------------
function GetModuleMenu(who, data) {
local entries = ::wxArrayString();
if (who == ::mtProjectManager) {
entries.Add(_("Display files targets"), 1);
}
return entries;
}
///-----------------------------------------------------------------------------
/// calback for context menu items clicking
// évènement lors d'une action sur les entrées du menu de contexte
///-----------------------------------------------------------------------------
function OnModuleMenuClicked(index) {
main();
}
///-----------------------------------------------------------------------------
///displays all files of each target on script console
// affiche dans la console de script, les fichiers de chaque cible
///-----------------------------------------------------------------------------
function main() {
/// general
local Project = GetProjectManager().GetActiveProject();
local Ntargets = Project.GetBuildTargetsCount() ;
//----------------------------------------------
/// file relative name
// le nom relatif d'un fichier
local file;
local target;
local nfiles;
local i=0;
/// informations
local Mes = _T("Project : '") + Project.GetTitle() + _T("' : ") ;
Mes += Project.GetFilesCount().tostring() + _T(" files, ") ;
Mes += Ntargets.tostring() + _T(" targets : ") ;
::print(Mes );
/// all project targets
// toutes les cibles du projet
for (local ti=0; ti < Ntargets ; ti++ ) {
target = Project.GetBuildTarget(ti) ;
Mes = _T("\nTarget ") + ti.tostring() + _T(" : '") ;
Mes += target.GetFullTitle() + _T("'") ;
::print(Mes);
///------------- patch to 'ProjectBuildTarget' class ---------------------------
nfiles = target.GetFilesCount();
///-----------------------------------------------------------------------------
/// all files target
// tous les fichiers d'une cible
for (local nf =0 ; nf < nfiles ; nf++) {
///------------- patch to 'ProjectBuildTarget' class ---------------------------
file = target.GetFile(nf).relativeFilename;;
///-----------------------------------------------------------------------------
::print (_T(" ") + nf.tostring() + _T(" : '") + file + _T("'"));
i++;
}
}
::print(_T("\nTotal files associated to targets : ") + i.tostring());
}
///-----------------------------------------------------------------------------
} /// class end
///-----------------------------------------------------------------------------
/// this call actually registers the script plugin with Code::Blocks
// register le script d'extension dans Code::Blocks
///-----------------------------------------------------------------------------
RegisterPlugin(DisplayAllFilesTargets());
///-----------------------------------------------------------------------------
--- End code ---
===> 'ProjectFile * cbProject::GetFile (int)' <===
using 'make_dist.script' and 'find_broken_files.script'
works very well.
LETARTARE:
I forgot 'wxArrayString ProjectFile::buildtargets', I go back!
LETARTARE:
Here is the test forgot ...
===> 'ProjectFile * cbProject::GetFile int()' <===
===> 'wxArrayString ProjectFile.buildTargets' <===
using the script 'lisfilesproject.script' as follows:
--- Code: ---/*******************************************************************************
* Name: listfilesproject.script
* Purpose: Script plugin in CODE::BLOCKS
* Author: LETARTARE (http://forums.codeblocks.org)
* Created: 2011-12-08
* Version 0.3.0
* Copyright: LETARTARE
* License: GPL
******************************************************************************/
///-----------------------------------------------------------------------------
/// use new methods (patch 'reimplement_GetFile_index_20111207-1.patch')
/// ===> 'ProjectFile * cbProject::GetFile(int)' <===
/// ===> 'wxArrayString ProjectFile::buildTargets' <===
/// svn in 7888 .. 7600
///-----------------------------------------------------------------------------
///-----------------------------------------------------------------------------
/// display all files projects with cibles
// affiche tous les fichiers avec leurs cibles
///-----------------------------------------------------------------------------
class DisplayAllFilesProject extends cbScriptPlugin {
/// members
// membres
VERSION = _T("0.3.0");
///-----------------------------------------------------------------------------
/// mandatory to init script plugin
// obligatoire pour initialiser le script d'extension
///-----------------------------------------------------------------------------
constructor() {
/// constructor base class
// constructeur de la classe de base
cbScriptPlugin.constructor();
/// setup the plugin's info
// les informations de l'extension
info.name = _T("DisplayAllFilesProject");
info.title = _("Display files project");
info.version = VERSION;
info.license = _T("GPL");
}
///-----------------------------------------------------------------------------
/// to create context menu entries
// pour créer les entrées du menu de contexte
///-----------------------------------------------------------------------------
function GetModuleMenu(who, data) {
local entries = ::wxArrayString();
if (who == ::mtProjectManager) {
entries.Add(_("Display files project"), 1);
}
return entries;
}
///-----------------------------------------------------------------------------
/// calback for context menu items clicking
// évènement lors d'une action sur les entrées du menu de contexte
///-----------------------------------------------------------------------------
function OnModuleMenuClicked(index) {
main();
}
///-----------------------------------------------------------------------------
///displays all files of each target on script console
// affiche dans la console de script, les fichiers de chaque cible
///-----------------------------------------------------------------------------
function main() {
/// general
local Project = GetProjectManager().GetActiveProject();
local Ntargets = Project.GetBuildTargetsCount() ;
local Nf = Project.GetFilesCount();
//----------------------------------------------
/// file relative name
local name;
/// informations
local Mes = _T("Project : '") + Project.GetTitle() + _T("' : ") ;
Mes += Nf.tostring() + _T(" files, ") ;
Mes += Ntargets.tostring() + _T(" targets : ") ;
::print(Mes );
/// array targets
local tabtargets;
local nt;
local target;
local prjfile;
// all files
for (local u =0 ; u < Nf; u++ ) {
///------------------ patch to 'Project' class ---------------------------------
prjfile = Project.GetFile(u);
///-----------------------------------------------------------------------------
name = prjfile.relativeFilename
/// copy
///----------------- patch to 'ProjectFile' class ------------------------------
tabtargets = prjfile.buildTargets;
///-----------------------------------------------------------------------------
nt = tabtargets.GetCount();
Mes = u.tostring() + _T("- '") + name + _T("'") ;
Mes += _T(" is linked to ") + nt.tostring() + _T(" target(s)")
::print(Mes);
Mes = _T("");
/// all file targets
for (local t=0; t < nt; t++) {
target = tabtargets.Item(t);
Mes += _T(" '")+ target + _T("',") ;
}
::print (Mes);
}
}
///-----------------------------------------------------------------------------
} /// class end
///-----------------------------------------------------------------------------
/// this call actually registers the script plugin with Code::Blocks
// register le script d'extension dans Code::Blocks
///-----------------------------------------------------------------------------
RegisterPlugin(DisplayAllFilesProject());
///-----------------------------------------------------------------------------
--- End code ---
everything is working properly.
@jens
How do svn <= 7587 (at least for release 10.05 and svn7550) ?
secondly, why allow access directly to the attributes of 'ProjectFile'?
why not use access methods such as 'GetBuildTargets ()' or 'GetRelativeFilename' because the user does not have to change these variables?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version