4
4
#
5
5
# NOTE: We have slightly modified copies of some of the files, to reduce the
6
6
# dependency surface area, so if you run this to update the sources, please
7
- # examine the diffs to remove things that don't make sense.
7
+ # examine the diffs to remove things that don't make sense and update 'llvm-patch.diff' .
8
8
9
9
import errno
10
10
import optparse
@@ -19,7 +19,7 @@ ADT_imports = ['EpochTracker', 'iterator', 'iterator_range', 'Hashing', 'None',
19
19
'Statistic' , 'StringExtras' , 'STLExtras' , 'AllocatorList' , 'Triple' ]
20
20
21
21
# ADT basic data structures.
22
- ADT_imports += ['APFloat' , 'APInt' , 'APSInt' , 'ArrayRef' , 'PointerIntPair' , 'SetVector' , 'StringRef' , 'StringSwitch' ,
22
+ ADT_imports += ['APFloat' , 'APInt' , 'APSInt' , 'ArrayRef' , 'bit' , ' PointerIntPair' , 'SetVector' , 'StringRef' , 'StringSwitch' ,
23
23
'Twine' , 'IntrusiveRefCntPtr' , 'ilist' , 'ilist_base' , 'ilist_node' , 'ilist_node_base' ,
24
24
'ilist_node_options' , 'ilist_iterator' , 'simple_ilist' , 'OptionSet' , 'PointerUnion' ]
25
25
@@ -35,11 +35,11 @@ ADT_imports += ['edit_distance']
35
35
# Support types and infrastructure.
36
36
Support_imports = [
37
37
'AlignOf' , 'Allocator' , 'Atomic' , 'CBindingWrapping' , 'Casting' , 'Capacity' , 'CommandLine' , 'Compiler' ,
38
- 'Endian' , 'Errno' , 'ErrorHandling' , 'Errc' , 'ErrorOr' , 'Error' , 'Format' ,
38
+ 'Endian' , 'Errno' , 'ErrorHandling' , 'Errc' , 'ErrorOr' , 'Error' , 'Format' , 'FormatAdapters' ,
39
39
'ManagedStatic' , 'MathExtras' , 'Mutex' , 'MutexGuard' , 'Memory' ,
40
40
'MemoryBuffer' , 'PointerLikeTypeTraits' , 'Recycler' , 'SwapByteOrder' ,
41
41
'Timer' , 'TimeValue' , 'Threading' , 'Unicode' , 'UniqueLock' , 'Unix' , 'WindowsError' ,
42
- 'Valgrind' , 'circular_raw_ostream' , 'raw_ostream' , 'type_traits' , 'JSON' ]
42
+ 'Valgrind' , 'circular_raw_ostream' , 'raw_ostream' , 'Signposts' , ' type_traits' , 'JSON' ]
43
43
44
44
# Stuff we don't want, but have to pull in.
45
45
Support_imports += [
@@ -49,23 +49,24 @@ Support_imports += [
49
49
'MemAlloc' , 'Chrono' , 'FormatProviders' , 'FormatVariadic' , 'FormatCommon' ,
50
50
'FormatVariadicDetails' , 'NativeFormatting' , 'DJB' , 'ReverseIteration' , 'MD5' ,
51
51
'SmallVectorMemoryBuffer' , 'WithColor' , 'Options' , 'PrettyStackTrace' , 'Watchdog' ,
52
- 'TargetParser' , 'ARMBuildAttributes' , 'ARMTargetParser.def' , 'AArch64TargetParser.def' , 'X86TargetParser.def' , 'LineIterator' ]
52
+ 'TargetParser' , 'ARMBuildAttributes' , 'ARMTargetParser' , 'AArch64TargetParser' ,
53
+ 'ARMTargetParser.def' , 'AArch64TargetParser.def' , 'X86TargetParser.def' , 'LineIterator' ]
53
54
54
55
# Dependencies from llvm-c needed by Support.
55
- C_imports = ['Types' , 'DataTypes' , 'Support' , 'ErrorHandling' ]
56
+ C_imports = ['Types' , 'DataTypes' , 'Support' , 'Error' , ' ErrorHandling' ]
56
57
57
58
# Support data structures.
58
59
Support_imports += ['YAMLParser' , 'YAMLTraits' ]
59
60
60
61
# Source files to exclude.
61
- Support_source_excludes = set (['Host' ])
62
+ Support_source_excludes = set ([])
62
63
63
64
llvm_srcroot = None
64
- sourcekit_srcroot = None
65
+ indexstoredb_srcroot = None
65
66
66
67
def note (msg ):
67
68
msg = msg .replace (llvm_srcroot , "<LLVM>" )
68
- msg = msg .replace (sourcekit_srcroot , "<INDEXSTOREDB>" )
69
+ msg = msg .replace (indexstoredb_srcroot , "<INDEXSTOREDB>" )
69
70
print >> sys .stderr , "note: %s" % (msg ,)
70
71
71
72
def mkdir_p (path ):
@@ -133,32 +134,32 @@ def main():
133
134
if len (args ) != 1 :
134
135
parser .error ("unexpected number of arguments" )
135
136
136
- global llvm_srcroot , sourcekit_srcroot
137
+ global llvm_srcroot , indexstoredb_srcroot
137
138
llvm_srcroot , = args
138
- sourcekit_srcroot = os .path .dirname (os .path .dirname (os .path .abspath (__file__ )))
139
+ indexstoredb_srcroot = os .path .dirname (os .path .dirname (os .path .abspath (__file__ )))
139
140
140
141
def import_header (dir , name ):
141
142
src = os .path .join (llvm_srcroot , 'include' , 'llvm' , dir , name )
142
143
if os .path .exists (src ):
143
- dst = os .path .join (sourcekit_srcroot , 'include' , 'llvm' , dir , name )
144
+ dst = os .path .join (indexstoredb_srcroot , 'include' , 'llvm' , dir , name )
144
145
mkdir_p (os .path .dirname (dst ))
145
146
copyfile (src , dst )
146
147
147
148
def import_c_header (name ):
148
149
src = os .path .join (llvm_srcroot , 'include' , 'llvm-c' , name )
149
150
if os .path .exists (src ):
150
- dst = os .path .join (sourcekit_srcroot , 'include' , 'llvm-c' , name )
151
+ dst = os .path .join (indexstoredb_srcroot , 'include' , 'llvm-c' , name )
151
152
mkdir_p (os .path .dirname (dst ))
152
153
copyfile (src , dst )
153
154
154
155
def import_source (dir , name ):
155
156
src = os .path .join (llvm_srcroot , 'lib' , dir , name )
156
157
if os .path .exists (src ):
157
- dst = os .path .join (sourcekit_srcroot , 'lib' , 'LLVMSupport' , dir , name )
158
+ dst = os .path .join (indexstoredb_srcroot , 'lib' , 'LLVMSupport' , dir , name )
158
159
mkdir_p (os .path .dirname (dst ))
159
160
copyfile (src , dst )
160
161
161
- print "note: importing from %r to %r" % (llvm_srcroot , sourcekit_srcroot )
162
+ print "note: importing from %r to %r" % (llvm_srcroot , indexstoredb_srcroot )
162
163
163
164
for name in ADT_imports :
164
165
import_header ('ADT' , name + '.h' )
@@ -175,6 +176,8 @@ def main():
175
176
import_source ('Support' , name + '.cpp' )
176
177
import_source ('Support' , os .path .join ('Unix' , name + '.h' ))
177
178
import_source ('Support' , os .path .join ('Unix' , name + '.inc' ))
179
+ import_source ('Support' , os .path .join ('Windows' , name + '.h' ))
180
+ import_source ('Support' , os .path .join ('Windows' , name + '.inc' ))
178
181
179
182
for name in C_imports :
180
183
import_c_header (name + '.h' )
@@ -183,17 +186,23 @@ def main():
183
186
print "Adding prefix header includes"
184
187
185
188
base_dirs = [
186
- os .path .join (sourcekit_srcroot , 'include' , 'llvm' ),
187
- os .path .join (sourcekit_srcroot , 'include' , 'llvm-c' ),
188
- os .path .join (sourcekit_srcroot , 'lib' , 'LLVMSupport' ),
189
+ os .path .join (indexstoredb_srcroot , 'include' , 'llvm' ),
190
+ os .path .join (indexstoredb_srcroot , 'include' , 'llvm-c' ),
191
+ os .path .join (indexstoredb_srcroot , 'lib' , 'LLVMSupport' ),
189
192
]
190
193
191
- include_dir = os .path .join (sourcekit_srcroot , 'include' )
194
+ include_dir = os .path .join (indexstoredb_srcroot , 'include' )
192
195
193
196
for base in base_dirs :
194
197
for root , dirs , files in os .walk (base ):
195
198
for file in files :
196
199
maybe_add_prefix (os .path .join (root , file ), include_dir )
197
200
201
+ print ""
202
+ print "Applying patch"
203
+
204
+ patch_path = os .path .join (indexstoredb_srcroot , 'Utilities' , 'llvm-patch.diff' ),
205
+ subprocess .call ("patch -p1 < '%s'" % patch_path , shell = True )
206
+
198
207
if __name__ == '__main__' :
199
208
main ()
0 commit comments