# ===--- compiler_stage.py -----------------------------------------------===#
#
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See https:#swift.org/LICENSE.txt for license information
# See https:#swift.org/CONTRIBUTORS.txt for the list of Swift project authors
#
# ===---------------------------------------------------------------------===#

class StageArgs(object):
    def __init__(self, stage, args):
        self.stage = stage
        self.args = args

    def __getattr__(self, key):
        real_key = '{}{}'.format(key, self.stage.postfix)
        if not hasattr(self.args, real_key):
            return None
        return getattr(self.args, real_key)


class Stage(object):
    def __init__(self, identifier, postfix=""):
        self.identifier = identifier
        self.postfix = postfix


STAGE_1 = Stage(1, "")
STAGE_2 = Stage(2, "_stage2")

Introduce infrastructure for auto-prefixing stage2 options.
[build-script] Introduce infrastructure for auto-prefixing stage2 options.

This will let me introduce a stage generic swift implementation that adds a
postfix '_stage2' to certain stage specific options. This ensures we can have a
single swift build-script product implementation for both stage1 and stage2
compilers.
