From 8bbf908ab1afd341e361dd5ad0c37f3c1b9a6635 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 28 Nov 2014 17:38:56 +0000 Subject: Autoconfig now detects libraries that libbu++ can use and generates the appropriate headers. bin2cpp now uses those headers to compile correctly despite having missing filters. --- src/tools/bin2cpp.cpp | 53 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 11 deletions(-) (limited to 'src/tools/bin2cpp.cpp') diff --git a/src/tools/bin2cpp.cpp b/src/tools/bin2cpp.cpp index cd57086..e0eab28 100644 --- a/src/tools/bin2cpp.cpp +++ b/src/tools/bin2cpp.cpp @@ -5,9 +5,16 @@ #include #include +#ifdef BU_HAS_DEFLATE #include +#endif +#ifdef BU_HAS_BZIP2 #include +#endif +#ifdef BU_HAS_LZMA #include +#endif + #include #include @@ -26,7 +33,17 @@ public: addOption( sClass, 'c', "Class name [default=\"Datafiles\"]"); addOption( sOutBase, 'o', "Output base filename [defaults to classname]"); addOption( sOutDir, 'd', "Output directory [defaults to current dir]"); - addOption( slot(this, &Options::addFilter), 'f', "Add filter: deflate, bzip2, lzma, base64, hex"); + addOption( slot(this, &Options::addFilter), 'f', "Add filter: " +#ifdef BU_HAS_DEFLATE + "deflate, " +#endif +#ifdef BU_HAS_BZIP2 + "bzip2, " +#endif +#ifdef BU_HAS_LZMA + "lzma, " +#endif + "base64, hex"); addOption( sSpecFile, 's', "Use the specified spec file instead of providing options on the command line. If you use this option all others are ignored."); setNonOption( slot(this, &Options::addInput) ); addHelpOption(); @@ -115,15 +132,22 @@ int main( int argc, char *argv[] ) << "};" << fHdr.nl << fHdr.nl; fHdr << "#endif"; - fSrc << "#include \"" << opt.sOutBase << ".h\"" << fSrc.nl - << "#include " << fSrc.nl - << "#include " << fSrc.nl - << "#include " << fSrc.nl - << "#include " << fSrc.nl - << "#include " << fSrc.nl - << "#include " << fSrc.nl - << "#include " << fSrc.nl << fSrc.nl - << "const " << opt.sClass << "::File " << opt.sClass << "::aFile[] = {" << fSrc.nl; + fSrc << "#include \"" << opt.sOutBase << ".h\"" << fSrc.nl; +#ifdef BU_HAS_DEFLATE + fSrc << "#include " << fSrc.nl; +#endif +#ifdef BU_HAS_BZIP2 + fSrc << "#include " << fSrc.nl; +#endif +#ifdef BU_HAS_LZMA + fSrc << "#include " << fSrc.nl; +#endif + fSrc << "#include " << fSrc.nl; + fSrc << "#include " << fSrc.nl; + fSrc << "#include " << fSrc.nl; + fSrc << "#include " << fSrc.nl; + fSrc << fSrc.nl; + fSrc << "const " << opt.sClass << "::File " << opt.sClass << "::aFile[] = {" << fSrc.nl; for( Bu::StringList::iterator i = opt.slInput.begin(); i; i++ ) { @@ -138,24 +162,31 @@ int main( int argc, char *argv[] ) Bu::String sFltDesc; for( Bu::StringList::iterator f = opt.slFilter.begin(); f; f++ ) { - if( *f == "deflate" ) + if( false ) { } // should optomize out +#ifdef BU_HAS_DEFLATE + else if( *f == "deflate" ) { sDat = encodeStr( sDat ); sFltDesc.prepend("d"); hFilters.insert('d', true ); } +#endif +#ifdef BU_HAS_BZIP2 else if( *f == "bzip2" ) { sDat = encodeStr( sDat ); sFltDesc.prepend("b"); hFilters.insert('b', true ); } +#endif +#ifdef BU_HAS_LZMA else if( *f == "lzma" ) { sDat = encodeStr( sDat ); sFltDesc.prepend("l"); hFilters.insert('l', true ); } +#endif else if( *f == "base64" ) { sDat = encodeStr( sDat ); -- cgit v1.2.3