BugID:17865306: Update scripts/aos_parse_components.py
@@ -33,23 +33,46 @@ def get_comp_name(mkfile):
return name
def write_config_file(source_root, config_file, mklist):
- config_contents = []
+ config_contents = {}
+ config_keys = []
aliasname = ""
patten = re.compile(source_root + "(/*|\\\\*)(.*)(/|\\\\.*mk)")
for mkfile in mklist:
name = get_comp_name(mkfile)
+
+ if not name:
+ continue
+
match = patten.match(mkfile)
if match:
aliasname = match.group(2)
aliasname = aliasname.replace("/", ".").replace("\\", ".")
- config_contents += ["%s_MAKEFILE := %s" % (name, mkfile)]
- config_contents += ["%s_MAKEFILE := %s" % (aliasname, mkfile)]
+ if not name in config_contents:
+ config_contents[name] = mkfile
+ config_keys += [name]
+ else:
+ print "[ERROR]: Duplicate component found: %s" % name
+ print "- %s: %s" % (name, config_contents[name])
+ print "- %s: %s" % (name, mkfile)
+ return 1
+
+ if name == aliasname:
+ continue
+
+ if not aliasname in config_contents:
+ config_contents[aliasname] = mkfile
+ config_keys += [aliasname]
+ else:
+ print "[ERROR]: Duplicate component found: %s" % aliasname
+ print "- %s: %s" % (aliasname, config_contents[aliasname])
+ print "- %s: %s" % (aliasname, mkfile)
+ return 1
with open (config_file, 'w') as f:
- for line in config_contents:
- f.write("%s\n" % line)
+ for key in config_keys:
+ f.write("%s_MAKEFILE := %s\n" % (key, config_contents[key]))
def main(argv):
if len(argv) < 3:
@@ -61,7 +84,6 @@ def main(argv):
mklist = find_comp_mkfile(source_root)
write_config_file(source_root, config_file, mklist)
-
if __name__ == "__main__":
ret = main(sys.argv)
sys.exit(ret)
