Skip to content

Commit

Permalink
new configure logic
Browse files Browse the repository at this point in the history
  • Loading branch information
gjc13 committed Jul 1, 2020
1 parent 7507cfe commit d9660a4
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 82 deletions.
2 changes: 1 addition & 1 deletion config/nrf5/nrf5-chip.mk
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ CHIP_CONFIGURE_OPTIONS = \
--with-chip-ble-project-includes=$(CHIP_PROJECT_CONFIG) \
--with-chip-warm-project-includes=$(CHIP_PROJECT_CONFIG) \
--with-chip-device-project-includes=$(CHIP_PROJECT_CONFIG) \
--with-openthread=$(NRF5_SDK_ROOT)/external/openthread \
--enable-openthread \
--disable-ipv4 \
--disable-tests \
--disable-tools \
Expand Down
81 changes: 30 additions & 51 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -904,36 +904,6 @@ NL_ENABLE_DOCS([auto],[NO])

AM_CONDITIONAL(CHIP_BUILD_DOCS, [test "${nl_cv_build_docs}" = "yes"])

#
# OpenThread
#

NL_WITH_OPTIONAL_INTERNAL_PACKAGE(
[OpenThread],
[OPENTHREAD],
[openthread],
[],
[
AC_MSG_NOTICE([No internal OpenThread support yet!])
with_openthread=no
],
[
# Check for required OpenThread headers.
AC_CHECK_HEADERS([openthread/dataset.h] [openthread/dataset_ftd.h] [openthread/error.h] [openthread/icmp6.h] [openthread/instance.h] [openthread/ip6.h] [openthread/link.h] [openthread/message.h] [openthread/netdata.h] [openthread/tasklet.h] [openthread/thread.h],
[],
[
AC_MSG_ERROR(The nlio header "$ac_header" is required but cannot be found.)
])
]
)
AM_CONDITIONAL([CHIP_ENABLE_OPENTHREAD], [test "${with_openthread}" != "no"])
if test "${with_openthread}" != "no"; then
CHIP_ENABLE_OPENTHREAD=1
else
CHIP_ENABLE_OPENTHREAD=0
fi
AC_DEFINE_UNQUOTED([CHIP_ENABLE_OPENTHREAD],[${CHIP_ENABLE_OPENTHREAD}],[Define to 1 if you want to enable OpenThread.])

#
# Network Technology Layer
#
Expand Down Expand Up @@ -1785,16 +1755,16 @@ if test "${nl_cv_build_tests}" = "yes"; then
fi

#
# otbr-client
# openthread
#

AC_ARG_ENABLE(otbr-client,
[AS_HELP_STRING([--enable-otbr-client], [Enable OpenThread Linux client])],
AC_ARG_ENABLE(openthread,
[AS_HELP_STRING([--enable-openthread], [Enable OpenThread])],
[
case "${enableval}" in
no|yes)
enable_otbr_client=${enableval}
enable_openthread=${enableval}
;;
*)
Expand All @@ -1803,33 +1773,42 @@ AC_ARG_ENABLE(otbr-client,
esac
],
[ enable_otbr_client="no" ]
[ enable_openthread="no" ]
)

AC_MSG_NOTICE("enable_otbr_client=${enable_otbr_client}")
AC_MSG_NOTICE("enable_openthread=${enable_openthread}")

if test "${enable_otbr_client}" = "yes"; then
maybe_otbr_client_dirstem="ot-br-posix"
otbr_client_dirstem="third_party/${maybe_otbr_client_dirstem}/repo"
if test "${enable_openthread}" = "yes"; then
if test "${with_device_layer}" = "linux"; then
maybe_ot_br_client_dirstem="ot-br-posix"
ot_br_client_dirstem="third_party/${maybe_ot_br_client_dirstem}/repo"

AC_MSG_NOTICE([attempting to create internal ${otbrclient_dirstem}])
AC_MSG_NOTICE([attempting to create internal ${ot_brclient_dirstem}])
${MAKE-make} --no-print-directory -C ${srcdir} -f Makefile-bootstrap ${ot_br_client_dirstem}

${MAKE-make} --no-print-directory -C ${srcdir} -f Makefile-bootstrap ${otbr_client_dirstem}
if test $? -ne 0; then
AC_MSG_ERROR([failed to create ${ot_br_client_dirstem}. Please check your network connection or the correctness of 'repos.conf'])
fi

