]> sigrok.org Git - pulseview.git/commitdiff
Made decode an optional feature disabled by default.
authorJoel Holdsworth <redacted>
Sat, 28 Dec 2013 18:29:23 +0000 (19:29 +0100)
committerJoel Holdsworth <redacted>
Sat, 28 Dec 2013 21:31:11 +0000 (22:31 +0100)
CMakeLists.txt
main.cpp
pv/dialogs/about.cpp
pv/mainwindow.cpp
pv/mainwindow.h
pv/sigsession.cpp
pv/sigsession.h
pv/view/view.cpp
test/CMakeLists.txt

index b24b9711c963542799066c653ba2d6b68057fc92..1fa6d5ad4f45809ba77163960533cb6d44c94f09 100644 (file)
@@ -34,6 +34,7 @@ project(pulseview)
 
 option(DISABLE_WERROR "Build without -Werror" FALSE)
 option(ENABLE_SIGNALS "Build with UNIX signals" TRUE)
+option(ENABLE_DECODE "Build with libsigrokdecode" FALSE)
 option(ENABLE_TESTS "Enable unit tests" FALSE)
 option(STATIC_PKGDEPS_LIBS "Statically link to (pkgconfig) libraries" FALSE)
 
@@ -56,9 +57,12 @@ endif()
 
 list(APPEND PKGDEPS
        libsigrok>=0.2.0
-       libsigrokdecode>=0.2.0
 )
 
+if(ENABLE_DECODE)
+       list(APPEND PKGDEPS libsigrokdecode>=0.2.0)
+endif()
+
 find_package(PkgConfig)
 pkg_check_modules(PKGDEPS REQUIRED ${PKGDEPS})
 
