Skip to content

Commit

Permalink
ubuntu: Support CPU profiling (--build-var PROF=1)
Browse files Browse the repository at this point in the history
  • Loading branch information
rojer committed Jan 22, 2020
1 parent a060c3c commit 7a68d14
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 8 additions & 1 deletion platforms/ubuntu/Makefile.build
Expand Up @@ -22,6 +22,7 @@ FW_DIR ?= $(CURDIR)/fw
APP_EXTRA_FW_PARTS ?=

ASAN ?= 0
PROF ?= 0

# Explicitly disable updater, it's not supported on POSIX build yet.
MGOS_ENABLE_DEBUG_UDP = 0
Expand All @@ -45,7 +46,7 @@ APP_SOURCE_DIRS = $(sort $(dir $(APP_SOURCES)))
INCLUDES = $(MGOS_IPATH) $(SRC_PATH) $(BUILD_DIR) $(sort $(APP_SOURCE_DIRS) $(APP_INCLUDES)) $(GEN_INCLUDES) $(PLATFORM_VPATH)
MGOS_SRCS = $(notdir $(wildcard *.c)) mgos_init.c \
frozen.c mgos_event.c \
mgos_system.c mgos_time.c mgos_timers.c \
mgos_core_dump.c mgos_system.c mgos_time.c mgos_timers.c \
mgos_config_util.c mgos_sys_config.c \
json_utils.c cs_rbuf.c mgos_uart.c \
mgos_utils.c cs_file.c cs_hex.c cs_crc32.c \
Expand All @@ -67,6 +68,12 @@ CXX = clang++
C_CXX_FLAGS += -fsanitize=address -fno-omit-frame-pointer
LDFLAGS += -fsanitize=address
endif
ifeq "$(PROF)" "1"
CC = clang
CXX = clang++
C_CXX_FLAGS += -fprofile-instr-generate -fcoverage-mapping
LDFLAGS += -fprofile-instr-generate
endif

ifdef MGOS_HAVE_DNS_SD
LDFLAGS += -lavahi-client -lavahi-common -lstdc++
Expand Down
6 changes: 6 additions & 0 deletions platforms/ubuntu/src/ubuntu_hal.c
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

#include <stdlib.h>

#include "mgos_hal.h"
#include "mgos_mongoose.h"
#include "mgos_net_hal.h"
Expand Down Expand Up @@ -41,3 +43,7 @@ int mg_ssl_if_mbed_random(void *ctx, unsigned char *buf, size_t len) {
(void) ctx;
return 0;
}

void mgos_cd_putc(int c) {
fputc(c, stderr);
}

0 comments on commit 7a68d14

Please sign in to comment.