Author Topic: Script C::B  (Read 11111 times)

Offline LETARTARE

  • Regular
  • ***
  • Posts: 399
  • L'ami de l'homme.The friend of man.
Script C::B
« on: November 28, 2011, 04:48:31 pm »
hello,
I can not find how to retrieve only the files associated with a target (not project) ?.

reference:
http://wiki.codeblocks.org/index.php?title=Scripting_commands
C::B  : svn11972, wx-3.1.1, plugins : QtPregen-2.7.2-sdk147
1-Win 7 Business Pack 1 64bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.5., 8.1.0,
=> !! The messages are translated by Deepl !!

Offline LETARTARE

  • Regular
  • ***
  • Posts: 399
  • L'ami de l'homme.The friend of man.
Re: Script C::B
« Reply #1 on: November 29, 2011, 02:03:10 pm »
I found a solution which requires modifying C:: B:
Code: [Select]
Index: src/sdk/scripting/bindings/scriptbindings.cpp
===================================================================
--- src/sdk/scripting/bindings/scriptbindings.cpp (révision 7621)
+++ src/sdk/scripting/bindings/scriptbindings.cpp (copie de travail)
@@ -394,7 +394,8 @@
                 var(&ProjectFile::compile, "compile").
                 var(&ProjectFile::link, "link").
                 var(&ProjectFile::weight, "weight").
-                var(&ProjectFile::compilerVar, "compilerVar");
+                var(&ProjectFile::compilerVar, "compilerVar").
+                var(&ProjectFile::buildTargets, "buildTargets");
 
         SqPlus::SQClassDef<CompileOptionsBase>("CompileOptionsBase").
                 func(&CompileOptionsBase::AddPlatform, "AddPlatform").

- OS: Vista Basic Pack 2
           Mingw32 with TDM-GCC 4.4/4.5 Series
- Tools: Code:: Blocks  sn7550  and 7621

I tested this code (script) , it works well on svn7550

This function indicates whether the 'prjfileori' is assigned to at least one target (otherwise returns -1)

Code: [Select]
function connected(prjfileori, project) { // ProjectFile , cbProject
                local nt = project.GetBuildTargetsCount();
local ciori ;
local nameci;
local ci ;
for (ci = 0; ci < nt; ci++) {
nameci = project.GetBuildTarget(ci).GetTitle();
                // ====> use wxStringArray buildTargets  < =====
ciori = prjfilecori.buildTargets.Index(nomci);
if (ciori != -1) {
break;
}
}

return ciori;
}

Is that change is possible in C: B?
And how?
C::B  : svn11972, wx-3.1.1, plugins : QtPregen-2.7.2-sdk147
1-Win 7 Business Pack 1 64bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.5., 8.1.0,
=> !! The messages are translated by Deepl !!

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12361
    • Travis build status
Re: Script C::B
« Reply #2 on: November 29, 2011, 02:23:45 pm »
Yes, it is.

Some questions:
1. Can you mess with the targets for the file or does the buildTargets array acts as a const object in the script?
2. Do we want the scripts to mess with the targets for a file? (this question is at the other devs)


About the how question: one of the developers will commit it in svn, when it is ready:)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline LETARTARE

  • Regular
  • ***
  • Posts: 399
  • L'ami de l'homme.The friend of man.
Re: Script C::B
« Reply #3 on: November 29, 2011, 02:35:12 pm »
/**** Translation by Google ****/
Note: I have some translation problems ...

thank you for responding.
Quote
1. Can you mess with the targets for the file or does the buildTargets array acts as a const object in the script?
'const object in the script'
I prefer a access method , but I have not studied enough 'Script binding' for write this.

Quote
2. Do we want the scripts to mess with the targets for a file? (this question is at the other devs)
I hope so?
« Last Edit: November 29, 2011, 02:38:23 pm by LETARTARE »
C::B  : svn11972, wx-3.1.1, plugins : QtPregen-2.7.2-sdk147
1-Win 7 Business Pack 1 64bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.5., 8.1.0,
=> !! The messages are translated by Deepl !!

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12361
    • Travis build status
Re: Script C::B
« Reply #4 on: November 29, 2011, 02:47:42 pm »
Quote
1. Can you mess with the targets for the file or does the buildTargets array acts as a const object in the script?
'const object in the script'
I prefer a access method , but I have not studied enough 'Script binding' for write this.
Can you try to modify them and then tell me if it works or not?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline LETARTARE

  • Regular
  • ***
  • Posts: 399
  • L'ami de l'homme.The friend of man.