@@ -107,13 +111,10 @@ set(pulseview_SOURCES
        pv/sigsession.cpp
        pv/data/analog.cpp
        pv/data/analogsnapshot.cpp
-       pv/data/decoderstack.cpp
        pv/data/logic.cpp
        pv/data/logicsnapshot.cpp
        pv/data/signaldata.cpp
        pv/data/snapshot.cpp
-       pv/data/decode/annotation.cpp
-       pv/data/decode/decoder.cpp
        pv/dialogs/about.cpp
        pv/dialogs/connect.cpp
        pv/popups/deviceoptions.cpp
@@ -125,13 +126,11 @@ set(pulseview_SOURCES
        pv/prop/property.cpp
        pv/prop/string.cpp
        pv/prop/binding/binding.cpp
-       pv/prop/binding/decoderoptions.cpp
        pv/prop/binding/deviceoptions.cpp
        pv/toolbars/samplingbar.cpp
        pv/view/analogsignal.cpp
        pv/view/cursor.cpp
        pv/view/cursorpair.cpp
-       pv/view/decodetrace.cpp
        pv/view/header.cpp
        pv/view/marginwidget.cpp
        pv/view/logicsignal.cpp
@@ -145,8 +144,6 @@ set(pulseview_SOURCES
        pv/view/viewport.cpp
        pv/widgets/colourbutton.cpp
        pv/widgets/colourpopup.cpp
-       pv/widgets/decodergroupbox.cpp
-       pv/widgets/decodermenu.cpp
        pv/widgets/popup.cpp
        pv/widgets/popuptoolbutton.cpp
        pv/widgets/wellarray.cpp
@@ -156,11 +153,10 @@ set(pulseview_SOURCES
 set(pulseview_HEADERS
        pv/mainwindow.h
        pv/sigsession.h
-       pv/data/decoderstack.h
        pv/dialogs/about.h
        pv/dialogs/connect.h
-       pv/popups/deviceoptions.h
        pv/popups/probes.h
+       pv/popups/deviceoptions.h
        pv/prop/bool.h
        pv/prop/double.h
        pv/prop/enum.h
@@ -169,7 +165,6 @@ set(pulseview_HEADERS
        pv/prop/string.h
        pv/toolbars/samplingbar.h
        pv/view/cursor.h
-       pv/view/decodetrace.h
        pv/view/header.h
        pv/view/logicsignal.h
        pv/view/marginwidget.h
@@ -182,8 +177,6 @@ set(pulseview_HEADERS
        pv/view/viewport.h
        pv/widgets/colourbutton.h
        pv/widgets/colourpopup.h
-       pv/widgets/decodergroupbox.h
-       pv/widgets/decodermenu.h
        pv/widgets/popup.h
        pv/widgets/popuptoolbutton.h
        pv/widgets/wellarray.h
@@ -202,6 +195,26 @@ if(ENABLE_SIGNALS)
        list(APPEND pulseview_HEADERS signalhandler.h)
 endif()
 
+if(ENABLE_DECODE)
+       list(APPEND pulseview_SOURCES
+               pv/data/decoderstack.cpp
+               pv/data/decode/annotation.cpp
+               pv/data/decode/decoder.cpp
+               pv/prop/binding/decoderoptions.cpp
+               pv/view/decodetrace.cpp
+               pv/widgets/decodergroupbox.cpp
+               pv/widgets/decodermenu.cpp
+               pv/widgets/wellarray.cpp
+       )
+
+       list(APPEND pulseview_HEADERS
+               pv/data/decoderstack.h
+               pv/view/decodetrace.h
+               pv/widgets/decodergroupbox.h
+               pv/widgets/decodermenu.h
+       )
+endif()
+
 qt4_wrap_cpp(pulseview_HEADERS_MOC ${pulseview_HEADERS})
 qt4_wrap_ui(pulseview_FORMS_HEADERS ${pulseview_FORMS})
 qt4_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES})
@@ -215,6 +228,10 @@ include(${QT_USE_FILE})
 add_definitions(${QT_DEFINITIONS})
 add_definitions(-Wall -Wextra)
 
+if(ENABLE_DECODE)
+       add_definitions(-DENABLE_DECODE)
+endif()
+
 if(NOT DISABLE_WERROR)
        add_definitions(-Werror)
 endif()
index 07cfa2facfb9eefce062c243ad4f6d7ead0a417b..3fa93c4586951c81618141a2ab5f7d28a6af3646 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -18,7 +18,9 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#ifdef ENABLE_DECODE
 #include <libsigrokdecode/libsigrokdecode.h> /* First, so we avoid a _POSIX_C_SOURCE warning. */
+#endif
 
 #include <stdint.h>
 #include <libsigrok/libsigrok.h>
@@ -82,7 +84,10 @@ int main(int argc, char *argv[])
                {
                        const int loglevel = atoi(optarg);
                        sr_log_loglevel_set(loglevel);
+
+#ifdef ENABLE_DECODE
                        srd_log_loglevel_set(loglevel);
+#endif
 
                        break;
                }
@@ -113,6 +118,7 @@ int main(int argc, char *argv[])
 
        do {
 
+#ifdef ENABLE_DECODE
                // Initialise libsigrokdecode
                if (srd_init(NULL) != SRD_OK) {
                        qDebug() << "ERROR: libsigrokdecode init failed.";
@@ -121,6 +127,7 @@ int main(int argc, char *argv[])
 
                // Load the protocol decoders
                srd_decoder_load_all();
+#endif
 
                try {
                        // Create the device manager, initialise the drivers
@@ -153,8 +160,10 @@ int main(int argc, char *argv[])
                        qDebug() << e.what();
                }
 
+#ifdef ENABLE_DECODE
                // Destroy libsigrokdecode
                srd_exit();
+#endif
 
        } while (0);
 
index 8484e47b371062426620dd2d4e27befa8c7c2dc3..fe0f16a9149a65fd83e2901fe3b59c3f15f250fe 100644 (file)
@@ -18,7 +18,9 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#ifdef ENABLE_DECODE
 #include <libsigrokdecode/libsigrokdecode.h>
+#endif
 
 #include <QTextDocument>
 
@@ -42,7 +44,9 @@ About::About(QWidget *parent) :
        struct sr_input_format **inputs;
        struct sr_output_format **outputs;
 
+#ifdef ENABLE_DECODE
        struct srd_decoder *dec;
+#endif
 
        QString s;
 
@@ -89,6 +93,7 @@ About::About(QWidget *parent) :
                        .arg(QString::fromUtf8(outputs[i]->description)));
        }
 
+#ifdef ENABLE_DECODE
        s.append("<tr><td colspan=\"2\"><b>" +
                tr("Supported protocol decoders:") +
                "</b></td></tr>");
@@ -98,6 +103,7 @@ About::About(QWidget *parent) :
                         .arg(QString::fromUtf8(dec->id))
                         .arg(QString::fromUtf8(dec->longname)));
        }
+#endif
 
        s.append("</table>");
 
index 6cb482873baee69b1e9fde71634aeba27649da61..2e0fa0ffe8746ce70b3886b94c11724fe7e80da1 100644 (file)
@@ -18,7 +18,9 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#ifdef ENABLE_DECODE
 #include <libsigrokdecode/libsigrokdecode.h>
+#endif
 
 #include <boost/bind.hpp>
 #include <boost/foreach.hpp>
@@ -42,7 +44,9 @@
 #include "toolbars/samplingbar.h"
 #include "view/logicsignal.h"
 #include "view/view.h"
+#ifdef ENABLE_DECODE
 #include "widgets/decodermenu.h"
+#endif
 
 /* __STDC_FORMAT_MACROS is required for PRIu64 and friends (in C++). */
 #define __STDC_FORMAT_MACROS
@@ -194,6 +198,7 @@ void MainWindow::setup_ui()
        menu_view->addAction(action_view_show_cursors);
 
        // Decoders Menu
+#ifdef ENABLE_DECODE
        QMenu *const menu_decoders = new QMenu;
        menu_decoders->setTitle(QApplication::translate(
                "MainWindow", "&Decoders", 0, QApplication::UnicodeUTF8));
@@ -206,6 +211,7 @@ void MainWindow::setup_ui()
                this, SLOT(add_decoder(srd_decoder*)));
 
        menu_decoders->addMenu(menu_decoders_add);
+#endif
 
        // Help Menu
        QMenu *const menu_help = new QMenu;
@@ -220,7 +226,9 @@ void MainWindow::setup_ui()
 
        menu_bar->addAction(menu_file->menuAction());
        menu_bar->addAction(menu_view->menuAction());
+#ifdef ENABLE_DECODE
        menu_bar->addAction(menu_decoders->menuAction());
+#endif
        menu_bar->addAction(menu_help->menuAction());
 
        setMenuBar(menu_bar);
@@ -380,8 +388,12 @@ void MainWindow::on_actionAbout_triggered()
 
 void MainWindow::add_decoder(srd_decoder *decoder)
 {
+#ifdef ENABLE_DECODE
        assert(decoder);
        _session.add_decoder(decoder);
+#else
+       (void)decoder;
+#endif
 }
 
 void MainWindow::run_stop()
index 0f1449d34fad15f1b9de897f6d685c4930bb452f..d5ac35ee92c68fc92dcf14651efa91167702a6d9 100644 (file)
@@ -29,6 +29,8 @@
 
 #include "sigsession.h"
 
+struct srd_decoder;
+
 class QVBoxLayout;
 
 namespace pv {
index 2e7be37f9fb499e85156bd8480330d80059e7b89..8cfd86d9a9782fc340c6fdebf9103d8edba96c3c 100644 (file)
@@ -18,7 +18,9 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#ifdef ENABLE_DECODE
 #include <libsigrokdecode/libsigrokdecode.h>
+#endif
 
 #include "sigsession.h"
 
@@ -202,6 +204,7 @@ boost::shared_ptr<data::Logic> SigSession::get_data()
        return _logic_data;
 }
 
+#ifdef ENABLE_DECODE
 bool SigSession::add_decoder(srd_decoder *const dec)
 {
        map<const srd_probe*, shared_ptr<view::LogicSignal> > probes;
@@ -273,6 +276,7 @@ void SigSession::remove_decode_signal(view::DecodeTrace *signal)
                        return;
                }
 }
