mirror of
https://github.com/espressif/openthread.git
synced 2026-08-01 08:37:47 +00:00
Change enable-default-logging build feature to a config option (#1879)
This commit changes the `--enable-default-logging` option into a OpenThread config option `OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT`. Makefiles and project core config header files for different platforms are also updated accordingly.
This commit is contained in:
committed by
Jonathan Hui
parent
1582d32a4e
commit
3526af39f8
@@ -837,36 +837,6 @@ AC_SUBST(OPENTHREAD_ENABLE_CHILD_SUPERVISION)
|
||||
AM_CONDITIONAL([OPENTHREAD_ENABLE_CHILD_SUPERVISION], [test "${enable_child_supervision}" = "yes"])
|
||||
AC_DEFINE_UNQUOTED([OPENTHREAD_ENABLE_CHILD_SUPERVISION],[${OPENTHREAD_ENABLE_CHILD_SUPERVISION}],[Define to 1 if you want to use child supervision feature])
|
||||
|
||||
#
|
||||
# Default Logging
|
||||
#
|
||||
|
||||
AC_ARG_ENABLE(default_logging,
|
||||
[AS_HELP_STRING([--enable-default-logging],[Enable default logging support @<:@default=no@:>@.])],
|
||||
[
|
||||
case "${enableval}" in
|
||||
|
||||
no|yes)
|
||||
enable_default_logging=${enableval}
|
||||
;;
|
||||
|
||||
*)
|
||||
AC_MSG_ERROR([Invalid value ${enable_default_logging} for --enable-default-logging])
|
||||
;;
|
||||
esac
|
||||
],
|
||||
[enable_default_logging=no])
|
||||
|
||||
if test "$enable_default_logging" = "yes"; then
|
||||
OPENTHREAD_ENABLE_DEFAULT_LOGGING=1
|
||||
else
|
||||
OPENTHREAD_ENABLE_DEFAULT_LOGGING=0
|
||||
fi
|
||||
|
||||
AC_SUBST(OPENTHREAD_ENABLE_DEFAULT_LOGGING)
|
||||
AM_CONDITIONAL([OPENTHREAD_ENABLE_DEFAULT_LOGGING], [test "${enable_default_logging}" = "yes"])
|
||||
AC_DEFINE_UNQUOTED([OPENTHREAD_ENABLE_DEFAULT_LOGGING],[${OPENTHREAD_ENABLE_DEFAULT_LOGGING}],[Define to 1 if you want to enable default logging])
|
||||
|
||||
#
|
||||
# Log for certification test
|
||||
#
|
||||
|
||||
@@ -50,7 +50,6 @@ configure_OPTIONS = \
|
||||
--with-platform-info=CC2538 \
|
||||
$(NULL)
|
||||
|
||||
DEFAULT_LOGGING ?= 1
|
||||
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk
|
||||
|
||||
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
|
||||
|
||||
@@ -49,7 +49,6 @@ configure_OPTIONS = \
|
||||
--with-platform-info=DA15000 \
|
||||
$(NULL)
|
||||
|
||||
DEFAULT_LOGGING ?= 1
|
||||
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk
|
||||
|
||||
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
|
||||
|
||||
@@ -51,7 +51,6 @@ configure_OPTIONS = \
|
||||
MBEDTLS_CPPFLAGS="$(EFR32_MBEDTLS_CPPFLAGS)" \
|
||||
$(NULL)
|
||||
|
||||
DEFAULT_LOGGING ?= 1
|
||||
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk
|
||||
|
||||
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
|
||||
|
||||
@@ -45,7 +45,6 @@ configure_OPTIONS = \
|
||||
--enable-cli-app=all \
|
||||
--enable-ncp-app=all \
|
||||
--with-ncp-bus=uart \
|
||||
--enable-default-logging \
|
||||
--with-examples=emsk \
|
||||
--with-platform-info=EMSK \
|
||||
$(NULL)
|
||||
|
||||
@@ -50,7 +50,6 @@ configure_OPTIONS = \
|
||||
--with-platform-info=KW41Z \
|
||||
$(NULL)
|
||||
|
||||
DEFAULT_LOGGING ?= 1
|
||||
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk
|
||||
|
||||
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
|
||||
|
||||
@@ -41,9 +41,17 @@ RM_F := rm -f
|
||||
|
||||
BuildJobs ?= 10
|
||||
|
||||
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
|
||||
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
|
||||
|
||||
CONFIG_FILE = OPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-posix-config.h\"'
|
||||
CONFIG_FILE_PATH = $(AbsTopSourceDir)/examples/platforms/posix/
|
||||
|
||||
COMMONCFLAGS := \
|
||||
-O1 \
|
||||
-g \
|
||||
-D$(CONFIG_FILE) \
|
||||
-I$(CONFIG_FILE_PATH) \
|
||||
$(NULL)
|
||||
|
||||
CPPFLAGS += \
|
||||
@@ -86,7 +94,6 @@ configure_OPTIONS = \
|
||||
--enable-ncp-app=all \
|
||||
--with-ncp-bus=uart \
|
||||
--enable-diag \
|
||||
--enable-default-logging \
|
||||
--enable-raw-link-api=yes \
|
||||
--with-examples=posix \
|
||||
--with-platform-info=POSIX \
|
||||
|
||||
@@ -62,10 +62,6 @@ ifeq ($(DHCP6_SERVER),1)
|
||||
configure_OPTIONS += --enable-dhcp6-server
|
||||
endif
|
||||
|
||||
ifeq ($(DEFAULT_LOGGING),1)
|
||||
configure_OPTIONS += --enable-default-logging
|
||||
endif
|
||||
|
||||
ifeq ($(DISABLE_DOC),1)
|
||||
configure_OPTIONS += --disable-docs
|
||||
endif
|
||||
|
||||
@@ -34,6 +34,14 @@
|
||||
#ifndef OPENTHREAD_CORE_CC2538_CONFIG_H_
|
||||
#define OPENTHREAD_CORE_CC2538_CONFIG_H_
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT
|
||||
*
|
||||
* Define to 1 to enable default log output.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT 1
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_ENABLE_SOFTWARE_ACK_TIMEOUT
|
||||
*
|
||||
|
||||
@@ -36,6 +36,14 @@
|
||||
|
||||
#define SETTINGS_CONFIG_BASE_ADDRESS (0x7B000)
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT
|
||||
*
|
||||
* Define to 1 to enable default log output.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT 1
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_ENABLE_SOFTWARE_ACK_TIMEOUT
|
||||
*
|
||||
|
||||
@@ -36,6 +36,14 @@
|
||||
#define OPENTHREAD_CORE_EFR32_CONFIG_H_
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT
|
||||
*
|
||||
* Define to 1 to enable default log output.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT 1
|
||||
|
||||
/*
|
||||
* @def OPENTHREAD_CONFIG_ENABLE_SOFTWARE_RETRANSMIT
|
||||
*
|
||||
* Define to 1 if you want to enable software retransmission logic.
|
||||
|
||||
@@ -34,6 +34,14 @@
|
||||
#ifndef OPENTHREAD_CORE_EMSK_CONFIG_H_
|
||||
#define OPENTHREAD_CORE_EMSK_CONFIG_H_
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT
|
||||
*
|
||||
* Define to 1 to enable default log output.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT 1
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_ENABLE_SOFTWARE_ACK_TIMEOUT
|
||||
*
|
||||
|
||||
@@ -35,6 +35,14 @@
|
||||
#ifndef OPENTHREAD_CORE_KW41Z_CONFIG_H_
|
||||
#define OPENTHREAD_CORE_KW41Z_CONFIG_H_
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT
|
||||
*
|
||||
* Define to 1 to enable default log output.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT 1
|
||||
|
||||
/**
|
||||
* @def SETTINGS_CONFIG_BASE_ADDRESS
|
||||
*
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#include <openthread-config.h>
|
||||
#include <openthread/types.h>
|
||||
|
||||
#if (OPENTHREAD_ENABLE_DEFAULT_LOGGING == 0)
|
||||
#if (OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT == 0)
|
||||
#include <segger_rtt/SEGGER_RTT.h>
|
||||
|
||||
#if (LOG_RTT_COLOR_ENABLE == 1)
|
||||
@@ -174,4 +174,4 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
#endif // (OPENTHREAD_ENABLE_DEFAULT_LOGGING == 0)
|
||||
#endif // (OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT == 0)
|
||||
|
||||
@@ -54,14 +54,14 @@ void PlatformInit(int argc, char *argv[])
|
||||
nrf5MiscInit();
|
||||
nrf5CryptoInit();
|
||||
nrf5RadioInit();
|
||||
#if (OPENTHREAD_ENABLE_DEFAULT_LOGGING == 0)
|
||||
#if (OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT == 0)
|
||||
nrf5LogInit();
|
||||
#endif
|
||||
}
|
||||
|
||||
void PlatformDeinit(void)
|
||||
{
|
||||
#if (OPENTHREAD_ENABLE_DEFAULT_LOGGING == 0)
|
||||
#if (OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT == 0)
|
||||
nrf5LogDeinit();
|
||||
#endif
|
||||
nrf5RadioDeinit();
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2017, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file includes posix compile-time configuration constants
|
||||
* for OpenThread.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_CORE_POSIX_CONFIG_H_
|
||||
#define OPENTHREAD_CORE_POSIX_CONFIG_H_
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT
|
||||
*
|
||||
* Define to 1 to enable default log output.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT 1
|
||||
|
||||
#endif // OPENTHREAD_CORE_POSIX_CONFIG_H_
|
||||
@@ -32,8 +32,8 @@
|
||||
/* Define to 1 to enable the NCP SPI interface. */
|
||||
// On the command line: #define OPENTHREAD_ENABLE_NCP_SPI 1
|
||||
|
||||
/* Define to 1 if you want to enable default logging */
|
||||
#define OPENTHREAD_ENABLE_DEFAULT_LOGGING 1
|
||||
/* Define to 1 if you want to enable default log output. */
|
||||
#define OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT 1
|
||||
|
||||
/* Define to 1 to enable the commissioner role. */
|
||||
#define OPENTHREAD_ENABLE_COMMISSIONER 1
|
||||
|
||||
@@ -238,7 +238,7 @@ void Uart::SendDoneTask(void)
|
||||
Send();
|
||||
}
|
||||
|
||||
#if OPENTHREAD_ENABLE_DEFAULT_LOGGING
|
||||
#if OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -261,7 +261,7 @@ void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
#endif // OPENTHREAD_ENABLE_DEFAULT_LOGGING
|
||||
#endif // OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT
|
||||
|
||||
} // namespace Cli
|
||||
} // namespace ot
|
||||
|
||||
@@ -599,6 +599,19 @@
|
||||
#define OPENTHREAD_CONFIG_PLAT_LOG_FUNCTION otPlatLog
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT
|
||||
*
|
||||
* Define to 1 to enable default log output.
|
||||
*
|
||||
* When enabled OpenThread provides a default implementation for `otPlatLog()` which is tied to either NCP or CLI
|
||||
* stream writes.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT
|
||||
#define OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_NUM_DHCP_PREFIXES
|
||||
*
|
||||
|
||||
@@ -273,7 +273,7 @@ void NcpUart::HandleError(otError aError, uint8_t *aBuf, uint16_t aBufLength)
|
||||
otNcpStreamWrite(0, reinterpret_cast<uint8_t *>(hexbuf + 1), static_cast<int>(strlen(hexbuf) - 1));
|
||||
}
|
||||
|
||||
#if OPENTHREAD_ENABLE_DEFAULT_LOGGING
|
||||
#if OPENTHREAD_CONFIG_ENABLE_DEFAULT_LOG_OUTPUT
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user