Author Topic: cccc plugin  (Read 12859 times)

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
cccc plugin
« on: November 12, 2009, 02:37:55 pm »
I am currently working on a small cccc plug-in.

The plug-in will issue a 'wxExecute' to have the cccc executable to it's thing.
I am observing a few strange things.

But first :
assumption : the starting working directory is the directory where the .cbp file is of the active project.

When I run command I want the plug-in to execute in the project directory it works.
Works meaning in this scenario :
* it finds the files specified on the command line (that is a list of ProjectFile::relativeFilename 's)
* it creates an output directory (.cccc, or when I specify a directory, my directory specified)

This is for example my command in the project directory :

Code
killerbot@thorgal:~/Projects/Traficon/view_vipnt_buildserver/vipnt/Codec/Project> cccc --outdir=ldc "../inc/CodecP.h" "../src/Codec.cpp" "../src/Codec.h" "../src/CodecDecoder.cpp" "../src/CodecDecoder.h" "../src/CodecDisplay.cpp" "../src/CodecDisplay.h" "../src/CodecP.cpp"

or

Code
killerbot@thorgal:~/Projects/Traficon/view_vipnt_buildserver/vipnt/Codec/Project> cccc "../inc/CodecP.h" "../src/Codec.cpp" "../src/Codec.h" "../src/CodecDecoder.cpp" "../src/CodecDecoder.h" "../src/CodecDisplay.cpp" "../src/CodecDisplay.h" "../src/CodecP.cpp"


However when this command is executed through wxExecute from the plug-in (NOTE :tested on LINUX) :
Then cccc can't find the files, when I remove those " , then it can find the files.
But in any case it will never create the output directory (and place the report files in it).

What would make it behave so different ?


Follow up : Anyone already can tell me how I can launch the CB html viewer, (the one which kicks in when you click the url at the bottom of the build log after a build), this would help me a lot otherwise I have to go hunting in the code ;-)   ?

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: cccc plugin
« Reply #1 on: November 12, 2009, 04:01:40 pm »
I just created a small test-program and run its own code through cccc, works fine here.

By the way: I only tested it with synchronous execution.

Here is my example code:
Code
void testFrame::OnExecute(wxCommandEvent& event)
{
    wxArrayString output, error;
    wxString cmd = _T("cccc --outdir=ldc \"testApp.h\" \"testApp.cpp\" \"testMain.h\" \"testMain.cpp\"");
    TextCtrl1->AppendText(_T("Now executing: ") + cmd + _T("\n\n"));
    long result = wxExecute(cmd , output, error, wxEXEC_SYNC | wxEXEC_NODISABLE);
    if(result != 0)
    {
        TextCtrl1->AppendText(_T("error executing ") + cmd + _T("\n"));
    }
    else
    {
        TextCtrl1->AppendText(_T("Output of output-stream:\n"));
        for(unsigned int i = 0; i < output.GetCount(); i++)
        {
            TextCtrl1->AppendText(output[i]+_T("\n"));
        }
        TextCtrl1->AppendText(_T("\nOutput of error-stream:\n"));
        for(unsigned int i = 0; i < error.GetCount(); i++)
        {
            TextCtrl1->AppendText(error[i]+_T("\n"));
        }
    }
}

and the output:
Code
Now executing: cccc --outdir=ldc "testApp.h" "testApp.cpp" "testMain.h" "testMain.cpp"

Output of output-stream:

Output of error-stream:
CCCC - a code counter for C and C++
===================================

A program to analyse C and C++ source code and report on
some simple software metrics
Version 3.pre84
Copyright Tim Littlefair, 1995, 1996, 1997, 1998, 1999, 2000
with contributions from Bill McLean, Herman Hueni, Lynn Wilson
Peter Bell, Thomas Hieber and Kenneth H. Cox.

The development of this program was heavily dependent on
the Purdue Compiler Construction Tool Set (PCCTS)
by Terence Parr, Will Cohen, Hank Dietz, Russel Quoung,
Tom Moog and others.

This software is provided with NO WARRANTY
Parsing
Processing testApp.h as C/C++ (c++.ansi)
Processing testApp.cpp as C/C++ (c++.ansi)
Processing testMain.h as C/C++ (c++.ansi)
testMain.h(50): syntax error at token DECLARE_EVENT_TABLE
testMain.h(50): trying to match class_block_item_list at 'DECLARE_EVENT_TABLE'
Processing testMain.cpp as C/C++ (c++.ansi)
failed opt_const_modifier for token 159 END_EVENT_TABLE
testMain.cpp(56): syntax error at token END_EVENT_TABLE
testMain.cpp(56): trying to match opt_const_modifier at 'END_EVENT_TABLE'

Generating HTML reports

Generating XML reports