if test $? -ne 0; then
AC_MSG_ERROR([failed to create ${otbr_client_dirstem}. Please check your network connection or the correctness of 'repos.conf'])
fi
PKG_CHECK_MODULES([DBUS], dbus-1 >= 1.4)
AC_SUBST([DBUS_CFLAGS])
AC_SUBST([DBUS_LIBS])
AC_SUBST(OTBR_CLIENT_SUBDIRS, [${maybe_ot_br_client_dirstem}])
else
openthread_dirstem="third_party/openthread/repo"

# otbrclient requires dbus
PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.4)
AC_SUBST([DBUS_CFLAGS])
AC_SUBST([DBUS_LIBS])
AC_MSG_NOTICE([attempting to create internal ${openthread_dirstem}])
${MAKE-make} --no-print-directory -C ${srcdir} -f Makefile-bootstrap ${openthread_dirstem}
if test $? -ne 0; then
AC_MSG_ERROR([failed to create ${ot_br_client_dirstem}. Please check your network connection or the correctness of 'repos.conf'])
fi
fi
else
maybe_otbr_client_dirstem=
maybe_ot_br_client_dirstem=
fi

AC_SUBST(OTBR_CLIENT_SUBDIRS, [${maybe_otbr_client_dirstem}])
AM_CONDITIONAL([CHIP_WITH_OTBR_CLIENT], [test "${enable_otbr_client}" != "no"])
AM_CONDITIONAL([CHIP_WITH_OT_BR_CLIENT], [test "${enable_openthread}" != "no" && test "${with_device_layer}" == "linux"])
AM_CONDITIONAL([CHIP_WITH_OPENTHREAD], [test "${enable_openthread}" != "no" && test "${with_device_layer}" != "linux"])

#
# Nlunit-test
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/nrf5/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ INC_DIRS = \
DEFINES = \
BOARD_PCA10056 \
BSP_DEFINES_ONLY \
CHIP_ENABLE_OPENTHREAD=1 \
CHIP_WITH_OPENTHREAD=1 \
CONFIG_GPIO_AS_PINRESET \
ENABLE_FEM \
FLOAT_ABI_HARD \
Expand Down
18 changes: 9 additions & 9 deletions examples/lock-app/nrf5/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
#include "nrf_crypto.h"
#endif
#include "mem_manager.h"
#if CHIP_ENABLE_OPENTHREAD
#if CHIP_WITH_OPENTHREAD
extern "C" {
#include "multiprotocol_802154_config.h"
#include "nrf_802154.h"
#include "nrf_cc310_platform_abort.h"
#include "nrf_cc310_platform_mutex.h"
#include <openthread/platform/platform-softdevice.h>
}
#endif // CHIP_ENABLE_OPENTHREAD
#endif // CHIP_WITH_OPENTHREAD

#if NRF_LOG_ENABLED
#include "nrf_log_backend_uart.h"
Expand All @@ -50,7 +50,7 @@ extern "C" {
#endif // NRF_LOG_ENABLED

#include <AppTask.h>
#if CHIP_ENABLE_OPENTHREAD
#if CHIP_WITH_OPENTHREAD
#include <mbedtls/platform.h>
#include <openthread/cli.h>
#include <openthread/dataset.h>
Expand All @@ -64,7 +64,7 @@ extern "C" {
#include <openthread/thread.h>
#include <platform/CHIPDeviceLayer.h>
#include <support/logging/CHIPLogging.h>
#endif // CHIP_ENABLE_OPENTHREAD
#endif // CHIP_WITH_OPENTHREAD

using namespace ::chip;
using namespace ::chip::Inet;
Expand Down Expand Up @@ -105,7 +105,7 @@ uint32_t LogTimestamp(void)

static void OnSoCEvent(uint32_t sys_evt, void * p_context)
{
#if CHIP_ENABLE_OPENTHREAD
#if CHIP_WITH_OPENTHREAD
otSysSoftdeviceSocEvtHandler(sys_evt);
#endif
UNUSED_PARAMETER(p_context);
Expand Down Expand Up @@ -221,7 +221,7 @@ int main(void)
APP_ERROR_HANDLER(ret);
}

#if CHIP_ENABLE_OPENTHREAD
#if CHIP_WITH_OPENTHREAD
NRF_LOG_INFO("Initializing OpenThread stack");

mbedtls_platform_set_calloc_free(calloc, free);
Expand Down Expand Up @@ -257,7 +257,7 @@ int main(void)
NRF_LOG_INFO("ConnectivityMgr().SetThreadDeviceType() failed");
APP_ERROR_HANDLER(ret);
}
#endif // CHIP_ENABLE_OPENTHREAD
#endif // CHIP_WITH_OPENTHREAD

NRF_LOG_INFO("Starting CHIP task");
ret = PlatformMgr().StartEventLoopTask();
Expand All @@ -267,7 +267,7 @@ int main(void)
APP_ERROR_HANDLER(ret);
}