Re: Script C::B
« Reply #5 on: November 29, 2011, 02:49:34 pm »
I will try ...
C::B  : svn11972, wx-3.1.1, plugins : QtPregen-2.7.2-sdk147
1-Win 7 Business Pack 1 64bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.5., 8.1.0,
=> !! The messages are translated by Deepl !!

Offline LETARTARE

  • Regular
  • ***
  • Posts: 399
  • L'ami de l'homme.The friend of man.
Re: Script C::B
« Reply #6 on: November 30, 2011, 09:16:17 am »
hello,
@oBFusCATed
Here are the proposed amendment
Code: [Select]
Index: src/include/projectfile.h
===================================================================
--- src/include/projectfile.h (révision 7550)
+++ src/include/projectfile.h (copie de travail)
@@ -64,6 +64,11 @@
           * @param targetName The build target's name to remove this file from. */
         void RemoveBuildTarget(const wxString& targetName);
 
+        /**
+  * @return An array of strings, containing the names of all the build
+  * targets this file belongs to. */
+        wxArrayString GetbuildTargets();
+
         /** Show the file properties dialog.
           * @param parent The parent window for the dialog (can be NULL).
           * @return True if the user closed the dialog with "OK", false if closed it with "Cancel".
Index: src/sdk/projectfile.cpp
===================================================================
--- src/sdk/projectfile.cpp (révision 7550)
+++ src/sdk/projectfile.cpp (copie de travail)
@@ -130,6 +130,10 @@
         generatedFiles[i]->RemoveBuildTarget(targetName);
 }
 
+ wxArrayString ProjectFile::GetbuildTargets() {
+ return buildTargets;
+ }
+
 bool ProjectFile::ShowOptions(wxWindow* parent)
 {
     ProjectFileOptionsDlg dlg(parent, this);
Index: src/sdk/scripting/bindings/scriptbindings.cpp
===================================================================
--- src/sdk/scripting/bindings/scriptbindings.cpp (révision 7550)
+++ src/sdk/scripting/bindings/scriptbindings.cpp (copie de travail)
@@ -380,6 +380,7 @@
                 func(&ProjectFile::AddBuildTarget, "AddBuildTarget").
                 func(&ProjectFile::RenameBuildTarget, "RenameBuildTarget").
                 func(&ProjectFile::RemoveBuildTarget, "RemoveBuildTarget").
+                func(&ProjectFile::GetbuildTargets, "GetbuildTargets").
                 func(&ProjectFile::GetBaseName, "GetBaseName").
                 func(&ProjectFile::GetObjName, "GetObjName").
                 func(&ProjectFile::SetObjName, "SetObjName").

I tested
Code: [Select]
function connecte(prjfileori, project) { // ProjectFile , cbProject
local nt = project.GetBuildTargetsCount();
local ciori ;
local nameci;
for (local ci = 0; ci < nt; ci++) {
nameci = project.GetBuildTarget(ci).GetTitle();
// return 'wxStringArray' from 'buildTargets'
ciori = prjfileori.GetbuildTargets().Index(nomci);
if (ciori != -1)
break;
}
return ciori;
}

in svn7550, and version 10.05, it works ok.

For testing I use a script large that uses  'Project * GetFile (int)', which has not been around svn7587 and replaced by 'FilesList& GetFileList ()'. But no connection for scripts !!
How so ?
The scripts 'MortenMacFly'
Quote
find_broken_files.script
Quote
make_dist.script
no longer works ( -> svn 7587).
« Last Edit: December 01, 2011, 09:18:09 am by LETARTARE »
C::B  : svn11972, wx-3.1.1, plugins : QtPregen-2.7.2-sdk147
1-Win 7 Business Pack 1 64bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.5., 8.1.0,
=> !! The messages are translated by Deepl !!

Offline LETARTARE

  • Regular
  • ***
  • Posts: 399
  • L'ami de l'homme.The friend of man.
Re: Script C::B
« Reply #7 on: December 03, 2011, 01:34:01 pm »
@oBFusCATed
No comments ??
C::B  : svn11972, wx-3.1.1, plugins : QtPregen-2.7.2-sdk147
1-Win 7 Business Pack 1 64bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.5., 8.1.0,
=> !! The messages are translated by Deepl !!

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12361
    • Travis build status
Re: Script C::B
« Reply #8 on: December 04, 2011, 04:19:00 pm »
I'm not sure what you are trying to achieve with this new version...

"wxArrayString GetbuildTargets()" doesn't look, too good, I think I prefer "const wxArrayString& GetbuildTargets() const;".
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline LETARTARE

  • Regular
  • ***
  • Posts: 399
  • L'ami de l'homme.The friend of man.
Re: Script C::B
« Reply #9 on: December 06, 2011, 01:28:44 pm »
Translate by GOOGLE

Yes, of course, is much better.
Unfortunately, trying to svn7620, I found that 'Project * cbProject::GetFile (int)' was missing from svn 7588.
This method was replaced by 'FilesList * cbProject::GetFilesList()' and 'FilesList * ProjectBuildTarget::GetFilesList()', but without connection to the scripts !
I guess 'FileList' is difficult to link scripts.

For then there is no further access to a file indexing for scripts!
Also, most scripts become unusable.

Is this an oversight, or is it voluntary?
C::B  : svn11972, wx-3.1.1, plugins : QtPregen-2.7.2-sdk147
1-Win 7 Business Pack 1 64bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.5., 8.1.0,
=> !! The messages are translated by Deepl !!

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7253
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Script C::B
« Reply #10 on: December 06, 2011, 08:24:53 pm »
Translate by GOOGLE

Yes, of course, is much better.
Unfortunately, trying to svn7620, I found that 'Project * cbProject::GetFile (int)' was missing from svn 7588.
This method was replaced by 'FilesList * cbProject::GetFilesList()' and 'FilesList * ProjectBuildTarget::GetFilesList()', but without connection to the scripts !
I guess 'FileList' is difficult to link scripts.

For then there is no further access to a file indexing for scripts!
Also, most scripts become unusable.

Is this an oversight, or is it voluntary?

Project * cbProject::GetFile (int) was removed to speed up the loading time of large projects.
To make it possible I created FilesList * cbProject::GetFilesList(), but did not implement it for scripting. I am not sure, if this can be done easily. I will look into it.

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.

Offline LETARTARE

  • Regular
  • ***
  • Posts: 399
  • L'ami de l'homme.The friend of man.
Re: Script C::B
« Reply #11 on: December 07, 2011, 09:51:44 am »
Translation by Google
thank you very much for that.

Quote
but m_Files (the member-variable, that is returned) was never filled
not because I use it (see below)

I do not see how to implement the type 'FilesList', also waiting for your result, I  added the method
'virtual wxArrayString ProjectBuildTarget::GetFiles () const'

 svn> = 7588:
Code: [Select]
Index: src/include/projectbuildtarget.h
===================================================================
--- src/include/projectbuildtarget.h (révision 7622)
+++ src/include/projectbuildtarget.h (copie de travail)
@@ -115,6 +115,11 @@
         /** Provides an easy way to iterate all the files belonging in this target.
           * @return A list of files belonging in this target. */
         virtual FilesList& GetFilesList(){ return m_Files; }
