12
12
from __future__ import print_function
13
13
14
14
import argparse
15
+ import json
15
16
import os
16
17
import sys
17
18
@@ -21,70 +22,12 @@ from SwiftBuildSupport import (
21
22
SWIFT_SOURCE_ROOT ,
22
23
) # noqa (E402 module level import not at top of file)
23
24
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 )
25
27
26
- from swift_build_support import shell # noqa (E402 )
28
+ sys . path . append ( os . path . join ( SCRIPT_DIR , ' swift_build_support' ) )
27
29
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)
88
31
89
32
90
33
def update_working_copy (repo_path , branch ):
@@ -112,8 +55,8 @@ def update_working_copy(repo_path, branch):
112
55
113
56
114
57
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 ():
117
60
if dir_name in skip_repositories :
118
61
print ("--- Skipping '" + dir_name + "' ---" )
119
62
continue
@@ -133,12 +76,13 @@ def obtain_additional_swift_sources(
133
76
dir_name ], echo = False )
134
77
if branch :
135
78
if branch == "master" or branch == "stable" :
136
- repo_branch = MASTER_BRANCHES [dir_name ]
79
+ repo_branch = config [ 'master-branches' ] [dir_name ]
137
80
elif branch == "stable-next" or branch == "master-next" :
138
- repo_branch = NEXT_BRANCHES [dir_name ]
81
+ repo_branch = config [ 'next-branches' ] [dir_name ]
139
82
elif branch == "swift-3.0-branch" or \
140
83
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 ]
142
86
else :
143
87
repo_branch = branch
144
88
src_path = SWIFT_SOURCE_ROOT + "/" + dir_name + "/" + \
@@ -176,30 +120,37 @@ By default, updates your checkouts of Swift, SourceKit, LLDB, and SwiftPM.""")
176
120
parser .add_argument (
177
121
"--branch" ,
178
122
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" )
179
127
args = parser .parse_args ()
180
128
181
129
clone = args .clone
182
130
clone_with_ssh = args .clone_with_ssh
183
131
skip_history = args .skip_history
184
132
branch = args .branch
185
133
134
+ with open (args .config ) as f :
135
+ config = json .load (f )
136
+
186
137
if clone or clone_with_ssh :
187
138
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 )
189
140
190
141
repo_branch = branch
191
- for dir_name , _ in REPOSITORIES .items ():
142
+ for dir_name , _ in config [ "repositories" ] .items ():
192
143
if dir_name in args .skip_repository :
193
144
print ("--- Skipping '" + dir_name + "' ---" )
194
145
continue
195
146
if branch :
196
147
if branch == "master" or branch == "stable" :
197
- repo_branch = MASTER_BRANCHES [dir_name ]
148
+ repo_branch = config [ "master-branches" ] [dir_name ]
198
149
elif branch == "stable-next" or branch == "master-next" :
199
- repo_branch = NEXT_BRANCHES [dir_name ]
150
+ repo_branch = config [ "next-branches" ] [dir_name ]
200
151
elif branch == "swift-3.0-branch" or \
201
152
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 ]
203
154
204
155
update_working_copy (os .path .join (SWIFT_SOURCE_ROOT , dir_name ),
205
156
repo_branch )
0 commit comments