diff --git a/src/core/BUILD.gn b/src/core/BUILD.gn index 9bb9ffd35..d79953aaa 100644 --- a/src/core/BUILD.gn +++ b/src/core/BUILD.gn @@ -30,6 +30,217 @@ import("../../etc/gn/openthread.gni") visibility = [ "../../*" ] if (openthread_enable_core_config_args) { + ot_bool_flags = [ + { + macro = "OPENTHREAD_CONFIG_ANYCAST_LOCATOR_ENABLE" + value = openthread_config_anycast_locator_enable + }, + { + macro = "OPENTHREAD_CONFIG_ASSERT_ENABLE" + value = openthread_config_assert_enable + }, + { + macro = "OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE" + value = openthread_config_backbone_router_enable + }, + { + macro = "OPENTHREAD_CONFIG_BLE_TCAT_ENABLE" + value = openthread_config_ble_tcat_enable + }, + { + macro = "OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE" + value = openthread_config_border_agent_enable + }, + { + macro = "OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE" + value = openthread_config_border_router_enable + }, + { + macro = "OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE" + value = openthread_config_border_routing_enable + }, + { + macro = "OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE" + value = openthread_config_channel_manager_enable + }, + { + macro = "OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE" + value = openthread_config_channel_monitor_enable + }, + { + macro = "OPENTHREAD_CONFIG_COAP_API_ENABLE" + value = openthread_config_coap_api_enable + }, + { + macro = "OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE" + value = openthread_config_coap_observe_api_enable + }, + { + macro = "OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE" + value = openthread_config_coap_secure_api_enable + }, + { + macro = "OPENTHREAD_CONFIG_COMMISSIONER_ENABLE" + value = openthread_config_commissioner_enable + }, + { + macro = "OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE" + value = openthread_config_dhcp6_client_enable + }, + { + macro = "OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE" + value = openthread_config_dhcp6_server_enable + }, + { + macro = "OPENTHREAD_CONFIG_DIAG_ENABLE" + value = openthread_config_diag_enable + }, + { + macro = "OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE" + value = openthread_config_dnssd_server_enable + }, + { + macro = "OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE" + value = openthread_config_dns_client_enable + }, + { + macro = "OPENTHREAD_CONFIG_DUA_ENABLE" + value = openthread_config_dua_enable + }, + { + macro = "OPENTHREAD_CONFIG_ECDSA_ENABLE" + value = openthread_config_ecdsa_enable + }, + { + macro = "OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE" + value = openthread_config_heap_external_enable + }, + { + macro = "OPENTHREAD_CONFIG_IP6_FRAGMENTATION_ENABLE" + value = openthread_config_ip6_fragmentation_enable + }, + { + macro = "OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE" + value = openthread_config_ip6_slaac_enable + }, + { + macro = "OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE" + value = openthread_config_jam_detection_enable + }, + { + macro = "OPENTHREAD_CONFIG_JOINER_ENABLE" + value = openthread_config_joiner_enable + }, + { + macro = "OPENTHREAD_CONFIG_LINK_RAW_ENABLE" + value = openthread_config_link_raw_enable + }, + { + macro = "OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE" + value = openthread_config_log_level_dynamic_enable + }, + { + macro = "OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE" + value = openthread_config_mac_csl_receiver_enable + }, + { + macro = "OPENTHREAD_CONFIG_MAC_FILTER_ENABLE" + value = openthread_config_mac_filter_enable + }, + { + macro = "OPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE" + value = openthread_config_message_use_heap + }, + { + macro = "OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE" + value = openthread_config_link_metrics_initiator_enable + }, + { + macro = "OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE" + value = openthread_config_link_metrics_subject_enable + }, + { + macro = "OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE" + value = openthread_config_mle_long_routes_enable + }, + { + macro = "OPENTHREAD_CONFIG_MLR_ENABLE" + value = openthread_config_mlr_enable + }, + { + macro = "OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE" + value = openthread_config_multiple_instance_enable + }, + { + macro = "OPENTHREAD_CONFIG_OTNS_ENABLE" + value = openthread_config_otns_enable + }, + { + macro = "OPENTHREAD_CONFIG_PING_SENDER_ENABLE" + value = openthread_config_ping_sender + }, + { + macro = "OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE" + value = openthread_config_platform_netif_enable + }, + { + macro = "OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE" + value = openthread_config_coexistence_enable + }, + { + macro = "OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE" + value = openthread_config_platform_udp_enable + }, + { + macro = "OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE" + value = openthread_config_reference_device_enable + }, + { + macro = "OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE" + value = openthread_config_sntp_client_enable + }, + { + macro = "OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE" + value = openthread_config_srp_client_enable + }, + { + macro = "OPENTHREAD_CONFIG_SRP_SERVER_ENABLE" + value = openthread_config_srp_server_enable + }, + { + macro = "OPENTHREAD_CONFIG_TCP_ENABLE" + value = openthread_config_tcp_enable + }, + { + macro = "OPENTHREAD_CONFIG_TIME_SYNC_ENABLE" + value = openthread_config_time_sync_enable + }, + { + macro = "OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE" + value = openthread_config_tmf_netdata_service_enable + }, + { + macro = "OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE" + value = openthread_config_tmf_netdiag_client_enable + }, + { + macro = "OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE" + value = openthread_config_udp_forward_enable + }, + { + macro = "OPENTHREAD_SETTINGS_RAM" + value = openthread_settings_ram + }, + { + macro = "OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS" + value = openthread_external_mbedtls == "" + }, + { + macro = "OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS_MANAGEMENT" + value = openthread_external_mbedtls == "" && openthread_config_enable_builtin_mbedtls_management + }, + ] + config("core_config_args") { defines = [] @@ -69,64 +280,13 @@ if (openthread_enable_core_config_args) { defines += [ "OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL=1" ] } - if (openthread_external_mbedtls != "") { - defines += [ "OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS=0" ] - } else { - defines += [ "OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS_MANAGEMENT=$openthread_config_enable_builtin_mbedtls_management" ] + foreach(flag, ot_bool_flags) { + if (flag.value) { + defines += [ "${flag.macro}=1" ] + } else { + defines += [ "${flag.macro}=0" ] + } } - - defines += [ - "OPENTHREAD_CONFIG_ANYCAST_LOCATOR_ENABLE=$openthread_config_anycast_locator_enable", - "OPENTHREAD_CONFIG_ASSERT_ENABLE=$openthread_config_assert_enable", - "OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE=$openthread_config_backbone_router_enable", - "OPENTHREAD_CONFIG_BLE_TCAT_ENABLE=$openthread_config_ble_tcat_enable", - "OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE=$openthread_config_border_agent_enable", - "OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE=$openthread_config_border_router_enable", - "OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE=$openthread_config_border_routing_enable", - "OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE=$openthread_config_channel_manager_enable", - "OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE=$openthread_config_channel_monitor_enable", - "OPENTHREAD_CONFIG_COAP_API_ENABLE=$openthread_config_coap_api_enable", - "OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE=$openthread_config_coap_observe_api_enable", - "OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE=$openthread_config_coap_secure_api_enable", - "OPENTHREAD_CONFIG_COMMISSIONER_ENABLE=$openthread_config_commissioner_enable", - "OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE=$openthread_config_dhcp6_client_enable", - "OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE=$openthread_config_dhcp6_server_enable", - "OPENTHREAD_CONFIG_DIAG_ENABLE=$openthread_config_diag_enable", - "OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE=$openthread_config_dnssd_server_enable", - "OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE=$openthread_config_dns_client_enable", - "OPENTHREAD_CONFIG_DUA_ENABLE=$openthread_config_dua_enable", - "OPENTHREAD_CONFIG_ECDSA_ENABLE=$openthread_config_ecdsa_enable", - "OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE=$openthread_config_heap_external_enable", - "OPENTHREAD_CONFIG_IP6_FRAGMENTATION_ENABLE=$openthread_config_ip6_fragmentation_enable", - "OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE=$openthread_config_ip6_slaac_enable", - "OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE=$openthread_config_jam_detection_enable", - "OPENTHREAD_CONFIG_JOINER_ENABLE=$openthread_config_joiner_enable", - "OPENTHREAD_CONFIG_LINK_RAW_ENABLE=$openthread_config_link_raw_enable", - "OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=$openthread_config_log_level_dynamic_enable", - "OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE=$openthread_config_mac_csl_receiver_enable", - "OPENTHREAD_CONFIG_MAC_FILTER_ENABLE=$openthread_config_mac_filter_enable", - "OPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE=$openthread_config_message_use_heap", - "OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE=$openthread_config_link_metrics_initiator_enable", - "OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE=$openthread_config_link_metrics_subject_enable", - "OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE=$openthread_config_mle_long_routes_enable", - "OPENTHREAD_CONFIG_MLR_ENABLE=$openthread_config_mlr_enable", - "OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE=$openthread_config_multiple_instance_enable", - "OPENTHREAD_CONFIG_OTNS_ENABLE=$openthread_config_otns_enable", - "OPENTHREAD_CONFIG_PING_SENDER_ENABLE=$openthread_config_ping_sender", - "OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE=$openthread_config_platform_netif_enable", - "OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE=$openthread_config_coexistence_enable", - "OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE=$openthread_config_platform_udp_enable", - "OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE=$openthread_config_reference_device_enable", - "OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE=$openthread_config_sntp_client_enable", - "OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE=$openthread_config_srp_client_enable", - "OPENTHREAD_CONFIG_SRP_SERVER_ENABLE=$openthread_config_srp_server_enable", - "OPENTHREAD_CONFIG_TCP_ENABLE=${openthread_config_tcp_enable}", - "OPENTHREAD_CONFIG_TIME_SYNC_ENABLE=$openthread_config_time_sync_enable", - "OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE=$openthread_config_tmf_netdata_service_enable", - "OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE=$openthread_config_tmf_netdiag_client_enable", - "OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE=$openthread_config_udp_forward_enable", - "OPENTHREAD_SETTINGS_RAM=$openthread_settings_ram", - ] } }