Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide build flag to disable compilation of yang dependent interfaces #3

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions common/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ common_libswsscommon_la_SOURCES = \
common/configdb.cpp \
common/dbconnector.cpp \
common/dbinterface.cpp \
common/defaultvalueprovider.cpp \
common/sonicv2connector.cpp \
common/table.cpp \
common/decoratortable.cpp \
common/json.cpp \
common/producertable.cpp \
common/producerstatetable.cpp \
Expand Down Expand Up @@ -60,7 +58,6 @@ common_libswsscommon_la_SOURCES = \
common/exec.cpp \
common/saiaclschema.cpp \
common/subscriberstatetable.cpp \
common/decoratorsubscriberstatetable.cpp \
common/timestamp.cpp \
common/warm_restart.cpp \
common/luatable.cpp \
Expand All @@ -70,14 +67,23 @@ common_libswsscommon_la_SOURCES = \
common/profileprovider.cpp \
common/zmqclient.cpp \
common/zmqserver.cpp \
common/asyncdbupdater.cpp \
common/asyncdbupdater.cpp \
common/redis_table_waiter.cpp

common_libswsscommon_la_CXXFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(LIBNL_CFLAGS) $(CODE_COVERAGE_CXXFLAGS)
common_libswsscommon_la_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(LIBNL_CPPFLAGS) $(CODE_COVERAGE_CPPFLAGS)
common_libswsscommon_la_LIBADD = -lpthread $(LIBNL_LIBS) $(CODE_COVERAGE_LIBS) -lzmq -lboost_serialization -luuid -lyang
common_libswsscommon_la_LIBADD = -lpthread $(LIBNL_LIBS) $(CODE_COVERAGE_LIBS) -lzmq -lboost_serialization -luuid
common_libswsscommon_la_LDFLAGS = -Wl,-z,now $(LDFLAGS)

if YANGMODS
common_libswsscommon_la_SOURCES += \
common/defaultvalueprovider.cpp \
common/decoratortable.cpp \
common/decoratorsubscriberstatetable.cpp

common_libswsscommon_la_LIBADD += -lyang
endif

common_swssloglevel_SOURCES = \
common/loglevel.cpp \
common/loglevel_util.cpp
Expand Down
6 changes: 6 additions & 0 deletions common/configdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,12 @@ class ConfigDBConnector_Native : public SonicV2Connector_Native
ret.setdefault(table_name, {})[self.deserialize_key(row)] = entry
return ret

%}
#endif

#if defined(SWIG) && defined(SWIGPYTHON) && defined(ENABLE_YANG_MODULES)
%pythoncode %{

class YangDefaultDecorator(object):
def __init__(self, config_db_connector):
self.connector = config_db_connector
Expand Down
8 changes: 8 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,16 @@ AC_ARG_ENABLE(python2,
no) python2=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-python2) ;;
esac],[python2=true])
AC_ARG_ENABLE(yang-modules,
[ --enable-yang-modules Generate classes that depend on libyang],
[case "${enableval}" in
yes) yang-modules=true ;;
no) yang-modules=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-yang-modules) ;;
esac],[yang-modules=true])
AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
AM_CONDITIONAL(PYTHON2, test x$python2 = xtrue)
AM_CONDITIONAL(YANGMODS, test x$yang-modules = xtrue)
if test x$CONFIGURED_ARCH = xarmhf && test x$CROSS_BUILD_ENVIRON = xy; then
AM_CONDITIONAL(ARCH64, false)
else
Expand Down
5 changes: 5 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ else
CONFIGURE_ARGS += --disable-python2
endif

# Skip compiling classes that depend on libyang
ifneq (,$(filter noyangmod,$(DEB_BUILD_PROFILES)))
CONFIGURE_ARGS += --disable-yang-modules
endif

