Uncrustify: Difference between revisions

From OpenPetra Wiki
Jump to navigation Jump to search
(showing diff on tests)
 
(14 intermediate revisions by the same user not shown)
Line 21: Line 21:


=== build installer from git master ===
=== build installer from git master ===
* see https://github.com/uncrustify/uncrustify/blob/master/make_win32.sh
* need a Fedora 25 64 bit virtual machine
* need a Ubuntu 14.04 64 bit virtual machine


  apt-get install mingw-w64 git automake g++ make zip python
  dnf install git automake gcc-c++ make zip python cmake
  git clone https://github.com/uncrustify/uncrustify.git
  git clone https://github.com/uncrustify/uncrustify.git
  cd uncrustify
  cd uncrustify
  chmod a+x *.sh
  mkdir build
  ./make_win32.sh
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


Result in: /root/release/uncrustify-0.62.92-g5c059c9-dirty-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 ==
== Debugging uncrustify and adding tests ==
Line 39: Line 56:
  git clone https://github.com/uncrustify/uncrustify.git
  git clone https://github.com/uncrustify/uncrustify.git
  cd uncrustify
  cd uncrustify
  ./autogen.sh
  mkdir build
  ./configure
cd build
  make
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 50: 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
You can change the log_level to 7 in https://github.com/uncrustify/uncrustify/blob/master/tests/run_tests.py#L84 so that you see the difference of the result of uncrustify compared to your expected output, if the test fails.


If uncrustify has an exception, you only get message like this:
If uncrustify has an exception, you only get message like this:
Line 60: 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

"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.

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

git clone -b ICT_OpenPetra_2016_06 https://github.com/tpokorra/uncrustify.git uncrustify.ICT_OpenPetra_2016_06

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:

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());