diff --git a/architecture.py b/architecture.py index 38e1317..b7609ba 100644 --- a/architecture.py +++ b/architecture.py @@ -2,10 +2,14 @@ import os import distribution +X86 = 'x86_64' +I86 = 'i686' + class Architecture: - def __init__(self, name): + def __init__(self, name, bits): self.name = name + self.bits = bits self.distribution = distribution.Distribution(self) # TODO subsystems self.subsystems = {} @@ -16,5 +20,7 @@ class Architecture: ] return os.linesep.join(lines) -X86 = Architecture('x86_64') -I86 = Architecture('i686') +ARCHITECTURES = { + X86: Architecture(X86, 64), + I86: Architecture(I86, 32), +} diff --git a/arguments.py b/arguments.py index aa098c0..bf19175 100644 --- a/arguments.py +++ b/arguments.py @@ -81,3 +81,7 @@ compression applying to archive ) return vars(parser.parse_args()) + +D = parse() + +architectures = D[ARCHITECTURES] diff --git a/msys.py b/msys.py index 9af1038..7369b4f 100644 --- a/msys.py +++ b/msys.py @@ -23,7 +23,7 @@ SUBSYSTEMS = [SUBSYSTEM, 'clang', 'mingw', 'ucrt'] def get_distribution(architecture): - return os.path.join(DISTRIBUTION, architecture) + return os.path.join(DISTRIBUTION, architecture.name) def get_subsystem(architecture, subsystem): @@ -32,18 +32,17 @@ def get_subsystem(architecture, subsystem): list.append(CRT) list.append(subsystem) if subsystem == SUBSYSTEM: - list.append(architecture) + list.append(architecture.name) return os.sep.join(list) def get_subsystems(architecture, families): list = [] - bits = ARCHITECTURES_BITS[architecture] for family in families: if family == SUBSYSTEM: subsystem = family else: - subsystem = f'{family}{bits}' - if subsystem in ARCHITECTURES_SUBSYSTEMS[architecture]: + subsystem = f'{family}{architecture.bits}' + if subsystem in ARCHITECTURES_SUBSYSTEMS[architecture.name]: list.append(subsystem) return list diff --git a/remote.py b/remote.py index 94703fc..1886111 100644 --- a/remote.py +++ b/remote.py @@ -11,7 +11,6 @@ import repository class Remote(repository.Repository): def __init__(self, args): super().__init__(args[arguments.REMOTE]) - self.architectures = args[arguments.ARCHITECTURES] self.subsystems = args[arguments.SUBSYSTEMS] self.load() diff --git a/repository.py b/repository.py index e6a69e4..93d0928 100644 --- a/repository.py +++ b/repository.py @@ -1,12 +1,18 @@ import os +import architecture +import arguments + class Repository: def __init__(self, location): self.location = location + self.architectures = [architecture.ARCHITECTURES[a] + for a in arguments.architectures] def __str__(self): lines = [ - f'Location: {self.location}', + f' Location: {self.location}', + f'Architectures: {[a.name for a in self.architectures]}', ] return os.linesep.join(lines) diff --git a/subsystem.py b/subsystem.py index 90421e7..d2bbf77 100644 --- a/subsystem.py +++ b/subsystem.py @@ -2,6 +2,8 @@ import os MAIN = 'msys' +FAMILIES = [MAIN, 'clang', 'mingw', 'ucrt'] + class SubSystem: def __init__(self, architecture):