Difference between revisions of "Policies/Kdepim Coding Style"

Jump to: navigation, search
(Public)
(No space before a comma)
 
(213 intermediate revisions by one user not shown)
Line 1: Line 1:
{{Construction}}
 
 
 
== Purpose of this document ==
 
== Purpose of this document ==
  
Line 10: Line 8:
 
[http://techbase.kde.org/Policies/Kdelibs_Coding_Style Kdelibs coding style].
 
[http://techbase.kde.org/Policies/Kdelibs_Coding_Style Kdelibs coding style].
  
== The rules for kdepim and akonadi ==
+
But we have some more rules for some more situations.
  
*don't use any <TAB>s
+
== Why is coding Style useful? ==
*Trim the lines
+
 
*Only single empty lines should be used
+
Let us make a comparision with real life.
*The first line, the last line(s) may not be empty
+
To make an addition, one can write:
*Use one space after each keyword, but not after a cast
+
 
*no "one line" if-statement
+
{{Output| 1=123
 +
+      456
 +
  ==========
 +
    =      579
 +
}}
 +
 
 +
But we have learned in primary school to write:
 +
 
 +
{{Output| 1=Addition
 +
  123
 +
+456
 +
====
 +
=579
 +
}}
 +
 
 +
Which is much more readable, easy to control (or debug).
 +
 
 +
This is Coding Style: not mandatory, but very useful and pretty to read.
 +
 
 +
== What do we need? ==
 +
 
 +
'''We need at least:'''
 +
*a '''specification''' (a set of rules) for the coding style of the sources
 +
*some tools to '''check the sources''' against the specification
 +
*some tools to '''change the sources'''
 +
 
 +
 
 +
[http://astyle.sourceforge.net/ astyle] is a very suitable tool to make such changes. But astyle doesn't implement (yet) all the specification rules.
 +
 
 +
You can find below some awk-scripts which help us to check all the rules.
 +
 
 +
You can find below some awk-scripts which help us to make most of the changes.
 +
The last part must be done manually.
 +
 
 +
== The specification rules of coding style for kdepim and akonadi ==
 +
 
 +
These are the sub-sections under '''The rules and the scripts ...'''
  
 
== Migration ==
 
== Migration ==
Line 24: Line 58:
 
be reviewed to follow the coding style.  This will be done over a long time,
 
be reviewed to follow the coding style.  This will be done over a long time,
 
directory after directory, for each of the
 
directory after directory, for each of the
rules defined above.  For each rule, one can find one or two script(s).
+
rules defined above.  For each rule, there are one or two script(s).
  
== Check the objects ==
+
The main part of the changes can be done with astyle:
 +
http://astyle.sourceforge.net/
  
As a first approach, not any object may have binary change after applying one of the rules.
+
The results can be seen [http://techbase.kde.org/ResultsOfTheMigration here].
To check this, one uses the '''Check-the-Objects.sh'''. Download the script: [[Media:Check-the-Objects.sh.gz]]
+
  
The script can be used with one of the commands:
+
== Download Coding Style ==
* save
+
* test
+
* clean
+
  
'''An example:'''
+
You can download the software with test files and install instructions.
  
{{Input|1=cd <some_kdepim_directory>
+
Download Coding Style: [[Media:CodingStyle.tar.gz]]
mkdir build
+
cd build
+
ccmake ../
+
make}}
+
{{Output|1=<span style="color:Fuchsia">Scanning dependencies of target gpgmepp</span>
+
[ 0%] <span style="color:green">Building CXX object gpgme++/CMakeFiles/gpgmepp.dir/gpgmepp_automoc.cpp.o</span>
+
[ 0%] <span style="color:green">Building CXX object gpgme++/CMakeFiles/gpgmepp.dir/exception.cpp.o</span>
+
[  0%] <span style="color:green">Building CXX object gpgme++/CMakeFiles/gpgmepp.dir/context.cpp.o</span>
+
...}}
+
  
{{Input|1=Check-the-Objects.sh save}}
+
== Two scripts '''to check all the rules''' and '''to make the all the changes''' ==
The script makes a copy of all the objects and a "time stamp":
+
{{Output|1=save the object ./kholidays/tests/CMakeFiles/testzodiac.dir/testzodiac.cpp.o
+
save the object ./kholidays/tests/CMakeFiles/testzodiac.dir/testzodiac_automoc.cpp.o
+
...
+
all objects are saved}}
+
  
Now, one makes somes change(s) on the source(s) and:
+
Most of the rules can be checked with the scripts below.
 +
For some of the rules, we don't have a script to change the sources.
 +
It is better first to make a check for such a rule, second to make the modification(s) manually to suscript the rule(s).
  
{{Input| 1=make}}
+
There are two scripts that run all the checks and apply all the changes at once:
 +
*All-Check.sh
 +
*Change-All.sh
  
Depending on the Makefile, some objects will be compiled again:
+
For each specification rule, the name of the scripts to check and apply the changes
 +
are given at the beginning of the section.
  
{{Output| 1=<span style="color:Fuchsia">Scanning dependencies of target akonadi-kde</span>
+
== The rules and the scripts '''to check''' and '''to make the changes''' ==
[ 17%] <span style="color:green">Building CXX object akonadi/CMakeFiles/akonadi-kde.dir/entitytreeview.cpp.o</span>
+
[ 17%] <span style="color:green">Building CXX object akonadi/CMakeFiles/akonadi-kde.dir/itemfetchjob.cpp.o</span>
+
[ 17%] <span style="color:green">Building CXX object akonadi/CMakeFiles/akonadi-kde.dir/statisticsproxymodel.cpp.o</span>
+
...
+
<span style="color:Fuchsia">Scanning dependencies of target akonadi-kmime</span>
+
[ 56%] <span style="color:green">Building CXX object akonadi/kmime/CMakeFiles/akonadi-kmime.dir/standardmailactionmanager.cpp.o</span>}}
+
  
{{Input|1=Check-the-Objects.sh test}}
+
The first script is '''to check''' a single file or all .h and .cpp files in a directory.
  
The script finds all the new objects, makes a comparision with the saved version:
+
If present, the second script '''applies the changes'''.
{{Output|1=test the object ./akonadi/CMakeFiles/akonadi-kde.dir/statisticsproxymodel.cpp.o
+
For some complicated situations, the script makes no change.
test the object ./akonadi/CMakeFiles/akonadi-kde.dir/entitytreeview.cpp.o
+
test the object ./akonadi/CMakeFiles/akonadi-kde.dir/itemfetchjob.cpp.o
+
test the object ./akonadi/kmime/CMakeFiles/akonadi-kmime.dir/standardmailactionmanager.cpp.o
+
all tests are OK
+
}}
+
  
== Check the assembler files ==
+
You can use the scripts for your own work. It is recommended to use them in this order.
If we add or remove some lines, the debug informations included in the object file will be change also.
+
  
This is the case with the test/change of "''Only single empty lines should be used''", "''First line, last line(s) may not be empty''" and some more test/change below (''adding some blocks'' with { and }).
+
=== Don't test all directories ===
  
For this reason it is no more possible to compare the objects.
+
If a '''.no_coding_style''' file is present on a directory, the test will not be done.
We have to compare the assembler files.
+
This works pretty well for the version with '''CMAKE_BUILD_TYPE''' set to ''release''.
+
For the version with '''CMAKE_BUILD_TYPE''' set to ''debug'', we must remove all the debug informations before the comparision could take place.
+
  
=== Generate the assembler files ===
+
If a '''.no_recursion''' file is present on a directory, we do not explore the subdirectory(ies)
  
To generate the assembler files, we only need to modify the ''build.make'' in every folder.
+
=== Indentation with four spaces, don't use any <TAB>s ===
  
The script '''Prepare-build_make_files.sh''' works on the all directory, finds the line with the compiler command,
+
*Tabs-check.sh
duplicates the line, add a ''-S option'' and changes the name of the output to ''somename.s''.
+
*Tabs.awk
After a new ''make'' command, we can save all the assembler files with the script '''Check-the-assembler_code.sh'''.
+
*The changes are well done with
Download the script: [[Media:Prepare-build_make_files.sh.gz]]
+
{{Output| 1=astyle --indent=spaces=4
 +
}}
  
=== Remove the debug informations ===
+
=== Trim the lines ===
  
The biggest part of the debug informations beginns with the directive line
+
*Trim-check.sh
*.Ldebug_info0
+
*Trim.awk
We drop all the next lines.
+
*The changes are well done with:
 +
{{Output| 1=astyle --indent=spaces
 +
}}
  
We drop also the lines with the directive .loc
+
=== Only single empty lines ===
They contain an information about the source line (here 123) we need later to drop the lines
+
Refer to http://techbase.kde.org/Policies/Kdelibs_Coding_Style#Whitespace
* movl $123, %edx
+
* movl $123, %ecx
+
  
The lines with
+
*Twice-check.sh
* .string "/home/guy-kde/projects/kdepimlibs/akonadi/agentbase.cpp:454"
+
*Twice-change.sh
will be also removed.
+
*Twice.awk
  
The script to check the assembler files can be used in the same way as the one above (Check-the-Objects.sh).
+
=== The first line and the last line(s) may not be empty ===
To check this, one uses the '''Check-the-assembler_code.sh'''. Download the script: [[Media:Check-the-assembler_code.sh.gz]]
+
  
The script can be used with one of the commands:
+
Some of the sources have empty lines at the beginning of the file. Some have one or more empty last line(s).
* save
+
*First-check.sh
* test
+
*First-change.sh
* clean
+
*First.awk
  
== The scripts ==
+
=== Only one statement per line ===
The first script is '''to check''' a single file or a complete directory for all .h and
+
.cpp files.
+
  
If present, the second script '''makes the changes''' for a single file or a complete
+
We don't provide (yet) any check for this rule.
directory for all .h and .cpp files.  For some complicated situations, the
+
script makes no change.
+
  
One can use the scripts for own work.It is recommanded to use them in this order.
+
=== Variable declaration ===
  
==== don't use any <TAB>s ====
+
We follow the kdelibs rule: [[http://techbase.kde.org/Policies/Kdelibs_Coding_Style#Variable_declaration]]
*coding-style-check-Tabs.sh
+
We don't provide (yet) any check for this rule.
*coding-style-change-Tabs.sh
+
  
Download the scripts: [[Media:Tabs.tar.gz]]
+
=== Only one declaration per line ===
  
The output of the '''check''' script is:
+
We follow the kdelibs rule: [[http://techbase.kde.org/Policies/Kdelibs_Coding_Style#Variable_declaration]]
{{Output|1=check the file /home/guy-kde/projects/kdepimlibs/ktnef/ktnefparser.cpp
+
We don't provide (yet) any check for this rule.
1->308: Tab at 16:  stream_ >> i;              // i <- attribute type & name
+
2->311: Tab at 16:  stream_ >> i;              // i <- data length
+
3->326: Tab at 22:  case attATTACHMENT:        // try to get attachment info
+
4->367: Tab at 16:  stream_ >> u;      // u <- checksum
+
a  b    c            d}}
+
 
+
This shows:
+
* the name of the file which is under test.
+
* the number of occurence('''a'''), the line number('''b'''), the position found('''c''') and the line itself('''d''').
+
  
The '''change''' script:
+
=== Use one space after each keyword, but not after a cast ===
*makes a substitution of any <TAB> with eight spaces,
+
*The change works for the complete source, even within comments and strings,
+
*That might be too much and changes the vertical alignment of the code.
+
  
==== Trim the lines ====
+
Refer to http://techbase.kde.org/Policies/Kdelibs_Coding_Style#Whitespace
  
*coding-style-check-Trim.sh
+
For most of the keywords, it is not necessary to make a test. Because the sources have been already compiled. For example this code never appear in a compiled source:
*coding-style-change-Trim.sh
+
{{Output|1=intmyVariableAa;
 +
floatmyVariableBb;}}
  
Download the scripts: [[Media:Trim.tar.gz]]
+
In this case, the missing space leads to a syntax error which is detected by the compiler. We don't need to check this manually.
  
The output of the '''check''' script is:
+
Some of the keywords are alone in the statement, such as '''break''' and '''continue'''. No test is necessary.
{{Output|1=check the file /home/guy-kde/Software/coding-style-check/trim.cpp
+
1->51: Space(s) at end of line (28):  QVariant m_matchData;}}
+
 
+
This shows:
+
* the name of the file which is under test.
+
* the number of occurence, the line number, the position found and the line itself.
+
  
 +
The only tests we have to do are the ones where a keyword is (or can be) followed
 +
by a sign '''( { [ :'''
  
The '''change''' script:
+
These are:
*remove all trailing space(s).
+
'''alignas decltype alignof noexcept typeid asm static_assert switch if catch while for foreach sizeof new Q_FOREACH FOREACH do try enum union Q_FOREVER bool char char16_t char32_t double float int long wchar_t signed unsigned short'''
  
==== Only single empty lines should be used ====
+
*SpaceAfter-check.sh
Refer to http://techbase.kde.org/Policies/Kdelibs_Coding_Style#Whitespace
+
*SpaceAfter-change.sh
 +
*SpaceAfter.awk
  
*coding-style-check-Twice.sh
+
=== Use a space after the name of the class ===
*coding-style-change-Twice.sh
+
  
The output of the '''check''' script is:
+
We prefer having a space before the keyword public at the definition of a new class:
{{Output|1=check the file /home/guy-kde/projects/kdepimlibs/syndication/rss2/enclosure.cpp
+
{{Output|1=class DbException : public Akonadi::Exception
1->25: next empty line found
+
{
2->26: next empty line found
+
  ...
3->30: next empty line found}}
+
};}}
   
+
This shows:
+
* the name of the file which is under test.
+
* the number of occurrences and the line numbers.
+
  
The '''change''' script:
+
*Public-check.sh
*removes all the next empty line(s).
+
*Public-change.sh
 +
*Public.awk
  
==== First line, last line(s) may not be empty ====
+
=== #include directive ===
  
Some of the sources have a first empty lines, some have one or more empty last line(s).
+
Refer to http://techbase.kde.org/Policies/Kdelibs_Coding_Style#Qt_Includes
*coding-style-check-First-Last.sh
+
*coding-style-change-First-Last.sh
+
  
The output of the '''check''' script is:
+
We prefer no space at the beginning of the directive. Some (not many) files need to be corrected to unify to all the other files.
{{Output|1=check the file /home/guy-kde/Software/coding-style-check/trim.cpp
+
The first line is empty
+
The last line is empty}}
+
   
+
The '''change''' script:
+
*removes the first line if empty, all the last empty line(s).
+
  
====put the comments away====
+
{{Output|1=// some files use this
 +
# include <A/b>
  
The comments might contain some keyword. It is very difficult to avoid the confusion with the very simple awk-scripts. We prefer to change all the comments with the same number of empty lines.
+
// we prefer to unify the coding style
 +
#include <A/b>}}
  
*Comments.awk
+
*Space-Include-check.sh
 +
*SpaceInclude.awk
  
====change the strings====
+
=== Place '''*''' and '''&''' next to the variable ===
  
It is very difficult to parse the strings correctly, so we prefer to change them to an empty string.
+
The declaration S *D; declares D as a pointer to the type determined by decl-specifier-seq S.
  
*Strings.awk
+
For most compilers, the three declarations below are semantically the same:
  
 +
{{Output|1=int *a;
 +
int* b;
 +
int * c
 +
}}
  
After the use of the last two awk-scripts (Comments.awk and Strings.awk), we go on with the next check.
+
We prefer the first one, without a space beetwen the star and the name of the variable:
  
====no "one line" if-statement====
+
{{Output|1=int *a;
 +
}}
  
Refer to http://techbase.kde.org/Policies/Kdelibs_Coding_Style#Braces
+
The same rule may be use for:
  
The following code:
+
{{Output|1=myFunction(int &a, int& b, int & c)
{{Output|1=if ( a > b ) c = 123;}}
+
{
is correct, but we prefer the block:
+
    // some lines
{{Output|1=if ( a > b ) {
+
}
  c = 123;
+
}}
} }}
+
which is easier to read, to modify.
+
  
It is also possible to put a breakpoint at the line in the block.
+
We prefer:
 +
{{Output|1=myFunction(int &a, int &b, int &c)
 +
}}
  
As the awk-script is too simple to recognize all the if-statements, we get some false alarm and
+
The awk-script checks also the occurences of:
we can't make the changes automatically.
+
* '''&,'''
 +
* '''& >'''
 +
* '''* >'''
 +
* '''( )''' and '''(  )''' ''empty function call''
  
*coding-style-check-One-Line-If.sh
+
* '''enum {''' ''untyped enum''
  
The output of the '''check''' script is:
+
Not all the ouputs are real errors. Some codings might be correct.
{{Output|1=check the file /home/guy-kde/Software/coding-style-check/if-example.cpp
+
1->25: one-line-if found}}
+
  
====Pedantic====
+
*NoSpace-check.sh
 +
*NoSpace.awk
 +
*using astyle to make the changes:
 +
{{Output| 1=astyle --reference=name --align-pointer=name
 +
}}
  
Looking over the git-history, one can find some "pedantic" changes.
 
These are changes to make a better code. The most of them are at the use of macro, where it is not necessary to have a ''';''' at the end ofthe command.
 
The script make a check over all these:
 
'''AKTEST_MAIN;MAKE_CMD_ROW;Q_DECLARE_FLAGS;Q_PRIVATE_SLOT;Q_DECLARE_METATYPE;Q_DECLARE_OPERATORS_FOR_FLAGS;Q_DE
 
CLARE_PRIVATE;Q_DECLARE_PUBLIC;Q_DISABLE_COPY;K_GLOBAL_STATIC;Q_IMPORT_PLUGIN;Q_PROPERTY;Q_UNUSED;QTEST_KDEMAIN;QTEST_MAIN'''
 
  
*coding-style-check-Pedantic.sh
+
Some lines with must be manually corrected.
  
====Public====
+
=== Use '''namespace foo {''' in the same line ===
  
We prefer not having a space before the keyword public at the definition of a new class:
+
We prefer having all in one line:
class DbException : public Akonadi::Exception
+
{{Output|1=namespace foo {
 +
  ...
 +
}
 +
}}
 +
 
 +
*Namespace-check.sh
 +
*Namespace.awk
 +
*astyle to make the changes.
 +
 
 +
=== Use '''struct foo''' with '''{''' at the next line ===
 +
 
 +
We prefer having the same coding style for a '''class''' and a '''struct'''
 +
{{Output|1=struct foo
 
{
 
{
 
   ...
 
   ...
 +
}
 +
}}
 +
 +
*Struct-check.sh
 +
*Struct-change.sh
 +
*Struct.awk
 +
 +
NOTE: The script must be use after astyle.
 +
 +
=== Each member initialization of a method in separate line ===
 +
 +
This example shows the indentation we prefer. Notice that colon sign and comma(s)
 +
are at the beginning of each initialization line(s):
 +
 +
{{Output|1=class myClass
 +
{
 +
    // some lines
 +
public:
 +
    myClass(int r, int b, int i, int j)
 +
        : r(0)
 +
        , b(i)
 +
        , i(5)
 +
        , j(13)
 +
{
 +
    // more lines
 +
}
 
};
 
};
 +
}}
  
*coding-style-check-Public.sh
+
*Default-check.sh
*coding-style-change-Public.sh
+
*Default-change.sh
 +
*Default.awk
  
====#include directive====
+
=== Surround all operators with spaces ===
  
Refer to http://techbase.kde.org/Policies/Kdelibs_Coding_Style#Qt_Includes
+
This is well done with astyle:
 +
{{Output| 1=astyle --pad-oper
 +
}}
  
We prefer no space at the beginning of the directive. Some (not many) files need to be corrected to unify to all the other files.
+
=== '''switch''' rules ===
  
{{Output|1=// some files use this
+
This example shows the indentation we prefer:
# include <A/b>
+
  
// we prefer, to unify the coding style
+
{{Output|1=switch (a) {
#include <A/b>}}
+
case ''one'':
 +
    // some lines
 +
    break;
 +
case ''two'': {
 +
    // some lines
 +
    break;
 +
}
 +
case ''three'': {
 +
    // some lines
 +
    return;
 +
}
 +
default:
 +
    // some lines
 +
    break;
 +
}
 +
}}
  
*coding-style-check-Space-Include.sh
+
*Switch-check.sh
 +
*Switch.awk
 +
*astyle makes the changes
  
====enum without empty element====
+
NOTE: By using a new block, we prefer having '''break;''' and '''return;''' within the new block.
 +
 
 +
=== '''try-catch''' rules ===
 +
 
 +
This example shows the indentation we prefer:
 +
 
 +
{{Output|1=try {
 +
    // some lines
 +
} catch (...) {
 +
}
 +
}}
 +
 
 +
*TryCatch-check.sh
 +
*TryCatch.awk
 +
 
 +
=== '''if''', '''else''', '''for''', '''while''' (and similar macros) rules ===
 +
 
 +
Even for blocks with only one statement, we prefer to use braces such as:
 +
 
 +
{{Output|1=if (''condition'') {
 +
    ''statement;''
 +
}
 +
}}
 +
 
 +
This should be used with the keywords '''if''', '''else''', '''for''', '''while''' and similar macros.
 +
 
 +
*If-check.sh
 +
*Else-check.sh
 +
*For-check.sh
 +
*While-check.sh
 +
*If.awk
 +
*Else.awk
 +
*For.awk
 +
*While.awk
 +
*astyle makes the changes.
 +
 
 +
 
 +
But we get some false alarm with statements that extend over more than one line:
 +
 
 +
{{Output|1=if (''condition_1''
 +
    && ''condition_2'') {
 +
    ''statement;''
 +
}
 +
}}
 +
 
 +
=== '''typedef struct''' statement over more lines ===
 +
 
 +
This example shows the indentation we prefer:
 +
 
 +
{{Output|1=typedef struct foo {
 +
    // some lines
 +
}
 +
}}
 +
 
 +
*TypedefStruct-check.sh
 +
*TypeStruct.awk
 +
 
 +
=== Don't use '''&''' without a variable ===
 +
 
 +
It is more readable to have the name of (all) the variable(s) in the first line of a method.
 +
 
 +
The chnages must be done manually.
 +
 
 +
=== Don't use untyped '''enum''' ===
 +
 
 +
Instead of having an untyped enum such as:
 +
{{Output|1=  enum {
 +
    aElement= 123
 +
}
 +
}}
 +
we prefer a #define directive:
 +
{{Output|1=#define aElement 123
 +
}}
 +
 
 +
=== Don't use '''enum''' with empty member ===
  
 
The most compilers do not complain such a code:
 
The most compilers do not complain such a code:
Line 290: Line 406:
 
}}
 
}}
  
The last element is empty.  
+
The last element is empty.
 
We prefer a "pedantic" code such as:
 
We prefer a "pedantic" code such as:
  
Line 299: Line 415:
 
}}
 
}}
  
*coding-style-check-Enum-Pedantic.sh
+
*EnumPedantic-check.sh
 +
*EnumPedantic.awk
  
The output of the '''check''' script is:
+
=== No ''';''' after some macros ===
{{Output|1=check the file /home/guy-kde/Software/coding-style-check/enum-example.cpp
+
 
enum with ,} found at
+
Looking over the git-history, one can find some "pedantic" changes.
3->   bElement,
+
These are changes to make a better code. The most of them are at the use of macro, where it is not necessary to have a ''';''' at the end ofthe command.
4-> }
+
The script make a check over all these:
 +
'''AKTEST_MAIN;MAKE_CMD_ROW;Q_DECLARE_FLAGS;Q_PRIVATE_SLOT;Q_DECLARE_METATYPE;Q_DECLARE_OPERATORS_FOR_FLAGS;Q_DE
 +
CLARE_PRIVATE;Q_DECLARE_PUBLIC;Q_DISABLE_COPY;K_GLOBAL_STATIC;Q_IMPORT_PLUGIN;Q_PROPERTY;QTEST_KDEMAIN;QTEST_MAIN'''
 +
 
 +
*Pedantic-check.sh
 +
*Pedantic.awk
 +
 
 +
=== No "one line" '''if''', '''else''', '''for''' or '''while''' statement ===
 +
 
 +
Refer to http://techbase.kde.org/Policies/Kdelibs_Coding_Style#Braces
 +
 
 +
The following code:
 +
{{Output|1=if (a > b) c = 123;}}
 +
is correct, but we prefer the block:
 +
{{Output|1=if (a > b) {
 +
  c = 123;
 +
}
 
}}
 
}}
 +
which is easier to debug, to read and to modify.
  
==== Some more space(s)  ====
+
It is also possible to put a breakpoint at the line in the block.
  
The declaration S *D; declares D as a pointer to the type determined by decl-specifier-seq S.
+
As the awk-script is too simple to recognize all the if-statements, we get some false alarm and
 +
we can't make the changes automatically.
  
The most compilers do not make any difference for such lines of code:
+
*OneLine-If.sh
 +
*OneLine-Else.sh
 +
*If.awk
 +
*Else.awk
  
{{Output|1=int *a;
+
=== No space between some keywords ===
int* b;
+
int * c}}
+
  
We prefer the first one, without a space beetwen the star and the name of the variable:
+
We don't want to have a space:
 +
*between '''&''' and '''>'''
 +
*between '''*''' and '''>'''
 +
*between '''(''' and ''')''', an empty parameter list.
  
{{Output|1=int *a;}}
+
*NoSpace-check.sh
 +
*NoSpace.awk
  
The same rule may be use for:
+
=== No space around the index of an array ===
  
{{Output|1=myFunction( int &a, int& b, int & c)
+
We don't want to have spaces around the index of an array element.
  { // some lines
+
 
  }
+
*SpaceInArray-check.sh
 +
*SpaceInArray-change.sh
 +
*SpaceInArray.awk
 +
 
 +
=== No space around an expression surrounded with braces ===
 +
 
 +
We prefer function definition and function call with no space after the opening brace and before the closing brace.
 +
 
 +
*Parenthesis-check.sh
 +
*Parenthesis.awk
 +
*This is well done with astyle:
 +
{{Output| 1=astyle --unpad-paren
 
}}
 
}}
  
We prefer:
+
Note that astyle makes also changes within the macros SIGNAL and SLOT, which aren't desired.
{{Output|1=myFunction( int &a, int &b, int &c) }}
+
This can be corrected with a Qt-utility qt5/qtrepotools/util/normalize/normalize:
 +
{{Output| 1=normalize --modify ''filename''
 +
}}
  
The awk-script checks also the occurences of:
+
=== No space before ''':''' in a case statement ===
* '''&,'''
+
* '''& >'''
+
* '''* >'''
+
* '''( )''' and '''(  )''' ''empty function call''
+
* '''[ ''' and ''' ]''' ''index of an array''
+
* '''enum {''' ''untyped enum''
+
  
*coding-style-check-NO_space_before_Star.sh
+
We don't provide (yet) any check for this rule.
  
The script gives informations about the found line(s).
+
=== No space before ''';''' at the end of statement ===
  
==== Member initialization in a class  ====
+
We don't provide (yet) any check for this rule.
  
This example shows the indentation we prefer:
+
=== No ''');''' alone in a line ===
  
{{Output|1=class myClass {
+
This is sometime to be find with a function call with many arguments, listed on many lines.
  // some lines
+
*ParenthesisAlone-check.sh
public:
+
*ParenthesisAlone.awk
  myClass( int i )
+
    : r( a )
+
    , b( i )
+
    , i( i )
+
    , j( this->i )
+
  {
+
  }
+
}}
+
  
*coding-style-check-Default.sh
+
=== No space before a comma ===
  
But the script produces a false alarm with the code:
+
This is sometime to be found in a function call.
{{Output| 1=if ( ''<expression>'' ) ? a : b;
+
}}
+
  
==== Parenthesis ====
+
*SpaceComma-check.sh
 +
*SpaceComma.awk
  
We prefer function definition and function call with a space after the opening brace and before the closing brace.
+
=== Operator overloading ===
The same is expected beetwen the braces of a '''if''', '''for''', '''do''', '''while''', '''foreach''' statements.
+
But not for the '''SLOT''' and '''SIGNAL''' macros.
+
The use of two braces '''((''' and '''))''' will be also signaled as a missing space.
+
  
*coding-style-check-Parenthesis.sh
+
As written at:
  
 +
http://www.drbio.cornell.edu/pl47/programming/TICPP-2nd-ed-Vol-one-html/Chapter12.html
  
The changes must bedone manually.
+
"... Defining an overloaded operator is like defining a function, but the name of that function is operator@, in which @ represents the operator that’s being overloaded. ..."
  
==== Switch statement ====
+
Some sources use a space after the reserved word operator. We prefer to use the syntax without space.
  
This example shows the indentation we prefer:
+
*Operator-check.sh
 +
*Operator-change.sh
 +
*Operator.awk
  
{{Output|1=switch ( a ) {
+
== Use all the scripts ==
case ''one'':
+
  // some lines
+
  break;
+
case ''two'':
+
  // some lines
+
  break;
+
default:
+
  // some lines
+
  break;
+
}
+
}}
+
  
*coding-style-check-Switch.sh
+
All the scripts can be used with one only script.
  
==== Use one space after each keyword, but not after a cast ====
+
== Check the objects and the libs ==
  
Refer to http://techbase.kde.org/Policies/Kdelibs_Coding_Style#Whitespace
+
Since the changes described above are only coding style changes, they are ignored by the compiler.
 +
Therefore, the result of the compilation is expected to be exactly the same after applying any of the rules.
  
For most of the keywords, it is not necessary to make a test. Because  the sources have been already compiled. For example this code never appear in a source:
+
To check this, one uses the '''Md5sum-the-Objects.sh'''.
{{Output|1=inta;
+
Same for the libs. Use the '''Md5sum-the-Libs.sh'''.
floatb;}}
+
  
Some of the keywords are alone in the statement, such as '''break''' and '''continue'''. No test is necessary.
+
The script can be used with one of the commands:
 +
* save
 +
* test
 +
* clean
  
The only tests we have to do are the ones where a keyword is (or can be) followed
+
'''An example:'''
by a sign '''( { [ :'''
+
  
These are:
+
{{Input|1=cd <some_kdepim_directory>
'''alignas decltype alignof noexcept typeid asm static_assert switch if catch while for sizeof new Q_FOREACH do try enum union Q_FOREVER bool char char16_t char32_t double float int long wchar_t signed unsigned short'''
+
mkdir build
 +
cd build
 +
ccmake ../
 +
make}}
 +
{{Output|1=<span style="color:Fuchsia">Scanning dependencies of target gpgmepp</span>
 +
[  0%] <span style="color:green">Building CXX object gpgme++/CMakeFiles/gpgmepp.dir/gpgmepp_automoc.cpp.o</span>
 +
[  0%] <span style="color:green">Building CXX object gpgme++/CMakeFiles/gpgmepp.dir/exception.cpp.o</span>
 +
[  0%] <span style="color:green">Building CXX object gpgme++/CMakeFiles/gpgmepp.dir/context.cpp.o</span>
 +
...}}
  
For only '''one''' keyword:
+
{{Input|1=Check-the-Objects.sh save}}
*coding-style-check-SpaceAfterKeyword.sh
+
The script makes a copy of all the objects and a "time stamp":
*coding-style-change-SpaceAfterKeyword.sh
+
{{Output|1=save the object ./kholidays/tests/CMakeFiles/testzodiac.dir/testzodiac.cpp.o
 +
save the object ./kholidays/tests/CMakeFiles/testzodiac.dir/testzodiac_automoc.cpp.o
 +
...
 +
all objects are saved}}
  
For '''all''' keywords above:
+
Now, one makes somes change(s) on the source(s) and:
*coding-style-check-SpaceAfter.sh
+
*coding-style-change-SpaceAfter.sh
+
  
The output of the '''check''' script is:
+
{{Input| 1=make}}
{{Output|1=check the file /home/guy-kde/projects/kdepimlibs/akonadi/contact/contactstreemodel.cpp
+
 
1->98: if( at 10:          if( contact.realName().isEmpty() ) {
+
Depending on the Makefile, some objects will be compiled again:
2->99if( at 12:            if( contact.preferredEmail().isEmpty() ) {
+
 
 +
{{Output| 1=<span style="color:Fuchsia">Scanning dependencies of target akonadi-kde</span>
 +
[ 17%] <span style="color:green">Building CXX object akonadi/CMakeFiles/akonadi-kde.dir/entitytreeview.cpp.o</span>
 +
[ 17%] <span style="color:green">Building CXX object akonadi/CMakeFiles/akonadi-kde.dir/itemfetchjob.cpp.o</span>
 +
[ 17%] <span style="color:green">Building CXX object akonadi/CMakeFiles/akonadi-kde.dir/statisticsproxymodel.cpp.o</span>
 +
...
 +
<span style="color:Fuchsia">Scanning dependencies of target akonadi-kmime</span>
 +
[ 56%] <span style="color:green">Building CXX object akonadi/kmime/CMakeFiles/akonadi-kmime.dir/standardmailactionmanager.cpp.o</span>}}
 +
 
 +
{{Input|1=Check-the-Objects.sh test}}
 +
 
 +
The script finds all the new objects, makes a comparision with the saved version:
 +
  {{Output|1=test the object ./akonadi/CMakeFiles/akonadi-kde.dir/statisticsproxymodel.cpp.o
 +
test the object ./akonadi/CMakeFiles/akonadi-kde.dir/entitytreeview.cpp.o
 +
test the object ./akonadi/CMakeFiles/akonadi-kde.dir/itemfetchjob.cpp.o
 +
test the object ./akonadi/kmime/CMakeFiles/akonadi-kmime.dir/standardmailactionmanager.cpp.o
 +
all tests are OK
 
}}
 
}}
  
The '''change''' script:
+
== Check the assembler files ==
*puts a space after the keyword.
+
If we add or remove some lines, the debug information included in the object file will change also.
 +
 
 +
This is the case with the test/change of "''Only single empty lines should be used''", "''First line, last line(s) may not be empty''" and some more test/change below (''adding some blocks'' with { and }).
 +
 
 +
For this reason it is no more possible to compare the objects.
 +
We have to compare the assembler files.
 +
This works pretty well for the version with '''CMAKE_BUILD_TYPE''' set to ''release''.
 +
For the version with '''CMAKE_BUILD_TYPE''' set to ''debug'', we must remove all the debug information before the comparision can take place.
 +
 
 +
=== Generate the assembler files ===
 +
 
 +
To generate the assembler files, we only need to modify the ''build.make'' in every folder.
 +
 
 +
The script '''Prepare-build_make_files.sh''' works on the all directory, finds the line with the compiler command,
 +
duplicates the line, add a ''-S option'' and changes the name of the output to ''somename.s''.
 +
After a new ''make'' command, we can save all the assembler files with the script '''Check-the-assembler_code.sh'''.
 +
 
 +
=== Remove the debug information ===
 +
 
 +
The debug information changes with the changes of line numbers.
 +
We drop all the debug information before making the test.
 +
 
 +
The script to check the assembler files can be used in the same way as the one above (Check-the-Objects.sh).
 +
To check this, one uses the '''Check-the-assembler_code.sh'''.
 +
 
 +
The script can be used with one of the commands:
 +
* save
 +
* test
 +
* clean
 +
 
 +
== The results of the migration ==
 +
 
 +
The results can be seen [http://techbase.kde.org/ResultsOfTheMigration here].

Latest revision as of 17:56, 4 November 2014

Contents

[edit] Purpose of this document

This document describes the recommended coding style for kdepim and akonadi. Nobody is forced to use this style, but to have consistent formatting of the source code files it is strongly recommended to make use of it.

In short: Kdepim and akonadi coding style follows the Kdelibs coding style.

But we have some more rules for some more situations.

[edit] Why is coding Style useful?

Let us make a comparision with real life. To make an addition, one can write:

123
+      456
  ==========
     =      579

But we have learned in primary school to write:

Addition
  123
 +456
 ====
 =579

Which is much more readable, easy to control (or debug).

This is Coding Style: not mandatory, but very useful and pretty to read.

[edit] What do we need?

We need at least:

  • a specification (a set of rules) for the coding style of the sources
  • some tools to check the sources against the specification
  • some tools to change the sources


astyle is a very suitable tool to make such changes. But astyle doesn't implement (yet) all the specification rules.

You can find below some awk-scripts which help us to check all the rules.

You can find below some awk-scripts which help us to make most of the changes. The last part must be done manually.

[edit] The specification rules of coding style for kdepim and akonadi

These are the sub-sections under The rules and the scripts ...

[edit] Migration

As discussed at the KDEPIM meeting, Berlin, 3 March 2013, all the files of KDEPIM will be reviewed to follow the coding style. This will be done over a long time, directory after directory, for each of the rules defined above. For each rule, there are one or two script(s).

The main part of the changes can be done with astyle: http://astyle.sourceforge.net/

The results can be seen here.

[edit] Download Coding Style

You can download the software with test files and install instructions.

Download Coding Style: Media:CodingStyle.tar.gz

[edit] Two scripts to check all the rules and to make the all the changes

Most of the rules can be checked with the scripts below. For some of the rules, we don't have a script to change the sources. It is better first to make a check for such a rule, second to make the modification(s) manually to suscript the rule(s).

There are two scripts that run all the checks and apply all the changes at once:

  • All-Check.sh
  • Change-All.sh

For each specification rule, the name of the scripts to check and apply the changes are given at the beginning of the section.

[edit] The rules and the scripts to check and to make the changes

The first script is to check a single file or all .h and .cpp files in a directory.

If present, the second script applies the changes. For some complicated situations, the script makes no change.

You can use the scripts for your own work. It is recommended to use them in this order.

[edit] Don't test all directories

If a .no_coding_style file is present on a directory, the test will not be done.

If a .no_recursion file is present on a directory, we do not explore the subdirectory(ies)

[edit] Indentation with four spaces, don't use any <TAB>s

  • Tabs-check.sh
  • Tabs.awk
  • The changes are well done with
astyle --indent=spaces=4

[edit] Trim the lines

  • Trim-check.sh
  • Trim.awk
  • The changes are well done with:
astyle --indent=spaces

[edit] Only single empty lines

Refer to http://techbase.kde.org/Policies/Kdelibs_Coding_Style#Whitespace

  • Twice-check.sh
  • Twice-change.sh
  • Twice.awk

[edit] The first line and the last line(s) may not be empty

Some of the sources have empty lines at the beginning of the file. Some have one or more empty last line(s).

  • First-check.sh
  • First-change.sh
  • First.awk

[edit] Only one statement per line

We don't provide (yet) any check for this rule.

[edit] Variable declaration

We follow the kdelibs rule: [[1]] We don't provide (yet) any check for this rule.

[edit] Only one declaration per line

We follow the kdelibs rule: [[2]] We don't provide (yet) any check for this rule.

[edit] Use one space after each keyword, but not after a cast

Refer to http://techbase.kde.org/Policies/Kdelibs_Coding_Style#Whitespace

For most of the keywords, it is not necessary to make a test. Because the sources have been already compiled. For example this code never appear in a compiled source:

intmyVariableAa;
floatmyVariableBb;

In this case, the missing space leads to a syntax error which is detected by the compiler. We don't need to check this manually.

Some of the keywords are alone in the statement, such as break and continue. No test is necessary.

The only tests we have to do are the ones where a keyword is (or can be) followed by a sign ( { [ :

These are: alignas decltype alignof noexcept typeid asm static_assert switch if catch while for foreach sizeof new Q_FOREACH FOREACH do try enum union Q_FOREVER bool char char16_t char32_t double float int long wchar_t signed unsigned short

  • SpaceAfter-check.sh
  • SpaceAfter-change.sh
  • SpaceAfter.awk

[edit] Use a space after the name of the class

We prefer having a space before the keyword public at the definition of a new class:

class DbException : public Akonadi::Exception
{
  ...
};
  • Public-check.sh
  • Public-change.sh
  • Public.awk

[edit] #include directive

Refer to http://techbase.kde.org/Policies/Kdelibs_Coding_Style#Qt_Includes

We prefer no space at the beginning of the directive. Some (not many) files need to be corrected to unify to all the other files.

// some files use this
# include <A/b>

// we prefer to unify the coding style
#include <A/b>
  • Space-Include-check.sh
  • SpaceInclude.awk

[edit] Place * and & next to the variable

The declaration S *D; declares D as a pointer to the type determined by decl-specifier-seq S.

For most compilers, the three declarations below are semantically the same:

int *a;
int* b;
int * c

We prefer the first one, without a space beetwen the star and the name of the variable:

int *a;

The same rule may be use for:

myFunction(int &a, int& b, int & c)
{
    // some lines
}

We prefer:

myFunction(int &a, int &b, int &c)

The awk-script checks also the occurences of:

  • &,
  • & >
  • * >
  • ( ) and ( ) empty function call
  • enum { untyped enum

Not all the ouputs are real errors. Some codings might be correct.

  • NoSpace-check.sh
  • NoSpace.awk
  • using astyle to make the changes:
astyle --reference=name --align-pointer=name


Some lines with must be manually corrected.

[edit] Use namespace foo { in the same line

We prefer having all in one line:

namespace foo {
  ...
}
  • Namespace-check.sh
  • Namespace.awk
  • astyle to make the changes.

[edit] Use struct foo with { at the next line

We prefer having the same coding style for a class and a struct

struct foo
{
  ...
}
  • Struct-check.sh
  • Struct-change.sh
  • Struct.awk

NOTE: The script must be use after astyle.

[edit] Each member initialization of a method in separate line

This example shows the indentation we prefer. Notice that colon sign and comma(s) are at the beginning of each initialization line(s):

class myClass
{
    // some lines
public:
    myClass(int r, int b, int i, int j)
        : r(0)
        , b(i)
        , i(5)
        , j(13)
{
    // more lines
}
};
  • Default-check.sh
  • Default-change.sh
  • Default.awk

[edit] Surround all operators with spaces

This is well done with astyle:

astyle --pad-oper

[edit] switch rules

This example shows the indentation we prefer:

switch (a) {
case one:
    // some lines
    break;
case two: {
    // some lines
    break;
}
case three: {
    // some lines
    return;
}
default:
    // some lines
    break;
}
  • Switch-check.sh
  • Switch.awk
  • astyle makes the changes

NOTE: By using a new block, we prefer having break; and return; within the new block.

[edit] try-catch rules

This example shows the indentation we prefer:

try {
    // some lines
} catch (...) {
}
  • TryCatch-check.sh
  • TryCatch.awk

[edit] if, else, for, while (and similar macros) rules

Even for blocks with only one statement, we prefer to use braces such as:

if (condition) {
    statement;
}

This should be used with the keywords if, else, for, while and similar macros.

  • If-check.sh
  • Else-check.sh
  • For-check.sh
  • While-check.sh
  • If.awk
  • Else.awk
  • For.awk
  • While.awk
  • astyle makes the changes.


But we get some false alarm with statements that extend over more than one line:

if (condition_1
    && condition_2) {
    statement;
}

[edit] typedef struct statement over more lines

This example shows the indentation we prefer:

typedef struct foo {
    // some lines
}
  • TypedefStruct-check.sh
  • TypeStruct.awk

[edit] Don't use & without a variable

It is more readable to have the name of (all) the variable(s) in the first line of a method.

The chnages must be done manually.

[edit] Don't use untyped enum

Instead of having an untyped enum such as:

enum {
    aElement= 123
}

we prefer a #define directive:

#define aElement 123

[edit] Don't use enum with empty member

The most compilers do not complain such a code:

enum mytype {
    aElement,
    bElement,
}

The last element is empty. We prefer a "pedantic" code such as:

enum mytype {
    aElement,
    bElement
}
  • EnumPedantic-check.sh
  • EnumPedantic.awk

[edit] No ; after some macros

Looking over the git-history, one can find some "pedantic" changes. These are changes to make a better code. The most of them are at the use of macro, where it is not necessary to have a ; at the end ofthe command. The script make a check over all these: AKTEST_MAIN;MAKE_CMD_ROW;Q_DECLARE_FLAGS;Q_PRIVATE_SLOT;Q_DECLARE_METATYPE;Q_DECLARE_OPERATORS_FOR_FLAGS;Q_DE CLARE_PRIVATE;Q_DECLARE_PUBLIC;Q_DISABLE_COPY;K_GLOBAL_STATIC;Q_IMPORT_PLUGIN;Q_PROPERTY;QTEST_KDEMAIN;QTEST_MAIN

  • Pedantic-check.sh
  • Pedantic.awk

[edit] No "one line" if, else, for or while statement

Refer to http://techbase.kde.org/Policies/Kdelibs_Coding_Style#Braces

The following code:

if (a > b) c = 123;

is correct, but we prefer the block:

if (a > b) {
   c = 123;
}

which is easier to debug, to read and to modify.

It is also possible to put a breakpoint at the line in the block.

As the awk-script is too simple to recognize all the if-statements, we get some false alarm and we can't make the changes automatically.

  • OneLine-If.sh
  • OneLine-Else.sh
  • If.awk
  • Else.awk

[edit] No space between some keywords

We don't want to have a space:

  • between & and >
  • between * and >
  • between ( and ), an empty parameter list.
  • NoSpace-check.sh
  • NoSpace.awk

[edit] No space around the index of an array

We don't want to have spaces around the index of an array element.

  • SpaceInArray-check.sh
  • SpaceInArray-change.sh
  • SpaceInArray.awk

[edit] No space around an expression surrounded with braces

We prefer function definition and function call with no space after the opening brace and before the closing brace.

  • Parenthesis-check.sh
  • Parenthesis.awk
  • This is well done with astyle:
astyle --unpad-paren

Note that astyle makes also changes within the macros SIGNAL and SLOT, which aren't desired. This can be corrected with a Qt-utility qt5/qtrepotools/util/normalize/normalize:

normalize --modify filename

[edit] No space before : in a case statement

We don't provide (yet) any check for this rule.

[edit] No space before ; at the end of statement

We don't provide (yet) any check for this rule.

[edit] No ); alone in a line

This is sometime to be find with a function call with many arguments, listed on many lines.

  • ParenthesisAlone-check.sh
  • ParenthesisAlone.awk

[edit] No space before a comma

This is sometime to be found in a function call.

  • SpaceComma-check.sh
  • SpaceComma.awk

[edit] Operator overloading

As written at:

http://www.drbio.cornell.edu/pl47/programming/TICPP-2nd-ed-Vol-one-html/Chapter12.html

"... Defining an overloaded operator is like defining a function, but the name of that function is operator@, in which @ represents the operator that’s being overloaded. ..."

Some sources use a space after the reserved word operator. We prefer to use the syntax without space.

  • Operator-check.sh
  • Operator-change.sh
  • Operator.awk

[edit] Use all the scripts

All the scripts can be used with one only script.

[edit] Check the objects and the libs

Since the changes described above are only coding style changes, they are ignored by the compiler. Therefore, the result of the compilation is expected to be exactly the same after applying any of the rules.

To check this, one uses the Md5sum-the-Objects.sh. Same for the libs. Use the Md5sum-the-Libs.sh.

The script can be used with one of the commands:

  • save
  • test
  • clean

An example:

cd <some_kdepim_directory>
mkdir build
cd build
ccmake ../
make
Scanning dependencies of target gpgmepp
[  0%] Building CXX object gpgme++/CMakeFiles/gpgmepp.dir/gpgmepp_automoc.cpp.o
[  0%] Building CXX object gpgme++/CMakeFiles/gpgmepp.dir/exception.cpp.o
[  0%] Building CXX object gpgme++/CMakeFiles/gpgmepp.dir/context.cpp.o
...
Check-the-Objects.sh save

The script makes a copy of all the objects and a "time stamp":

save the object ./kholidays/tests/CMakeFiles/testzodiac.dir/testzodiac.cpp.o
save the object ./kholidays/tests/CMakeFiles/testzodiac.dir/testzodiac_automoc.cpp.o
...
all objects are saved

Now, one makes somes change(s) on the source(s) and:

make

Depending on the Makefile, some objects will be compiled again:

Scanning dependencies of target akonadi-kde
[ 17%] Building CXX object akonadi/CMakeFiles/akonadi-kde.dir/entitytreeview.cpp.o
[ 17%] Building CXX object akonadi/CMakeFiles/akonadi-kde.dir/itemfetchjob.cpp.o
[ 17%] Building CXX object akonadi/CMakeFiles/akonadi-kde.dir/statisticsproxymodel.cpp.o
...
Scanning dependencies of target akonadi-kmime
[ 56%] Building CXX object akonadi/kmime/CMakeFiles/akonadi-kmime.dir/standardmailactionmanager.cpp.o
Check-the-Objects.sh test

The script finds all the new objects, makes a comparision with the saved version:

test the object ./akonadi/CMakeFiles/akonadi-kde.dir/statisticsproxymodel.cpp.o
test the object ./akonadi/CMakeFiles/akonadi-kde.dir/entitytreeview.cpp.o
test the object ./akonadi/CMakeFiles/akonadi-kde.dir/itemfetchjob.cpp.o
test the object ./akonadi/kmime/CMakeFiles/akonadi-kmime.dir/standardmailactionmanager.cpp.o
all tests are OK

[edit] Check the assembler files

If we add or remove some lines, the debug information included in the object file will change also.

This is the case with the test/change of "Only single empty lines should be used", "First line, last line(s) may not be empty" and some more test/change below (adding some blocks with { and }).

For this reason it is no more possible to compare the objects. We have to compare the assembler files. This works pretty well for the version with CMAKE_BUILD_TYPE set to release. For the version with CMAKE_BUILD_TYPE set to debug, we must remove all the debug information before the comparision can take place.

[edit] Generate the assembler files

To generate the assembler files, we only need to modify the build.make in every folder.

The script Prepare-build_make_files.sh works on the all directory, finds the line with the compiler command, duplicates the line, add a -S option and changes the name of the output to somename.s. After a new make command, we can save all the assembler files with the script Check-the-assembler_code.sh.

[edit] Remove the debug information

The debug information changes with the changes of line numbers. We drop all the debug information before making the test.

The script to check the assembler files can be used in the same way as the one above (Check-the-Objects.sh). To check this, one uses the Check-the-assembler_code.sh.

The script can be used with one of the commands:

  • save
  • test
  • clean

[edit] The results of the migration

The results can be seen here.


This page was last modified on 4 November 2014, at 17:56. This page has been accessed 26,958 times. Content is available under Creative Commons License SA 3.0 as well as the GNU Free Documentation License 1.2.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal