Skip to content

Commit 7623708

Browse files
committed
Merge pull request #2922 from gottesmm/use-update-checkout-config-file-instead-of-hard-coding-repos
2 parents 41886e3 + bedca5c commit 7623708

File tree

2 files changed

+82
-72
lines changed

2 files changed

+82
-72
lines changed

utils/update-checkout

Lines changed: 23 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from __future__ import print_function
1313

1414
import argparse
15+
import json
1516
import os
1617
import sys
1718

@@ -21,70 +22,12 @@ from SwiftBuildSupport import (
2122
SWIFT_SOURCE_ROOT,
2223
) # noqa (E402 module level import not at top of file)
2324

24-
sys.path.append(os.path.join(os.path.dirname(__file__), 'swift_build_support'))
25+
SCRIPT_FILE = os.path.abspath(__file__)
26+
SCRIPT_DIR = os.path.dirname(SCRIPT_FILE)
2527

26-
from swift_build_support import shell # noqa (E402)
28+
sys.path.append(os.path.join(SCRIPT_DIR, 'swift_build_support'))
2729

28-
REPOSITORIES = {
29-
'llvm': 'apple/swift-llvm',
30-
'clang': 'apple/swift-clang',
31-
'swift': 'apple/swift-swift',
32-
'lldb': 'apple/swift-lldb',
33-
'cmark': 'apple/swift-cmark',
34-
'llbuild': 'apple/swift-llbuild',
35-
'swiftpm': 'apple/swift-package-manager',
36-
'compiler-rt': 'apple/swift-compiler-rt',
37-
'swift-corelibs-xctest': 'apple/swift-corelibs-xctest',
38-
'swift-corelibs-foundation': 'apple/swift-corelibs-foundation',
39-
'swift-corelibs-libdispatch': 'apple/swift-corelibs-libdispatch',
40-
'swift-integration-tests': 'apple/swift-integration-tests',
41-
}
42-
43-
MASTER_BRANCHES = {
44-
'llvm': 'stable',
45-
'clang': 'stable',
46-
'swift': 'master',
47-
'lldb': 'master',
48-
'cmark': 'master',
49-
'llbuild': 'master',
50-
'swiftpm': 'master',
51-
'compiler-rt': 'stable',
52-
'swift-corelibs-xctest': 'master',
53-
'swift-corelibs-foundation': 'master',
54-
'swift-corelibs-libdispatch': 'master',
55-
'swift-integration-tests': 'master',
56-
}
57-
58-
NEXT_BRANCHES = {
59-
'llvm': 'stable-next',
60-
'clang': 'stable-next',
61-
'compiler-rt': 'stable-next',
62-
'swift': 'master-next',
63-
'lldb': 'master-next',
64-
'cmark': 'master',
65-
'llbuild': 'master',
66-
'swiftpm': 'master',
67-
'compiler-rt': 'stable-next',
68-
'swift-corelibs-xctest': 'master',
69-
'swift-corelibs-foundation': 'master',
70-
'swift-corelibs-libdispatch': 'master',
71-
'swift-integration-tests': 'master',
72-
}
73-
74-
SWIFT_3_0_PREVIEW_1_BRANCHES = {
75-
'llvm': 'swift-3.0-branch',
76-
'clang': 'swift-3.0-branch',
77-
'swift': 'swift-3.0-preview-1-branch',
78-
'lldb': 'swift-3.0-preview-1-branch',
79-
'cmark': 'swift-3.0-preview-1-branch',
80-
'llbuild': 'swift-3.0-preview-1-branch',
81-
'swiftpm': 'swift-3.0-preview-1-branch',
82-
'compiler-rt': 'swift-3.0-branch',
83-
'swift-corelibs-xctest': 'swift-3.0-preview-1-branch',
84-
'swift-corelibs-foundation': 'swift-3.0-preview-1-branch',
85-
'swift-corelibs-libdispatch': 'swift-3.0-preview-1-branch',
86-
'swift-integration-tests': 'swift-3.0-preview-1-branch',
87-
}
30+
from swift_build_support import shell # noqa (E402)
8831

8932

9033
def update_working_copy(repo_path, branch):
@@ -112,8 +55,8 @@ def update_working_copy(repo_path, branch):
11255

11356

