Skip to content

Commit

Permalink
Makefile - remove -j0 (betaflight#13838)
Browse files Browse the repository at this point in the history
Makefile - don't override user-supplied --jobs argument

Some targets will default to parallel build, but only when no
-j / --jobs argument is specified on make command line
  • Loading branch information
ledvinap authored Aug 30, 2024
1 parent dc741d4 commit 3e130de
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ ifneq ($(wildcard $(MAKE_SCRIPT_DIR)/local.mk),)
include $(MAKE_SCRIPT_DIR)/local.mk
endif

# some targets use parallel build by default
# MAKEFLAGS is valid only inside target, do not use this at parse phase
DEFAULT_PARALLEL_JOBS := # all jobs in parallel (for backward compatibility)
MAKE_PARALLEL = $(if $(filter -j%, $(MAKEFLAGS)),$(EMPTY),-j$(DEFAULT_PARALLEL_JOBS))

# pre-build sanity checks
include $(MAKE_SCRIPT_DIR)/checks.mk

Expand Down Expand Up @@ -507,11 +512,11 @@ test_clean:

## <TARGET>_clean : clean up one specific target (alias for above)
$(TARGETS_CLEAN):
$(V0) $(MAKE) -j TARGET=$(subst _clean,,$@) clean
$(V0) $(MAKE) $(MAKE_PARALLEL) TARGET=$(subst _clean,,$@) clean

## <CONFIG>_clean : clean up one specific target (alias for above)
$(CONFIGS_CLEAN):
$(V0) $(MAKE) -j CONFIG=$(subst _clean,,$@) clean
$(V0) $(MAKE) $(MAKE_PARALLEL) CONFIG=$(subst _clean,,$@) clean

## clean_all : clean all targets
clean_all: $(TARGETS_CLEAN) test_clean
Expand Down Expand Up @@ -568,10 +573,10 @@ zip:
$(V0) zip $(TARGET_ZIP) $(TARGET_HEX)

binary:
$(V0) $(MAKE) -j $(TARGET_BIN)
$(V0) $(MAKE) $(MAKE_PARALLEL) $(TARGET_BIN)

hex:
$(V0) $(MAKE) -j $(TARGET_HEX)
$(V0) $(MAKE) $(MAKE_PARALLEL) $(TARGET_HEX)

TARGETS_REVISION = $(addsuffix _rev,$(BASE_TARGETS))
## <TARGET>_rev : build target and add revision to filename
Expand Down
4 changes: 2 additions & 2 deletions mk/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ endif

$(BASE_CONFIGS):
@echo "Building target config $@"
$(V0) $(MAKE) -j hex CONFIG=$@
$(V0) $(MAKE) $(MAKE_PARALLEL) hex CONFIG=$@
@echo "Building target config $@ succeeded."

## <CONFIG>_rev : build configured target and add revision to filename
$(addsuffix _rev,$(BASE_CONFIGS)):
$(V0) $(MAKE) -j hex CONFIG=$(subst _rev,,$@) REV=yes
$(V0) $(MAKE) $(MAKE_PARALLEL) hex CONFIG=$(subst _rev,,$@) REV=yes

0 comments on commit 3e130de

Please sign in to comment.