Skip to content

Commit 8084fda

Browse files
authored
Merge pull request #38 from vkraleti/content-xml
Add build_id placeholder to contents.xml
2 parents f410a56 + e59b578 commit 8084fda

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ CONTENTS_XML := $(patsubst %.xml.in,%.xml, $(CONTENTS_XML_IN))
88
BINS := gen_contents.py gen_partition.py msp.py ptool.py
99
PREFIX ?= /usr/local
1010

11+
# optional build_id for Axiom contents.xml files
12+
BUILD_ID ?=
13+
1114
.PHONY: all check clean lint integration
1215

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

2124
%/contents.xml: %/partitions.xml %/contents.xml.in
22-
$(TOPDIR)/gen_contents.py -p $< -t $@.in -o $@
25+
$(TOPDIR)/gen_contents.py -p $< -t $@.in -o $@ $${BUILD_ID:+ -b $(BUILD_ID)}
2326

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

4245
clean:
43-
@rm -f platforms/*/*.xml platforms/*/*.bin
46+
@rm -f platforms/*/*/*.xml platforms/*/*/*.bin

gen_contents.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def ParseXML(XMLFile):
2727
return None
2828

2929

30-
def UpdateMetaData(TemplateRoot, PartitionRoot):
30+
def UpdateMetaData(TemplateRoot, PartitionRoot, BuildId):
3131
ChipIdList = TemplateRoot.findall('product_info/chipid')
3232
DefaultStorageType = None
3333
for ChipId in ChipIdList:
@@ -64,6 +64,8 @@ def _add_file_elements(parent_element, pathname, file_path_flavor=None):
6464
for build in builds:
6565
Name = build.find('name')
6666
print(f"Build Name: {Name.text}")
67+
new_build_id = ET.SubElement(build, "build_id")
68+
new_build_id.text = BuildId
6769
if Name.text != "common":
6870
continue
6971
DownloadFile = build.find('download_file')
@@ -113,14 +115,17 @@ def _add_file_elements(parent_element, pathname, file_path_flavor=None):
113115
if sys.argv[1] == "-h" or sys.argv[1] == "--help":
114116
usage()
115117
try:
116-
opts, rem = getopt.getopt(sys.argv[1:], "t:p:o:")
118+
build_id = ""
119+
opts, rem = getopt.getopt(sys.argv[1:], "t:p:o:b:")
117120
for (opt, arg) in opts:
118121
if opt in ["-t"]:
119122
template = arg
120123
elif opt in ["-p"]:
121124
partition_xml = arg
122125
elif opt in ["-o"]:
123126
output_xml = arg
127+
elif opt in ["-b"]:
128+
build_id = arg
124129
else:
125130
usage()
126131
except Exception as argerr:
@@ -133,11 +138,11 @@ def _add_file_elements(parent_element, pathname, file_path_flavor=None):
133138
print("Selected Partition XML: " + partition_xml)
134139
partition_root = ParseXML(partition_xml)
135140

136-
UpdateMetaData(xml_root, partition_root)
141+
UpdateMetaData(xml_root, partition_root, build_id)
137142

138143
OutputTree = ET.ElementTree(xml_root)
139144
ET.indent(OutputTree, space="\t", level=0)
140-
OutputTree.write(output_xml, encoding="utf-8", xml_declaration=True)
145+
OutputTree.write(output_xml, encoding="utf-8", xml_declaration=True, short_empty_elements=False)
141146
except Exception as e:
142147
print(("Error: ", e))
143148
sys.exit(1)

0 commit comments

Comments
 (0)