make: Don't immediately expand PROJECT_VERSION

When there is nothing to do we don't need this variable
so we don't want to calculate it unnecessarily.

Because this variable is only used once, when
producing the .app file, we don't have to worry
about the calculation being done multiple times.
If we ever do then it will need to be lazily
evaluated[1] instead.

[1] Managing Projects with GNU Make, 3rd Edition Chapter 10

Execution speed differences:

  make -C deps/rabbit nope  0,02s user 0,03s system 101% cpu 0,051 total
  make -C deps/rabbit nope  0,02s user 0,01s system 97% cpu 0,031 total
This commit is contained in:
Loïc Hoguin 2024-05-28 12:19:39 +02:00
parent 4bfef36251
commit 1535e730de
No known key found for this signature in database
GPG Key ID: C69E26E3A9DF618F
1 changed files with 1 additions and 1 deletions

View File

@ -14,7 +14,7 @@ endif
PROJECT_VERSION := $(RABBITMQ_VERSION) PROJECT_VERSION := $(RABBITMQ_VERSION)
ifeq ($(PROJECT_VERSION),) ifeq ($(PROJECT_VERSION),)
PROJECT_VERSION := $(shell \ PROJECT_VERSION = $(shell \
if test -f git-revisions.txt; then \ if test -f git-revisions.txt; then \
head -n1 git-revisions.txt | \ head -n1 git-revisions.txt | \
awk '{print $$$(words $(PROJECT_DESCRIPTION) version);}'; \ awk '{print $$$(words $(PROJECT_DESCRIPTION) version);}'; \