Uncrustify: Difference between revisions
(showing diff on tests) |
|||
(16 intermediate revisions by the same user not shown) | |||
Line 18: | Line 18: | ||
* the sources for the installer are at https://github.com/openpetra/openpetra/tree/master/setup/tools/uncrustify | * the sources for the installer are at https://github.com/openpetra/openpetra/tree/master/setup/tools/uncrustify | ||
== Debugging uncrustify == | * usually we use the zip file released for Windows by the uncrustify project, from https://sourceforge.net/projects/uncrustify/files/ | ||
=== build installer from git master === | |||
* need a Fedora 25 64 bit virtual machine | |||
dnf install git automake gcc-c++ make zip python cmake | |||
git clone https://github.com/uncrustify/uncrustify.git | |||
cd uncrustify | |||
mkdir build | |||
cd build | |||
cmake -DCMAKE_BUILD_TYPE=Release .. | |||
cmake --build . | |||
# resulting linux binary is build/uncrustify | |||
cd .. | |||
dnf install mingw32-gcc-c++ mingw32-winpthreads-static | |||
mkdir buildwin-32 | |||
cd buildwin-32 | |||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw32.cmake \ | |||
-DCMAKE_EXE_LINKER_FLAGS="-static -s" .. | |||
make | |||
cpack | |||
# Result in: buildwin-32/uncrustify-Uncrustify-0.64-574-bc4307b-win32.zip | |||
==== Release ICT_OpenPetra_2016_06 ==== | |||
* see https://github.com/tpokorra/uncrustify/tree/ICT_OpenPetra_2016_06 | |||
* it is based on git master of uncrustify, in the preparation for 0.63 | |||
* see github commit log which patches have been applied | |||
git clone -b ICT_OpenPetra_2016_06 https://github.com/tpokorra/uncrustify.git uncrustify.ICT_OpenPetra_2016_06 | |||
* download here: https://sourceforge.net/projects/openpetraorg/files/openpetraorg/Tools/Uncrustify-Setup-0.62.173-gc2a1d74-dirty.exe/download | |||
== Debugging uncrustify and adding tests == | |||
For C# 6 support we noticed that even version 0.62 did not support all new C# 6 features. see https://sourceforge.net/p/uncrustify/bugs/672/ for details. | For C# 6 support we noticed that even version 0.62 did not support all new C# 6 features. see https://sourceforge.net/p/uncrustify/bugs/672/ for details. | ||
Line 25: | Line 56: | ||
git clone https://github.com/uncrustify/uncrustify.git | git clone https://github.com/uncrustify/uncrustify.git | ||
cd uncrustify | cd uncrustify | ||
./ | mkdir build | ||
./ | cd build | ||
cmake -DCMAKE_BUILD_TYPE=Debug .. | |||
cmake --build . | |||
cd ../src/ | |||
ln -s ../build/uncrustify | |||
cd .. | |||
To run the tests: | To run the tests: | ||
./run_tests.sh c-sharp | ./run_tests.sh c-sharp | ||
To show diff on failure, use the parameter -g when calling uncrustify: | |||
./run_tests.sh c-sharp -d | |||
You can add new tests with these steps: | You can add new tests with these steps: | ||
Line 36: | Line 74: | ||
* add an expected output file to https://github.com/uncrustify/uncrustify/tree/master/tests/output/cs | * add an expected output file to https://github.com/uncrustify/uncrustify/tree/master/tests/output/cs | ||
* add the test in https://github.com/uncrustify/uncrustify/blob/master/tests/c-sharp.test | * add the test in https://github.com/uncrustify/uncrustify/blob/master/tests/c-sharp.test | ||
If uncrustify has an exception, you only get message like this: | If uncrustify has an exception, you only get message like this: | ||
Line 46: | Line 82: | ||
cd tests | cd tests | ||
/home/timotheusp/dev/uncrustify.tpokorra/src/uncrustify -c config/ben.cfg -f input/cs/exception-filters.cs > results/cs/10160-exception-filters.cs | /home/timotheusp/dev/uncrustify.tpokorra/src/uncrustify -c config/ben.cfg -f input/cs/exception-filters.cs > results/cs/10160-exception-filters.cs | ||
Some hints for debugging: | |||
* does the parsing work? brace_cleanup.cpp, combine.cpp | |||
* does the output work? space.cpp, newlines.cpp | |||
* chunk_t, see uncrustify_types.h. | |||
printf("my message %s\n", pc->str.c_str()); | |||
printf("my message %s\n", pc->next->str.c_str()); |
Latest revision as of 05:39, 8 Haziran 2017
about uncrustify
- homepage: http://uncrustify.sourceforge.net/
"Source Code Beautifier for C, C++, C#, ObjectiveC, D, Java, Pawn and VALA"
"The goals of this project are simple: Create a highly configurable, easily modifiable source code beautifier."
See sources at Github: https://github.com/uncrustify/uncrustify
current version used
- Currently we still use version 0.56.
our own installer for Windows
it is easier to have an installer for Windows, instead of the zip file provided by the uncrustify project.
- download from http://sourceforge.net/projects/openpetraorg/files/openpetraorg/Tools/Uncrustify-Setup-0.56.exe/download
- the sources for the installer are at https://github.com/openpetra/openpetra/tree/master/setup/tools/uncrustify
- usually we use the zip file released for Windows by the uncrustify project, from https://sourceforge.net/projects/uncrustify/files/
build installer from git master
- need a Fedora 25 64 bit virtual machine
dnf install git automake gcc-c++ make zip python cmake git clone https://github.com/uncrustify/uncrustify.git cd uncrustify mkdir build cd build cmake -DCMAKE_BUILD_TYPE=Release .. cmake --build . # resulting linux binary is build/uncrustify cd .. dnf install mingw32-gcc-c++ mingw32-winpthreads-static mkdir buildwin-32 cd buildwin-32 cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw32.cmake \ -DCMAKE_EXE_LINKER_FLAGS="-static -s" .. make cpack # Result in: buildwin-32/uncrustify-Uncrustify-0.64-574-bc4307b-win32.zip
Release ICT_OpenPetra_2016_06
- see https://github.com/tpokorra/uncrustify/tree/ICT_OpenPetra_2016_06
- it is based on git master of uncrustify, in the preparation for 0.63
- see github commit log which patches have been applied
git clone -b ICT_OpenPetra_2016_06 https://github.com/tpokorra/uncrustify.git uncrustify.ICT_OpenPetra_2016_06
- download here: https://sourceforge.net/projects/openpetraorg/files/openpetraorg/Tools/Uncrustify-Setup-0.62.173-gc2a1d74-dirty.exe/download
Debugging uncrustify and adding tests
For C# 6 support we noticed that even version 0.62 did not support all new C# 6 features. see https://sourceforge.net/p/uncrustify/bugs/672/ for details.
On Linux, I cloned the git master of uncrustify, to see if those issues had already been fixed there.
git clone https://github.com/uncrustify/uncrustify.git cd uncrustify mkdir build cd build cmake -DCMAKE_BUILD_TYPE=Debug .. cmake --build . cd ../src/ ln -s ../build/uncrustify cd ..
To run the tests:
./run_tests.sh c-sharp
To show diff on failure, use the parameter -g when calling uncrustify:
./run_tests.sh c-sharp -d
You can add new tests with these steps:
- add an input file to https://github.com/uncrustify/uncrustify/tree/master/tests/input/cs
- add an expected output file to https://github.com/uncrustify/uncrustify/tree/master/tests/output/cs
- add the test in https://github.com/uncrustify/uncrustify/blob/master/tests/c-sharp.test
If uncrustify has an exception, you only get message like this:
RUN: /home/timotheusp/dev/uncrustify.tpokorra/src/uncrustify -q -c config/ben.cfg -f input/cs/exception-filters.cs > results/cs/10160-exception-filters.cs FAILED: 10160
Then you should run this on the commandline, but without the -q:
cd tests /home/timotheusp/dev/uncrustify.tpokorra/src/uncrustify -c config/ben.cfg -f input/cs/exception-filters.cs > results/cs/10160-exception-filters.cs
Some hints for debugging:
- does the parsing work? brace_cleanup.cpp, combine.cpp
- does the output work? space.cpp, newlines.cpp
- chunk_t, see uncrustify_types.h.
printf("my message %s\n", pc->str.c_str()); printf("my message %s\n", pc->next->str.c_str());