Skip to content

Commit 40ba6a0

Browse files
committed
Update ab.
1 parent a6593af commit 40ba6a0

File tree

3 files changed

+33
-27
lines changed

3 files changed

+33
-27
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,5 @@ all: +all
5656
PLATIND = $(INSDIR)/share/ack
5757
PLATDEP = $(INSDIR)/lib/ack
5858

59+
AB_ENABLE_PROGRESS_INFO = false
5960
include build/ab.mk

build/ab.mk

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ else
3838
endif
3939
endif
4040

41+
# If enabled, shows a nice display of how far through the build you are. This
42+
# doubles Make startup time. Also, on Make 4.3 and above, rebuilds don't show
43+
# correct progress information.
44+
AB_ENABLE_PROGRESS_INFO ?= true
45+
4146
WINDOWS := no
4247
OSX := no
4348
LINUX := no
@@ -60,13 +65,17 @@ EXT ?=
6065

6166
CWD=$(shell pwd)
6267

63-
ifeq ($(PROGRESSINFO),)
64-
# The first make invocation here has to have its output discarded or else it
65-
# produces spurious 'Leaving directory' messages... don't know why.
66-
rulecount := $(strip $(shell $(MAKE) --no-print-directory -q $(OBJ)/build.mk PROGRESSINFO=1 > /dev/null \
67-
&& $(MAKE) --no-print-directory -n $(MAKECMDGOALS) PROGRESSINFO=XXXPROGRESSINFOXXX | grep XXXPROGRESSINFOXXX | wc -l))
68-
ruleindex := 1
69-
PROGRESSINFO = "[$(ruleindex)/$(rulecount)]$(eval ruleindex := $(shell expr $(ruleindex) + 1))"
68+
ifeq ($(AB_ENABLE_PROGRESS_INFO),true)
69+
ifeq ($(PROGRESSINFO),)
70+
# The first make invocation here has to have its output discarded or else it
71+
# produces spurious 'Leaving directory' messages... don't know why.
72+
rulecount := $(strip $(shell $(MAKE) --no-print-directory -q $(OBJ)/build.mk PROGRESSINFO=1 > /dev/null \
73+
&& $(MAKE) --no-print-directory -n $(MAKECMDGOALS) PROGRESSINFO=XXXPROGRESSINFOXXX | grep XXXPROGRESSINFOXXX | wc -l))
74+
ruleindex := 1
75+
PROGRESSINFO = "[$(ruleindex)/$(rulecount)]$(eval ruleindex := $(shell expr $(ruleindex) + 1)) "
76+
endif
77+
else
78+
PROGRESSINFO = ""
7079
endif
7180

7281
PKG_CONFIG_HASHES = $(OBJ)/.pkg-config-hashes/target-$(word 1, $(shell $(PKG_CONFIG) --list-all | md5sum))

build/ab.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,8 @@ def emit(*args, into=None):
470470

471471
def emit_rule(self, ins, outs, cmds=[], label=None):
472472
name = self.name
473-
fins = set(filenamesof(ins))
473+
fins_list = filenamesof(ins)
474+
fins = set(fins_list)
474475
fouts = filenamesof(outs)
475476
nonobjs = [f for f in fouts if not f.startswith("$(OBJ)")]
476477

@@ -481,21 +482,22 @@ def emit_rule(self, ins, outs, cmds=[], label=None):
481482
emit("clean::", into=lines)
482483
emit("\t$(hide) rm -f", *nonobjs, into=lines)
483484

485+
hashable = cmds + fins_list + fouts
486+
hash = hashlib.sha1(bytes("\n".join(hashable), "utf-8")).hexdigest()
487+
hashfile = join(self.dir, f"hash_{hash}")
488+
484489
emit(".PHONY:", name, into=lines)
485490
if outs:
486-
emit(name, ":", *fouts, into=lines)
487-
if len(fouts) == 1:
488-
emit(*fouts, ":", *fins, "\x01", into=lines)
489-
else:
490-
emit("ifeq ($(MAKE4.3),yes)", into=lines)
491-
emit(*fouts, "&:", *fins, "\x01", into=lines)
492-
emit("else", into=lines)
493-
emit(*(fouts[1:]), ":", fouts[0], into=lines)
494-
emit(fouts[0], ":", *fins, "\x01", into=lines)
495-
emit("endif", into=lines)
491+
emit(name, ":", hashfile, *fouts, into=lines)
492+
emit("ifeq ($(MAKE4.3),yes)", into=lines)
493+
emit(hashfile, *fouts, "&:", *fins, into=lines)
494+
emit("else", into=lines)
495+
emit(*fouts, ":", hashfile, into=lines)
496+
emit(hashfile, ":", *fins, into=lines)
497+
emit("endif", into=lines)
496498

497499
if label:
498-
emit("\t$(hide)", "$(ECHO) $(PROGRESSINFO)", label, into=lines)
500+
emit("\t$(hide)", "$(ECHO) $(PROGRESSINFO)" + label, into=lines)
499501

500502
sandbox = join(self.dir, "sandbox")
501503
emit("\t$(hide)", f"rm -rf {sandbox}", into=lines)
@@ -517,16 +519,10 @@ def emit_rule(self, ins, outs, cmds=[], label=None):
517519
assert len(cmds) == 0, "rules with no outputs cannot have commands"
518520
emit(name, ":", *fins, into=lines)
519521

520-
cmd = "".join(lines)
521-
hash = hashlib.sha1(bytes(cmd, "utf-8")).hexdigest()
522-
523-
outputFp.write(cmd.replace("\x01", f"$(OBJ)/.hashes/{hash}"))
522+
outputFp.write("".join(lines))
524523

525524
if outs:
526-
emit(f"$(OBJ)/.hashes/{hash}:")
527-
emit(
528-
f"\t$(hide) mkdir -p $(OBJ)/.hashes && touch $(OBJ)/.hashes/{hash}"
529-
)
525+
emit(f"\t$(hide) touch {hashfile}")
530526
emit("")
531527

532528

0 commit comments

Comments
 (0)