Thursday, September 24, 2015

gnatpp could not align exception declaration properly

I normally use the GNAT Pretty-Printer gnatpp to format my Ada code.  The output of it is not perfect but acceptable and make my code look consistent.

It has a small alignment bug, for exception declaration, it could not handle it properly.  For this specification align_test.ads:
package Align_Test is
    Index: Integer;
    Number_Test : Integer;

    Bad_File : exception;
    Bad_Argument : exception;
end Align_Test;
gnatpp -r align_test.ads will produce:
package Align_Test is
   Index       : Integer;
   Number_Test : Integer;

   Bad_File : exception;
   Bad_Argument : exception;
end Align_Test;
I have to manually align the declaration and add specific comments to fence it from gnatpp to change my alignment in future. 
package Align_Test is
   Index       : Integer;
   Number_Test : Integer;

   --!pp off
   Bad_File     : exception;
   Bad_Argument : exception;
   --!pp on
end Align_Test;
It does not look good, but acceptable.  Wish next version of gnatpp could solve this problem.

P.S. Hooray, today (May. 19, 2016) AdaCore fixed the alignment problem. It will properly show up in GNAT GPL 2016.

Wednesday, September 16, 2015

Where/when is my next laptop purchase

My fastest computer in my home right now is a MacBook from 2009.  It's hard disk has been replaced by a SSD and runs smoothly with the latest OS X and Slackware with some minor glitches (web-camera not working, occasionally system have USB bus error, result in non usable system without keyboard, have to reboot back to OS X to fix it).  I have been searching for my next laptop for some time, but still don't find a perfect one that suites my particular requirements:
  • With 13"/14" screen resolution must be high DPI, the higher the better, minimum 3200x1800.
  • Must have optical digital sound output, be it dedicated TOSLINK connector or combo with head phone jack (this has been standard for MacBook for years).
  • Be lightweight and have longer battery life (>= 8 hours)
  • Must be Linux friendly.
Actually, Dell's XPS 13 almost meets the requirement, except for the optical digital sound output.  Apple's MacBook Pro comes close but it is not Linux friendly, and screen resolution is lower than Dell's.  All of Lenovo's offers lack optical digital sound output, X1 carbon does not have high resolution screen, Yoga Pro does not have enough CPU power.

Maybe I should wait one or two more years, then Intel's new 3D XPoint maybe used for storage, oh my, maybe I will never buy a new one ... ...

Tuesday, September 15, 2015

Microsoft is downloading Windows 10 to your machine 'just in case'

Oh, Microsoft is doing his "smart" again. Now it will silently download Windows 10 image to your machine regardless you want it or not.

News from Inquirer confirmed it with Microsoft.

It is time to turn off automatically update if you still want to keep running it, or better wipe it out with a Linux distribution (Slackware, should you ask for recommendation). ^_^

Thursday, September 10, 2015

Getting Started with GtkAda - Content

This is the content for my previous Getting Started with GtkAda blogs.

Building Ada programming environment with GCC 5 and GNAT GPL 2015

I would like to rebuild the Ada programming environment based on GCC 5 and GNAT GPL 2015 in Slackware64 14.1, as Ada 2012 support is more mature in GCC 5.

The FSF GCC compiler

At the writing, the latest release of GCC is 5.2.0.  First I update the build script to matched what's in the current tree.  I would to like to replace the stock Slackware64 14.1's compiler with the new one, but GCC changed the default standard C++ library ABI since 5.1.0.  To make it compatible with GCC 4, a configure switch (--with-default-libstdcxx-abi=gcc4-compatible) was added to the build script.  Also, I have changed the build directory to a fixed location to avoid the random location in the original script.  As it is needed for gnat_util build, a fixed location is easier for the script to find the right files.  I had problem on i586 platform, which I had to explicitly add the --disable-multilib switch to the configuration and remove the conditional test for it.  Built and install without problem.

P.S. Due to GPRBuild will look for GNAT's runtime library as libgnat-5.2.so in stead of libgnat-5.so, build script was modified to create the softlink when packaging the GNAT compiler.  Also created libgnarl-5.2.so from libgnarl-5.so

XMLAda

For XMLAda GPL 2015, the default build process is making use of gprbuild, which depends on XMLAda.  I followed what was done on Arch Linux and created a custom Makefile.SlackBuild.  But I installed the package with the following scheme, similar to what GNAT GPL 2015 is doing but with sub-directories for each sub-module:
 usr/include/xmlada
             |- input
             |- unicode
             ...
 usr/lib64/xmlada
           |- input
           |  |- static
           |  `- relocatable
           |- unicode
           |  |- static
           |  `- relocatable
           ...
The document build requires Sphinx, as SlackBuilds.org provides all necessary build scripts, it is a matter of installing the relevant packages and dependencies.

GPRBuild

The 2015 version of gprbuild required gprbuild itself.  So Similar to XMLAda, a custom Makefile was borrowed from the Arch Linux project and modified to suite the needs of Slackware.  My first build was without error, but it failed to build when trying it for gnat_uitl, complained about:
gnat_util.gpr:21:09: warning: no compiler specified for language "C", ignoring all its sources
gnat_util.gpr:21:09: warning: no compiler specified for language "Ada", ignoring all its sources
Further investigation showed that the default target for gprconfig was wrong, it was set to "Slackware" when generating gprconfig-sdefault.ads in my build script, due to not fully understand what it means.  After set it to "$ARCH-slackare-linux", it still failed on linking, looking for GNAT's runtime library libgnat-5.2.so, which does not exist for a standard GCC build, as it only has libgnat-5.so.  After created a soft link from libgnat-5.so, it builds and working.

GNAT_UTIL

The GNAT Util Library provides access to GNAT compiler internals for AdaCore utilities.  The latest release is 5.1.0, since there are no changes on Ada part of the GCC for 5.2.0, it is sufficient for us.  The build went well except for the initial gprbuild target problem.

GTKAda

GTKAda require Gtk+3 version after 3.8.3, the stock version in Slackware 14.1 is 3.8.2, need to upgrade to a latter version.  The version in Slackware current tree is too new, I settled on the latest 3.8 release 3.8.9 and rebuild the GTK+3 package.  The GL support is turned on for this version, but when building test program, it complained:
gtkada-gpl-2015-src/src/lib/gtkada_gl/static/libgtkada_gl.a(gdkgl.o): undefined reference to symbol 'XFree'
/usr/lib/libX11.so.6: error adding symbols: DSO missing from command line
After patching the testgtk.gpr with linker option to link with -lX11 -lm, it built and run fine.

Aunit

Aunit's build script needed to adapt to gprinstall command, other than that, it built smoothly.

GNATColl

GNATColl compiled OK, with minor problem with libgnarl-5.2.so.

GPS

The IDE compiler could be compiled now given all dependencies had been built.  The build did not go smoothly related to some xmlada library issues, back and forth a few times, finally got it compiled.  When running GPS, it gave python script warning about pep8 and jedi, after install those two from SlackBuilds.org, everything is working fine.

Florist

The florist library changed to use gprinstall, which breaks the install process.  After adjust the build script and patched the Makefile.in generated proper project file for used with others, it built and install fine.

Asis

Asis has little problem for installing to correct path, some patch needed to be re-do, after that, everything built and installed correctly.

Gnatmem and Ahven

Gnatmem gave no trouble when compiled for the 2015 version.  Ahven's 2.6 version changed the build process and I had to create a gpr file for it.  Other than that, there is no big problems.

Where are the build scripts

All build scripts are available at GitHub.