build system: Run parallel builds without warnings

Ref github #38
This commit is contained in:
Angus Gratton 2016-10-06 18:29:34 +11:00
parent 6a890e6c49
commit 305bc9fd9c
4 changed files with 21 additions and 8 deletions

View file

@ -16,8 +16,8 @@ BOOTLOADER_BIN=$(BOOTLOADER_BUILD_DIR)/bootloader.bin
BOOTLOADER_SDKCONFIG=$(BOOTLOADER_BUILD_DIR)/sdkconfig
# Custom recursive make for bootloader sub-project
BOOTLOADER_MAKE=$(MAKE) -C $(BOOTLOADER_COMPONENT_PATH)/src \
MAKEFLAGS= V=$(V) SDKCONFIG=$(BOOTLOADER_SDKCONFIG) \
BOOTLOADER_MAKE=+$(MAKE) -C $(BOOTLOADER_COMPONENT_PATH)/src \
V=$(V) SDKCONFIG=$(BOOTLOADER_SDKCONFIG) \
BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) \
.PHONY: bootloader-clean bootloader-flash bootloader $(BOOTLOADER_BIN)

View file

@ -37,6 +37,7 @@ help:
@echo "'make partition_table', etc, etc."
# disable built-in make rules, makes debugging saner
MAKEFLAGS_OLD := $(MAKEFLAGS)
MAKEFLAGS +=-rR
# Figure out PROJECT_PATH if not set
@ -231,7 +232,7 @@ define GenerateComponentPhonyTarget
# $(2) - target to generate (build, clean)
.PHONY: $(notdir $(1))-$(2)
$(notdir $(1))-$(2): | $(BUILD_DIR_BASE)/$(notdir $(1))
@+$(MAKE) -C $(BUILD_DIR_BASE)/$(notdir $(1)) -f $(1)/component.mk COMPONENT_BUILD_DIR=$(BUILD_DIR_BASE)/$(notdir $(1)) $(2)
$(Q) +$(MAKE) -C $(BUILD_DIR_BASE)/$(notdir $(1)) -f $(1)/component.mk COMPONENT_BUILD_DIR=$(BUILD_DIR_BASE)/$(notdir $(1)) $(2)
endef
define GenerateComponentTargets

View file

@ -11,10 +11,9 @@ KCONFIG_TOOL_DIR=$(IDF_PATH)/tools/kconfig
# unless it's overriden (happens for bootloader)
SDKCONFIG ?= $(PROJECT_PATH)/sdkconfig
# clear MAKEFLAGS as the menuconfig makefile uses implicit compile rules
# reset MAKEFLAGS as the menuconfig makefile uses implicit compile rules
$(KCONFIG_TOOL_DIR)/mconf $(KCONFIG_TOOL_DIR)/conf:
MAKEFLAGS="" \
CC=$(HOSTCC) LD=$(HOSTLD) \
MAKEFLAGS=$(ORIGINAL_MAKEFLAGS) CC=$(HOSTCC) LD=$(HOSTLD) \
$(MAKE) -C $(KCONFIG_TOOL_DIR)
# use a wrapper environment for where we run Kconfig tools

View file

@ -92,7 +92,7 @@ function run_tests()
fi
print_status "Moving BUILD_DIR_BASE out of tree"
rm -rf --preserve-root ${BUILD}/*
clean_build_dir
OUTOFTREE_BUILD=${TESTDIR}/alt_build
make BUILD_DIR_BASE=${OUTOFTREE_BUILD} || failure "Failed to build with BUILD_DIR_BASE overriden"
NEW_BUILD_FILES=$(find ${OUTOFREE_BUILD} -type f)
@ -105,13 +105,20 @@ function run_tests()
fi
print_status "BUILD_DIR_BASE inside default build directory"
rm -rf --preserve-root ${BUILD}/*
clean_build_dir
make BUILD_DIR_BASE=build/subdirectory || failure "Failed to build with BUILD_DIR_BASE as subdir"
NEW_BUILD_FILES=$(find ${BUILD}/subdirectory -type f)
if [ -z "${NEW_BUILD_FILES}" ]; then
failure "No files found in new build directory!"
fi
print_status "Parallel builds should work OK"
clean_build_dir
(make -j5 2>&1 | tee ${TESTDIR}/parallel_build.log) || failure "Failed to build in parallel"
if grep -q "warning: jobserver unavailable" ${TESTDIR}/parallel_build.log; then
failure "Parallel build prints 'warning: jobserver unavailable' errors"
fi
print_status "Can still clean build if all text files are CRLFs"
make clean || failure "Unexpected failure to make clean"
find . -exec unix2dos {} \; # CRLFify template dir
@ -222,5 +229,11 @@ function assert_not_rebuilt()
done
}
# do a "clean" that doesn't depend on 'make clean'
function clean_build_dir()
{
rm -rf --preserve-root ${BUILD}/*
}
cd ${TESTDIR}
run_tests