Skip to content

Commit

Permalink
refactor: don't set the build jobs when nproc is not found (#2034)
Browse files Browse the repository at this point in the history
refactor: don't set the build jobs when nproc not found
  • Loading branch information
zyy17 authored Jul 25, 2023
1 parent 48996b0 commit 662879f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,25 @@ CARGO_REGISTRY_CACHE ?= ${HOME}/.cargo/registry
ETCD_VERSION ?= v3.5.9
ETCD_IMAGE ?= quay.io/coreos/etcd:${ETCD_VERSION}
RETRY_COUNT ?= 3
BUILD_JOBS ?= $(shell expr $$(nproc) / 2)
NEXTEST_OPTS := --retries ${RETRY_COUNT}
BUILD_JOBS ?= $(shell which nproc 1>/dev/null && expr $$(nproc) / 2) # If nproc is not available, we don't set the build jobs.
ifeq ($(BUILD_JOBS), 0) # If the number of cores is less than 2, set the build jobs to 1.
BUILD_JOBS := 1
endif

ifdef CARGO_PROFILE
ifneq ($(strip $(BUILD_JOBS)),)
NEXTEST_OPTS += --build-jobs=${BUILD_JOBS}
endif

ifneq ($(strip $(CARGO_PROFILE)),)
CARGO_BUILD_OPTS += --profile ${CARGO_PROFILE}
endif

ifdef FEATURES
ifneq ($(strip $(FEATURES)),)
CARGO_BUILD_OPTS += --features ${FEATURES}
endif

ifdef TARGET_DIR
ifneq ($(strip $(TARGET_DIR)),)
CARGO_BUILD_OPTS += --target-dir ${TARGET_DIR}
endif

Expand Down Expand Up @@ -111,7 +116,7 @@ multi-platform-buildx: ## Create buildx multi-platform builder.

##@ Test
test: nextest ## Run unit and integration tests.
cargo nextest run --retries ${RETRY_COUNT} --build-jobs=${BUILD_JOBS}
cargo nextest run ${NEXTEST_OPTS}

.PHONY: nextest ## Install nextest tools.
nextest:
Expand Down

0 comments on commit 662879f

Please sign in to comment.