BIND 10 trac826, updated. 46b859de71e1e39916eb9fda391229a399ac87a6 liblog compiler
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Jun 27 01:08:33 UTC 2012
The branch, trac826 has been updated
via 46b859de71e1e39916eb9fda391229a399ac87a6 (commit)
via 978509041da5f9cd21c544c7d16d3ee2d5d9f4fa (commit)
from a5589107286e49c71f0307937b3af8fcbf55c209 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 46b859de71e1e39916eb9fda391229a399ac87a6
Author: Francis Dupont <fdupont at isc.org>
Date: Wed Jun 27 03:08:20 2012 +0200
liblog compiler
commit 978509041da5f9cd21c544c7d16d3ee2d5d9f4fa
Author: Francis Dupont <fdupont at isc.org>
Date: Wed Jun 27 03:05:09 2012 +0200
liblog take 2
-----------------------------------------------------------------------
Summary of changes:
src/lib/log/compiler/.gitignore | 1 +
src/lib/log/compiler/Makefile.am | 1 +
src/lib/log/compiler/message.cc | 62 +++++++++++++----------
src/lib/log/logger.cc | 2 +
src/lib/log/logger_impl.cc | 2 +
src/lib/log/logger_level.cc | 2 +
src/lib/log/logger_level_impl.cc | 2 +
src/lib/log/logger_manager.cc | 2 +
src/lib/log/logger_manager_impl.cc | 2 +
src/lib/log/logger_support.cc | 2 +
src/lib/log/logger_unittest_support.cc | 7 +++
src/lib/log/output_option.cc | 2 +
win32build/VS2008/liblog/liblog.vcproj | 8 ++-
win32build/VS2010/liblog/liblog.vcxproj | 5 +-
win32build/VS2010/liblog/liblog.vcxproj.filters | 5 +-
15 files changed, 73 insertions(+), 32 deletions(-)
create mode 100644 src/lib/log/compiler/.gitignore
-----------------------------------------------------------------------
diff --git a/src/lib/log/compiler/.gitignore b/src/lib/log/compiler/.gitignore
new file mode 100644
index 0000000..b6afc24
--- /dev/null
+++ b/src/lib/log/compiler/.gitignore
@@ -0,0 +1 @@
+/message
diff --git a/src/lib/log/compiler/Makefile.am b/src/lib/log/compiler/Makefile.am
index 1f47ba9..84cd4f6 100644
--- a/src/lib/log/compiler/Makefile.am
+++ b/src/lib/log/compiler/Makefile.am
@@ -16,3 +16,4 @@ noinst_PROGRAMS = message
message_SOURCES = message.cc
message_LDADD = $(top_builddir)/src/lib/log/liblog.la
message_LDADD += $(top_builddir)/src/lib/util/libutil.la
+message_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
diff --git a/src/lib/log/compiler/message.cc b/src/lib/log/compiler/message.cc
index 8eb79b3..edb9a6b 100644
--- a/src/lib/log/compiler/message.cc
+++ b/src/lib/log/compiler/message.cc
@@ -27,6 +27,8 @@
#include <unistd.h>
#endif
+#include <exceptions/exceptions.h>
+
#include <util/filename.h>
#include <util/strutil.h>
@@ -58,14 +60,14 @@ static const char* VERSION = "1.0-0";
/// \b Invocation<BR>
/// The program is invoked with the command:
///
-/// <tt>message [-v | -h | -p | -d <dir> | <message-file>]</tt>
+/// <tt>message [-v | -h | -p | -d <dir> | <message-file>]</tt>
///
/// It reads the message file and writes out two files of the same
/// name in the current working directory (unless -d is used) but
/// with extensions of .h and .cc, or .py if -p is used.
///
/// -v causes it to print the version number and exit. -h prints a help
-/// message (and exits). -p sets the output to python. -d <dir> will make
+/// message (and exits). -p sets the output to python. -d <dir> will make
/// it write the output file(s) to dir instead of current working
/// directory
@@ -119,9 +121,9 @@ currentTime() {
/// \brief Create Header Sentinel
///
-/// Given the name of a file, create an #ifdef sentinel name. The name is
-/// __<name>_<ext>, where <name> is the name of the file, and <ext> is the
-/// extension less the leading period. The sentinel will be upper-case.
+/// Given the name of a file, create an \#ifdef sentinel name. The name is
+/// __<name>_<ext>, where <name> is the name of the file, and <ext>
+/// is the extension less the leading period. The sentinel will be upper-case.
///
/// \param file Filename object representing the file.
///
@@ -226,7 +228,7 @@ writeOpeningNamespace(ostream& output, const vector<string>& ns) {
if (!ns.empty()) {
// Output namespaces in correct order
- for (unsigned int i = 0; i < ns.size(); ++i) {
+ for (vector<string>::size_type i = 0; i < ns.size(); ++i) {
output << "namespace " << ns[i] << " {\n";
}
output << "\n";
@@ -247,7 +249,7 @@ writeClosingNamespace(ostream& output, const vector<string>& ns) {
}
}
-/// \breif Write python file
+/// \brief Write python file
///
/// Writes the python file containing the symbol definitions as module level
/// constants. These are objects which register themself at creation time,
@@ -303,8 +305,8 @@ writePythonFile(const string& file, MessageDictionary& dictionary,
///
/// \param file Name of the message file. The header file is written to a
/// file of the same name but with a .h suffix.
-/// \param ns Namespace in which the definitions are to be placed. An empty
-/// string indicates no namespace.
+/// \param ns_components Namespace in which the definitions are to be placed.
+/// An empty string indicates no namespace.
/// \param dictionary Dictionary holding the message definitions.
/// \param output_directory if not null NULL, output files are written
/// to the given directory. If NULL, they are written to the current
@@ -327,8 +329,9 @@ writeHeaderFile(const string& file, const vector<string>& ns_components,
ofstream hfile(header_file.fullName().c_str());
if (hfile.fail()) {
- throw MessageException(LOG_OPEN_OUTPUT_FAIL, header_file.fullName(),
- strerror(errno));
+ isc_throw_4(MessageException, "Failed to open output file",
+ LOG_OPEN_OUTPUT_FAIL, header_file.fullName(),
+ strerror(errno), 0);
}
// Write the header preamble. If there is an error, we'll pick it up
@@ -361,8 +364,9 @@ writeHeaderFile(const string& file, const vector<string>& ns_components,
// Report errors (if any) and exit
if (hfile.fail()) {
- throw MessageException(LOG_WRITE_ERROR, header_file.fullName(),
- strerror(errno));
+ isc_throw_4(MessageException, "Error writing to output file",
+ LOG_WRITE_ERROR, header_file.fullName(), strerror(errno),
+ 0);
}
hfile.close();
@@ -406,8 +410,8 @@ replaceNonAlphaNum(char c) {
///
/// \param file Name of the message file. The header file is written to a
/// file of the same name but with a .h suffix.
-/// \param ns Namespace in which the definitions are to be placed. An empty
-/// string indicates no namespace.
+/// \param ns_components Namespace in which the definitions are to be placed.
+/// An empty string indicates no namespace.
/// \param dictionary Dictionary holding the message definitions.
/// \param output_directory if not null NULL, output files are written
/// to the given directory. If NULL, they are written to the current
@@ -427,8 +431,9 @@ writeProgramFile(const string& file, const vector<string>& ns_components,
ofstream ccfile(program_file.fullName().c_str());
if (ccfile.fail()) {
- throw MessageException(LOG_OPEN_OUTPUT_FAIL, program_file.fullName(),
- strerror(errno));
+ isc_throw_4(MessageException, "Error opening output file",
+ LOG_OPEN_OUTPUT_FAIL, program_file.fullName(),
+ strerror(errno), 0);
}
// Write the preamble. If there is an error, we'll pick it up after
@@ -485,30 +490,31 @@ writeProgramFile(const string& file, const vector<string>& ns_components,
// Report errors (if any) and exit
if (ccfile.fail()) {
- throw MessageException(LOG_WRITE_ERROR, program_file.fullName(),
- strerror(errno));
+ isc_throw_4(MessageException, "Error writing to output file",
+ LOG_WRITE_ERROR, program_file.fullName(), strerror(errno),
+ 0);
}
ccfile.close();
}
-/// \brief Warn of Duplicate Entries
+/// \brief Error and exit if there are duplicate entries
///
-/// If the input file contained duplicate message IDs, only the first will be
-/// processed. However, we should warn about it.
+/// If the input file contained duplicate message IDs, we print an
+/// error for each of them, then exit the program with a non-0 value.
///
/// \param reader Message Reader used to read the file
void
-warnDuplicates(MessageReader& reader) {
+errorDuplicates(MessageReader& reader) {
// Get the duplicates (the overflow) and, if present, sort them into some
// order and remove those which occur more than once (which mean that they
// occur more than twice in the input file).
MessageReader::MessageIDCollection duplicates = reader.getNotAdded();
- if (duplicates.size() > 0) {
- cout << "Warning: the following duplicate IDs were found:\n";
+ if (!duplicates.empty()) {
+ cout << "Error: the following duplicate IDs were found:\n";
sort(duplicates.begin(), duplicates.end());
MessageReader::MessageIDCollection::iterator new_end =
@@ -517,6 +523,7 @@ warnDuplicates(MessageReader& reader) {
i != new_end; ++i) {
cout << " " << *i << "\n";
}
+ exit(1);
}
}
@@ -582,6 +589,9 @@ main(int argc, char* argv[]) {
MessageReader reader(&dictionary);
reader.readFile(message_file);
+ // Error (and quit) if there are of any duplicates encountered.
+ errorDuplicates(reader);
+
if (doPython) {
// Warn in case of ignored directives
if (!reader.getNamespace().empty()) {
@@ -606,8 +616,6 @@ main(int argc, char* argv[]) {
output_directory);
}
- // Finally, warn of any duplicates encountered.
- warnDuplicates(reader);
}
catch (const MessageException& e) {
// Create an error message from the ID and the text
diff --git a/src/lib/log/logger.cc b/src/lib/log/logger.cc
index c0af58a..619b472 100644
--- a/src/lib/log/logger.cc
+++ b/src/lib/log/logger.cc
@@ -12,6 +12,8 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE
+#include <config.h>
+
#include <stdarg.h>
#include <stdio.h>
diff --git a/src/lib/log/logger_impl.cc b/src/lib/log/logger_impl.cc
index f7c65fa..7997fbe 100644
--- a/src/lib/log/logger_impl.cc
+++ b/src/lib/log/logger_impl.cc
@@ -12,6 +12,8 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE
+#include <config.h>
+
#include <iostream>
#include <iomanip>
#include <algorithm>
diff --git a/src/lib/log/logger_level.cc b/src/lib/log/logger_level.cc
index abac5be..065427b 100644
--- a/src/lib/log/logger_level.cc
+++ b/src/lib/log/logger_level.cc
@@ -12,6 +12,8 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE
+#include <config.h>
+
#include <log/logger_level.h>
#include <log/macros.h>
#include <log/log_messages.h>
diff --git a/src/lib/log/logger_level_impl.cc b/src/lib/log/logger_level_impl.cc
index 3bc6ff7..76739b5 100644
--- a/src/lib/log/logger_level_impl.cc
+++ b/src/lib/log/logger_level_impl.cc
@@ -12,6 +12,8 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
+#include <config.h>
+
#include <algorithm>
#include <string.h>
#include <iostream>
diff --git a/src/lib/log/logger_manager.cc b/src/lib/log/logger_manager.cc
index 8431c2e..a944929 100644
--- a/src/lib/log/logger_manager.cc
+++ b/src/lib/log/logger_manager.cc
@@ -12,6 +12,8 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
+#include <config.h>
+
#include <algorithm>
#include <vector>
diff --git a/src/lib/log/logger_manager_impl.cc b/src/lib/log/logger_manager_impl.cc
index 4a9253a..2b2211e 100644
--- a/src/lib/log/logger_manager_impl.cc
+++ b/src/lib/log/logger_manager_impl.cc
@@ -12,6 +12,8 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
+#include <config.h>
+
#include <algorithm>
#include <iostream>
diff --git a/src/lib/log/logger_support.cc b/src/lib/log/logger_support.cc
index 2097136..ab32de9 100644
--- a/src/lib/log/logger_support.cc
+++ b/src/lib/log/logger_support.cc
@@ -12,6 +12,8 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE
+#include <config.h>
+
#include <string>
#include <log/logger_support.h>
#include <log/logger_manager.h>
diff --git a/src/lib/log/logger_unittest_support.cc b/src/lib/log/logger_unittest_support.cc
index 6afc539..c4fe1c8 100644
--- a/src/lib/log/logger_unittest_support.cc
+++ b/src/lib/log/logger_unittest_support.cc
@@ -12,6 +12,8 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
+#include <config.h>
+
#include <iostream>
#include <algorithm>
#include <string>
@@ -165,7 +167,12 @@ void initLogger(isc::log::Severity severity, int dbglevel) {
const char* localfile = getenv("B10_LOGGER_LOCALMSG");
// Set a directory for creating lockfiles when running tests
+#ifdef _WIN32
+ string vv("B10_LOCKFILE_DIR_FROM_BUILD" TOP_BUILDDIR);
+ _putenv(vv.c_str());
+#else
setenv("B10_LOCKFILE_DIR_FROM_BUILD", TOP_BUILDDIR, 1);
+#endif
// Initialize logging
initLogger(root, isc::log::DEBUG, isc::log::MAX_DEBUG_LEVEL, localfile);
diff --git a/src/lib/log/output_option.cc b/src/lib/log/output_option.cc
index f56efb9..c06a050 100644
--- a/src/lib/log/output_option.cc
+++ b/src/lib/log/output_option.cc
@@ -12,6 +12,8 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
+#include <config.h>
+
#include <string>
#include <boost/algorithm/string.hpp>
diff --git a/win32build/VS2008/liblog/liblog.vcproj b/win32build/VS2008/liblog/liblog.vcproj
index 393e9e6..06b2081 100755
--- a/win32build/VS2008/liblog/liblog.vcproj
+++ b/win32build/VS2008/liblog/liblog.vcproj
@@ -42,7 +42,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..;..\..;..\..\..\src\lib;..\..\..\src\lib\log;..\..\..\..\log4cplus\include;"$(BOOST)""
- PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB;TOP_BUILDDIR=\"$(BIND10HOME)\""
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@@ -106,7 +106,7 @@
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..;..\..;..\..\..\src\lib;..\..\..\src\lib\log;..\..\..\..\log4cplus\include;"$(BOOST)""
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB;TOP_BUILDDIR=\"$(BIND10HOME)\""
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
@@ -229,6 +229,10 @@
>
</File>
<File
+ RelativePath="..\..\..\src\lib\log\log_dbglevels.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\src\lib\log\log_formatter.h"
>
</File>
diff --git a/win32build/VS2010/liblog/liblog.vcxproj b/win32build/VS2010/liblog/liblog.vcxproj
index 7966e16..db2c95c 100755
--- a/win32build/VS2010/liblog/liblog.vcxproj
+++ b/win32build/VS2010/liblog/liblog.vcxproj
@@ -12,6 +12,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\src\lib\log\dummylog.h" />
+ <ClInclude Include="..\..\..\src\lib\log\log_dbglevels.h" />
<ClInclude Include="..\..\..\src\lib\log\log_formatter.h" />
<ClInclude Include="..\..\..\src\lib\log\logger.h" />
<ClInclude Include="..\..\..\src\lib\log\logger_impl.h" />
@@ -90,7 +91,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;TOP_BUILDDIR="%BIND10HOME%";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..;..\..\..\src\lib;..\..\..\src\lib\log;..\..\..\..\log4cplus\include;%BOOST%;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile>
@@ -106,7 +107,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;TOP_BUILDDIR="%BIND10HOME%";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..;..\..\..\src\lib;..\..\..\src\lib\log;..\..\..\..\log4cplus\include;%BOOST%;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile>
diff --git a/win32build/VS2010/liblog/liblog.vcxproj.filters b/win32build/VS2010/liblog/liblog.vcxproj.filters
index 17a87ef..2b7de14 100755
--- a/win32build/VS2010/liblog/liblog.vcxproj.filters
+++ b/win32build/VS2010/liblog/liblog.vcxproj.filters
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
@@ -78,6 +78,9 @@
<ClInclude Include="..\..\..\src\lib\log\output_option.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\src\lib\log\log_dbglevels.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\src\lib\log\dummylog.cc">
More information about the bind10-changes
mailing list