+#endif
 
 void SigSession::set_capture_state(capture_state state)
 {
index 980fef947192e2ecb06202400b7d4dc6650ab08c..8b97f8c0364eedd1fcf60a9bd2782e800d46314f 100644 (file)
@@ -94,12 +94,14 @@ public:
 
        boost::shared_ptr<data::Logic> get_data();
 
+#ifdef ENABLE_DECODE
        bool add_decoder(srd_decoder *const dec);
 
        std::vector< boost::shared_ptr<view::DecodeTrace> >
                get_decode_signals() const;
 
        void remove_decode_signal(view::DecodeTrace *signal);
+#endif
 
 private:
        void set_capture_state(capture_state state);
index f5f626b38a4be15bffaa84b13a187f8758dffdfb..18ce679df877f030b2f35a11e208f9ef72e63bcd 100644 (file)
@@ -18,7 +18,9 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#ifdef ENABLE_DECODE
 #include <libsigrokdecode/libsigrokdecode.h>
+#endif
 
 #include <assert.h>
 #include <limits.h>
@@ -236,14 +238,20 @@ vector< shared_ptr<Trace> > View::get_traces() const
 {
        const vector< shared_ptr<Signal> > sigs(
                session().get_signals());
+#ifdef ENABLE_DECODE
        const vector< shared_ptr<DecodeTrace> > decode_sigs(
                session().get_decode_signals());
        vector< shared_ptr<Trace> > traces(
                sigs.size() + decode_sigs.size());
+#else
+       vector< shared_ptr<Trace> > traces(sigs.size());
+#endif
 
        vector< shared_ptr<Trace> >::iterator i = traces.begin();
        i = copy(sigs.begin(), sigs.end(), i);
+#ifdef ENABLE_DECODE
        i = copy(decode_sigs.begin(), decode_sigs.end(), i);
+#endif
 
        stable_sort(traces.begin(), traces.end(), compare_trace_v_offsets);
        return traces;
index f167ffb1e09c8db14019340a1a6cf44541254efb..de2ef909cf86fdf7af5d07ebc1acd337a42b2b20 100644 (file)
 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ##
 
-list(APPEND PKGDEPS
-       libsigrok>=0.2.0
-       libsigrokdecode>=0.2.0
-)
+option(ENABLE_DECODE "Build with libsigrokdecode" FALSE)
+
+list(APPEND PKGDEPS libsigrok>=0.2.0)
+
+if(ENABLE_DECODE)
+       list(APPEND PKGDEPS libsigrokdecode>=0.2.0)
+endif()
 
 find_package(PkgConfig)
 pkg_check_modules(PKGDEPS REQUIRED ${PKGDEPS})
@@ -41,22 +44,17 @@ set(pulseview_TEST_SOURCES
        ${PROJECT_SOURCE_DIR}/pv/view/cursorpair.cpp
        ${PROJECT_SOURCE_DIR}/pv/data/analog.cpp
        ${PROJECT_SOURCE_DIR}/pv/data/analogsnapshot.cpp
-       ${PROJECT_SOURCE_DIR}/pv/data/decoderstack.cpp
        ${PROJECT_SOURCE_DIR}/pv/data/logic.cpp
        ${PROJECT_SOURCE_DIR}/pv/data/logicsnapshot.cpp
        ${PROJECT_SOURCE_DIR}/pv/data/snapshot.cpp
        ${PROJECT_SOURCE_DIR}/pv/data/signaldata.cpp
-       ${PROJECT_SOURCE_DIR}/pv/data/decode/decoder.cpp
-       ${PROJECT_SOURCE_DIR}/pv/data/decode/annotation.cpp
        ${PROJECT_SOURCE_DIR}/pv/prop/int.cpp
        ${PROJECT_SOURCE_DIR}/pv/prop/property.cpp
        ${PROJECT_SOURCE_DIR}/pv/prop/string.cpp
        ${PROJECT_SOURCE_DIR}/pv/prop/binding/binding.cpp
-       ${PROJECT_SOURCE_DIR}/pv/prop/binding/decoderoptions.cpp
        ${PROJECT_SOURCE_DIR}/pv/view/analogsignal.cpp
        ${PROJECT_SOURCE_DIR}/pv/view/cursor.cpp
        ${PROJECT_SOURCE_DIR}/pv/view/cursorpair.cpp
-       ${PROJECT_SOURCE_DIR}/pv/view/decodetrace.cpp
        ${PROJECT_SOURCE_DIR}/pv/view/header.cpp
        ${PROJECT_SOURCE_DIR}/pv/view/logicsignal.cpp
        ${PROJECT_SOURCE_DIR}/pv/view/marginwidget.cpp
@@ -70,12 +68,9 @@ set(pulseview_TEST_SOURCES
        ${PROJECT_SOURCE_DIR}/pv/view/viewport.cpp
        ${PROJECT_SOURCE_DIR}/pv/widgets/colourbutton.cpp
        ${PROJECT_SOURCE_DIR}/pv/widgets/colourpopup.cpp
-       ${PROJECT_SOURCE_DIR}/pv/widgets/decodergroupbox.cpp
-       ${PROJECT_SOURCE_DIR}/pv/widgets/decodermenu.cpp
        ${PROJECT_SOURCE_DIR}/pv/widgets/popup.cpp
        ${PROJECT_SOURCE_DIR}/pv/widgets/wellarray.cpp
        data/analogsnapshot.cpp
-       data/decoderstack.cpp
        data/logicsnapshot.cpp
        test.cpp
 )
@@ -83,12 +78,10 @@ set(pulseview_TEST_SOURCES
 # This list includes only QObject derrived class headers
 set(pulseview_TEST_HEADERS
        ${PROJECT_SOURCE_DIR}/pv/sigsession.h
-       ${PROJECT_SOURCE_DIR}/pv/data/decoderstack.h
        ${PROJECT_SOURCE_DIR}/pv/prop/int.h
        ${PROJECT_SOURCE_DIR}/pv/prop/property.h
        ${PROJECT_SOURCE_DIR}/pv/prop/string.h
        ${PROJECT_SOURCE_DIR}/pv/view/cursor.h
-       ${PROJECT_SOURCE_DIR}/pv/view/decodetrace.h
        ${PROJECT_SOURCE_DIR}/pv/view/header.h
        ${PROJECT_SOURCE_DIR}/pv/view/logicsignal.h
        ${PROJECT_SOURCE_DIR}/pv/view/marginwidget.h
@@ -101,14 +94,36 @@ set(pulseview_TEST_HEADERS
        ${PROJECT_SOURCE_DIR}/pv/view/viewport.h
        ${PROJECT_SOURCE_DIR}/pv/widgets/colourbutton.h
        ${PROJECT_SOURCE_DIR}/pv/widgets/colourpopup.h
-       ${PROJECT_SOURCE_DIR}/pv/widgets/decodergroupbox.h
-       ${PROJECT_SOURCE_DIR}/pv/widgets/decodermenu.h
        ${PROJECT_SOURCE_DIR}/pv/widgets/popup.h
        ${PROJECT_SOURCE_DIR}/pv/widgets/wellarray.h
 )
 
+if(ENABLE_DECODE)
+       list(APPEND pulseview_TEST_SOURCES
+               ${PROJECT_SOURCE_DIR}/pv/data/decoderstack.cpp
+               ${PROJECT_SOURCE_DIR}/pv/data/decode/decoder.cpp
+               ${PROJECT_SOURCE_DIR}/pv/data/decode/annotation.cpp
+               ${PROJECT_SOURCE_DIR}/pv/prop/binding/decoderoptions.cpp
+               ${PROJECT_SOURCE_DIR}/pv/view/decodetrace.cpp
+               ${PROJECT_SOURCE_DIR}/pv/widgets/decodergroupbox.cpp
+               ${PROJECT_SOURCE_DIR}/pv/widgets/decodermenu.cpp
+               data/decoderstack.cpp
+       )
+
+       list(APPEND pulseview_TEST_HEADERS
+               ${PROJECT_SOURCE_DIR}/pv/data/decoderstack.h
+               ${PROJECT_SOURCE_DIR}/pv/view/decodetrace.h
+               ${PROJECT_SOURCE_DIR}/pv/widgets/decodergroupbox.h
+               ${PROJECT_SOURCE_DIR}/pv/widgets/decodermenu.h
+       )
+endif()
+
 qt4_wrap_cpp(pulseview_TEST_HEADERS_MOC ${pulseview_TEST_HEADERS})
 
+if(ENABLE_DECODE)
+       add_definitions(-DENABLE_DECODE)
+endif()
+
 add_definitions(-DBOOST_TEST_DYN_LINK)
 add_definitions(${QT_DEFINITIONS})