After the program has been built it can be run or debugged in QtCreator. For now, command line arguments need to be added before running the program, otherwise it will only output a usage message.
Command line arguments are set on the Projects screen (the Projects icon on the side or Ctrl+5) by selecting the Run Settings button along the top of the screen. For example, under Run, enter ../thunder422‑ibcp/test/translator01.dat to run the first translator test (assuming the default directories were used up to now).
Again there are multiple ways to run the program (play icon on lower side, Ctrl+R, Run on the Build menu). Same for running in the debugger; though note that in order to trace through the program, a breakpoint needs to be set first or the program runs (in the debugger) until it exits.
Saturday, October 20, 2012
Building With QtCreator
Now that it has been configured for all the tools, everything can be done inside QtCreator. Start QtCreator and select New Project... on the File menu. In the New dialog select Project from Version Control and then Git Repository Clone. After clicking the Choose... button, the git repository can be selected. For Clone URL: enter https://github.com/thunder422/ibcp. If desired, change the Checkout path. The Checkout directory will default to thunder422-ibcp. Click the Next button and the repository will be cloned.
Once finished, the CMake Wizard dialog appears asking for the Build Location. The default directory can be used. The next dialog of the wizard is to Run CMake. On Windows, the Generator: needs to be changed to MinGW Generator (MinGW (x86 32bit)) assuming MinGW 4.4 was installed with Qt SDK, otherwise this is the only generator available.
Clicking the Run CMake button at this point causes a bunch of errors.Adding ‑G "MSYS Makefiles" to the Arguments: line appears to resolve the problem. Adding this before clicking the Run CMake button the first time does not make it work though clicking a second time does. Clicking the Run CMake button a second time works. I have no explanation for this at the moment. This is a similar problem that caused issues with NetBeans and CMake. On Linux, clicking the Run CMake button is all that is necessary.
Adding ‑DCMAKE_BUILD_TYPE=Debug to the Arguments: line turns on debug information to that the debugger can be used. After CMake is run, the program can be built. There are a number of ways to begin the build, including the Build menu, Ctrl+B and the hammer looking icon at the bottom of the tool bar on the left side. The build can be monitored by clicking the 4 Compile Output button along the bottom of the screen.
Once finished, the CMake Wizard dialog appears asking for the Build Location. The default directory can be used. The next dialog of the wizard is to Run CMake. On Windows, the Generator: needs to be changed to MinGW Generator (MinGW (x86 32bit)) assuming MinGW 4.4 was installed with Qt SDK, otherwise this is the only generator available.
Clicking the Run CMake button at this point causes a bunch of errors.
Adding ‑DCMAKE_BUILD_TYPE=Debug to the Arguments: line turns on debug information to that the debugger can be used. After CMake is run, the program can be built. There are a number of ways to begin the build, including the Build menu, Ctrl+B and the hammer looking icon at the bottom of the tool bar on the left side. The build can be monitored by clicking the 4 Compile Output button along the bottom of the screen.
Post Qt Installation Setup (Windows)
After installation of the Qt SDK, the tools (git, MinGW and CMake) need to be integrated with QtCreator. On Linux, no further configuration is needed as all tools will be located where QtCreator can find them. However, on Windows, this is not the case.
For git, the binary directory for the git tools need to be in the execution path. On Windows XP, right-click on My Computer and select Properties. On the Advanced tab, click the Environment Variables button. On the lower pane under System Variables, find and selected the Path variable. Click Edit and add C:\Program Files\Git\bin somewhere on the Variable value line (make sure to add the semicolon separator). On Windows 7 the instructions are similar. Start by right-clicking Computer and select Properties. Now select Advanced system settings, go to the Advanced tab and follow the same instructions except add C:\Program Files (x86)\Git\bin to Path.
Now start QtCreator. QtCreator should have automatically found the external MSYS/MinGW 4.6.2 previously installed. On the Tools menu select Options, go to the Build & Run page, and select the Tool Chains tab. Under Auto-detected there will be an entry Mingw as a GCC for Windows targets (if the MinGW 4.4 was installed as part of Qt SDK) and an entry MinGW (x86 32bit), which is the previously installed MinGW 4.6.2. The g++ path can be seen by selecting this entry, which should show C:\MinGW\bin\g++.exe.
For the final tool, CMake, select the CMake tab next to Tool Chains. If the correct path was added to the Path under Environment Variables, the path to cmake.exe will already be set. Otherwise, click Browse and find cmake.exe, which will be found under C:\Program Files\CMake 2.8\bin\cmake.exe (Windows XP) or C:\Program Files (x86)\CMake 2.8\bin\cmake.exe (Windows 7) if CMake was installed in the default location. Don't select cmake-gui.exe.
Now it's time to see if QtCreator is able to build and debug the ibcp program before we start any Qt related modifications.
For git, the binary directory for the git tools need to be in the execution path. On Windows XP, right-click on My Computer and select Properties. On the Advanced tab, click the Environment Variables button. On the lower pane under System Variables, find and selected the Path variable. Click Edit and add C:\Program Files\Git\bin somewhere on the Variable value line (make sure to add the semicolon separator). On Windows 7 the instructions are similar. Start by right-clicking Computer and select Properties. Now select Advanced system settings, go to the Advanced tab and follow the same instructions except add C:\Program Files (x86)\Git\bin to Path.
Now start QtCreator. QtCreator should have automatically found the external MSYS/MinGW 4.6.2 previously installed. On the Tools menu select Options, go to the Build & Run page, and select the Tool Chains tab. Under Auto-detected there will be an entry Mingw as a GCC for Windows targets (if the MinGW 4.4 was installed as part of Qt SDK) and an entry MinGW (x86 32bit), which is the previously installed MinGW 4.6.2. The g++ path can be seen by selecting this entry, which should show C:\MinGW\bin\g++.exe.
For the final tool, CMake, select the CMake tab next to Tool Chains. If the correct path was added to the Path under Environment Variables, the path to cmake.exe will already be set. Otherwise, click Browse and find cmake.exe, which will be found under C:\Program Files\CMake 2.8\bin\cmake.exe (Windows XP) or C:\Program Files (x86)\CMake 2.8\bin\cmake.exe (Windows 7) if CMake was installed in the default location. Don't select cmake-gui.exe.
Now it's time to see if QtCreator is able to build and debug the ibcp program before we start any Qt related modifications.
Installation For Qt Development
On Windows, when installing the Qt SDK, select Custom then on the Select Components dialog, unselect the following under Documentation: Harmattan, Qt Simulator, Symbian, and Qt Mobility; under APIs: Qt Mobility APIs and Qt Quick Components for Symbian; and under Development Tools: Harmattan, Simulator, Symbian Toolchains, under Desktop Qt: Qt 4.7.4 (Qt 4.8.1 will be used). Under Miscellaneous, it is unnecessary to select MinGW 4.4 (the previously installed MSYS/MinGW 4.6.2 will be used, see here for instructions). Also, the Qt Examples are not necessary but can be left in.
These selections will decrease the amount to download when using the on-line installer. Once installed, any of the unselected components can be added using the Maintain Qt SDK program under the Qt SDK program group using the Package manager. The Default installation can also be used Once installed, QtCreator needs to be connected to our tools (git, MinGW and CMake; see next post).
On Linux, the download installers can be used with the same selections as above (make sure the correct installer versions are downloaded, 32-bit or 64-bit to match the version of Linux). On Ubuntu 12.04 based distros (for example Linux Mint 13), it is not necessary to install the Qt SDK as the packages needed for Qt development are in the Ubuntu repositories. Most of the Qt libraries should already be installed (especially if KDE is being used since it was developed using Qt). The only additional packages that need to be installed are qtcreator, libqt4‑dev, qtcreator‑doc and qt4‑doc (use the sudo apt‑get install command or the package manager). The version of QtCreator installed from the repositories is the same as in the current Qt SDK, specifically 2.4.1.
These selections will decrease the amount to download when using the on-line installer. Once installed, any of the unselected components can be added using the Maintain Qt SDK program under the Qt SDK program group using the Package manager. The Default installation can also be used Once installed, QtCreator needs to be connected to our tools (git, MinGW and CMake; see next post).
On Linux, the download installers can be used with the same selections as above (make sure the correct installer versions are downloaded, 32-bit or 64-bit to match the version of Linux). On Ubuntu 12.04 based distros (for example Linux Mint 13), it is not necessary to install the Qt SDK as the packages needed for Qt development are in the Ubuntu repositories. Most of the Qt libraries should already be installed (especially if KDE is being used since it was developed using Qt). The only additional packages that need to be installed are qtcreator, libqt4‑dev, qtcreator‑doc and qt4‑doc (use the sudo apt‑get install command or the package manager). The version of QtCreator installed from the repositories is the same as in the current Qt SDK, specifically 2.4.1.
Preparing For Qt Development
Qt has its own IDE (Integrated Development Environment) called QtCreator. Qt also requires all the various Qt libraries as well as Qt header files and several utilities. Qt has its own make system called Qmake, but QtCreator is also compatible with CMake, so Qmake won't be used.
For Windows, the best way to start is to simply install the Qt SDK (Software Development Kit) that contains and installs all the necessary programs and files. The current SDK, version 1.2.1, which contains Qt libraries version 4.8.1 and QtCreator version 2.4.1 as well as MinGW compiler suite. However, the version of MinGW installed contains an older GCC, version 4.4. Although it can easily be made to work with an existing MSYS/MinGW installation like the one the project has been using based on GCC 4.6.2.
Several choices of installers are available, a small on-line installer and a very large off-line installer. The off-line installer has the advantage of quick reinstalls. However, the on-line installer only downloads the components selected during installation so potentially there is much less to download (more can be downloaded and installed later if needed). Many of the components are unnecessary when strictly used for desktop development (for example, all the mobile development files can be ignored). Next post, installation...
For Windows, the best way to start is to simply install the Qt SDK (Software Development Kit) that contains and installs all the necessary programs and files. The current SDK, version 1.2.1, which contains Qt libraries version 4.8.1 and QtCreator version 2.4.1 as well as MinGW compiler suite. However, the version of MinGW installed contains an older GCC, version 4.4. Although it can easily be made to work with an existing MSYS/MinGW installation like the one the project has been using based on GCC 4.6.2.
Several choices of installers are available, a small on-line installer and a very large off-line installer. The off-line installer has the advantage of quick reinstalls. However, the on-line installer only downloads the components selected during installation so potentially there is much less to download (more can be downloaded and installed later if needed). Many of the components are unnecessary when strictly used for desktop development (for example, all the mobile development files can be ignored). Next post, installation...
New Focus – Introducing Qt
When this project was started, the plan was to first develop all the internal routines (parser, translator, recreator, etc) and wrap a simple command line interface around it initially for testing before tackling a modern interface (GUI). I even went as far as starting to learn about using the Console mode on Windows (though this couldn't be used on Linux). That was the purpose in parsing immediate commands.
Over the past year or so, I have been learning and using Qt, a cross-platform application framework (and it is Open Source). With Qt, it is fairly easy to develop programs with a sophisticated GUI, plus it does a whole lot more. So instead of fooling with some antiquated command line interface, the project will be transitioned over to using Qt. This desire accelerated after discovering the Basic-256 program early this year. This program is a great platform for teaching programming (was formally called Kid-Basic). This program also uses Qt.
It is not totally clear all what is necessary for this transition to Qt, but several items come to mind. The classes implemented towards the beginning of the project, the List and Stack classes, will be removed and the Qt equivalents will used in their place. Though not necessary, variable and function names will be changed to the Qt way of naming. The exceptions used during initialization will be removed as there are no exceptions in Qt.
Since this will be a major change in development, the Release 0.1 series will be concluded and development of the Release 0.2 series will begin. The change in direction mentioned with Release 0.1.15 will continue after the transition to Qt. First though, the computer needs to set up for Qt Development...
Over the past year or so, I have been learning and using Qt, a cross-platform application framework (and it is Open Source). With Qt, it is fairly easy to develop programs with a sophisticated GUI, plus it does a whole lot more. So instead of fooling with some antiquated command line interface, the project will be transitioned over to using Qt. This desire accelerated after discovering the Basic-256 program early this year. This program is a great platform for teaching programming (was formally called Kid-Basic). This program also uses Qt.
It is not totally clear all what is necessary for this transition to Qt, but several items come to mind. The classes implemented towards the beginning of the project, the List and Stack classes, will be removed and the Qt equivalents will used in their place. Though not necessary, variable and function names will be changed to the Qt way of naming. The exceptions used during initialization will be removed as there are no exceptions in Qt.
Since this will be a major change in development, the Release 0.1 series will be concluded and development of the Release 0.2 series will begin. The change in direction mentioned with Release 0.1.15 will continue after the transition to Qt. First though, the computer needs to set up for Qt Development...
Friday, October 19, 2012
Project – CMake (Release)
It took a little extra time generating the release (it has been a while). GitHub recommends that the project include both a README and LICENSE file, so these were also added to the project. GitHub was updated yesterday and all the download files have been uploaded to Sourceforge today.
Since both Windows and Linux natively use different format text files (CRLF vs. newline for line separator), both sets of source files were uploaded. The Windows download file ibcp_0.1.16‑src.zip is in zip format and the Linux download file ibcp_0.1.16‑src.tar.gz is in tar format compressed with gzip, use the tar xzf <filename> command to uncompress and untar the file with a single command.
The binary download files that were uploaded contain not only the executable program, but also the test input files, expected result files and regression test scripts. Again the included text files are in the correct file format for the platform. The Windows binary download also contains a DOS batch file for running the regression tests. Nothing needs to be installed to run the program and regression tests.
Since both Windows and Linux natively use different format text files (CRLF vs. newline for line separator), both sets of source files were uploaded. The Windows download file ibcp_0.1.16‑src.zip is in zip format and the Linux download file ibcp_0.1.16‑src.tar.gz is in tar format compressed with gzip, use the tar xzf <filename> command to uncompress and untar the file with a single command.
The binary download files that were uploaded contain not only the executable program, but also the test input files, expected result files and regression test scripts. Again the included text files are in the correct file format for the platform. The Windows binary download also contains a DOS batch file for running the regression tests. Nothing needs to be installed to run the program and regression tests.
Wednesday, October 17, 2012
CMake Updated For Test Programs
The old make file also built the various test programs residing in the test sub-directory. The CMake build system was updated to also build these test programs. This required quite a bit of experimentation to get working, but the final solution was rather simple. First, each of the test programs an add_executable command was added to CmakeLists.txt with the list of the source files required to build the program along with any dependent header files.
To create the new make tests target required an add_custom_target command naming the target (tests) and specifying the test programs that this target is dependent on using the DEPENDS option. However, there was a problem where the test programs were built with the standard make command (the same as make all) in addition to when the make tests command was issued. This problem was resolved by adding the EXCLUDE_FROM_ALL option to each of the test programs add_executable command.
Each of the test programs were tested to verify that they produced the same output on all three platforms. Several of the test programs were updated to achieve this, and the expected output files were updated accordingly. Hit Continue... below for details on the changes made to the test programs.
Now that all the CMake issues have been resolved, it is time to make official release 0.1.16. It's going to take a little time to prepare the release notes, merge branch0.1.16 to master, generate all the archive files for uploading, etc.. In the mean time, the latest changes have been pushed to GitHub and tagged v0.1.16‑pre‑2. The should be close to the actual release, since none of the core program files are expected to change.
To create the new make tests target required an add_custom_target command naming the target (tests) and specifying the test programs that this target is dependent on using the DEPENDS option. However, there was a problem where the test programs were built with the standard make command (the same as make all) in addition to when the make tests command was issued. This problem was resolved by adding the EXCLUDE_FROM_ALL option to each of the test programs add_executable command.
Each of the test programs were tested to verify that they produced the same output on all three platforms. Several of the test programs were updated to achieve this, and the expected output files were updated accordingly. Hit Continue... below for details on the changes made to the test programs.
Now that all the CMake issues have been resolved, it is time to make official release 0.1.16. It's going to take a little time to prepare the release notes, merge branch0.1.16 to master, generate all the archive files for uploading, etc.. In the mean time, the latest changes have been pushed to GitHub and tagged v0.1.16‑pre‑2. The should be close to the actual release, since none of the core program files are expected to change.
Sunday, October 14, 2012
Updated Auto-Generated Test Header
When correcting the parser code, it was noticed that there were two constant arrays that contain text strings for the names of their associated enumerations, namely the token and data type enumerations. These are used, along with the code name array (that is already auto-generated) in the parser test code to output the test results.
The issue is that the text strings must match the enumerations. The code name array was already set up to be auto-generated (getting the text strings by scanning the table.cpp source file). The token and data type enumerations are contained in the ibcp.h header file.
The awk script test_codes.awk was generating the contents (text string elements) of the code names array. This script was renamed to test_names.awk and was modified to generate a complete array definition along with scanning ibcp.h header file for the token and data type enumerations to create name arrays for these also. The generated file was changed from test_codes.h to test_names.h and the CMakeLists.txt was modified accordingly.
Several other minor changes were made along with this commit, for details see the commit log on GitHub. The remaining issue is to add the test programs to CMake, which were in the older make file that has been removed.
Update (9:06): I should now better then to rush out a change without testing on both major platforms. It turns out the updated test_names.awk script reported an error on Windows. The problem was that the awk script was in DOS format and contained line continuations (back-slash at the end of the line). The awk program saw the CR at the end of these continuation lines and got confused. These were removed to eliminate the problem and GitHub was updated.
The issue is that the text strings must match the enumerations. The code name array was already set up to be auto-generated (getting the text strings by scanning the table.cpp source file). The token and data type enumerations are contained in the ibcp.h header file.
The awk script test_codes.awk was generating the contents (text string elements) of the code names array. This script was renamed to test_names.awk and was modified to generate a complete array definition along with scanning ibcp.h header file for the token and data type enumerations to create name arrays for these also. The generated file was changed from test_codes.h to test_names.h and the CMakeLists.txt was modified accordingly.
Several other minor changes were made along with this commit, for details see the commit log on GitHub. The remaining issue is to add the test programs to CMake, which were in the older make file that has been removed.
Update (9:06): I should now better then to rush out a change without testing on both major platforms. It turns out the updated test_names.awk script reported an error on Windows. The problem was that the awk script was in DOS format and contained line continuations (back-slash at the end of the line). The awk program saw the CR at the end of these continuation lines and got confused. These were removed to eliminate the problem and GitHub was updated.
All Platform Parser Issues Resolved
On the Windows platform, the C format specifier "%g" outputs three digits in the exponent always whereas on Linux, only two digits output unless three are needed. Looking at the C99 standard, it says basically "at least two exponent digits" should be output, so with that criteria, Windows is acceptable. It also appears that Microsoft decided that three exponent digits should always be output, and the GNU compiler suite decided to follow this on Windows. There is no way to control the number of exponent digits in the "%g" specifier.
The parser print token routine was modified to output two exponent digits if the first one is zero. This was accomplished by first outputting the number into a temporary character buffer using the "%g" specifier. Then it searches for an 'e' character in the string. If the fourth character from the 'e' is not a zero-terminator, then that means there are three exponent digits. If the second character from the 'e' is a '0' then the last two digits is moved on top of this zero.
Hit the Continue... for a code snippet of the solution. This change will now output two exponent digits always if the first one is zero. This code will do nothing on the Linux platform. The expected results for parser test #3 were updated for two exponent digits were applicable (five instances).
Since the major CMake issues have been resolved and the 0.1.16 release will be about the build system, the cmake0.1.16 branch was merged to branch0.1.16 branch. This last commit was also tagged as v0.1.16‑pre‑1. On GitHub, a zip (or .tar.gz) files can be downloaded directly for a tag, which contain all the files at that tag, so it is not necessary to install git to retrieve the files. This file does not contain the git repository however. There are still a few more build issues to take care of.
The parser print token routine was modified to output two exponent digits if the first one is zero. This was accomplished by first outputting the number into a temporary character buffer using the "%g" specifier. Then it searches for an 'e' character in the string. If the fourth character from the 'e' is not a zero-terminator, then that means there are three exponent digits. If the second character from the 'e' is a '0' then the last two digits is moved on top of this zero.
Hit the Continue... for a code snippet of the solution. This change will now output two exponent digits always if the first one is zero. This code will do nothing on the Linux platform. The expected results for parser test #3 were updated for two exponent digits were applicable (five instances).
Since the major CMake issues have been resolved and the 0.1.16 release will be about the build system, the cmake0.1.16 branch was merged to branch0.1.16 branch. This last commit was also tagged as v0.1.16‑pre‑1. On GitHub, a zip (or .tar.gz) files can be downloaded directly for a tag, which contain all the files at that tag, so it is not necessary to install git to retrieve the files. This file does not contain the git repository however. There are still a few more build issues to take care of.
Resolving Platform Parser Issues
The first parser issue is that on the Windows 7 (64-bit) platform, values as small as around 1e‑323 are accepted without a range error, whereas on the Linux (64‑bit) and Windows XP (32‑bit), values smaller than around 1e-308 produce a range error. This is equivalent to the large value around 1e+308.
I thought possibly this had to do with Intel (what Windows 7 is running) on and AMD (what Linux and the Windows XP virtual machine are running on). However, in testing the limits on a Scientific Linux 6.2 (equivalent to RedHat Enterprise 6.2) 64-bit virtual machine on the Intel, the limit was around 1e‑308 (though it was with the older GCC 4.4 vs. 4.6 on the others).
The float and long double conversions were also tested on all three platforms. The float had a limit of around 1e‑38 on all three platforms as well as the long double having a limit of around 1e‑4931. So I have no explanation why double conversions are different on Windows 7. Both 7 and XP have identical versions of MinGW installed.
So instead of fighting this problem any longer, the 1.234e‑308 test value in parser test #3 was changed to 1.234e‑324, a value that will produce a range error on all three platforms. Next to deal with the differences in the number of exponent digits output.
I thought possibly this had to do with Intel (what Windows 7 is running) on and AMD (what Linux and the Windows XP virtual machine are running on). However, in testing the limits on a Scientific Linux 6.2 (equivalent to RedHat Enterprise 6.2) 64-bit virtual machine on the Intel, the limit was around 1e‑308 (though it was with the older GCC 4.4 vs. 4.6 on the others).
The float and long double conversions were also tested on all three platforms. The float had a limit of around 1e‑38 on all three platforms as well as the long double having a limit of around 1e‑4931. So I have no explanation why double conversions are different on Windows 7. Both 7 and XP have identical versions of MinGW installed.
So instead of fighting this problem any longer, the 1.234e‑308 test value in parser test #3 was changed to 1.234e‑324, a value that will produce a range error on all three platforms. Next to deal with the differences in the number of exponent digits output.
Saturday, October 13, 2012
Updated Regression Test Scripts
The regression test scripts were modified for the changes in the test code (and new command line). The test numbering was removed and the scipts now determine which tests to run by the presence of the parser*.dat, expression*.dat and translator*.dat files in the test directory. The regtest script (for Windows/MSYS and Linux) no longer references ibcp.exe but simply ibcp, which will work on both Windows and Linux, with the ".exe" part added automatically on Windows.
To be able to handle any build directory (in source or out of source), the regtest script uses the source directory directly. This was accomplished by making CMake configure this, so regtest was renamed to regtest.in and references the CMake ibcp_SOURCE_DIR variable to create regtest in the binary (build) directory that uses the correct source directory. Now a build and test consists of just three steps, running cmake (with the proper options and path to the build directory), running make and running regtest (in the build directory).
I considered dropping the Windows Command window regtest.bat batch file, but decided this should still be included so that the regression tests could be run from the downloaded binary along with the source directory without having to build the program. It is still a crude alternative to the regtest bash script, but it gets the job done. When run, the "Compare more files (Y/N)?" question still has to be answered with an N now three times with the addition of the expression test compares.
The tests with the regression tests script work on all three platforms, except one problem remains: the problem with parser test #3 giving different results on the three platforms (the Windows XP results are in the repository), which still needs to be resolved. All the testing changes has be pushed to the repository on github, including a new .gitignore file, which tells git to ignore any files in the build and nbproject sub-directories.
To be able to handle any build directory (in source or out of source), the regtest script uses the source directory directly. This was accomplished by making CMake configure this, so regtest was renamed to regtest.in and references the CMake ibcp_SOURCE_DIR variable to create regtest in the binary (build) directory that uses the correct source directory. Now a build and test consists of just three steps, running cmake (with the proper options and path to the build directory), running make and running regtest (in the build directory).
I considered dropping the Windows Command window regtest.bat batch file, but decided this should still be included so that the regression tests could be run from the downloaded binary along with the source directory without having to build the program. It is still a crude alternative to the regtest bash script, but it gets the job done. When run, the "Compare more files (Y/N)?" question still has to be answered with an N now three times with the addition of the expression test compares.
The tests with the regression tests script work on all three platforms, except one problem remains: the problem with parser test #3 giving different results on the three platforms (the Windows XP results are in the repository), which still needs to be resolved. All the testing changes has be pushed to the repository on github, including a new .gitignore file, which tells git to ignore any files in the build and nbproject sub-directories.
New Test Code
The new test code design outlined on October 10 has been implemented and tested. The old test_parser() and test_translator() functions with their test inputs, were replaced with a single test_ibcp() function that reads an input file and calls the appropriate function based on the type. The ibcp program command lines options have changed as shown:
Early in the translator development, the translator only processed expressions. The first four tests only have expressions. This implementation was left in the code and was changed to be activated only if an expression only flag is passed to the translator. The old test code set this flag for the first four tests. To keep things simple, since the file name is being used to detect the type, this was extended by the new expression type.
The expected result files were renamed accordingly. Also, the translator tests were given two digit test numbers, with a leading 0 for the first nine tests, so that these would be processed in order by the regression test scripts. The new test input files were given a ".dat" extension. The code was also modified to not output the ".exe" with the program name in the header of the output so that Windows and Linux output matches. Now the regression test scripts need to be updated.
ibcp -t <testfile>The first command form specifies the test file, which contains the tests inputs. The test code determines the type of file by the beginning of its name (parser, expression, or translator). The file name may contain anything after the type, including any extension. Blank lines and comment lines (first character '#') are ignored. The second command form activates the interactive mode when the program asks for each input for one of the three types. The new expression type needs further explanation.
ibcp -tp|-te|-tt
Early in the translator development, the translator only processed expressions. The first four tests only have expressions. This implementation was left in the code and was changed to be activated only if an expression only flag is passed to the translator. The old test code set this flag for the first four tests. To keep things simple, since the file name is being used to detect the type, this was extended by the new expression type.
The expected result files were renamed accordingly. Also, the translator tests were given two digit test numbers, with a leading 0 for the first nine tests, so that these would be processed in order by the regression test scripts. The new test input files were given a ".dat" extension. The code was also modified to not output the ".exe" with the program name in the header of the output so that Windows and Linux output matches. Now the regression test scripts need to be updated.
Friday, October 12, 2012
CMake with NetBeans
There were problems getting the new test code to work properly. Using gdb from the command line was not the first choice (more time is spent looking up help on commands than actually debugging). So this left NetBeans, which I was hoping to delay if not permanently postpone the use of (for the reason the change in development alluded to earlier, more on this soon). NetBeans is supposed to work with CMake and it was time to find out.
In the spirit of staying current, the latest version (7.2) was downloaded from NetBeans.org. The C/C++ bundle was selected for both Windows and Linux (x86/x64). The defaults for the installer were used on all three platforms (XP, 7 and Mint 13) and available updates were installed.
On Windows XP and 7, getting NetBeans to work with CMake was problematic, in fact, I never did figure out how to get it to work correctly. NetBeans appeared to give CMake incorrect options and CMake said that the compiler was not able to be used. All attempts to get the options that worked were unsuccessful.
The solution found searching the Internet was to run CMake outside of NetBeans, then point NetBeans to the Makefile produced and this worked. CMake would have to be run outside of NetBeans from then on when needed - not ideal. After a bit of work, debugging was enabled and the program could be stepped through.
On Mint 13, NetBeans worked with CMake the way it was supposed to. NetBeans was able to run CMake and build the program. The program was built with debugging enabled by default. Debugging the problems in the new test code went without a hitch. Hit Continue... for details of the procedures on both platforms.
In the spirit of staying current, the latest version (7.2) was downloaded from NetBeans.org. The C/C++ bundle was selected for both Windows and Linux (x86/x64). The defaults for the installer were used on all three platforms (XP, 7 and Mint 13) and available updates were installed.
On Windows XP and 7, getting NetBeans to work with CMake was problematic, in fact, I never did figure out how to get it to work correctly. NetBeans appeared to give CMake incorrect options and CMake said that the compiler was not able to be used. All attempts to get the options that worked were unsuccessful.
The solution found searching the Internet was to run CMake outside of NetBeans, then point NetBeans to the Makefile produced and this worked. CMake would have to be run outside of NetBeans from then on when needed - not ideal. After a bit of work, debugging was enabled and the program could be stepped through.
On Mint 13, NetBeans worked with CMake the way it was supposed to. NetBeans was able to run CMake and build the program. The program was built with debugging enabled by default. Debugging the problems in the new test code went without a hitch. Hit Continue... for details of the procedures on both platforms.
Wednesday, October 10, 2012
Testing Implementation Change
In considering how to modify the CMake build system to handle regression testing, I realized that there was a better design in how testing should be handled. Currently all the test inputs are contained in a source file with the testing code. The disadvantage is that every time a new test input or test is added, this source file needs to be modified. Adding a new test requires additional work including several changes to the test source file and modifying both regression test scripts. And finally, strange looking C string quoting is required for double quotes and back-slashes in the test strings.
A better design would be for the tests and their inputs to be in separate test files that would be read and processed by the test code. To change or add test inputs, these test files would be modified instead of the source file. To add a new test, a new test file would be added. The regression test scripts would simply run the program for each test file present. Another advantage is that the test code does not need to be recompiled when tests are modified or added.
The test files will also support simple comments. Lines that start with the pound '#' character and blanks lines will be ignored by the test code. This method of commenting was chosen since no BASIC lines will start with this character and editors that support syntax highlighting (for example, vim, Kate and probably notepad++) show these comments in a different color and/or font when the file is treated as a configuration file (which vim does automatically, and Kate remembers after the option is set once).
A better design would be for the tests and their inputs to be in separate test files that would be read and processed by the test code. To change or add test inputs, these test files would be modified instead of the source file. To add a new test, a new test file would be added. The regression test scripts would simply run the program for each test file present. Another advantage is that the test code does not need to be recompiled when tests are modified or added.
The test files will also support simple comments. Lines that start with the pound '#' character and blanks lines will be ignored by the test code. This method of commenting was chosen since no BASIC lines will start with this character and editors that support syntax highlighting (for example, vim, Kate and probably notepad++) show these comments in a different color and/or font when the file is treated as a configuration file (which vim does automatically, and Kate remembers after the option is set once).
Monday, October 8, 2012
Additional CMake Corrections
Back at the end of September when Mint 12 (Ubuntu 11.10) with GCC 4.4 (needed for CUDA development) was still being used, a change to the CMake file to allow (with a warning) GCC versions less than 4.5, which do not support linking static libraries. This option was used to create an executable that did not require dynamic libraries (so the binaries posted on SourceForge would run without having to install any other software).
This change was considered temporary and the warnings produced with older GCC versions could be ignored and any executables produced couldn't be posted. To eliminate this compiler warning, an if statement was added around the statement that added the static library link options in the CMake file, so that this option is used for GCC versions 4.5 and later.
The problem with in source directory builds was due to the local string.h header file name conflicting with the standard header file of the same name, which was included in the local string.h header file - the local header file was being included instead of the standard header file.
There is a statement in the CMake file that adds the project's binary directory to the include directories searched so that the auto-generated include files can be found. So, with an in source directory build, the local string.h file was being found even with angle brackets on the include statement since the project directory was now being searched and is apparently being search before the standard directories.
With an in source directory build, if the project directory is not added to the include directories, the correct header file is found. Since it is not necessary to add the project directory if building in the source directory (the auto-generated header files will be in the same directory as the source files including them), so to correct this problem, a check was added to the CMake file that if the project binary (build) directory is the same as the project source directory, then it is not added to the include directories.
The old make file was also removed since it now being generated by CMake and there are problems when doing in source directory builds with it present since CMake modifies the make file that is under source control (git then indicates that is was modified). These two commits are now up on github.
This change was considered temporary and the warnings produced with older GCC versions could be ignored and any executables produced couldn't be posted. To eliminate this compiler warning, an if statement was added around the statement that added the static library link options in the CMake file, so that this option is used for GCC versions 4.5 and later.
The problem with in source directory builds was due to the local string.h header file name conflicting with the standard header file of the same name, which was included in the local string.h header file - the local header file was being included instead of the standard header file.
There is a statement in the CMake file that adds the project's binary directory to the include directories searched so that the auto-generated include files can be found. So, with an in source directory build, the local string.h file was being found even with angle brackets on the include statement since the project directory was now being searched and is apparently being search before the standard directories.
With an in source directory build, if the project directory is not added to the include directories, the correct header file is found. Since it is not necessary to add the project directory if building in the source directory (the auto-generated header files will be in the same directory as the source files including them), so to correct this problem, a check was added to the CMake file that if the project binary (build) directory is the same as the project source directory, then it is not added to the include directories.
The old make file was also removed since it now being generated by CMake and there are problems when doing in source directory builds with it present since CMake modifies the make file that is under source control (git then indicates that is was modified). These two commits are now up on github.
Subscribe to:
Posts (Atom)