Add support for GNAT Pro for Rust

This commit is contained in:
Tobias Reiher
2024-08-20 13:22:32 +02:00
committed by Tobias Reiher
parent c0e36a0f7b
commit 72abd7412e
3 changed files with 32 additions and 0 deletions

View File

@@ -58,6 +58,8 @@ class Tool:
@staticmethod
def from_archive(archive: Path) -> Tool:
if archive.name.startswith(GnatProRust.archive_name()):
return GnatProRust(archive)
if archive.name.startswith(Gnat.archive_name()):
return Gnat(archive)
if archive.name.startswith(Spark.archive_name()):
@@ -72,6 +74,8 @@ class Tool:
@staticmethod
def from_module(module_name: str) -> Tool:
if module_name.startswith(GnatProRust.name()):
return GnatProRust(module_name=module_name)
if module_name.startswith(Gnat.name()):
return Gnat(module_name=module_name)
if module_name.startswith(Spark.name()):
@@ -255,6 +259,27 @@ class Rust(Tool):
)
class GnatProRust(Tool):
@staticmethod
def name() -> str:
return "gnatpro-rust"
@staticmethod
def archive_name() -> str:
return "gnatpro-rust"
@staticmethod
def _installation_file() -> Path:
return Path("bin/rustc")
def _install_archive(self, installation_dir: Path) -> None:
call(
f"./install --install-dir='{installation_dir}' --force",
cwd=self._extracted_archive_dir(),
shell=True,
)
def main() -> Union[int, str]:
parser = argparse.ArgumentParser()

View File

@@ -240,6 +240,13 @@ def test_install_unexpected_archive_name_format(monkeypatch: MonkeyPatch, tmp_pa
"25.0w-20240417",
),
],
[
Archive(
"gnatpro-rust-25.0w-20240820-x86_64-linux-bin.tar.gz",
"gnatpro-rust",
"25.0w-20240820",
),
],
],
)
def test_install_and_uninstall(