From 7846277fa54fd21da9eb70e4d68bc13c0c7bf2e2 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 29 Aug 2019 21:07:09 +0200 Subject: [PATCH] tool/metric: Makefile to run ccsm and process it, minimal inttypes.h for ccsm --- tool/metrics/.gitignore | 3 ++ tool/metrics/Makefile | 30 ++++++++++++++++++++ tool/metrics/btstack_config.h | 53 +++++++++++++++++++++++++++++++++++ tool/metrics/inttypes.h | 39 ++++++++++++++++++++++++++ 4 files changed, 125 insertions(+) create mode 100644 tool/metrics/.gitignore create mode 100644 tool/metrics/Makefile create mode 100644 tool/metrics/btstack_config.h create mode 100644 tool/metrics/inttypes.h diff --git a/tool/metrics/.gitignore b/tool/metrics/.gitignore new file mode 100644 index 000000000..0339e708b --- /dev/null +++ b/tool/metrics/.gitignore @@ -0,0 +1,3 @@ +__pycache__ +metrics.tsv +metrics.txt diff --git a/tool/metrics/Makefile b/tool/metrics/Makefile new file mode 100644 index 000000000..285e0e173 --- /dev/null +++ b/tool/metrics/Makefile @@ -0,0 +1,30 @@ +C_HEADERS=/Projects/c_headers/include/ +BTSTACK_ROOT=../.. +VPATH=${BTSTACK_ROOT}/src + +INCLUDES= \ + -I ${BTSTACK_ROOT}/src \ + -I ${BTSTACK_ROOT}/3rd-party/micro-ecc/ \ + -I ${BTSTACK_ROOT}/3rd-party/md5 \ + -I ${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/include/ \ + -I ${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/include/ \ + -I ${BTSTACK_ROOT}/3rd-party/yxml \ + -I . + +SRC_FILES=$(wildcard ${BTSTACK_ROOT}/src/*.c) +SRC_BLE_FILES=$(wildcard ${BTSTACK_ROOT}/src/ble/*.c) +SRC_BLE_GATT_FILES_FILES=$(wildcard ${BTSTACK_ROOT}/src/ble/gatt-service/*.c) +SRC_CLASSIC_FILES=$(wildcard ${BTSTACK_ROOT}/src/classic/*.c) + +SRCS = ${SRC_FILES} ${SRC_BLE_FILES} ${SRC_BLE_GATT_SERVICE_FILES} ${SRC_CLASSIC_FILES} + +all: metrics.txt + +metrics.tsv: ${SRCS} + ccsm --disable-file --disable-global --exclude-std-headers --exclude-file=.h$$ --output-format=tsv --output-metrics=HIS_.* $^ -- -isystem ${C_HEADERS}/c90 -isystem ${C_HEADERS}/c99 ${INCLUDES} > $@ + +metrics.txt: metrics.tsv metrics-ccsm.py + ./metrics-ccsm.py > metrics.txt + +clean: + rm -f metrics.tsv metrics.txt diff --git a/tool/metrics/btstack_config.h b/tool/metrics/btstack_config.h new file mode 100644 index 000000000..77b1e31ed --- /dev/null +++ b/tool/metrics/btstack_config.h @@ -0,0 +1,53 @@ +// +// btstack_config.h for metric calculation +// + +#ifndef __BTSTACK_CONFIG +#define __BTSTACK_CONFIG + +// Port related features +#define HAVE_BTSTACK_STDIN + +// BTstack features that can be enabled +#define ENABLE_BLE +#define ENABLE_CLASSIC +#define ENABLE_HFP_WIDE_BAND_SPEECH +#define ENABLE_LE_CENTRAL +#define ENABLE_LE_PERIPHERAL +#define ENABLE_LE_SECURE_CONNECTIONS +#define ENABLE_LE_DATA_CHANNELS +#define ENABLE_MICRO_ECC_FOR_LE_SECURE_CONNECTIONS +#define ENABLE_LE_DATA_LENGTH_EXTENSION +#define ENABLE_ATT_DELAYED_RESPONSE +#define ENABLE_LOG_ERROR +#define ENABLE_LOG_INFO +#define ENABLE_SCO_OVER_HCI +#define ENABLE_SDP_DES_DUMP +#define ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE + +// BTstack configuration. buffers, sizes, ... +#define HCI_ACL_PAYLOAD_SIZE (1691 + 4) +#define HCI_INCOMING_PRE_BUFFER_SIZE 14 // sizeof BNEP header, avoid memcpy + +#define MAX_NR_LE_DEVICE_DB_ENTRIES 4 + +#define NVM_NUM_DEVICE_DB_ENTRIES 10 + +// Mesh Configuration +#define ENABLE_MESH +#define ENABLE_MESH_ADV_BEARER +#define ENABLE_MESH_GATT_BEARER +#define ENABLE_MESH_PB_ADV +#define ENABLE_MESH_PB_GATT +#define ENABLE_MESH_PROXY_SERVER +#define ENABLE_MESH_PROVISIONER + +#define MAX_NR_MESH_TRANSPORT_KEYS 16 +#define MAX_NR_MESH_VIRTUAL_ADDRESSES 16 +#define MAX_NR_MESH_SUBNETS 2 + +// allow for one NetKey update +#define MAX_NR_MESH_NETWORK_KEYS (MAX_NR_MESH_SUBNETS+1) + +#endif + diff --git a/tool/metrics/inttypes.h b/tool/metrics/inttypes.h new file mode 100644 index 000000000..80191d1b9 --- /dev/null +++ b/tool/metrics/inttypes.h @@ -0,0 +1,39 @@ +/* + +inttypes.h + +IMPORTANT NOTE: This header is not intended to be functional. It is intended +purely to be an ANSI-compliant header which can be used when performing static +analyis of code (i.e. compiler independent) + + +Copyright (c) 2015 John Bailey + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +*/ + +#if !defined __INTTYPES_H +#define __INTTYPES_H + +// assume 32-bit architecture +#define PRIu32 "I32u" +#define PRIx32 "I32x" + +#endif