Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ CONTENTS_XML := $(patsubst %.xml.in,%.xml, $(CONTENTS_XML_IN))
BINS := gen_contents.py gen_partition.py msp.py ptool.py
PREFIX ?= /usr/local

# optional build_id for Axiom contents.xml files
BUILD_ID ?=

.PHONY: all check clean lint integration

all: $(PLATFORMS) $(PARTITIONS_XML) $(CONTENTS_XML)
Expand All @@ -19,7 +22,7 @@ all: $(PLATFORMS) $(PARTITIONS_XML) $(CONTENTS_XML)
$(TOPDIR)/gen_partition.py -i $^ -o $@

%/contents.xml: %/partitions.xml %/contents.xml.in
$(TOPDIR)/gen_contents.py -p $< -t [email protected] -o $@
$(TOPDIR)/gen_contents.py -p $< -t [email protected] -o $@ $${BUILD_ID:+ -b $(BUILD_ID)}

lint:
# W605: invalid escape sequence
Expand All @@ -40,4 +43,4 @@ install: $(BINS)
install -m 755 $^ $(DESTDIR)$(PREFIX)/bin

clean:
@rm -f platforms/*/*.xml platforms/*/*.bin
@rm -f platforms/*/*/*.xml platforms/*/*/*.bin
13 changes: 9 additions & 4 deletions gen_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def ParseXML(XMLFile):
return None


def UpdateMetaData(TemplateRoot, PartitionRoot):
def UpdateMetaData(TemplateRoot, PartitionRoot, BuildId):
ChipIdList = TemplateRoot.findall('product_info/chipid')
DefaultStorageType = None
for ChipId in ChipIdList:
Expand Down Expand Up @@ -64,6 +64,8 @@ def _add_file_elements(parent_element, pathname, file_path_flavor=None):
for build in builds:
Name = build.find('name')
print(f"Build Name: {Name.text}")
new_build_id = ET.SubElement(build, "build_id")
new_build_id.text = BuildId
if Name.text != "common":
continue
DownloadFile = build.find('download_file')
Expand Down Expand Up @@ -113,14 +115,17 @@ def _add_file_elements(parent_element, pathname, file_path_flavor=None):
if sys.argv[1] == "-h" or sys.argv[1] == "--help":
usage()
try:
opts, rem = getopt.getopt(sys.argv[1:], "t:p:o:")
build_id = ""
opts, rem = getopt.getopt(sys.argv[1:], "t:p:o:b:")
for (opt, arg) in opts:
if opt in ["-t"]:
template = arg
elif opt in ["-p"]:
partition_xml = arg
elif opt in ["-o"]:
output_xml = arg
elif opt in ["-b"]:
build_id = arg
else:
usage()
except Exception as argerr:
Expand All @@ -133,11 +138,11 @@ def _add_file_elements(parent_element, pathname, file_path_flavor=None):
print("Selected Partition XML: " + partition_xml)
partition_root = ParseXML(partition_xml)

UpdateMetaData(xml_root, partition_root)
UpdateMetaData(xml_root, partition_root, build_id)

OutputTree = ET.ElementTree(xml_root)
ET.indent(OutputTree, space="\t", level=0)
OutputTree.write(output_xml, encoding="utf-8", xml_declaration=True)
OutputTree.write(output_xml, encoding="utf-8", xml_declaration=True, short_empty_elements=False)
except Exception as e:
print(("Error: ", e))
sys.exit(1)
Expand Down
Loading