+
+        /** Provides an easy way to iterate all the files belonging in this target.
+          * @return An array of files belonging in this target.*/
+ virtual wxArrayString GetFiles() const;
+
     private:
         friend class ProjectFile; // to allow it to add/remove files in FilesList
         cbProject* m_Project;
Index: src/sdk/projectbuildtarget.cpp
===================================================================
--- src/sdk/projectbuildtarget.cpp (révision 7622)
+++ src/sdk/projectbuildtarget.cpp (copie de travail)
@@ -44,6 +44,20 @@
     return m_Project->GetTitle() + _T(" - ") + GetTitle();
 }
 
+// get the list of files of this target
+wxArrayString ProjectBuildTarget::GetFiles() const
+{
+ wxArrayString filearray;
+ ProjectFile * pf;
+ FilesList::const_iterator it = m_Files.begin();
+ while (it != m_Files.end()) {
+ pf = *it++;
+ filearray.Add(pf->relativeFilename);
+ }
+
+ return filearray;
+}
+
 const wxString & ProjectBuildTarget::GetExternalDeps() const
 {
     return m_ExternalDeps;
Index: src/sdk/scripting/bindings/scriptbindings.cpp
===================================================================
--- src/sdk/scripting/bindings/scriptbindings.cpp (révision 7622)
+++ src/sdk/scripting/bindings/scriptbindings.cpp (copie de travail)
@@ -482,6 +482,7 @@
                 func(&CompileTargetBase::MakeCommandsModified, "MakeCommandsModified");
 
         SqPlus::SQClassDef<ProjectBuildTarget>("ProjectBuildTarget", "CompileTargetBase").
+ func(&ProjectBuildTarget::GetFiles, "GetFiles").
                 func(&ProjectBuildTarget::GetParentProject, "GetParentProject").
                 func(&ProjectBuildTarget::GetFullTitle, "GetFullTitle").
                 func(&ProjectBuildTarget::GetExternalDeps, "GetExternalDeps").

and svn6283 .. 7587 this:
Code: [Select]
Index: src/include/projectbuildtarget.h
===================================================================
--- src/include/projectbuildtarget.h (révision 6283)
+++ src/include/projectbuildtarget.h (copie de travail)
@@ -117,6 +117,10 @@
         /** Provides an easy way to iterate all the files belonging in this target.
           * @return A list of files belonging in this target. */
         virtual FilesList& GetFilesList(){ return m_Files; }
+ /** Provides an easy way to iterate all the files belonging in this target.
+          * @return An array of files belonging in this target.*/
+ virtual wxArrayString GetFiles() const;
+
     private:
         friend class ProjectFile; // to allow it to add/remove files in FilesList
         cbProject* m_Project;
Index: src/sdk/projectbuildtarget.cpp
===================================================================
--- src/sdk/projectbuildtarget.cpp (révision 6283)
+++ src/sdk/projectbuildtarget.cpp (copie de travail)
@@ -44,6 +44,20 @@
     return m_Project->GetTitle() + _T(" - ") + GetTitle();
 }
 
