Skip to content

Commit 18f84f2

Browse files
committed
[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.
1 parent c7001f9 commit 18f84f2

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# ===--- compiler_stage.py -----------------------------------------------===#
2+
#
3+
# This source file is part of the Swift.org open source project
4+
#
5+
# Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
6+
# Licensed under Apache License v2.0 with Runtime Library Exception
7+
#
8+
# See https:#swift.org/LICENSE.txt for license information
9+
# See https:#swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
#
11+
# ===---------------------------------------------------------------------===#
12+
13+
class StageArgs(object):
14+
def __init__(self, stage, args):
15+
self.stage = stage
16+
self.args = args
17+
18+
def __getattr__(self, key):
19+
real_key = '{}{}'.format(key, self.stage.postfix)
20+
if not hasattr(self.args, real_key):
21+
return None
22+
return getattr(self.args, real_key)
23+
24+
25+
class Stage(object):
26+
def __init__(self, identifier, postfix=""):
27+
self.identifier = identifier
28+
self.postfix = postfix
29+
30+
31+
STAGE_1 = Stage(1, "")
32+
STAGE_2 = Stage(2, "_stage2")

0 commit comments

Comments
 (0)