From: g0dil Date: Wed, 29 Aug 2007 12:10:41 +0000 (+0000) Subject: senfscons: Much improved install implementation X-Git-Url: http://g0dil.de/git?p=senf.git;a=commitdiff_plain;h=a9fd0471a3ca128c626a6771c4518f33ef78f053 senfscons: Much improved install implementation Socket/Protocols: Removed obsolete GenericSockAddr Utils: Add missing unit tests Fix debian '.install' files git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@413 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Packets/DefaultBundle/SConscript b/Packets/DefaultBundle/SConscript index eaf1982..0514a40 100644 --- a/Packets/DefaultBundle/SConscript +++ b/Packets/DefaultBundle/SConscript @@ -12,6 +12,6 @@ SENFSCons.StandardTargets(env) SENFSCons.Object(env, target = 'DefaultBundle', sources=sources, LIBS = ['Packets', 'Socket', 'Utils']) SENFSCons.Lib(env, library = 'Packets_DefaultBundle', sources = sources[0], - LIBS = ['Packets', 'Socket', 'Utils']) + LIBS = ['Packets', 'Socket', 'Utils'], no_includes = 1) SENFSCons.Doxygen(env) diff --git a/Packets/MPEGDVBBundle/SConscript b/Packets/MPEGDVBBundle/SConscript index 5d94e25..b52cf4c 100644 --- a/Packets/MPEGDVBBundle/SConscript +++ b/Packets/MPEGDVBBundle/SConscript @@ -12,6 +12,6 @@ SENFSCons.StandardTargets(env) SENFSCons.Object(env, target = 'MPEGDVBBundle', sources=sources, LIBS = ['Packets', 'Socket', 'Utils']) SENFSCons.Lib(env, library = 'Packets_MPEGDVBBundle', sources = sources[0], - LIBS = ['Packets', 'Socket', 'Utils']) + LIBS = ['Packets', 'Socket', 'Utils'], no_includes = 1) SENFSCons.Doxygen(env) diff --git a/Packets/ParseArray.ct b/Packets/ParseArray.ct index 411b077..5094b68 100644 --- a/Packets/ParseArray.ct +++ b/Packets/ParseArray.ct @@ -21,7 +21,7 @@ /** \file \brief ParseArray non-inline template implementation */ -//#include "ParseArray.ih" +#include "ParseArray.ih" // Custom includes @@ -41,8 +41,6 @@ prefix_ void senf::Parse_Array::init() (*i).init(); } - - ///////////////////////////////ct.e//////////////////////////////////////// #undef prefix_ diff --git a/Packets/ParseArray.hh b/Packets/ParseArray.hh index 8dfca23..5260201 100644 --- a/Packets/ParseArray.hh +++ b/Packets/ParseArray.hh @@ -102,7 +102,7 @@ namespace senf { #if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_ParseArray_i_) #define HH_ParseArray_i_ //#include "ParseArray.cci" -//#include "ParseArray.ct" +#include "ParseArray.ct" #include "ParseArray.cti" #endif diff --git a/Packets/SConscript b/Packets/SConscript index 153a67c..3ed13bf 100644 --- a/Packets/SConscript +++ b/Packets/SConscript @@ -5,26 +5,22 @@ import SENFSCons, glob ########################################################################### -def makeAllIncludesHH(target = None, source = None, env = None): - file(target[0].abspath,"w").write("".join([ '#include "%s"\n' % f - for f in env['SOURCE_HEADERS']])) -makeAllIncludesHH = env.Action(makeAllIncludesHH, varlist=['SOURCE_HEADERS']) +def makeAllIncludesHH(target, headers): + file(env.File(target).abspath,"w").write("".join([ '#include "%s"\n' % f + for f in headers ])) ########################################################################### -sources = SENFSCons.GlobSources() +source_headers = [ f for f in glob.glob("*.hh") + if 'defined(SENF_PACKETS_DECL_ONLY)' in file(f).read() ] +source_headers.sort() +makeAllIncludesHH('all_includes.hh', source_headers) SENFSCons.StandardTargets(env) - -env.Command('all_includes.hh', 'SConscript', makeAllIncludesHH, - SOURCE_HEADERS = [ f for f in glob.glob("*.hh") - if 'defined(SENF_PACKETS_DECL_ONLY)' in file(f).read() ]) - SENFSCons.Lib(env, library = 'Packets', - sources = sources, + sources = SENFSCons.GlobSources(), LIBS = [ 'Socket', 'Utils' ]) - SENFSCons.Doxygen(env, extra_sources = [ env.Dia2Png("structure.dia") ]) diff --git a/Socket/Protocols/GenericSockAddr.hh b/Socket/Protocols/GenericSockAddr.hh deleted file mode 100644 index 66d4fa9..0000000 --- a/Socket/Protocols/GenericSockAddr.hh +++ /dev/null @@ -1,107 +0,0 @@ -// $Id$ -// -// Copyright (C) 2006 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -/** \file - \brief GenericSockAddr public header */ - -/** \defgroup addr_group Socket Addressing - - To support the core socket functionality we need a collection of classing providing addressing - for the different protocols. - - For all standard BSD socket protocols we base the address classes on the corresponding \c - sockaddr structures, wrapped into appropriate C++ adapters. These Address classes are based on - GenericSockAddr, the corresponding addressing policy is defined in GenericAddressingPolicy. - - You are however not limit to BSD type socket address classes as long as you implement the - corresponding addressing policy. - */ - -#ifndef HH_GenericSockAddr_ -#define HH_GenericSockAddr_ 1 - -// Custom includes -#include - -//#include "GenericSockAddr.mpp" -///////////////////////////////hh.p//////////////////////////////////////// - -namespace senf { - - /// \addtogroup addr_group - /// @{ - - /** \brief Generic protocol-independant socket address - - This address type does not depend on the protocol of the socket. It does nowever not support - any protocol specific API, so access to the address is very limited. - */ - class GenericSockAddr - { - public: - GenericSockAddr(); - - /// \name Generic Address Interface - /// @{ - - struct sockaddr * sockaddr_p(); ///< Return a pointer to sockaddr structure - /**< The exact structure pointed to depends on the address - family. The data pointed to must be \e mutable. The - value must be changeable and any change of the value - through this pointer must be reflected in the visible - address interface. - \returns non-const (!) pointer to sockaddr structure */ - struct sockaddr const * sockaddr_p() const; ///< Return a pointer to sockaddr structure - /**< This member is like sockaddr_p(), however it does not - allow changing the address. - \returns const pointer to sockaddr structure */ - unsigned sockaddr_len() const; ///< Return size of address - /**< This member return the size of the socket address - structure as returned by sockaddr_p() in bytes. - \returns size of respective sockaddr structure in bytes - */ - /// @} - - private: - struct ::sockaddr_storage addr_; - }; - - /// @} -} - -///////////////////////////////hh.e//////////////////////////////////////// -#include "GenericSockAddr.cci" -//#include "GenericSockAddr.ct" -//#include "GenericSockAddr.cti" -//#include "GenericSockAddr.mpp" -#endif - - -// Local Variables: -// mode: c++ -// fill-column: 100 -// c-file-style: "senf" -// indent-tabs-mode: nil -// ispell-local-dictionary: "american" -// compile-command: "scons -u test" -// comment-column: 40 -// End: diff --git a/Socket/Protocols/GenericSockAddr.cci b/Utils/Buffer.test.cc similarity index 64% copy from Socket/Protocols/GenericSockAddr.cci copy to Utils/Buffer.test.cc index 3aa05af..a5d9d4e 100644 --- a/Socket/Protocols/GenericSockAddr.cci +++ b/Utils/Buffer.test.cc @@ -1,4 +1,6 @@ -// Copyright (C) 2007 +// $Id$ +// +// Copyright (C) 2007 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) // Kompetenzzentrum fuer Satelitenkommunikation (SatCom) // Stefan Bund @@ -19,43 +21,39 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief GenericSockAddr inline non-template implementation */ + \brief Buffer.test unit tests */ + +//#include "Buffer.test.hh" +//#include "Buffer.test.ih" // Custom includes +#include "Buffer.hh" -#define prefix_ inline -///////////////////////////////cci.p/////////////////////////////////////// +#include +#include -prefix_ senf::GenericSockAddr::GenericSockAddr() -{} +#define prefix_ +///////////////////////////////cc.p//////////////////////////////////////// -prefix_ struct sockaddr * senf::GenericSockAddr::sockaddr_p() +BOOST_AUTO_UNIT_TEST(buffer) { - return reinterpret_cast(&addr_); -} + int size (128); -prefix_ struct sockaddr const * senf::GenericSockAddr::sockaddr_p() - const -{ - return reinterpret_cast(&addr_); + // Just check for compile errors, the rest can't be checked + SENF_SCOPED_BUFFER(char, buf, size); + (void) buf; } -prefix_ unsigned senf::GenericSockAddr::sockaddr_len() - const -{ - return sizeof(addr_); -} - -///////////////////////////////cci.e/////////////////////////////////////// +///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ // Local Variables: // mode: c++ // fill-column: 100 +// comment-column: 40 // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" -// comment-column: 40 // End: diff --git a/Socket/Protocols/GenericSockAddr.cci b/Utils/SafeBool.test.cc similarity index 59% copy from Socket/Protocols/GenericSockAddr.cci copy to Utils/SafeBool.test.cc index 3aa05af..39a95be 100644 --- a/Socket/Protocols/GenericSockAddr.cci +++ b/Utils/SafeBool.test.cc @@ -1,4 +1,6 @@ -// Copyright (C) 2007 +// $Id$ +// +// Copyright (C) 2007 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) // Kompetenzzentrum fuer Satelitenkommunikation (SatCom) // Stefan Bund @@ -19,43 +21,55 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief GenericSockAddr inline non-template implementation */ + \brief SafeBool.test unit tests */ + +//#include "SafeBool.test.hh" +//#include "SafeBool.test.ih" // Custom includes +#include "SafeBool.hh" -#define prefix_ inline -///////////////////////////////cci.p/////////////////////////////////////// +#include +#include -prefix_ senf::GenericSockAddr::GenericSockAddr() -{} +#define prefix_ +///////////////////////////////cc.p//////////////////////////////////////// -prefix_ struct sockaddr * senf::GenericSockAddr::sockaddr_p() -{ - return reinterpret_cast(&addr_); -} +namespace { -prefix_ struct sockaddr const * senf::GenericSockAddr::sockaddr_p() - const -{ - return reinterpret_cast(&addr_); + class TestTrue : public senf::SafeBool + { + public: + bool boolean_test() const { + return true; + } + }; + + class TestFalse : public senf::SafeBool + { + public: + bool boolean_test() const { + return false; + } + }; } -prefix_ unsigned senf::GenericSockAddr::sockaddr_len() - const +BOOST_AUTO_UNIT_TEST(safeBool) { - return sizeof(addr_); + BOOST_CHECK( TestTrue() ); + BOOST_CHECK( ! TestFalse() ); } -///////////////////////////////cci.e/////////////////////////////////////// +///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ // Local Variables: // mode: c++ // fill-column: 100 +// comment-column: 40 // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" -// comment-column: 40 // End: diff --git a/Utils/TypeIdValue.cci b/Utils/TypeIdValue.cci index 9b5a0bf..ea4ee65 100644 --- a/Utils/TypeIdValue.cci +++ b/Utils/TypeIdValue.cci @@ -26,6 +26,7 @@ //#include "TypeIdValue.ih" // Custom includes +#include "TypeInfo.hh" #define prefix_ inline ///////////////////////////////cci.p/////////////////////////////////////// @@ -64,11 +65,23 @@ prefix_ std::string senf::TypeIdValue::name() return std::string(value_->id().name()); } +prefix_ std::type_info const & senf::TypeIdValue::id() + const +{ + return value_->id(); +} + prefix_ senf::TypeIdValue const senf::typeIdValue() { return TypeIdValue(); } +prefix_ std::ostream & senf::operator<<(std::ostream & os, TypeIdValue const & v) +{ + os << prettyName(v.id()); + return os; +} + ///////////////////////////////cci.e/////////////////////////////////////// #undef prefix_ diff --git a/Utils/TypeIdValue.hh b/Utils/TypeIdValue.hh index 4e6c853..e0db4ed 100644 --- a/Utils/TypeIdValue.hh +++ b/Utils/TypeIdValue.hh @@ -64,6 +64,7 @@ namespace senf { bool operator<(TypeIdValue const & other) const; std::string name() const; + std::type_info const & id() const; protected: @@ -92,9 +93,7 @@ namespace senf { template TypeIdValue const typeIdValue(); - inline std::ostream & operator<<(std::ostream & os, TypeIdValue const & v) - { return os << v.name(); } - + std::ostream & operator<<(std::ostream & os, TypeIdValue const & v); } ///////////////////////////////hh.e//////////////////////////////////////// diff --git a/Socket/Protocols/GenericSockAddr.cci b/Utils/TypeIdValue.test.cc similarity index 64% copy from Socket/Protocols/GenericSockAddr.cci copy to Utils/TypeIdValue.test.cc index 3aa05af..12b9251 100644 --- a/Socket/Protocols/GenericSockAddr.cci +++ b/Utils/TypeIdValue.test.cc @@ -1,4 +1,6 @@ -// Copyright (C) 2007 +// $Id$ +// +// Copyright (C) 2007 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) // Kompetenzzentrum fuer Satelitenkommunikation (SatCom) // Stefan Bund @@ -19,43 +21,37 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief GenericSockAddr inline non-template implementation */ - -// Custom includes + \brief TypeIdValue.test unit tests */ -#define prefix_ inline -///////////////////////////////cci.p/////////////////////////////////////// +//#include "TypeIdValue.test.hh" +//#include "TypeIdValue.test.ih" -prefix_ senf::GenericSockAddr::GenericSockAddr() -{} +// Custom includes +#include "TypeIdValue.hh" -prefix_ struct sockaddr * senf::GenericSockAddr::sockaddr_p() -{ - return reinterpret_cast(&addr_); -} +#include +#include -prefix_ struct sockaddr const * senf::GenericSockAddr::sockaddr_p() - const -{ - return reinterpret_cast(&addr_); -} +#define prefix_ +///////////////////////////////cc.p//////////////////////////////////////// -prefix_ unsigned senf::GenericSockAddr::sockaddr_len() - const +BOOST_AUTO_UNIT_TEST(typeIdValue) { - return sizeof(addr_); + // We don't care for the ordering, just that the following compiles + (void) ( senf::typeIdValue() < senf::typeIdValue() ); + (void) ( senf::typeIdValue() == senf::typeIdValue() ); } -///////////////////////////////cci.e/////////////////////////////////////// +///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ // Local Variables: // mode: c++ // fill-column: 100 +// comment-column: 40 // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" -// comment-column: 40 // End: diff --git a/Utils/hexdump.hh b/Utils/hexdump.hh index dc6b3f4..7a31aef 100644 --- a/Utils/hexdump.hh +++ b/Utils/hexdump.hh @@ -34,7 +34,7 @@ namespace senf { - /** \brief write the contents from Iterator i to i_end to the output stream in hexadecimal format. + /** \brief Write range [ i, i_end ) to output stream in hexadecimal format */ template void hexdump(Iterator i, Iterator i_end, std::ostream & stream, unsigned block_size=16); diff --git a/Socket/Protocols/GenericSockAddr.cci b/Utils/hexdump.test.cc similarity index 64% copy from Socket/Protocols/GenericSockAddr.cci copy to Utils/hexdump.test.cc index 3aa05af..ac64f5f 100644 --- a/Socket/Protocols/GenericSockAddr.cci +++ b/Utils/hexdump.test.cc @@ -1,4 +1,6 @@ -// Copyright (C) 2007 +// $Id$ +// +// Copyright (C) 2007 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) // Kompetenzzentrum fuer Satelitenkommunikation (SatCom) // Stefan Bund @@ -19,43 +21,39 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief GenericSockAddr inline non-template implementation */ - -// Custom includes + \brief hexdump.test unit tests */ -#define prefix_ inline -///////////////////////////////cci.p/////////////////////////////////////// +//#include "hexdump.test.hh" +//#include "hexdump.test.ih" -prefix_ senf::GenericSockAddr::GenericSockAddr() -{} +// Custom includes +#include "hexdump.hh" +#include -prefix_ struct sockaddr * senf::GenericSockAddr::sockaddr_p() -{ - return reinterpret_cast(&addr_); -} +#include +#include -prefix_ struct sockaddr const * senf::GenericSockAddr::sockaddr_p() - const -{ - return reinterpret_cast(&addr_); -} +#define prefix_ +///////////////////////////////cc.p//////////////////////////////////////// -prefix_ unsigned senf::GenericSockAddr::sockaddr_len() - const +BOOST_AUTO_UNIT_TEST(hExDuMp) { - return sizeof(addr_); + char data[] = { 0x18, 0x19, 0x20, 0x21, 0x7c, 0x7d, 0x7e, 0x7f }; + std::stringstream s; + senf::hexdump(data, data+sizeof(data), s, 8); + BOOST_CHECK_EQUAL( s.str(), " 0000 18 19 20 21 7c 7d 7e 7f .. ! |}..\n" ); } -///////////////////////////////cci.e/////////////////////////////////////// +///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ // Local Variables: // mode: c++ // fill-column: 100 +// comment-column: 40 // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" -// comment-column: 40 // End: diff --git a/Socket/Protocols/GenericSockAddr.cci b/Utils/pool_alloc_mixin.test.cc similarity index 59% copy from Socket/Protocols/GenericSockAddr.cci copy to Utils/pool_alloc_mixin.test.cc index 3aa05af..2fb6107 100644 --- a/Socket/Protocols/GenericSockAddr.cci +++ b/Utils/pool_alloc_mixin.test.cc @@ -1,4 +1,6 @@ -// Copyright (C) 2007 +// $Id$ +// +// Copyright (C) 2007 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) // Kompetenzzentrum fuer Satelitenkommunikation (SatCom) // Stefan Bund @@ -19,43 +21,50 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief GenericSockAddr inline non-template implementation */ + \brief pool_alloc_mixin.test unit tests */ + +//#include "pool_alloc_mixin.test.hh" +//#include "pool_alloc_mixin.test.ih" // Custom includes +#include "pool_alloc_mixin.hh" +#include -#define prefix_ inline -///////////////////////////////cci.p/////////////////////////////////////// +#include +#include -prefix_ senf::GenericSockAddr::GenericSockAddr() -{} +#define prefix_ +///////////////////////////////cc.p//////////////////////////////////////// -prefix_ struct sockaddr * senf::GenericSockAddr::sockaddr_p() -{ - return reinterpret_cast(&addr_); +namespace { + class Test : public senf::pool_alloc_mixin + {}; } -prefix_ struct sockaddr const * senf::GenericSockAddr::sockaddr_p() - const +BOOST_AUTO_UNIT_TEST(poolAllocMixin) { - return reinterpret_cast(&addr_); -} +#ifndef NDEBUG + BOOST_CHECK_EQUAL( Test::allocCounter(), 0u ); -prefix_ unsigned senf::GenericSockAddr::sockaddr_len() - const -{ - return sizeof(addr_); + { + boost::scoped_ptr test (new Test()); + BOOST_CHECK_EQUAL( Test::allocCounter(), 1u ); + } + + BOOST_CHECK_EQUAL( Test::allocCounter(), 0u ); +#endif } -///////////////////////////////cci.e/////////////////////////////////////// +///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ // Local Variables: // mode: c++ // fill-column: 100 +// comment-column: 40 // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" -// comment-column: 40 // End: diff --git a/Socket/Protocols/GenericSockAddr.cci b/Utils/singleton.test.cc similarity index 61% rename from Socket/Protocols/GenericSockAddr.cci rename to Utils/singleton.test.cc index 3aa05af..fb134af 100644 --- a/Socket/Protocols/GenericSockAddr.cci +++ b/Utils/singleton.test.cc @@ -1,4 +1,6 @@ -// Copyright (C) 2007 +// $Id$ +// +// Copyright (C) 2007 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) // Kompetenzzentrum fuer Satelitenkommunikation (SatCom) // Stefan Bund @@ -19,43 +21,52 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief GenericSockAddr inline non-template implementation */ + \brief singleton.test unit tests */ + +//#include "singleton.test.hh" +//#include "singleton.test.ih" // Custom includes +#include "singleton.hh" -#define prefix_ inline -///////////////////////////////cci.p/////////////////////////////////////// +#include +#include -prefix_ senf::GenericSockAddr::GenericSockAddr() -{} +#define prefix_ +///////////////////////////////cc.p//////////////////////////////////////// -prefix_ struct sockaddr * senf::GenericSockAddr::sockaddr_p() -{ - return reinterpret_cast(&addr_); -} +namespace { + + class Test : public senf::singleton + { + friend class senf::singleton; + + Test() : foo_(1234) {} -prefix_ struct sockaddr const * senf::GenericSockAddr::sockaddr_p() - const -{ - return reinterpret_cast(&addr_); + int foo_; + + public: + using senf::singleton::instance; + + int foo() { return foo_; } + }; } -prefix_ unsigned senf::GenericSockAddr::sockaddr_len() - const +BOOST_AUTO_UNIT_TEST(sInGlEtOn) { - return sizeof(addr_); + BOOST_CHECK_EQUAL( Test::instance().foo(), 1234 ); } -///////////////////////////////cci.e/////////////////////////////////////// +///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ // Local Variables: // mode: c++ // fill-column: 100 +// comment-column: 40 // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" -// comment-column: 40 // End: diff --git a/debian/libsenf-socket-dev.install b/debian/libsenf-socket-dev.install index f1d6c8d..b8441a1 100644 --- a/debian/libsenf-socket-dev.install +++ b/debian/libsenf-socket-dev.install @@ -1,3 +1,3 @@ debian/tmp/usr/lib/libSocket.a -debian/tmp/usr/include/Scheduler -debian/README usr/share/doc/libsenf-scheduler-dev +debian/tmp/usr/include/Socket +debian/README usr/share/doc/libsenf-socket-dev diff --git a/debian/libsenf-utils.dev.install b/debian/libsenf-utils-dev.install similarity index 100% rename from debian/libsenf-utils.dev.install rename to debian/libsenf-utils-dev.install diff --git a/find-sources.sh b/find-sources.sh index 9cb24ec..32008f4 100755 --- a/find-sources.sh +++ b/find-sources.sh @@ -14,7 +14,7 @@ fi cond="" if [ "$1" = "-c" ]; then shift - cond='( -name *.h -o -name *.hh -o -name *.ih -o -name *.c -o -name *.cc -o -name *.cci -o -name *.ct -o -name *.cti )' + cond='( -name *.h -o -name *.hh -o -name *.ih -o -name *.c -o -name *.cc -o -name *.cci -o -name *.ct -o -name *.cti -o -name *.mpp )' fi set -f diff --git a/senfscons/InstallIncludes.py b/senfscons/InstallIncludes.py new file mode 100644 index 0000000..8845fa8 --- /dev/null +++ b/senfscons/InstallIncludes.py @@ -0,0 +1,68 @@ +## \file +# \brief InstallIncludes builder + +## \package senfscons.InstallIncludes +# \brief Install all include files which some targets depend upon +# +# \ingroup builder + +import SCons.Builder, SCons.Action, SCons.Environment, SCons.Node.FS + +def recursiveChildren(f): + rv = {} + map(rv.setdefault,f) + for c in f: + map(rv.setdefault,recursiveChildren(c.children())) + return rv.keys() + +def filterIncludes(files, extensions): + return [ f for f in files + if f.get_suffix() in extensions ] + +def filterDirectory(files, dir): + return [ f for f in files + if f.abspath.startswith(dir.abspath) ] + +def excludeDirectories(files, dirs): + return [ f for f in files + if not [ True for d in dirs if files.abspath.startswith(dirs.abspath) ] ] + +def emitter(target, source, env): + source = recursiveChildren(source) + source = filterIncludes(source, env['CPP_INCLUDE_EXTENSIONS']) + source = filterDirectory(source, env['INSTALL_BASE']) + source = excludeDirectories(source, env['INCLUDE_IGNORED_DIRECTORIES']) + + # Build target file by appending the path of 'src' relative to INSTALL_BASE to target[0] + target = [ target[0].File(src.get_path(env.Dir(env['INSTALL_BASE']))) + for src in source ] + + return (target, source) + +class Installer: + def __init__(self, target, source): + self.target = target; + self.source = source + + def __call__(self, target, source, env): + SCons.Environment.installFunc([self.target], [self.source], env) + +def generator(target, source, env, for_signature): + return [ SCons.Action.Action( Installer(trg, src), + SCons.Environment.installString([trg], [src], env) ) + for trg, src in zip(target,source) ] + +InstallIncludes = SCons.Builder.Builder(emitter = emitter, + generator = generator, + source_factory = SCons.Node.FS.Entry, + target_factory = SCons.Node.FS.Dir, + name = 'InstallIncludesBuilder', + ) + +def generate(env): + env['BUILDERS']['InstallIncludes'] = InstallIncludes + env['INSTALL_BASE'] = '#' + env['INCLUDE_IGNORED_DIRECTORIES'] = [] + +def exists(env): + return 1 diff --git a/senfscons/SENFSCons.py b/senfscons/SENFSCons.py index 7c193c4..72087a3 100644 --- a/senfscons/SENFSCons.py +++ b/senfscons/SENFSCons.py @@ -50,6 +50,7 @@ SCONS_TOOLS = [ "Doxygen", "Dia2Png", "CopyToDir", + "InstallIncludes", ] opts = None @@ -343,27 +344,28 @@ def Objects(env, sources, testSources = None, LIBS = [], OBJECTS = []): return objects -def InstallWithSources(env, targets, dir, sources, testSources = []): +def InstallWithSources(env, targets, dir, sources, testSources = [], no_includes = False): if type(sources) is type(()): - sources = sources[0] + sources[1] - if testSources: - sources += testSources + sources, testSources = sources if type(sources) is not type([]): sources = [ sources ] + if type(testSources) is not type([]): + testSources = [ testSources ] installs = [] installs.append( env.Install(dir, targets) ) - for source in sources: - l = len(env.Dir('#').abspath) - source = str(source) - while '.' in source: - source = os.path.splitext(source)[0] - for ext in env['CPP_INCLUDE_EXTENSIONS']: - f = env.File(source+ext) - if f.exists(): - installs.append(env.Install( - '$INCLUDEINSTALLDIR' + f.dir.abspath[l:], f)) + if not no_includes: + target = env.Dir(env['INCLUDEINSTALLDIR']).Dir( + env.Dir('.').get_path(env.Dir(env['INSTALL_BASE']))) + source = targets + if testSources: + source.append( env.File('.test.bin') ) + + installs.append(env.InstallIncludes( + target = target, + source = targets, + INSTALL_BASE = env.Dir('.') )) return installs @@ -568,25 +570,25 @@ def DoxyXRef(env, docs=None, # The library is added to the list of default targets. # #\ingroup target -def Lib(env, library, sources, testSources = None, LIBS = [], OBJECTS = []): +def Lib(env, library, sources, testSources = None, LIBS = [], OBJECTS = [], no_includes = False): objects = Objects(env,sources,testSources,LIBS=LIBS,OBJECTS=OBJECTS) lib = None if objects: lib = env.Library(env.File(LibPath(library)),objects) env.Default(lib) env.Append(ALLLIBS = library) - install = InstallWithSources(env, lib, '$LIBINSTALLDIR', sources) + install = InstallWithSources(env, lib, '$LIBINSTALLDIR', sources, testSources, no_includes) env.Alias('install_all', install) return lib ## \brief Build Object from multiple sources -def Object(env, target, sources, testSources = None, LIBS = [], OBJECTS = []): +def Object(env, target, sources, testSources = None, LIBS = [], OBJECTS = [], no_includes = False): objects = Objects(env,sources,testSources,LIBS=LIBS,OBJECTS=OBJECTS) ob = None if objects: ob = env.Command(target+".o", objects, "ld -r -o $TARGET $SOURCES") env.Default(ob) - install = InstallWithSources(env, ob, '$OBJINSTALLDIR', sources) + install = InstallWithSources(env, ob, '$OBJINSTALLDIR', sources, testSources, no_includes) env.Alias('install_all', install) return ob @@ -600,7 +602,7 @@ def Object(env, target, sources, testSources = None, LIBS = [], OBJECTS = []): # construction environment parameters or the framework helpers. # # \ingroup target -def Binary(env, binary, sources, testSources = None, LIBS = [], OBJECTS = []): +def Binary(env, binary, sources, testSources = None, LIBS = [], OBJECTS = [], no_includes = False): objects = Objects(env,sources,testSources,LIBS=LIBS,OBJECTS=OBJECTS) program = None if objects: @@ -609,7 +611,7 @@ def Binary(env, binary, sources, testSources = None, LIBS = [], OBJECTS = []): program = progEnv.Program(target=binary,source=objects+OBJECTS) env.Default(program) env.Depends(program, [ env.File(LibPath(x)) for x in LIBS ]) - install = InstallWithSources(env, program, '$BININSTALLDIR', - sources, testSources) + install = InstallWithSources(env, program, '$BININSTALLDIR', sources, testSources, + no_includes) env.Alias('install_all', install) return program diff --git a/unchecked-includes.sh b/unchecked-includes.sh new file mode 100755 index 0000000..df60a3a --- /dev/null +++ b/unchecked-includes.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +cd "`dirname "$0"`" + +scons -n install_all PREFIX="non-existing-target" \ + | awk -F \" '/^Install file:/ && $2~/\.(h|hh|ih|ct|cti|cci|mpp)$/ {print $2}' \ + | sort > installed_includes + +./find-sources.sh -c ! -name "*.cc" ! -path "./debian/*" ! -name "*.test.*" -printf "%P\n" \ + | sort > source_includes + +comm -13 installed_includes source_includes + +rm -f installed_includes source_includes