+// get the list of files of this target
+wxArrayString ProjectBuildTarget::GetFiles() const {
+ wxArrayString filearray;
+ ProjectFile * pf;
+ FilesList::Node * node = m_Files.GetFirst();
+ while (node) {
+ pf = node->GetData();
+ filearray.Add(pf->relativeFilename);
+ // the next
+ node = node->GetNext();
+ }
+ return filearray;
+}
+
 const wxString & ProjectBuildTarget::GetExternalDeps() const
 {
     return m_ExternalDeps;
Index: src/sdk/scripting/bindings/scriptbindings.cpp
===================================================================
--- src/sdk/scripting/bindings/scriptbindings.cpp (révision 6283)
+++ src/sdk/scripting/bindings/scriptbindings.cpp (copie de travail)
@@ -482,6 +482,7 @@
                 func(&CompileTargetBase::MakeCommandsModified, "MakeCommandsModified");
 
         SqPlus::SQClassDef<ProjectBuildTarget>("ProjectBuildTarget", "CompileTargetBase").
+      func(&ProjectBuildTarget::GetFiles, "GetFiles").
                 func(&ProjectBuildTarget::GetParentProject, "GetParentProject").
                 func(&ProjectBuildTarget::GetFullTitle, "GetFullTitle").
                 func(&ProjectBuildTarget::GetExternalDeps, "GetExternalDeps").

positive tests have been carried out with the script extension following:
Code: [Select]
///-----------------------------------------------------------------------------
/// ===> use a new method to 'wxArrayString ProjectBuildTarget::GetFiles()' <===
/// get the list of files of this target
///-----------------------------------------------------------------------------

///-----------------------------------------------------------------------------
/// display all files project
// affiche tous les fichiers du projet
///-----------------------------------------------------------------------------
class DisplayAllFilesTargets extends cbScriptPlugin {
/// members
// membres
VERSION = _T("1.0.2");
///-----------------------------------------------------------------------------
/// 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) {
local result = main();
}
///-----------------------------------------------------------------------------
///displays all files of each target
//
function main() {
///
local Projet = GetProjectManager().GetActiveProject();
local Nt = Projet.GetBuildTargetsCount() ;
//----------------------------------------------
/// file relative name
// le nom relatif d'un fichier
local file;
local tabfile = ::wxArrayString();
local target ;
local i=0;
local good = false;
/// informations
local Mes = _T("Project : '") + Projet.GetTitle() + _T("' : ") ;
Mes += Projet.GetFilesCount().tostring() + _T(" files, ") ;
Mes +=  Nt.tostring() + _T(" targets : ") ;
::print(Mes );
/// all project targets
// toutes les cibles du projet
for (local ci=0; ci < Nt ; ci++ ) {
target = Projet.GetBuildTarget(ci) ;
::print(_T("\nTarget ") + ci.tostring() + _T(" : '") + target.GetFullTitle() + _T("'"));
/// the array of files name
// le tableau des noms de fichiers relatifs associés à cette cible
///------------- patch to 'ProjectBuildTarget' class ---------------------------
tabfile = target.GetFiles(ci);
///-----------------------------------------------------------------------------
/// all files target
// analyser tous les fichiers de la cible
for (local u=0; u < tabfile.GetCount(); u++) {
file = tabfile.Item(u);
::print (_T("   ") + u.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());
///-----------------------------------------------------------------------------
/// if you want to call this plugin's Execute() function, use this in a script:
// si vous désirez appeler, depuis un script, la fonction 'Execute' de l'extension
///-----------------------------------------------------------------------------
// ExecutePlugin(_T("QtPreBuildPlugin"));
///-----------------------------------------------------------------------------

because I needed to list the files of each target (not all files in the project)

soon.
C::B  : svn11972, wx-3.1.1, plugins : QtPregen-2.7.2-sdk147
1-Win 7 Business Pack 1 64bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.5., 8.1.0,
=> !! The messages are translated by Deepl !!

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7253
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Script C::B
« Reply #12 on: December 07, 2011, 09:56:50 am »
Project * cbProject::GetFile (int) was removed to speed up the loading time of large projects.
To make it possible I created FilesList * cbProject::GetFilesList(), but did not implement it for scripting. I am not sure, if this can be done easily. I will look into it.
I will see, if I can reimplement it, just for looping through the files.
NOTE: if it works, the index should not be used for looping through the list, because after any change (or even reload of the same project) it might differ, because the real list is stored in a hash-map without guaranteed order.
If it does not work, I use your approach.
And I will test both ways, to see which one is faster (just a simple wxStopWatch measuring over a for-loop through all files of a large project).

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.

It definitely worked before, but seems to be broken due to my changes, I will fix this.

Offline LETARTARE

  • Regular
  • ***
  • Posts: 399
  • L'ami de l'homme.The friend of man.
Re: Script C::B
« Reply #13 on: December 07, 2011, 10:02:19 am »
Well, good luck.
 I just did the test this morning
I have not tried speed, only the use for scripts, because I need to validate a
the project.
« Last Edit: December 07, 2011, 10:05:11 am by LETARTARE »
C::B  : svn11972, wx-3.1.1, plugins : QtPregen-2.7.2-sdk147
1-Win 7 Business Pack 1 64bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.5., 8.1.0,
=> !! The messages are translated by Deepl !!

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2213
Re: Script C::B
« Reply #14 on: December 07, 2011, 01:19:04 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.

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.

Look for the line
Code: [Select]
file->AddBuildTarget(targetName);in projectloader.cpp

ProjectFile.cpp line 78
Code: [Select]
void ProjectFile::AddBuildTarget(const wxString& targetName)
{
    if (buildTargets.Index(targetName) == wxNOT_FOUND)
        buildTargets.Add(targetName);

    // add this file to the target's list of files
    if (project)
    {
        ProjectBuildTarget* target = project->GetBuildTarget(targetName);
        if (target && (target->m_Files.find(this) == target->m_Files.end()))
            target->m_Files.insert(this);
    }

    // also do this for auto-generated files
    for (size_t i = 0; i < generatedFiles.size(); ++i)
        generatedFiles[i]->AddBuildTarget(targetName);
}

« Last Edit: December 07, 2011, 01:24:42 pm by Pecan »

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7253
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Script C::B
« Reply #15 on: December 07, 2011, 03:17:40 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.

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.

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
« Last Edit: December 13, 2011, 12:06:26 am by jens »

Offline LETARTARE

  • Regular
  • ***
  • Posts: 399
  • L'ami de l'homme.The friend of man.
Re: Script C::B
« Reply #16 on: December 07, 2011, 03:20:45 pm »
thanks
I try ...
C::B  : svn11972, wx-3.1.1, plugins : QtPregen-2.7.2-sdk147
1-Win 7 Business Pack 1 64bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.5., 8.1.0,
=> !! The messages are translated by Deepl !!

Offline LETARTARE

  • Regular
  • ***
  • Posts: 399
  • L'ami de l'homme.The friend of man.
Re: Script C::B
« Reply #17 on: December 08, 2011, 01:05:15 pm »
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: [Select]
///-----------------------------------------------------------------------------
/// 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());
///-----------------------------------------------------------------------------
===> 'ProjectFile * cbProject::GetFile (int)' <===
using 'make_dist.script' and 'find_broken_files.script'
works very well.

« Last Edit: December 08, 2011, 01:08:56 pm by LETARTARE »
C::B  : svn11972, wx-3.1.1, plugins : QtPregen-2.7.2-sdk147
1-Win 7 Business Pack 1 64bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.5., 8.1.0,
=> !! The messages are translated by Deepl !!

Offline LETARTARE

  • Regular
  • ***
  • Posts: 399
  • L'ami de l'homme.The friend of man.
Re: Script C::B
« Reply #18 on: December 08, 2011, 01:11:30 pm »
 I forgot 'wxArrayString ProjectFile::buildtargets', I go back!
C::B  : svn11972, wx-3.1.1, plugins : QtPregen-2.7.2-sdk147
1-Win 7 Business Pack 1 64bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.5., 8.1.0,
=> !! The messages are translated by Deepl !!

Offline LETARTARE

  • Regular
  • ***
  • Posts: 399
  • L'ami de l'homme.The friend of man.
Re: Script C::B
« Reply #19 on: December 08, 2011, 03:02:28 pm »
Here is the test forgot ...

===> 'ProjectFile * cbProject::GetFile int()' <===
===> 'wxArrayString ProjectFile.buildTargets' <===
using the script 'lisfilesproject.script' as follows:
Code: [Select]
/*******************************************************************************
 * 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());
///-----------------------------------------------------------------------------

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?


C::B  : svn11972, wx-3.1.1, plugins : QtPregen-2.7.2-sdk147
1-Win 7 Business Pack 1 64bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.5., 8.1.0,
=> !! The messages are translated by Deepl !!

Offline LETARTARE

  • Regular
  • ***
  • Posts: 399
  • L'ami de l'homme.The friend of man.
Re: Script C::B
« Reply #20 on: December 12, 2011, 08:08:08 am »
@jens
I'm sorry, but my previous tests were incomplete.
both methods :
Quote
 ===> 'int ProjectBuildTarget::GetFilesCount ()' <===
  ===> 'ProjectFile * ProjectBuildTarget::GetFile (int)' <===
do not work properly.
I used a very simple project with a file 'main.cpp' and two targets
here's the result at the beginning (with my plugin script )
Quote
Project : 'wxProjetVide' : 1 files, 2 targets :

Target 0 : 'wxProjetVide - Release'
   0 : 'main.cpp'

Target 1 : 'wxProjetVide - Debug'
   0 : 'main.cpp'

Total files associated to targets : 2
then I delete the 'main.cpp and add it again', the result: two 'main.cpp'!
Quote
Total files associated to targets : 2
Project : 'wxProjetVide' : 1 files, 2 targets :

Target 0 : 'wxProjetVide - Release'
   0 : 'main.cpp'
   1 : 'main.cpp'

Target 1 : 'wxProjetVide - Debug'
   0 : 'main.cpp'
   1 : 'main.cpp'

Total files associated to targets : 4
it is a fantastic result. I think they do not like 'HASH'!
enough joking, I apologize for any inconvenience.
C::B  : svn11972, wx-3.1.1, plugins : QtPregen-2.7.2-sdk147
1-Win 7 Business Pack 1 64bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.5., 8.1.0,
=> !! The messages are translated by Deepl !!

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7253
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Script C::B
« Reply #21 on: December 13, 2011, 12:03:19 am »
@jens
I'm sorry, but my previous tests were incomplete.
both methods :
Quote
 ===> 'int ProjectBuildTarget::GetFilesCount ()' <===
  ===> 'ProjectFile * ProjectBuildTarget::GetFile (int)' <===
do not work properly.
I used a very simple project with a file 'main.cpp' and two targets
here's the result at the beginning (with my plugin script )

I have seen it already.

The attached patch should fix this (and similar issues).

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9592
Re: Script C::B
« Reply #22 on: December 13, 2011, 07:16:46 am »
The attached patch should fix this (and similar issues).
I don't know what's wrong again. While the latest patches of you did work, these two show an error: "Chunk info expected". :-( I even tried to convert them to Windows line-feed etc... it doesn't help.

Did you do something different this time?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7253
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Script C::B
« Reply #23 on: December 13, 2011, 01:26:31 pm »
The attached patch should fix this (and similar issues).
I don't know what's wrong again. While the latest patches of you did work, these two show an error: "Chunk info expected". :-( I even tried to convert them to Windows line-feed etc... it doesn't help.

Did you do something different this time?
I just tested it with TortoiseSVN (1.7.1) on XP and it works without any errors.

Offline LETARTARE

  • Regular
  • ***
  • Posts: 399
  • L'ami de l'homme.The friend of man.
Re: Script C::B
« Reply #24 on: December 13, 2011, 03:28:06 pm »
with the two previous scripts plugin.
I just tested it with svn 7633 and it works without any errors.
C::B  : svn11972, wx-3.1.1, plugins : QtPregen-2.7.2-sdk147
1-Win 7 Business Pack 1 64bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.5., 8.1.0,
=> !! The messages are translated by Deepl !!

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7253
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Script C::B
« Reply #25 on: December 17, 2011, 02:55:55 pm »
with the two previous scripts plugin.
I just tested it with svn 7633 and it works without any errors.
I just committed the patch in svn r7639 .

Offline LETARTARE

  • Regular
  • ***
  • Posts: 399
  • L'ami de l'homme.The friend of man.
Re: Script C::B
« Reply #26 on: December 17, 2011, 03:04:11 pm »
Quote
I just committed the patch in svn r7639 .
I care and I test svn 7639
I wrote the equivalent for svn <7588.
C::B  : svn11972, wx-3.1.1, plugins : QtPregen-2.7.2-sdk147
1-Win 7 Business Pack 1 64bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.5., 8.1.0,
=> !! The messages are translated by Deepl !!

Offline LETARTARE

  • Regular
  • ***
  • Posts: 399
  • L'ami de l'homme.The friend of man.
Re: Script C::B
« Reply #27 on: December 19, 2011, 01:35:55 pm »
Quote
I care and I test svn 7639
big thank you to 'jens' for the work done (days have 72 hours!)

My test results on r7639 :

I check 'wxArrayString ProjectFile::buildTargets'  and  'ProjectFile * cbProject::GetFile(int)'
with  script plugin : 'listfilesproject.script'
Code: [Select]
/*******************************************************************************
 * Name:      listfilesproject.script
 * Purpose:   Script plugin in CODE::BLOCKS
 * Author:    LETARTARE (http://forums.codeblocks.org)
 * Created:   2011-12-17
 * Version    0.4.0
 * Copyright: LETARTARE
 * License:   GPL
 ******************************************************************************/
/// ATTENTION
///-----------------------------------------------------------------------------
/// ** for svn r7639 ** (by 'jens')
///-----------------------------------------------------------------------------
///  ** for svn in r7588..r7639 **, 'GetFile(int)' was deleted !!!
/// patch 'reimplement_GetFile_index_20111212-1.patch' in r7639 (by 'jens')
/// this script use new methods of patch:
/// use, add ====> 'wxArrayString ProjectFile::buildTargets' <==== use
///   add => 'int ProjectBuildTarget::GetFilesCount()' <=
/// add => 'ProjectFile* ProjectBuildTarget* GetFile(int)' <=
/// use, add ====> 'ProjectFile * cbProject::GetFile(int)'   <==== use
///-----------------------------------------------------------------------------
///  ** for svn < r7588 **  (release 10.05, svn7550, ..)
/// no official patch : 'projectbuildtarget_GetFiles.patch'
/// this script use one new method of patch :
/// use, add ====> 'wxArrayString ProjectFile::buildTargets' <==== use
/// add => 'int ProjectBuildTarget::GetFilesCount()' <=
/// add => 'ProjectFile* ProjectBuildTarget* GetFile(int)' <=
///-----------------------------------------------------------------------------

///-----------------------------------------------------------------------------
/// display all files projects with cibles
///-----------------------------------------------------------------------------
class DisplayAllFilesProject extends cbScriptPlugin {
/// members
// membres
VERSION = _T("0.4.0");
///-----------------------------------------------------------------------------
/// mandatory to init script plugin
///-----------------------------------------------------------------------------
constructor() {
/// constructor base class
cbScriptPlugin.constructor();
/// setup the plugin's info
info.name = _T("DisplayAllFilesProject");
info.title = _("Display files project");
info.version = VERSION;
info.license = _T("GPL");
}
///-----------------------------------------------------------------------------
/// to create context menu entries
///-----------------------------------------------------------------------------
function GetModuleMenu(who, data) {
local entries = ::wxArrayString();
   if (who == ::mtProjectManager)   {
            entries.Add(_("Display files project"), 1);
   }
return entries;
}
///-----------------------------------------------------------------------------
/// calback for context menu items clicking
///-----------------------------------------------------------------------------
function OnModuleMenuClicked(index) {
main();
}
///-----------------------------------------------------------------------------
///displays all files of each target on script console
///-----------------------------------------------------------------------------
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++ ) {
///-- only >= r7588------ 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);
}
} /// end main()

} /// class end
///-----------------------------------------------------------------------------
/// this call actually registers the script plugin with Code::Blocks
///-----------------------------------------------------------------------------
RegisterPlugin(DisplayAllFilesProject());
///-----------------------------------------------------------------------------
no problem using the methods.

I check 'int ProjectBuildTarget::GetFilesCount()'  and  'ProjectFile* ProjectBuildTarget* GetFile(int)'
with  script plugin : 'listfilestargets.script' :
Code: [Select]
/*******************************************************************************
 * Name:      listfilestargets.script
 * Purpose:   Script plugin in CODE::BLOCKS
 * Author:    LETARTARE (http://forums.codeblocks.org)
 * Created:   2011-12-17
 * Version    0.5.0
 * Copyright: LETARTARE
 * License:   GPL
 ******************************************************************************/
/// ATTENTION
///-----------------------------------------------------------------------------
/// ** for svn r7639 ** (by 'jens')
///-----------------------------------------------------------------------------
///  ** for svn in r7588..r7639 **, 'GetFile(int)' was deleted !!!
/// patch 'reimplement_GetFile_index_20111212-1.patch' in r7639 (by 'jens')
/// this script use two new methods of patch :
///   add => 'wxArrayString ProjectFile::buildTargets' <=
/// use, add ====> 'int ProjectBuildTarget::GetFilesCount()' <====
/// use, add ====> 'ProjectFile* ProjectBuildTarget* GetFile(int)' <====
///   add => 'ProjectFile * cbProject::GetFile(int)'   <=
///-----------------------------------------------------------------------------
///  ** for svn < r7588 **  (release 10.05, svn7550, ..)
/// no official patch : 'projectbuildtarget_GetFiles.patch'
/// this script use two new methods of patch :
/// add => 'wxArrayString ProjectFile::buildTargets' <===
/// use, add ====> 'int ProjectBuildTarget::GetFilesCount()' <==== use
/// use, add ====> 'ProjectFile* ProjectBuildTarget* GetFile(int)' <==== use
///-----------------------------------------------------------------------------

///-----------------------------------------------------------------------------
/// display all files targets
///-----------------------------------------------------------------------------
class DisplayAllFilesTargets extends cbScriptPlugin {
/// members
VERSION = _T("0.5.0");
///-----------------------------------------------------------------------------
/// mandatory to init script plugin
///-----------------------------------------------------------------------------
constructor() {
/// constructor base class
cbScriptPlugin.constructor();
/// setup the plugin's info
info.name = _T("DisplayAllFilesTargets");
info.title = _("Display files targets");
info.version = VERSION;
info.license = _T("GPL");
}
///-----------------------------------------------------------------------------
/// to create context menu entries
///-----------------------------------------------------------------------------
function GetModuleMenu(who, data) {
local entries = ::wxArrayString();
   if (who == ::mtProjectManager)   {
            entries.Add(_("Display files targets only"), 1);
   }
return entries;
}
///-----------------------------------------------------------------------------
/// calback for context menu items clicking
///-----------------------------------------------------------------------------
function OnModuleMenuClicked(index) {
main();
}
///-----------------------------------------------------------------------------
///displays all files of each target on script console
///-----------------------------------------------------------------------------
function main() {
/// general
local Project = GetProjectManager().GetActiveProject();
if (IsNull(Project)) {
ShowError( _("Currently no project is loaded/activated. Cannot continue.") );
return 0;
}
local Ntargets = Project.GetBuildTargetsCount() ;
if (Ntargets == 0) {
ShowError( _("No target in this project. Cannot continue.") );
return 0;
}
local Nfiles = Project.GetFilesCount() ;
if (Nfiles == 0) {
ShowError( _("No file in this project. Cannot continue.") );
return 0;
}
/// file relative name
local file;
local target;
local nfilestarget;
local i=0;
/// informations
local Mes = _T("Project : '") + Project.GetTitle() + _T("' : ") ;
Mes += Nfiles.tostring() + _T(" files, ") ;
Mes +=  Ntargets.tostring() + _T(" targets : ") ;
::print(Mes );
/// all project targets
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 ---------------------------
nfilestarget = target.GetFilesCount();
///-----------------------------------------------------------------------------
if (nfilestarget == 0)
continue;
/// all files target
for (local nf =0 ; nf < nfilestarget ; 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());
} /// end main()

} /// class end
///-----------------------------------------------------------------------------
/// this call actually registers the script plugin with Code::Blocks
///-----------------------------------------------------------------------------
RegisterPlugin(DisplayAllFilesTargets());
///-----------------------------------------------------------------------------
no problem using the methods.

As against the testing of a large project C::B (eg svn 7550) shows a display in the console, which blocks 2 to 3 seconds (at about 2 / 3) and then restarts !

This anomaly does not occur in  r7550 and r6283 (adjusted with patch personnal).

I guess it comes from the refresh of the window ?
Perhaps he should open another topic ?

« Last Edit: December 19, 2011, 03:49:27 pm by LETARTARE »
C::B  : svn11972, wx-3.1.1, plugins : QtPregen-2.7.2-sdk147
1-Win 7 Business Pack 1 64bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.5., 8.1.0,
=> !! The messages are translated by Deepl !!