#if CHIP_ENABLE_OPENTHREAD
#if CHIP_WITH_OPENTHREAD
NRF_LOG_INFO("Starting OpenThread task");

// Start OpenThread task
Expand All @@ -277,7 +277,7 @@ int main(void)
NRF_LOG_INFO("ThreadStackMgr().StartThreadTask() failed");
APP_ERROR_HANDLER(ret);
}
#endif // CHIP_ENABLE_OPENTHREAD
#endif // CHIP_WITH_OPENTHREAD

ret = GetAppTask().StartAppTask();
if (ret != NRF_SUCCESS)
Expand Down
7 changes: 4 additions & 3 deletions src/platform/Linux/ThreadStackManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ using otbr::DBus::NeighborInfo;
namespace chip {
namespace DeviceLayer {

ThreadStackManagerImpl::ThreadStackManagerImpl(DBusConnection *aConnection) :
mThreadApi(nullptr), mConnection(aConnection), mNetworkInfo(), mAttached(false) {}
ThreadStackManagerImpl::ThreadStackManagerImpl(DBusConnection * aConnection) :
mThreadApi(nullptr), mConnection(aConnection), mNetworkInfo(), mAttached(false)
{}

CHIP_ERROR ThreadStackManagerImpl::_InitThreadStack()
{
Expand Down Expand Up @@ -174,7 +175,7 @@ bool ThreadStackManagerImpl::_IsThreadProvisioned()
return mNetworkInfo.ThreadNetworkName[0] != '\0';
}

void ThreadStackManagerImpl::_ClearThreadProvision()
void ThreadStackManagerImpl::_ErasePersistentInfo()
{
mNetworkInfo = Internal::DeviceNetworkInfo{};
}
Expand Down
4 changes: 2 additions & 2 deletions src/platform/Linux/ThreadStackManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace DeviceLayer {
class ThreadStackManagerImpl : public ThreadStackManager
{
public:
ThreadStackManagerImpl(DBusConnection *aConnection);
ThreadStackManagerImpl(DBusConnection * aConnection);

CHIP_ERROR _InitThreadStack();
CHIP_ERROR _ProcessThreadActivity();
Expand All @@ -49,7 +49,7 @@ class ThreadStackManagerImpl : public ThreadStackManager

CHIP_ERROR _SetThreadProvision(const Internal::DeviceNetworkInfo & netInfo);

void _ClearThreadProvision();
void _ErasePersistentInfo();

bool _IsThreadProvisioned();

Expand Down
6 changes: 3 additions & 3 deletions src/platform/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ libDeviceLayer_a_SOURCES = \
Globals.cpp \
$(NULL)

if CHIP_ENABLE_OPENTHREAD
if CHIP_WITH_OPENTHREAD
libDeviceLayer_a_SOURCES += \
OpenThread/OpenThreadUtils.cpp \
$(NULL)
Expand All @@ -142,7 +142,7 @@ libDeviceLayer_a_SOURCES += \
Linux/SystemTimeSupport.cpp \
$(NULL)

if CHIP_WITH_OTBR_CLIENT
if CHIP_WITH_OT_BR_CLIENT
libDeviceLayer_a_SOURCES += \
Linux/ThreadStackManagerImpl.cpp \
$(NULL)
Expand All @@ -169,7 +169,7 @@ libDeviceLayer_a_SOURCES += \
FreeRTOS/SystemTimeSupport.cpp \
$(NULL)

if CHIP_ENABLE_OPENTHREAD
if CHIP_WITH_OPENTHREAD
libDeviceLayer_a_SOURCES += \
nRF5/ThreadStackManagerImpl.cpp \
$(NULL)
Expand Down
2 changes: 1 addition & 1 deletion src/platform/nRF5/CHIPDevicePlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 0
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0

#if CHIP_ENABLE_OPENTHREAD
#if CHIP_WITH_OPENTHREAD
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD 1
#endif

Expand Down
6 changes: 4 additions & 2 deletions src/platform/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ AM_CPPFLAGS = \
$(NULL)

if CHIP_DEVICE_LAYER_TARGET_LINUX
if CHIP_WITH_OTBR_CLIENT
if CHIP_WITH_OT_BR_CLIENT
AM_CPPFLAGS += \
$(DBUS_CFLAGS) \
-I$(top_srcdir)/third_party/ot-br-posix/repo/include \
Expand All @@ -87,11 +87,13 @@ CHIP_LDADD = \
$(NULL)

if CHIP_DEVICE_LAYER_TARGET_LINUX
if CHIP_WITH_OT_BR_CLIENT
CHIP_LDADD += \
$(DBUS_LIBS) \
$(top_builddir)/third_party/ot-br-posix/libotbrclient.a \
$(NULL)
endif
endif

COMMON_LDADD = \
libPlatformTests.a \
Expand All @@ -112,7 +114,7 @@ check_PROGRAMS = \
$(NULL)

if CHIP_DEVICE_LAYER_TARGET_LINUX
if CHIP_WITH_OTBR_CLIENT
if CHIP_WITH_OT_BR_CLIENT
check_PROGRAMS += TestThreadStackMgr

TestThreadStackMgr_LDADD = $(COMMON_LDADD)
Expand Down
13 changes: 6 additions & 7 deletions src/platform/tests/TestThreadStackMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,18 @@
*/

#include <assert.h>
#include <memory>
#include <dbus/dbus.h>
#include <memory>

#include "platform/internal/CHIPDeviceLayerInternal.h"

#include "platform/ThreadStackManager.h"
#include "platform/PlatformManager.h"

#include "platform/ThreadStackManager.h"

#if CHIP_DEVICE_LAYER_TARGET == LINUX
struct DBusConnectionDeleter
{
void operator()(DBusConnection *aConnection) { dbus_connection_unref(aConnection); }
void operator()(DBusConnection * aConnection) { dbus_connection_unref(aConnection); }
};

using UniqueDBusConnection = std::unique_ptr<DBusConnection, DBusConnectionDeleter>;
Expand All @@ -37,8 +36,8 @@ using UniqueDBusConnection = std::unique_ptr<DBusConnection, DBusConnectionDelet
int TestThreadStackManager(void)
{
#if CHIP_DEVICE_LAYER_TARGET == LINUX
DBusError error;
UniqueDBusConnection connection;
DBusError error;
UniqueDBusConnection connection;

dbus_error_init(&error);
connection = UniqueDBusConnection(dbus_bus_get(DBUS_BUS_SYSTEM, &error));
Expand Down Expand Up @@ -67,7 +66,7 @@ int TestThreadStackManager(void)

printf("Start Thread task done\n");

//chip::DeviceLayer::PlatformMgrImpl().RunEventLoop();
// chip::DeviceLayer::PlatformMgrImpl().RunEventLoop();

return 0;
}
4 changes: 2 additions & 2 deletions third_party/ot-br-posix/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am

if CHIP_DEVICE_LAYER_TARGET_LINUX
if CHIP_WITH_OTBR_CLIENT
if CHIP_WITH_OT_BR_CLIENT

lib_LIBRARIES = libotbrclient.a

Expand All @@ -42,7 +42,7 @@ libotbrclient_a_CPPFLAGS = \
$(DBUS_CFLAGS) \
$(NULL)

endif # CHIP_WITH_OTBR_CLIENT
endif # CHIP_WITH_OT_BR_CLIENT
endif # CHIP_DEVICE_LAYER_TARGET_LINUX

include $(abs_top_nlbuild_autotools_dir)/automake/post.am

0 comments on commit d9660a4

Please sign in to comment.