Skip to content

Commit 3c0849d

Browse files
authored
Build examples in parallel (#75)
Restructure build-examples to fetch corral dependencies once at the top level, then spawn a parallel sub-make for the actual compilations. Passing GET_DEPENDENCIES_WITH=true to the sub-make overrides the variable in each example's Makefile, skipping redundant corral fetch calls. This turns N+1 sequential fetches into 1 fetch followed by N parallel compilations. Also switch the example sub-make invocation from literal `make` to `$(MAKE)` so command-line variable overrides propagate correctly through recursive make.
1 parent 252e9d5 commit 3c0849d

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,14 @@ $(tests_binary): $(SOURCE_FILES) | $(BUILD_DIR)
5353
$(GET_DEPENDENCIES_WITH)
5454
$(PONYC) -o $(BUILD_DIR) $(SRC_DIR)
5555

56-
build-examples: $(EXAMPLES_BINARIES)
56+
build-examples:
57+
$(GET_DEPENDENCIES_WITH)
58+
@$(MAKE) -j$(shell nproc) _build_examples GET_DEPENDENCIES_WITH=true
59+
60+
_build_examples: $(EXAMPLES_BINARIES)
5761

5862
$(EXAMPLES_BINARIES): $(BUILD_DIR)/%: $(SOURCE_FILES) $(EXAMPLES_SOURCE_FILES) | $(BUILD_DIR)
59-
BUILD_DIR=$(mkfile_path)$(BUILD_DIR) make -C $(EXAMPLES_DIR)/$*
63+
BUILD_DIR=$(mkfile_path)$(BUILD_DIR) $(MAKE) -C $(EXAMPLES_DIR)/$*
6064

6165
clean:
6266
$(CLEAN_DEPENDENCIES_WITH)
@@ -77,4 +81,4 @@ all: test
7781
$(BUILD_DIR):
7882
mkdir -p $(BUILD_DIR)
7983

80-
.PHONY: all build-examples clean TAGS test
84+
.PHONY: all build-examples _build_examples clean TAGS test

0 commit comments

Comments
 (0)