Changeset 751

Show
Ignore:
Timestamp:
12/01/07 05:42:30 (16 years ago)
Author:
ppalmers
Message:

implement cache versioning

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/config.h.in

    r739 r751  
    2121#define PACKAGE_VERSION "$VERSION-$REVISION" 
    2222 
     23/* Define to the version of the cace. */ 
     24#define CACHE_VERSION "$VERSION-$REVISION" 
     25 
    2326/* Define to the api version */ 
    2427#define FFADO_API_VERSION $FFADO_API_VERSION 
  • trunk/libffado/SConstruct

    r750 r751  
    227227        env['REVISION'] = '' 
    228228 
    229 env['FFADO_API_VERSION']="4
     229env['FFADO_API_VERSION']="5
    230230 
    231231env['PACKAGE'] = "libffado" 
    232 env['VERSION'] = "1.999.7
     232env['VERSION'] = "1.999.8
    233233env['LIBVERSION'] = "1.0.0" 
    234234 
     
    242242# 
    243243env.ScanReplace( "config.h.in" ) 
     244# ensure that the config.h is updated with the version 
     245NoCache("config.h") 
     246AlwaysBuild("config.h") 
    244247 
    245248pkgconfig = env.ScanReplace( "libffado.pc.in" ) 
  • trunk/libffado/src/bebob/bebob_avdevice.cpp

    r750 r751  
    442442    Util::XMLDeserialize deser( sFileName, getDebugLevel() ); 
    443443 
     444    if (!deser.isValid()) { 
     445        debugOutput( DEBUG_LEVEL_NORMAL, "cache not valid: %s\n", 
     446                     sFileName.c_str() ); 
     447        return false; 
     448    } 
     449 
    444450    bool result = deserialize( "", deser ); 
    445451    if ( result ) { 
  • trunk/libffado/src/libutil/serialize.cpp

    r742 r751  
    2121 * 
    2222 */ 
     23#include "config.h" // FOR CACHE_VERSION 
    2324 
    2425#include "serialize.h" 
     
    3334    : IOSerialize() 
    3435    , m_filepath( fileName ) 
    35     , m_verboseLevel( 0 ) 
    36 
     36    , m_verboseLevel( DEBUG_LEVEL_NORMAL ) 
     37
     38    setDebugLevel( DEBUG_LEVEL_NORMAL ); 
    3739    try { 
    3840        m_doc.create_root_node( "ffado_cache" ); 
     41        writeVersion(); 
    3942    } catch ( const exception& ex ) { 
    4043        cout << "Exception caught: " << ex.what(); 
    4144    } 
    4245} 
    43  
    4446 
    4547Util::XMLSerialize::XMLSerialize( Glib::ustring fileName, int verboseLevel ) 
     
    4850    , m_verboseLevel( verboseLevel ) 
    4951{ 
     52    setDebugLevel(verboseLevel); 
    5053    try { 
    5154        m_doc.create_root_node( "ffado_cache" ); 
     55        writeVersion(); 
    5256    } catch ( const exception& ex ) { 
    5357        cout << "Exception caught: " << ex.what(); 
     
    6367    } 
    6468 
     69} 
     70 
     71void 
     72Util::XMLSerialize::writeVersion() 
     73{ 
     74    xmlpp::Node* pNode = m_doc.get_root_node(); 
     75    xmlpp::Element* pElem = pNode->add_child( "CacheVersion" ); 
     76    char* valstr; 
     77    asprintf( &valstr, "%s", CACHE_VERSION ); 
     78    pElem->set_child_text( valstr ); 
     79    free( valstr ); 
    6580} 
    6681 
     
    164179    : IODeserialize() 
    165180    , m_filepath( fileName ) 
    166     , m_verboseLevel( 0 ) 
    167 
     181    , m_verboseLevel( DEBUG_LEVEL_NORMAL ) 
     182
     183    setDebugLevel(DEBUG_LEVEL_NORMAL); 
    168184    try { 
    169185        m_parser.set_substitute_entities(); //We just want the text to 
     
    181197    , m_verboseLevel( verboseLevel ) 
    182198{ 
     199    setDebugLevel(verboseLevel); 
    183200    try { 
    184201        m_parser.set_substitute_entities(); //We just want the text to 
     
    193210Util::XMLDeserialize::~XMLDeserialize() 
    194211{ 
     212} 
     213 
     214bool 
     215Util::XMLDeserialize::isValid() 
     216{ 
     217    return checkVersion(); 
     218} 
     219 
     220bool 
     221Util::XMLDeserialize::checkVersion() 
     222{ 
     223    Glib::ustring savedVersion; 
     224    if (read( "CacheVersion", savedVersion )) { 
     225        Glib::ustring expectedVersion = CACHE_VERSION; 
     226        debugOutput( DEBUG_LEVEL_NORMAL, "Cache version: %s, expected: %s.\n", savedVersion.c_str(), expectedVersion.c_str() ); 
     227        if (expectedVersion == savedVersion) { 
     228            debugOutput( DEBUG_LEVEL_VERBOSE, "Cache version OK.\n" ); 
     229            return true; 
     230        } else { 
     231            debugOutput( DEBUG_LEVEL_VERBOSE, "Cache version not OK.\n" ); 
     232            return false; 
     233        } 
     234    } else return false; 
    195235} 
    196236 
  • trunk/libffado/src/libutil/serialize.h

    r742 r751  
    7272                            Glib::ustring str); 
    7373    private: 
     74        void writeVersion(); 
     75 
    7476        Glib::ustring    m_filepath; 
    7577        xmlpp::Document  m_doc; 
     
    9496 
    9597        virtual bool isExisting( std::string strMemberName ); 
    96  
     98        bool isValid(); 
     99        bool checkVersion(); 
    97100    private: 
    98101        Glib::ustring    m_filepath; 
  • trunk/libffado/src/SConscript

    r750 r751  
    171171' ) 
    172172 
     173# Explicitly make these files dependent on config.h 
     174# to make sure they contain the most recent version 
     175# #define's 
     176version_dependent_files = [ 
     177    "ffado.os", # external API versioning 
     178    "libutil/serialize.os", # cache versioning 
     179    ] 
     180 
     181 
    173182source = ffado_source 
    174183pkgdata = [] 
     
    215224ffadolib = libenv.SharedLibrary( "ffado", source ) 
    216225 
     226for file in version_dependent_files: 
     227    Depends(file, '#/config.h') 
     228    NoCache(file) 
     229    AlwaysBuild(file) 
     230 
     231# FIXME: there has to be a better way 
     232AlwaysBuild(ffadolib) 
     233NoCache(ffadolib) 
     234 
    217235# 
    218236# All the following tries to emulate the versioning of installed libs as seen from libtool...