# main packaging script
%:
dh $@
Expand Down
5 changes: 5 additions & 0 deletions pyext/py2/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ pyext_py2__swsscommon_la_CPPFLAGS = -std=c++11 -Icommon -I/usr/include/python$(P
pyext_py2__swsscommon_la_LDFLAGS = -module -Wl,-z,now
pyext_py2__swsscommon_la_LIBADD = common/libswsscommon.la -lpython$(PYTHON_VERSION)

if YANGMODS
SWIG_FLAG += -DENABLE_YANG_MODULES
pyext_py2__swsscommon_la_CPPFLAGS += -DENABLE_YANG_MODULES
endif

pyext/py2/swsscommon_wrap.cpp: $(SWIG_SOURCES)
$(SWIG) $(SWIG_FLAG) -Icommon -o $@ $<

Expand Down
5 changes: 5 additions & 0 deletions pyext/py3/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ pyext_py3__swsscommon_la_CPPFLAGS = -std=c++11 -Icommon -I/usr/include/python$(P
pyext_py3__swsscommon_la_LDFLAGS = -module -Wl,-z,now
pyext_py3__swsscommon_la_LIBADD = common/libswsscommon.la $(PYTHON3_BLDLIBRARY)

if YANGMODS
SWIG_FLAG += -DENABLE_YANG_MODULES
pyext_py3__swsscommon_la_CPPFLAGS += -DENABLE_YANG_MODULES
endif

pyext/py3/swsscommon_wrap.cpp: $(SWIG_SOURCES)
$(SWIG) $(SWIG_FLAG) -Icommon -o $@ $<

Expand Down
12 changes: 10 additions & 2 deletions pyext/swsscommon.i
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@
#include "schema.h"
#include "dbconnector.h"
#include "dbinterface.h"
#include "defaultvalueprovider.h"
#include "sonicv2connector.h"
#include "pubsub.h"
#include "select.h"
#include "selectable.h"
#include "rediscommand.h"
#include "table.h"
#include "decoratortable.h"
#include "countertable.h"
#include "redispipeline.h"
#include "redisreply.h"
Expand All @@ -40,7 +38,11 @@
#include "profileprovider.h"
#include "consumertable.h"
#include "subscriberstatetable.h"
#ifdef ENABLE_YANG_MODULES
#include "decoratortable.h"
#include "defaultvalueprovider.h"
#include "decoratorsubscriberstatetable.h"
#endif
#include "notificationconsumer.h"
#include "notificationproducer.h"
#include "warm_restart.h"
Expand Down Expand Up @@ -251,7 +253,9 @@ T castSelectableObj(swss::Selectable *temp)

%include "schema.h"
%include "dbconnector.h"
#ifdef ENABLE_YANG_MODULES
%include "defaultvalueprovider.h"
#endif
%include "sonicv2connector.h"
%include "pubsub.h"
%include "profileprovider.h"
Expand All @@ -278,7 +282,9 @@ T castSelectableObj(swss::Selectable *temp)
%apply std::vector<std::pair<std::string, std::string>>& OUTPUT {std::vector<std::pair<std::string, std::string>> &ovalues};
%apply std::string& OUTPUT {std::string &value};
%include "table.h"
#ifdef ENABLE_YANG_MODULES
%include "decoratortable.h"
#endif
%clear std::vector<std::string> &keys;
%clear std::vector<std::string> &ops;
%clear std::vector<std::vector<std::pair<std::string, std::string>>> &fvss;
Expand Down Expand Up @@ -318,7 +324,9 @@ T castSelectableObj(swss::Selectable *temp)
%include "consumertable.h"
%include "consumerstatetable.h"
%include "subscriberstatetable.h"
#ifdef ENABLE_YANG_MODULES
%include "decoratorsubscriberstatetable.h"
#endif

%apply std::string& OUTPUT {std::string &op};
%apply std::string& OUTPUT {std::string &data};
Expand Down
5 changes: 4 additions & 1 deletion tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ tests_tests_SOURCES = tests/redis_ut.cpp \
tests/countertable_ut.cpp \
tests/timer_ut.cpp \
tests/cli_ut.cpp \
tests/defaultvalueprovider_ut.cpp \
tests/events_common_ut.cpp \
tests/events_service_ut.cpp \
tests/events_ut.cpp \
Expand All @@ -48,3 +47,7 @@ tests_tests_SOURCES = tests/redis_ut.cpp \
tests_tests_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(LIBNL_CFLAGS)
tests_tests_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(LIBNL_CFLAGS) -fno-access-control
tests_tests_LDADD = $(LDADD_GTEST) -lpthread common/libswsscommon.la $(LIBNL_LIBS) $(CODE_COVERAGE_LIBS) sonic-db-cli/libsonicdbcli.la -lzmq -luuid -lboost_serialization

if YANGMODS
tests_tests_SOURCES += tests/defaultvalueprovider_ut.cpp
endif
Loading