Primary HTML output is in ldc/cccc.html
Detailed HTML reports on modules and source are in ldc
Primary XML output is in ldc/cccc.xml
Detailed XML reports on modules are in ldc
Database dump is in ldc/cccc.db

The output-directory (ldc) is created.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: cccc plugin
« Reply #2 on: November 12, 2009, 04:40:37 pm »
It works for me too (without surrounding "") when I have a directory layout like this :

'MyProgram' directory containing the  sources and cbp file.


But it fails when I have a directory layout like this :
'MyProgram' directory
|
+Project subdirectory containing the cbp file
|
+src subdirectory containing source files (*.cpp/h)
|
+inc subdirectory containing exported headers (*.h)

Strange that the " still don't work for me.
And why in such a changed project structure this would make a difference, dunno at all ?
Other plug-ins work correctly on this (codestat, clearcase, ..)



Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: cccc plugin
« Reply #3 on: November 12, 2009, 05:23:09 pm »
I changed my directory-structure to:
Code
.
|-- include
|   |-- testApp.h
|   |-- testMain.h
|   |-- wx_pch.h
|   `-- wx_pch.h.gch
|       `-- Debug_include_wx_pch_h_gch
|-- src
|   |-- testApp.cpp
|   `-- testMain.cpp
|-- test
|   |-- test.cbp
|   `-- test.depend
`-- wxsmith
    `-- testframe.wxs

and the command to:
Code
wxString cmd = _T("cccc --outdir=ldc \"../include/testApp.h\" \"../src/testApp.cpp\" \"../include/testMain.h\" \"../src/testMain.cpp\"");

Execution working dir is "."

output is now:
Code
Now executing: cccc --outdir=ldc "../include/testApp.h" "../src/testApp.cpp" "../include/testMain.h" "../src/testMain.cpp"

Output of output-stream:

Output of error-stream:
CCCC - a code counter for C and C++
===================================

A program to analyse C and C++ source code and report on
some simple software metrics
Version 3.pre84
Copyright Tim Littlefair, 1995, 1996, 1997, 1998, 1999, 2000
with contributions from Bill McLean, Herman Hueni, Lynn Wilson
Peter Bell, Thomas Hieber and Kenneth H. Cox.

The development of this program was heavily dependent on
the Purdue Compiler Construction Tool Set (PCCTS)
by Terence Parr, Will Cohen, Hank Dietz, Russel Quoung,
Tom Moog and others.

This software is provided with NO WARRANTY
Parsing
Processing ../include/testApp.h as C/C++ (c++.ansi)
Processing ../src/testApp.cpp as C/C++ (c++.ansi)
Processing ../include/testMain.h as C/C++ (c++.ansi)
../include/testMain.h(50): syntax error at token DECLARE_EVENT_TABLE
../include/testMain.h(50): trying to match class_block_item_list at 'DECLARE_EVENT_TABLE'
Processing ../src/testMain.cpp as C/C++ (c++.ansi)
failed opt_const_modifier for token 159 END_EVENT_TABLE
../src/testMain.cpp(56): syntax error at token END_EVENT_TABLE
../src/testMain.cpp(56): trying to match opt_const_modifier at 'END_EVENT_TABLE'

Generating HTML reports

Generating XML reports

Primary HTML output is in ldc/cccc.html
Detailed HTML reports on modules and source are in ldc
Primary XML output is in ldc/cccc.xml
Detailed XML reports on modules are in ldc
Database dump is in ldc/cccc.db

As you can see, it still works.

Can you provide the code you use, maybe I find a problem, you did not see ("Two heads are better than one").

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: cccc plugin
« Reply #4 on: November 12, 2009, 05:52:43 pm »
Extremely strange, I just tried it out on Windows : works OK.

I will commit my code later in our svn, and if this takes too long I will PM it to you.

2 heads are indeed better then 1.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: cccc plugin
« Reply #5 on: January 10, 2010, 09:44:41 pm »
It seems to crash when I use it on larger project (C::B debugger branch and my own project).
Does it work for you? If yes I'll try to find why it crashes.
The backtrace is meaningless, even I've used --enable-debug... :(

I'm using debugger branch r6019.

Also, where I need to look/read in order to learn how to make the "Html viewer" go into the editors notebook?
(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 Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: cccc plugin
« Reply #6 on: January 10, 2010, 09:53:45 pm »
It seems to crash when I use it on larger project (C::B debugger branch and my own project).
Does it work for you? If yes I'll try to find why it crashes.
The backtrace is meaningless, even I've used --enable-debug... :(

I'm using debugger branch r6019.

Also, where I need to look/read in order to learn how to make the "Html viewer" go into the editors notebook?

It's a known issue, caused by very long command-lines.
The exact length depends on the OS as far as I know.

I tried to make it read a file-list from standard input (after creating a temporary file holding the list of project files), but it crashed also.
I don't know if there is an easy solution (if any).


EDIT:
The same problem exists for the cppcheck-plugin.