From: Joel Holdsworth Date: Sat, 28 Dec 2013 18:29:23 +0000 (+0100) Subject: Made decode an optional feature disabled by default. X-Git-Tag: pulseview-0.2.0~177 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=269528f55e7fd77f762c2008d257921cd30e1519;p=pulseview.git Made decode an optional feature disabled by default. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index b24b9711..1fa6d5ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/main.cpp b/main.cpp index 07cfa2fa..3fa93c45 100644 --- 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 /* First, so we avoid a _POSIX_C_SOURCE warning. */ +#endif #include #include @@ -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); diff --git a/pv/dialogs/about.cpp b/pv/dialogs/about.cpp index 8484e47b..fe0f16a9 100644 --- a/pv/dialogs/about.cpp +++ b/pv/dialogs/about.cpp @@ -18,7 +18,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifdef ENABLE_DECODE #include +#endif #include @@ -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("Supported protocol decoders:") + ""); @@ -98,6 +103,7 @@ About::About(QWidget *parent) : .arg(QString::fromUtf8(dec->id)) .arg(QString::fromUtf8(dec->longname))); } +#endif s.append(""); diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 6cb48287..2e0fa0ff 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -18,7 +18,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifdef ENABLE_DECODE #include +#endif #include #include @@ -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() diff --git a/pv/mainwindow.h b/pv/mainwindow.h index 0f1449d3..d5ac35ee 100644 --- a/pv/mainwindow.h +++ b/pv/mainwindow.h @@ -29,6 +29,8 @@ #include "sigsession.h" +struct srd_decoder; + class QVBoxLayout; namespace pv { diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index 2e7be37f..8cfd86d9 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -18,7 +18,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifdef ENABLE_DECODE #include +#endif #include "sigsession.h" @@ -202,6 +204,7 @@ boost::shared_ptr SigSession::get_data() return _logic_data; } +#ifdef ENABLE_DECODE bool SigSession::add_decoder(srd_decoder *const dec) { map > probes; @@ -273,6 +276,7 @@ void SigSession::remove_decode_signal(view::DecodeTrace *signal) return; } } +#endif void SigSession::set_capture_state(capture_state state) { diff --git a/pv/sigsession.h b/pv/sigsession.h index 980fef94..8b97f8c0 100644 --- a/pv/sigsession.h +++ b/pv/sigsession.h @@ -94,12 +94,14 @@ public: boost::shared_ptr get_data(); +#ifdef ENABLE_DECODE bool add_decoder(srd_decoder *const dec); std::vector< boost::shared_ptr > get_decode_signals() const; void remove_decode_signal(view::DecodeTrace *signal); +#endif private: void set_capture_state(capture_state state); diff --git a/pv/view/view.cpp b/pv/view/view.cpp index f5f626b3..18ce679d 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -18,7 +18,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifdef ENABLE_DECODE #include +#endif #include #include @@ -236,14 +238,20 @@ vector< shared_ptr > View::get_traces() const { const vector< shared_ptr > sigs( session().get_signals()); +#ifdef ENABLE_DECODE const vector< shared_ptr > decode_sigs( session().get_decode_signals()); vector< shared_ptr > traces( sigs.size() + decode_sigs.size()); +#else + vector< shared_ptr > traces(sigs.size()); +#endif vector< shared_ptr >::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; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f167ffb1..de2ef909 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -18,10 +18,13 @@ ## along with this program. If not, see . ## -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})