Skip to content

Commit

Permalink
Rebuilding targets when configurations change
Browse files Browse the repository at this point in the history
In situations where configuration changes necessitate a rebuild of
dependencies, such as due to feature modifications, these targets must
be dependent on the build system itself. While this approach may not
always be perfect, it ensures that we avoid using outdated artifacts
in our builds.

To enhance this process, we no longer rely on file timestamps but
instead base dependencies on configurations. The relevant file is
generated by a rule that always executes, but the target will only be
updated if there are actual changes to the configuration content.
This approach ensures that only substantial content alterations trigger
an update to the file's timestamp.
  • Loading branch information
jserv committed Oct 9, 2023
1 parent 72c4ca9 commit 14dee35
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
23 changes: 16 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,19 @@ $(BIN): $(OBJS)
$(VECHO) " LD\t$@\n"
$(Q)$(CC) -o $@ $^ $(LDFLAGS)

clean-generated-files = \
$(RM) $(BIN) $(OBJS) $(HIST_BIN) $(HIST_OBJS) $(deps) $(CACHE_OUT)

.PHONY: config
config:
$(Q)echo "$(CFLAGS)" | xargs -n1 | sort | sed -n 's/^RV32_FEATURE/ENABLE/p' > $(CONFIG_FILE)
$(VECHO) "Check the file $(OUT)/.config for configured items.\n"
$(Q)echo "$(CFLAGS)" | xargs -n1 | sort | sed -n 's/^RV32_FEATURE/ENABLE/p' > $(CONFIG_FILE).tmp
$(Q)cmp -s $(CONFIG_FILE) $(CONFIG_FILE).tmp; \
RETVAL=$$?; \
if [ $$RETVAL -ne 0 ]; then \
mv -f $(CONFIG_FILE).tmp $(CONFIG_FILE); \
$(call clean-generated-files); \
$(PRINTF) "Check the file $(OUT)/.config for configured items.\n\n"; \
fi

# Tools
include mk/tools.mk
Expand Down Expand Up @@ -160,10 +169,10 @@ EXPECTED_aes = Dec 15 2022 16:35:12 Test results AES-128 ECB encryption: PASSED!
misalign: $(BIN)
$(Q)$(PRINTF) "Running aes.elf ... ";
$(Q)if [ "$(shell $(BIN) -m $(OUT)/aes.elf | uniq)" = "$(EXPECTED_aes)" ]; then \
$(call notice, [OK]); \
else \
$(PRINTF) "Failed.\n"; \
fi
$(call notice, [OK]); \
else \
$(PRINTF) "Failed.\n"; \
fi

include mk/external.mk

Expand All @@ -178,7 +187,7 @@ endif
endif

clean:
$(RM) $(BIN) $(OBJS) $(HIST_BIN) $(HIST_OBJS) $(deps) $(CACHE_OUT)
$(Q)$(call clean-generated-files)
distclean: clean
-$(RM) $(DOOM_DATA) $(QUAKE_DATA)
$(RM) -r $(OUT)/id1
Expand Down
6 changes: 3 additions & 3 deletions mk/riscv-arch-test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ endif
git submodule update --init $(dir $(ARCH_TEST_DIR))
$(Q)python3 -B $(RISCV_TARGET)/setup.py --riscv_device=$(RISCV_DEVICE)
$(Q)riscof run --work-dir=$(WORK) \
--config=$(RISCV_TARGET)/config.ini \
--suite=$(ARCH_TEST_DIR)/riscv-test-suite \
--env=$(ARCH_TEST_DIR)/riscv-test-suite/env
--config=$(RISCV_TARGET)/config.ini \
--suite=$(ARCH_TEST_DIR)/riscv-test-suite \
--env=$(ARCH_TEST_DIR)/riscv-test-suite/env

0 comments on commit 14dee35

Please sign in to comment.