Add alias support for unique board revs

This way we can list different board styles and track their
downloads without a completely new binary.

Fixes #1673
This commit is contained in:
Scott Shawcroft 2019-04-11 11:25:04 -07:00
parent cf3f3e510c
commit 1eb1430d82
No known key found for this signature in database
GPG Key ID: FD0EDC4B6C53CA59
2 changed files with 46 additions and 25 deletions

View File

@ -42,6 +42,12 @@ extension_by_board = {
"pca10059": BIN_UF2
}
aliases_by_board = {
"circuitplayground_express": ["circuitplayground_express_4h", "circuitplayground_express_digikey_pycon2019"],
"gemma_m0": ["gemma_m0_pycon2018"],
"pewpew10": ["pewpew13"]
}
def get_languages():
languages = []
for f in os.scandir("../locale"):
@ -59,7 +65,17 @@ def get_board_mapping():
board_id = board_path.name
extensions = extension_by_port[port]
extensions = extension_by_board.get(board_path.name, extensions)
boards[board_id] = {"port": port, "extensions": extensions, "download_count": 0}
aliases = aliases_by_board.get(board_path.name, [])
boards[board_id] = {"port": port,
"extensions": extensions,
"download_count": 0,
"aliases": aliases}
for alias in aliases:
boards[alias] = {"port": port,
"extensions": extensions,
"download_count": 0,
"alias": True,
"aliases": []}
return boards
def get_version_info():
@ -235,9 +251,11 @@ def generate_download_info():
board_id = board_path.name
board_info = board_mapping[board_id]
if board_id not in current_info:
changes["new_boards"].append(board_id)
current_info[board_id] = {"downloads": 0,
for alias in [board_id] + board_info["aliases"]:
alias_info = board_mapping[alias]
if alias not in current_info:
changes["new_boards"].append(alias)
current_info[alias] = {"downloads": 0,
"versions": []}
new_version = {
@ -249,9 +267,9 @@ def generate_download_info():
files = []
new_version["files"][language] = files
for extension in board_info["extensions"]:
files.append("https://github.com/adafruit/circuitpython/releases/download/{tag}/adafruit-circuitpython-{board}-{language}-{tag}.{extension}".format(tag=new_tag, board=board_id, language=language, extension=extension))
current_info[board_id]["downloads"] = board_info["download_count"]
current_info[board_id]["versions"].append(new_version)
files.append("https://github.com/adafruit/circuitpython/releases/download/{tag}/adafruit-circuitpython-{alias}-{language}-{tag}.{extension}".format(tag=new_tag, alias=alias, language=language, extension=extension))
current_info[alias]["downloads"] = alias_info["download_count"]
current_info[alias]["versions"].append(new_version)
changes["new_languages"] = set(languages) - previous_languages

View File

@ -48,7 +48,10 @@ for board in build_boards:
for extension in board_info["extensions"]:
temp_filename = "../ports/{port}/build-{board}/firmware.{extension}".format(port=board_info["port"], board=board, extension=extension)
final_filename = "adafruit-circuitpython-{board}-{language}-{version}.{extension}".format(board=board, language=language, version=version, extension=extension)
for alias in board_info["aliases"] + [board]:
bin_directory = "../bin/{alias}/{language}".format(alias=alias, language=language)
os.makedirs(bin_directory, exist_ok=True)
final_filename = "adafruit-circuitpython-{alias}-{language}-{version}.{extension}".format(alias=alias, language=language, version=version, extension=extension)
final_filename = os.path.join(bin_directory, final_filename)
try:
shutil.copyfile(temp_filename, final_filename)