Skip to content

Commit

Permalink
27
Browse files Browse the repository at this point in the history
  • Loading branch information
mkst committed Sep 13, 2023
1 parent bf58dd5 commit d9d74d6
Showing 1 changed file with 150 additions and 149 deletions.
299 changes: 150 additions & 149 deletions download.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,150 +22,11 @@

COMPILERS_DIR = Path("/tmp/compilers")

COMPILERS = {
"n64": [
"gcc2.7.2kmc",
"gcc2.7.2kmc",
"gcc2.7.2sn",
"gcc2.7.2snew",
"gcc2.8.1",
"gcc2.8.1sn",
"ido5.3",
"ido5.3_c++",
"ido6.0",
"ido7.1",
"mips_pro_744",
"egcs_1.1.2-4",
"gcc4.4.0-mips64-elf",
],
"ps1": [
"psyq3.3",
"psyq3.5",
"psyq3.6",
"psyq4.0",
"psyq4.1",
"psyq4.3",
"psyq4.5",
"psyq4.6",
"gcc2.6.3-psx-mipsel",
"gcc2.6.3-mipsel",
"gcc2.7.1-mipsel",
"gcc2.7.2-mipsel",
"gcc2.7.2.1-mipsel",
"gcc2.7.2.3-mipsel",
"gcc2.8.0-mipsel",
"gcc2.8.1-mipsel",
"gcc2.91.66-mipsel",
"gcc2.95.2-mipsel",
],
"ps2": [
"ee-gcc2.9-990721",
"ee-gcc2.9-991111",
"ee-gcc2.9-991111a",
"ee-gcc2.9-991111-01",
"ee-gcc2.96",
"ee-gcc3.2-040921",
],
"macosx": [
"gcc-5370",
"gcc-5026",
"gcc-5363",
"gcc3-1041",
],
"gba": [
"agbcc",
"agbccpp",
],
"saturn": [
"cygnus-2.7-96Q3",
],
"switch": [
"clang-3.9.1",
"clang-4.0.1",
"clang-8.0.0",
],
"nds_arm9": [
"mwcc_20_72",
"mwcc_20_79",
"mwcc_20_82",
"mwcc_20_84",
"mwcc_20_87",
"mwcc_30_114",
"mwcc_30_123",
"mwcc_30_126",
"mwcc_30_131",
"mwcc_30_133",
"mwcc_30_134",
"mwcc_30_136",
"mwcc_30_137",
"mwcc_30_138",
"mwcc_30_139",
"mwcc_40_1018",
"mwcc_40_1024",
"mwcc_40_1026",
"mwcc_40_1027",
"mwcc_40_1028",
"mwcc_40_1034",
"mwcc_40_1036",
"mwcc_40_1051",
],
"n3ds": [
"armcc_40_771",
"armcc_40_821",
"armcc_41_561",
"armcc_41_713",
"armcc_41_791",
"armcc_41_894",
"armcc_41_921",
"armcc_41_1049",
"armcc_41_1440",
"armcc_41_1454",
"armcc_504_82",
],
"gc_wii": [
"mwcc_233_144",
"mwcc_233_159",
"mwcc_233_163",
"mwcc_233_163n",
"mwcc_242_81",
"mwcc_247_92",
"mwcc_247_105",
"mwcc_247_107",
"mwcc_247_108",
"mwcc_41_60831",
"mwcc_41_60126",
"mwcc_42_142",
"mwcc_43_151",
"mwcc_43_172",
"mwcc_43_213",
"mwcc_242_81r",
"mwcc_233_163e",
"mwcc_42_127",
],
"msdos": [
"wcc10.5",
"wcc10.5a",
"wcc10.6",
"wcc11.0",
],
"win9x": [
"msvc6.0",
"msvc6.3",
"msvc6.4",
"msvc6.5",
"msvc6.5pp",
"msvc6.6",
"msvc7.0",
"msvc7.1",
"msvc4.0",
"msvc4.2",
],
}

# TODO: can we do this better?
host_arch = platform.system().lower()