11457
def obtain_additional_swift_sources(
115-
with_ssh, branch, skip_history, skip_repositories):
116-
for dir_name, repo in REPOSITORIES.items():
58+
config, with_ssh, branch, skip_history, skip_repositories):
59+
for dir_name, repo in config['repositories'].items():
11760
if dir_name in skip_repositories:
11861
print("--- Skipping '" + dir_name + "' ---")
11962
continue
@@ -133,12 +76,13 @@ def obtain_additional_swift_sources(
13376
dir_name], echo=False)
13477
if branch:
13578
if branch == "master" or branch == "stable":
136-
repo_branch = MASTER_BRANCHES[dir_name]
79+
repo_branch = config['master-branches'][dir_name]
13780
elif branch == "stable-next" or branch == "master-next":
138-
repo_branch = NEXT_BRANCHES[dir_name]
81+
repo_branch = config['next-branches'][dir_name]
13982
elif branch == "swift-3.0-branch" or \
14083
branch == "swift-3.0-preview-1-branch":
141-
repo_branch = SWIFT_3_0_PREVIEW_1_BRANCHES[dir_name]
84+
repo_branch = \
85+
config["swift-3.0-preview-1-branches"][dir_name]
14286
else:
14387
repo_branch = branch
14488
src_path = SWIFT_SOURCE_ROOT + "/" + dir_name + "/" + \
@@ -176,30 +120,37 @@ By default, updates your checkouts of Swift, SourceKit, LLDB, and SwiftPM.""")
176120
parser.add_argument(
177121
"--branch",
178122
help="Obtain Sources for specific branch")
123+
parser.add_argument(
124+
"--config",
125+
default=os.path.join(SCRIPT_DIR, "update-checkout-config.json"),
126+
help="Configuration file to use")
179127
args = parser.parse_args()
180128

181129
clone = args.clone
182130
clone_with_ssh = args.clone_with_ssh
183131
skip_history = args.skip_history
184132
branch = args.branch
185133

134+
with open(args.config) as f:
135+
config = json.load(f)
136+
186137
if clone or clone_with_ssh:
187138
obtain_additional_swift_sources(
188-
clone_with_ssh, branch, skip_history, args.skip_repository)
139+
config, clone_with_ssh, branch, skip_history, args.skip_repository)
189140

190141
repo_branch = branch
191-
for dir_name, _ in REPOSITORIES.items():
142+
for dir_name, _ in config["repositories"].items():
192143
if dir_name in args.skip_repository:
193144
print("--- Skipping '" + dir_name + "' ---")
194145
continue
195146
if branch:
196147
if branch == "master" or branch == "stable":
197-
repo_branch = MASTER_BRANCHES[dir_name]
148+
repo_branch = config["master-branches"][dir_name]
198149
elif branch == "stable-next" or branch == "master-next":
199-
repo_branch = NEXT_BRANCHES[dir_name]
150+
repo_branch = config["next-branches"][dir_name]
200151
elif branch == "swift-3.0-branch" or \
201152
branch == "swift-3.0-preview-1-branch":
202-
repo_branch = SWIFT_3_0_PREVIEW_1_BRANCHES[dir_name]
153+
repo_branch = config["swift-3.0-preview-1-branches"][dir_name]
203154

204155
update_working_copy(os.path.join(SWIFT_SOURCE_ROOT, dir_name),
205156
repo_branch)

utils/update-checkout-config.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"repositories" : {
3+
"llvm": "apple/swift-llvm",
4+
"clang": "apple/swift-clang",
5+
"swift": "apple/swift-swift",
6+
"lldb": "apple/swift-lldb",
7+
"cmark": "apple/swift-cmark",
8+
"llbuild": "apple/swift-llbuild",
9+
"swiftpm": "apple/swift-package-manager",
10+
"compiler-rt": "apple/swift-compiler-rt",
11+
"swift-corelibs-xctest": "apple/swift-corelibs-xctest",
12+
"swift-corelibs-foundation": "apple/swift-corelibs-foundation",
13+
"swift-corelibs-libdispatch": "apple/swift-corelibs-libdispatch",
14+
"swift-integration-tests": "apple/swift-integration-tests"
15+
},
16+
"master-branches": {
17+
"llvm": "stable",
18+
"clang": "stable",
19+
"swift": "master",
20+
"lldb": "master",
21+
"cmark": "master",
22+
"llbuild": "master",
23+
"swiftpm": "master",
24+
"compiler-rt": "stable",
25+
"swift-corelibs-xctest": "master",
26+
"swift-corelibs-foundation": "master",
27+
"swift-corelibs-libdispatch": "master",
28+
"swift-integration-tests": "master"
29+
},
30+
"next-branches" : {
31+
"llvm": "stable-next",
32+
"clang": "stable-next",
33+
"compiler-rt": "stable-next",
34+
"swift": "master-next",
35+
"lldb": "master-next",
36+
"cmark": "master",
37+
"llbuild": "master",
38+
"swiftpm": "master",
39+
"compiler-rt": "stable-next",
40+
"swift-corelibs-xctest": "master",
41+
"swift-corelibs-foundation": "master",
42+
"swift-corelibs-libdispatch": "master",
43+
"swift-integration-tests": "master"
44+
},
45+
"swift-3.0-preview-1-branches" : {
46+
"llvm": "swift-3.0-branch",
47+
"clang": "swift-3.0-branch",
48+
"swift": "swift-3.0-preview-1-branch",
49+
"lldb": "swift-3.0-preview-1-branch",
50+
"cmark": "swift-3.0-preview-1-branch",
51+
"llbuild": "swift-3.0-preview-1-branch",
52+
"swiftpm": "swift-3.0-preview-1-branch",
53+
"compiler-rt": "swift-3.0-branch",
54+
"swift-corelibs-xctest": "swift-3.0-preview-1-branch",
55+
"swift-corelibs-foundation": "swift-3.0-preview-1-branch",
56+
"swift-corelibs-libdispatch": "swift-3.0-preview-1-branch",
57+
"swift-integration-tests": "swift-3.0-preview-1-branch"
58+
}
59+
}

0 commit comments

Comments
 (0)