@@ -116,6 +116,36 @@ def _build_z3():
116
116
env = build_env , cwd = BUILD_DIR ) != 0 :
117
117
raise LibError ("Unable to build Z3." )
118
118
119
+ def _cp_vs_runtime ():
120
+ platform = "x64"
121
+ vcdir = os .environ ['VCINSTALLDIR' ]
122
+ path = '%sredist' % vcdir
123
+ vs_runtime_files = []
124
+ # Everything changes with every release of VS
125
+ # Prior versions of VS had DLLs under "redist\x64"
126
+ # There are now several variants of redistributables
127
+ # The naming convention defies my understanding so
128
+ # we use a "check_root" filter to find some hopefully suitable
129
+ # redistributable.
130
+ def check_root (root ):
131
+ return platform in root and ("CRT" in root or "MP" in root ) and "onecore" not in root and "debug" not in root
132
+ for root , dirs , files in os .walk (path ):
133
+ for filename in files :
134
+ if fnmatch (filename , '*.dll' ) and check_root (root ):
135
+ print ("Checking %s %s" % (root , filename ))
136
+ for pat in VS_RUNTIME_PATS :
137
+ if pat .match (filename ):
138
+ fname = os .path .join (root , filename )
139
+ if not os .path .isdir (fname ):
140
+ vs_runtime_files .append (fname )
141
+ if not vs_runtime_files :
142
+ raise MKException ("Did not find any runtime files to include" )
143
+ for f in vs_runtime_files :
144
+ shutil .copy (f , bin_dist_path )
145
+ if is_verbose ():
146
+ print ("Copied '%s' to '%s'" % (f , LIBS_DIR ))
147
+
148
+
119
149
def _copy_bins ():
120
150
"""
121
151
Copy the library and header files into their final destinations
@@ -141,6 +171,7 @@ def _copy_bins():
141
171
os .mkdir (HEADERS_DIR )
142
172
shutil .copy (os .path .join (BUILD_DIR , LIBRARY_FILE ), LIBS_DIR )
143
173
shutil .copy (os .path .join (BUILD_DIR , EXECUTABLE_FILE ), BINS_DIR )
174
+ _cp_vs_runtime ()
144
175
145
176
for header_dir in HEADER_DIRS :
146
177
for fname in os .listdir (header_dir ):
0 commit comments