if host_arch == "darwin":
compilers = {
COMPILERS = {
"n64": [
"ido5.3",
"ido7.1",
Expand All @@ -177,6 +38,146 @@
"clang-8.0.0",
],
}
else:
COMPILERS = {
"n64": [
"gcc2.7.2kmc",
"gcc2.7.2kmc",
"gcc2.7.2sn",
"gcc2.7.2snew",
"gcc2.8.1pm",
"gcc2.8.1sn",
"ido5.3",
"ido5.3_c++",
"ido6.0",
"ido7.1",
"mips_pro_744",
"egcs_1.1.2-4",
"gcc4.4.0-mips64-elf",
],
"ps1": [
"psyq3.3",
"psyq3.5",
"psyq3.6",
"psyq4.0",
"psyq4.1",
"psyq4.3",
"psyq4.5",
"psyq4.6",
"gcc2.6.3-psx-mipsel",
"gcc2.6.3-mipsel",
"gcc2.7.1-mipsel",
"gcc2.7.2-mipsel",
"gcc2.7.2.1-mipsel",
"gcc2.7.2.3-mipsel",
"gcc2.8.0-mipsel",
"gcc2.8.1-mipsel",
"gcc2.91.66-mipsel",
"gcc2.95.2-mipsel",
],
"ps2": [
"ee-gcc2.9-990721",
"ee-gcc2.9-991111",
"ee-gcc2.9-991111a",
"ee-gcc2.9-991111-01",
"ee-gcc2.96",
"ee-gcc3.2-040921",
],
"macosx": [
"gcc-5370",
"gcc-5026",
"gcc-5363",
"gcc3-1041",
],
"gba": [
"agbcc",
"agbccpp",
],
"saturn": [
"cygnus-2.7-96Q3",
],
"switch": [
"clang-3.9.1",
"clang-4.0.1",
"clang-8.0.0",
],
"nds_arm9": [
"mwcc_20_72",
"mwcc_20_79",
"mwcc_20_82",
"mwcc_20_84",
"mwcc_20_87",
"mwcc_30_114",
"mwcc_30_123",
"mwcc_30_126",
"mwcc_30_131",
"mwcc_30_133",
"mwcc_30_134",
"mwcc_30_136",
"mwcc_30_137",
"mwcc_30_138",
"mwcc_30_139",
"mwcc_40_1018",
"mwcc_40_1024",
"mwcc_40_1026",
"mwcc_40_1027",
"mwcc_40_1028",
"mwcc_40_1034",
"mwcc_40_1036",
"mwcc_40_1051",
],
"n3ds": [
"armcc_40_771",
"armcc_40_821",
"armcc_41_561",
"armcc_41_713",
"armcc_41_791",
"armcc_41_894",
"armcc_41_921",
"armcc_41_1049",
"armcc_41_1440",
"armcc_41_1454",
"armcc_504_82",
],
"gc_wii": [
"mwcc_233_144",
"mwcc_233_159",
"mwcc_233_163",
"mwcc_233_163n",
"mwcc_242_81",
"mwcc_247_92",
"mwcc_247_105",
"mwcc_247_107",
"mwcc_247_108",
"mwcc_41_60831",
"mwcc_41_60126",
"mwcc_42_142",
"mwcc_43_151",
"mwcc_43_172",
"mwcc_43_213",
"mwcc_242_81r",
"mwcc_233_163e",
"mwcc_42_127",
],
"msdos": [
"wcc10.5",
"wcc10.5a",
"wcc10.6",
"wcc11.0",
],
"win9x": [
"msvc6.0",
"msvc6.3",
"msvc6.4",
"msvc6.5",
"msvc6.5pp",
"msvc6.6",
"msvc7.0",
"msvc7.1",
"msvc4.0",
"msvc4.2",
],
}


client = docker.from_env()
Expand Down Expand Up @@ -228,30 +229,31 @@ def get_compiler(platform_compiler_id):
return

try:
logger.info("Creating container...")
container = client.containers.create(docker_image, "ls")
except Exception as err:
logger.fatal(err)
logger.error("Unable to create container for %s: %s", docker_image, err)
return

try:
stream, _ = container.get_archive(f"/compilers/{platform}/{compiler_id}")
compiler_container_path = f"/compilers/{platform}/{compiler_id}"
stream, _ = container.get_archive(compiler_container_path)
except Exception as err:
logger.fatal(err)
logger.error("Unable to pull %s from container: %s", compiler_container_path, err)
container.remove()
return

try:
with tempfile.TemporaryDirectory() as temp_dir:
tar_file = Path(temp_dir) / f"{compiler_id}.tar"
logger.info("Writing tar_file...")
logger.info("Writing to %s...", tar_file)
with tar_file.open("wb") as f:
for chunk in stream:
f.write(chunk)

new_compiler_dir = COMPILERS_DIR / platform / f".{compiler_id}"
new_compiler_dir.mkdir(parents=True, exist_ok=True)

logger.info(f"Extracting {tar_file} to {new_compiler_dir}")
logger.info(f"Extracting %s to %s", tar_file, new_compiler_dir)
shutil.unpack_archive(tar_file, new_compiler_dir.parent)

if compiler_dir.exists():
Expand All @@ -262,9 +264,8 @@ def get_compiler(platform_compiler_id):

logger.info("%s successfully downloaded to %s", compiler_id, compiler_dir)
except Exception as err:
logger.fatal(err)
logger.error(err)

logger.info("Removing container...")
container.remove()

def main():
Expand Down

0 comments on commit d9d74d6

Please sign in to comment.