Skip to content

Commit fbbbf4e

Browse files
committed
[build-script] Update ClangVersionType to match SwiftVersionType
SwiftVersionType needs 5 components, and ClangVersionType needs to match SwiftVersionType because some build automation wants to mark the clang version as being the same as the Swift version while generating version numbers. Fixes rdar://85508050
1 parent 1ca3b93 commit fbbbf4e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

utils/build_swift/build_swift/argparse/types.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,10 @@ class ClangVersionType(RegexType):
139139
"""
140140

141141
ERROR_MESSAGE = ('Invalid version value, must be '
142-
'"MAJOR.MINOR.PATCH" or "MAJOR.MINOR.PATCH.PATCH"')
142+
'"MAJOR.MINOR.PATCH", "MAJOR.MINOR.PATCH.PATCH"'
143+
', or "MAJOR.MINOR.PATCH.PATCH.PATCH".')
143144

144-
VERSION_REGEX = r'^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$'
145+
VERSION_REGEX = r'^(\d+)\.(\d+)\.(\d+)(\.(\d+))?(\.(\d+))?$'
145146

146147
def __init__(self):
147148
super(ClangVersionType, self).__init__(

utils/build_swift/tests/build_swift/argparse/test_types.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,15 @@ def test_valid_clang_version(self):
157157
self.assertIsInstance(version, types.Version)
158158
self.assertEqual(version.components, (1, 0, 0, 1))
159159

160+
version = clang_version_type('1.0.0.1.2')
161+
self.assertIsInstance(version, types.Version)
162+
self.assertEqual(version.components, (1, 0, 0, 1, 2))
163+
160164
clang_version_type('1.0.0')
161165
clang_version_type('3.0.2.1')
162166
clang_version_type('200.0.56.3')
163167
clang_version_type('100000.0.0.1')
168+
clang_version_type('5.6.0.994.2')
164169

165170
def test_invalid_clang_version(self):
166171
clang_version_type = types.ClangVersionType()
@@ -170,9 +175,9 @@ def test_invalid_clang_version(self):
170175
with self.assertRaises(ArgumentTypeError):
171176
clang_version_type('3.0')
172177
with self.assertRaises(ArgumentTypeError):
173-
clang_version_type('1.8.0.2.1')
178+
clang_version_type('1.8.0.2.1.3')
174179
with self.assertRaises(ArgumentTypeError):
175-
clang_version_type('100.0.56.1.1')
180+
clang_version_type('100.0.56.1.1.1')
176181

177182

178183
class TestSwiftVersionType(unittest.TestCase):

0 commit comments

Comments
 (0)