enable parallel builds (#303)

* add automate test-driver for openthread

*  enable parallel builds and tests

* enable adding flags to compiler

* Fix typo
This commit is contained in:
Marcin K Szczodrak
2016-08-01 08:48:23 -07:00
committed by Jonathan Hui
parent 5f9f9e2ce2
commit 309685f9f0
12 changed files with 611 additions and 43 deletions
+15 -8
View File
@@ -39,13 +39,15 @@ NM = arm-none-eabi-nm
RANLIB = arm-none-eabi-ranlib
OBJCOPY = arm-none-eabi-objcopy
BuildJobs ?= 99
configure_OPTIONS = \
--enable-cli \
--enable-ncp \
--with-examples=cc2538 \
$(NULL)
COMMONCFLAGS = \
COMMONCFLAGS := \
-fdata-sections \
-ffunction-sections \
-Os \
@@ -55,24 +57,24 @@ COMMONCFLAGS = \
-Werror \
$(NULL)
CPPFLAGS = \
CPPFLAGS += \
$(COMMONCFLAGS) \
$(target_CPPFLAGS) \
$(NULL)
CFLAGS = \
CFLAGS += \
$(COMMONCFLAGS) \
$(target_CFLAGS) \
$(NULL)
CXXFLAGS = \
CXXFLAGS += \
$(COMMONCFLAGS) \
$(target_CXXFLAGS) \
-fno-exceptions \
-fno-rtti \
$(NULL)
LDFLAGS = \
LDFLAGS += \
$(COMMONCFLAGS) \
$(target_LDFLAGS) \
-nostartfiles \
@@ -108,6 +110,11 @@ ARCHS = cortex-m3
TopTargetLibDir = $(TopResultDir)/$(if $(1),$(1)-,)$(TargetTuple)/lib
ifndef BuildJobs
BuildJobs := $(shell getconf _NPROCESSORS_ONLN)
endif
JOBSFLAG := -j$(BuildJobs)
#
# configure-arch <arch>
#
@@ -136,7 +143,7 @@ endef # configure-arch
#
define build-arch
$(ECHO) " BUILD $(1)-$(TargetTuple)"
$(MAKE) -C $(BuildPath)/$(1)-$(TargetTuple) --no-print-directory \
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(1)-$(TargetTuple) --no-print-directory \
all
endef # build-arch
@@ -150,7 +157,7 @@ endef # build-arch
#
define stage-arch
$(ECHO) " STAGE $(1)-$(TargetTuple)"
$(MAKE) -C $(BuildPath)/$(1)-$(TargetTuple) --no-print-directory \
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(1)-$(TargetTuple) --no-print-directory \
DESTDIR=$(AbsTopResultDir) \
install
endef # stage-arch
@@ -183,7 +190,7 @@ $(BuildPath)/$(1)-$(TargetTuple)/config.status: | $(BuildPath)/$(1)-$(TargetTupl
do-build-$(1): configure-$(1)
do-build-$(1):
$$(call build-arch,$(1))
+$$(call build-arch,$(1))
stage-$(1): do-build-$(1)
+27 -20
View File
@@ -30,14 +30,16 @@
.NOTPARALLEL:
COVERAGE ?= 0
DEBUG ?= 0
COVERAGE ?= 0
DEBUG ?= 0
ECHO := @echo
MAKE := make
MKDIR_P := mkdir -p
LN_S := ln -s
RM_F := rm -f
ECHO := @echo
MAKE := make
MKDIR_P := mkdir -p
LN_S := ln -s
RM_F := rm -f
BuildJobs ?= 99
COMMONCFLAGS := \
-O1 \
@@ -47,21 +49,21 @@ COMMONCFLAGS := \
-Werror \
$(NULL)
CPPFLAGS = \
CPPFLAGS += \
$(COMMONCFLAGS) \
$(NULL)
CFLAGS = \
CFLAGS += \
$(COMMONCFLAGS) \
$(NULL)
CXXFLAGS = \
CXXFLAGS += \
$(COMMONCFLAGS) \
-fno-exceptions \
-fno-rtti \
$(NULL)
LDFLAGS = \
LDFLAGS += \
$(COMMONCFLAGS) \
$(NULL)
@@ -101,6 +103,11 @@ else
configure_OPTIONS +=
endif
ifndef BuildJobs
BuildJobs := $(shell getconf _NPROCESSORS_ONLN)
endif
JOBSFLAG := -j$(BuildJobs)
#
# configure-arch <target>
#
@@ -128,7 +135,7 @@ endef # configure-target
#
define build-target
$(ECHO) " BUILD $(1)"
$(MAKE) -C $(BuildPath)/$(1) --no-print-directory \
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(1) --no-print-directory \
all
endef # build-target
@@ -141,7 +148,7 @@ endef # build-target
#
define check-target
$(ECHO) " CHECK $(1)"
$(MAKE) -C $(BuildPath)/$(1) --no-print-directory \
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(1) --no-print-directory \
check
endef # check-target
@@ -154,7 +161,7 @@ endef # check-target
#
define distcheck-target
$(ECHO) " DISTCHECK $(1)"
$(MAKE) -C $(BuildPath)/$(1) --no-print-directory \
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(1) --no-print-directory \
distcheck
endef # distcheck-target
@@ -168,7 +175,7 @@ endef # distcheck-target
#
define coverage-target
$(ECHO) " COVERAGE $(1)"
$(MAKE) -C $(BuildPath)/$(1) --no-print-directory \
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(1) --no-print-directory \
coverage
endef # coverage-target
@@ -182,7 +189,7 @@ endef # coverage-target
#
define stage-target
$(ECHO) " STAGE $(1)"
$(MAKE) -C $(BuildPath)/$(1) --no-print-directory \
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(1) --no-print-directory \
DESTDIR=$(AbsTopResultDir) \
install
endef # stage-target
@@ -213,22 +220,22 @@ $(BuildPath)/$(1)/config.status: | $(BuildPath)/$(1)
do-build-$(1): configure-$(1)
do-build-$(1):
$$(call build-target,$(1))
+$$(call build-target,$(1))
check-$(1): do-build-$(1)
check-$(1):
$$(call check-target,$(1))
+$$(call check-target,$(1))
distcheck-$(1): do-build-$(1)
distcheck-$(1):
$$(call distcheck-target,$(1))
+$$(call distcheck-target,$(1))
coverage-$(1): do-build-$(1)
coverage-$(1):
$$(call coverage-target,$(1))
+$$(call coverage-target,$(1))
stage-$(1): do-build-$(1)
+10 -1
View File
@@ -36,6 +36,7 @@
#include <errno.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
@@ -49,12 +50,20 @@ uint32_t WELLKNOWN_NODE_ID = 34;
void PlatformInit(int argc, char *argv[])
{
char *endptr;
if (argc != 2)
{
exit(1);
}
NODE_ID = atoi(argv[1]);
NODE_ID = strtol(argv[1], &endptr, 0);
if (*endptr != '\0')
{
fprintf(stderr, "Invalid NODE_ID: %s\n", argv[1]);
exit(1);
}
posixAlarmInit();
posixRadioInit();
+22 -3
View File
@@ -111,6 +111,7 @@ static uint16_t sPanid;
static int sSockFd;
static bool sPromiscuous = false;
static bool sAckWait = false;
static uint16_t sPortOffset = 0;
static inline bool isFrameTypeAck(const uint8_t *frame)
{
@@ -308,16 +309,34 @@ void otPlatRadioSetPromiscuous(bool aEnable)
void posixRadioInit(void)
{
struct sockaddr_in sockaddr;
char *offset;
memset(&sockaddr, 0, sizeof(sockaddr));
sockaddr.sin_family = AF_INET;
offset = getenv("PORT_OFFSET");
if (offset)
{
char *endptr;
sPortOffset = strtol(offset, &endptr, 0);
if (*endptr != '\0')
{
fprintf(stderr, "Invalid PORT_OFFSET: %s\n", offset);
exit(1);
}
sPortOffset *= WELLKNOWN_NODE_ID;
}
if (sPromiscuous)
{
sockaddr.sin_port = htons(9000 + WELLKNOWN_NODE_ID);
sockaddr.sin_port = htons(9000 + sPortOffset + WELLKNOWN_NODE_ID);
}
else
{
sockaddr.sin_port = htons(9000 + NODE_ID);
sockaddr.sin_port = htons(9000 + sPortOffset + NODE_ID);
}
sockaddr.sin_addr.s_addr = INADDR_ANY;
@@ -520,7 +539,7 @@ void radioTransmit(const struct RadioMessage *msg, const struct RadioPacket *pkt
continue;
}
sockaddr.sin_port = htons(9000 + i);
sockaddr.sin_port = htons(9000 + sPortOffset + i);
rval = sendto(sSockFd, msg, 1 + pkt->mLength,
0, (struct sockaddr *)&sockaddr, sizeof(sockaddr));
assert(rval >= 0);