diff --git a/BUILD.gn b/BUILD.gn index 5e03ad26b..15399a25d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -28,6 +28,7 @@ import("etc/gn/openthread.gni") config("openthread_config") { + defines = [] if (openthread_config_file != "") { defines += [ "OPENTHREAD_CONFIG_FILE=${openthread_config_file}" ] } @@ -41,15 +42,27 @@ config("openthread_config") { } config("openthread_ftd_config") { - defines = [ "OPENTHREAD_FTD=1" ] + defines = [ + "OPENTHREAD_FTD=1", + "OPENTHREAD_MTD=0", + "OPENTHREAD_RADIO=0", + ] } config("openthread_mtd_config") { - defines = [ "OPENTHREAD_MTD=1" ] + defines = [ + "OPENTHREAD_MTD=1", + "OPENTHREAD_FTD=0", + "OPENTHREAD_RADIO=0", + ] } config("openthread_radio_config") { - defines = [ "OPENTHREAD_RADIO=1" ] + defines = [ + "OPENTHREAD_RADIO=1", + "OPENTHREAD_FTD=0", + "OPENTHREAD_MTD=0", + ] } group("libopenthread-ftd") { diff --git a/etc/gn/openthread.gni b/etc/gn/openthread.gni index d8180fb6f..084aa61cb 100644 --- a/etc/gn/openthread.gni +++ b/etc/gn/openthread.gni @@ -55,6 +55,9 @@ declare_args() { # Use external mbedtls. If blank, internal mbedtls will be used. openthread_external_mbedtls = "" + # Enable building for POSIX platforms. + openthread_posix = current_os == "linux" + # Package name for OpenThread. openthread_package_name = "OPENTHREAD" diff --git a/src/cli/BUILD.gn b/src/cli/BUILD.gn index 6ed4a8129..7c72c6308 100644 --- a/src/cli/BUILD.gn +++ b/src/cli/BUILD.gn @@ -25,6 +25,8 @@ # POSSIBILITY OF SUCH DAMAGE. # +import("../../etc/gn/openthread.gni") + openthread_cli_sources = [ "cli.cpp", "cli.hpp", @@ -48,14 +50,25 @@ openthread_cli_sources = [ "x509_cert_key.hpp", ] +config("cli_config") { + defines = [] + if (openthread_posix) { + defines += ["OPENTHREAD_POSIX=1"] + } else { + defines += ["OPENTHREAD_POSIX=0"] + } +} + static_library("libopenthread-cli-ftd") { sources = openthread_cli_sources public_deps = [ "../core:libopenthread-ftd" ] + public_configs = [":cli_config"] visibility = [ "../../*" ] } static_library("libopenthread-cli-mtd") { sources = openthread_cli_sources public_deps = [ "../core:libopenthread-mtd" ] + public_configs = [":cli_config"] visibility = [ "../../*" ] }