Skip to content

Commit 59b3bda

Browse files
committed
Makefile: unified stamp-based build for all platforms
Replace the separate partitions.xml, gpt, and contents.xml rules with a single stamp-based rule that runs gen_partition.py -d then ptool.py on each generated partitions.xml. This handles both single-disk and future multi-disk partitions.conf files uniformly. Update gitignore for new .built files. Signed-off-by: Loïc Minier <loic.minier@oss.qualcomm.com>
1 parent e50bd1f commit 59b3bda

2 files changed

Lines changed: 33 additions & 12 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
platforms/**/*.xml
21
platforms/**/*.bin
2+
platforms/**/.built
3+
platforms/**/*.xml

Makefile

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
TOPDIR := $(PWD)
22
PARTITIONS := $(wildcard platforms/*/*/partitions.conf)
3-
PARTITIONS_XML := $(patsubst %.conf,%.xml, $(PARTITIONS))
4-
PLATFORMS := $(patsubst %/partitions.conf,%/gpt, $(PARTITIONS))
3+
STAMPS := $(patsubst %/partitions.conf,%/.built, $(PARTITIONS))
54

65
CONTENTS_XML_IN := $(wildcard platforms/*/*/contents.xml.in)
76
CONTENTS_XML := $(patsubst %.xml.in,%.xml, $(CONTENTS_XML_IN))
@@ -13,16 +12,35 @@ BUILD_ID ?=
1312

1413
.PHONY: all check clean lint integration
1514

16-
all: $(PLATFORMS) $(PARTITIONS_XML) $(CONTENTS_XML)
15+
all: $(STAMPS) $(CONTENTS_XML)
1716

18-
%/gpt: %/partitions.xml
19-
cd $(shell dirname $^) && $(TOPDIR)/ptool.py -x partitions.xml
17+
# Generate partitions.xml and GPT binaries from partitions.conf
18+
# - single-disk: writes partitions.xml in the platform dir, runs ptool there
19+
# - multi-disk: writes partitions0.xml, partitions1.xml, ... in the platform dir,
20+
# runs ptool in disk0/, disk1/, ... subdirectories
21+
%/.built: %/partitions.conf
22+
$(TOPDIR)/gen_partition.py -i $< -o $*/partitions.xml
23+
@if [ -f $*/partitions.xml ]; then \
24+
(cd $* && $(TOPDIR)/ptool.py -x partitions.xml); \
25+
else \
26+
i=0; \
27+
while [ -f $*/partitions$${i}.xml ]; do \
28+
mkdir -p $*/disk$${i}; \
29+
(cd $*/disk$${i} && $(TOPDIR)/ptool.py -x ../partitions$${i}.xml); \
30+
i=$$((i+1)); \
31+
done; \
32+
fi
33+
@touch $@
2034

21-
%/partitions.xml: %/partitions.conf
22-
$(TOPDIR)/gen_partition.py -i $^ -o $@
23-
24-
%/contents.xml: %/partitions.xml %/contents.xml.in
25-
$(TOPDIR)/gen_contents.py -p $< -t $@.in -o $@ $${BUILD_ID:+ -b $(BUILD_ID)}
35+
%/contents.xml: %/contents.xml.in %/.built
36+
# default to partitions.xml from same dir; for multi-disk use partitions0.xml
37+
# with an explicit file prefix of disk0 for gen_contents
38+
@partxml="$*/partitions.xml"; prefix=""; \
39+
if [ ! -f "$$partxml" ]; then \
40+
partxml="$*/partitions0.xml"; prefix="disk0"; \
41+
fi; \
42+
$(TOPDIR)/gen_contents.py -p "$$partxml" -t $@.in -o $@ \
43+
$${prefix:+ -f $$prefix} $${BUILD_ID:+ -b $(BUILD_ID)}
2644

2745
lint:
2846
# W605: invalid escape sequence
@@ -45,4 +63,6 @@ install: $(BINS)
4563
install -m 755 $^ $(DESTDIR)$(PREFIX)/bin
4664

4765
clean:
48-
@rm -f platforms/*/*/*.xml platforms/*/*/*.bin
66+
@rm -f platforms/*/*/*.xml platforms/*/*/*.bin platforms/*/*/*/*.xml platforms/*/*/*/*.bin
67+
@rm -f platforms/*/*/.built
68+
@rm -rf platforms/*/*/disk[0-9]*/

0 commit comments

Comments
 (0)