@@ -24,6 +24,15 @@ from SwiftBuildSupport import (
24
24
check_output ,
25
25
)
26
26
27
+ REPOSITORIES = {
28
+ 'llvm' : 'apple/swift-llvm' ,
29
+ 'clang' : 'apple/swift-clang' ,
30
+ 'swift' : 'apple/swift-swift' ,
31
+ 'lldb' : 'apple/swift-lldb' ,
32
+ 'cmark' : 'apple/swift-cmark' ,
33
+ 'swift-integration-tests' : 'apple/swift-integration-tests' ,
34
+ }
35
+
27
36
def update_working_copy (repo_path , branch ):
28
37
if not os .path .isdir (repo_path ):
29
38
return
@@ -44,23 +53,23 @@ def update_working_copy(repo_path, branch):
44
53
check_call (["git" , "fetch" ])
45
54
check_call (["git" , "rebase" , "FETCH_HEAD" ])
46
55
47
- def obtain_additional_swift_sources (with_ssh , branch ):
48
- additional_repos = {
49
- 'llvm' : 'apple/swift-llvm' ,
50
- 'clang' : 'apple/swift-clang' ,
51
- 'lldb' : 'apple/swift-lldb' ,
52
- 'cmark' : 'apple/swift-cmark' ,
53
- 'swift-integration-tests' : 'apple/swift-integration-tests' ,
54
- }
55
- for dir_name , repo in additional_repos .items ():
56
+ def obtain_additional_swift_sources (
57
+ with_ssh , branch , skip_history , skip_repositories ):
58
+ for dir_name , repo in REPOSITORIES .items ():
59
+ if dir_name in skip_repositories :
60
+ print ("--- Skipping '" + dir_name + "' ---" )
61
+ continue
56
62
with WorkingDirectory (SWIFT_SOURCE_ROOT ):
57
63
if not os .path .isdir (os .path .join (dir_name , ".git" )):
58
64
print ("--- Cloning '" + dir_name + "' ---" )
59
65
if with_ssh is True :
60
66
remote = "git@github.com:" + repo + '.git'
61
67
else :
62
68
remote = "https://github.com/" + repo + '.git'
63
- check_call (['git' , 'clone' , remote , dir_name ])
69
+ if skip_history :
70
+ check_call (['git' , 'clone' , '--depth' , '1' , remote , dir_name ])
71
+ else :
72
+ check_call (['git' , 'clone' , remote , dir_name ])
64
73
if branch :
65
74
src_path = SWIFT_SOURCE_ROOT + "/" + dir_name + "/" + ".git"
66
75
check_call (['git' , '--git-dir' , src_path , '--work-tree' , os .path .join (SWIFT_SOURCE_ROOT , dir_name ), 'checkout' , branch ])
@@ -71,38 +80,39 @@ def main():
71
80
description = """
72
81
repositories.
73
82
74
- By default, updates your checkouts of Swift, and LLDB.""" )
75
- parser .add_argument ("-a" , "--all" ,
76
- help = "also update checkouts of LLVM, and Clang" ,
77
- action = "store_true" )
83
+ By default, updates your checkouts of Swift, SourceKit, LLDB, and SwiftPM.""" )
78
84
parser .add_argument ("--clone" ,
79
85
help = "Obtain Sources for Swift and Related Projects" ,
80
86
action = "store_true" )
81
87
parser .add_argument ("--clone-with-ssh" ,
82
88
help = "Obtain Sources for Swift and Related Projects via SSH" ,
83
89
action = "store_true" )
90
+ parser .add_argument ("--skip-history" ,
91
+ help = "Skip histories when obtaining sources" ,
92
+ action = "store_true" )
93
+ parser .add_argument ("--skip-repository" ,
94
+ metavar = "DIRECTORY" ,
95
+ default = [],
96
+ help = "Skip the specified repository" ,
97
+ action = "append" )
84
98
parser .add_argument ("--branch" ,
85
99
help = "Obtain Sources for specific branch" )
86
100
args = parser .parse_args ()
87
101
88
102
clone = args .clone
89
103
clone_with_ssh = args .clone_with_ssh
104
+ skip_history = args .skip_history
90
105
branch = args .branch
91
106
92
107
if clone or clone_with_ssh :
93
- obtain_additional_swift_sources (clone_with_ssh , branch )
94
- return 0
95
-
96
- if args .all :
97
- update_working_copy (os .path .join (SWIFT_SOURCE_ROOT , "llvm" ), branch )
98
- update_working_copy (os .path .join (SWIFT_SOURCE_ROOT , "clang" ), branch )
99
-
100
- update_working_copy (os .path .join (SWIFT_SOURCE_ROOT , "swift" ), branch )
101
- update_working_copy (
102
- os .path .join (SWIFT_SOURCE_ROOT , "swift" , "benchmark" , "PerfTestSuite" ), branch )
103
- update_working_copy (os .path .join (SWIFT_SOURCE_ROOT , "cmark" ), branch )
104
- update_working_copy (os .path .join (SWIFT_SOURCE_ROOT , "lldb" ), branch )
105
- update_working_copy (os .path .join (SWIFT_SOURCE_ROOT , "swift-integration-tests" ), branch )
108
+ obtain_additional_swift_sources (
109
+ clone_with_ssh , branch , skip_history , args .skip_repository )
110
+
111
+ for dir_name , _ in REPOSITORIES .items ():
112
+ if dir_name in args .skip_repository :
113
+ print ("--- Skipping '" + dir_name + "' ---" )
114
+ continue
115
+ update_working_copy (os .path .join (SWIFT_SOURCE_ROOT , dir_name ), branch )
106
116
107
117
return 0
108
118
0 commit comments