diff --git a/Makefile b/Makefile index bfd072f..f09a581 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,13 @@ TOPDIR := $(PWD) PLATFORMS := $(foreach platform,$(wildcard platforms/*),$(platform)/gpt) -BINS := gen_partition.py msp.py ptool.py +PARTITIONS_XML := $(foreach platform,$(wildcard platforms/*),$(platform)/partitions.xml) +CONTENTS_XML := $(patsubst %.xml.in,%.xml,$(wildcard platforms/*/contents.xml.in)) +BINS := gen_contents.py gen_partition.py msp.py ptool.py PREFIX ?= /usr/local -.PHONY: all check lint integration +.PHONY: all check clean lint integration -all: $(PLATFORMS) +all: $(PLATFORMS) $(PARTITIONS_XML) $(CONTENTS_XML) %/gpt: %/partitions.xml cd $(shell dirname $^) && $(TOPDIR)/ptool.py -x partitions.xml @@ -13,10 +15,17 @@ all: $(PLATFORMS) %/partitions.xml: %/partitions.conf $(TOPDIR)/gen_partition.py -i $^ -o $@ +%/contents.xml: %/partitions.xml %/contents.xml.in + $(TOPDIR)/gen_contents.py -p $< -t $@.in -o $@ + lint: # W605: invalid escape sequence pycodestyle --select=W605 *.py + # gen_contents.py is nearly perfect except E501: line too long. + # Ensure there are no regressions. + pycodestyle --ignore=E501 gen_contents.py + integration: all # make sure generated output has created expected files tests/integration/check-missing-files platforms/*/*.xml @@ -26,3 +35,6 @@ check: lint integration install: $(BINS) install -d $(DESTDIR)$(PREFIX)/bin install -m 755 $^ $(DESTDIR)$(PREFIX)/bin + +clean: + @rm -f platforms/*/*.xml platforms/*/*.bin diff --git a/gen_contents.py b/gen_contents.py new file mode 100755 index 0000000..3fafbfc --- /dev/null +++ b/gen_contents.py @@ -0,0 +1,148 @@ +#!/usr/bin/env python3 +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause + +import getopt +import sys + +from xml.etree import ElementTree as ET + + +def usage(): + print(("\n\tUsage: %s -t