@@ -235,18 +235,36 @@ def build_cmake(self, source_root, build_root):
235235 if len(m) == 1:
236236 build_root = m[0]
237237
238- cmake_build_dir = os.path.join(build_root, 'cmake-%s' %
238+ cmake_install_dir = os.path.join(build_root, 'cmake-%s' %
239+ self.args.host_target)
240+ cmake_build_dir = os.path.join(build_root, 'cmake-%s-build' %
239241 self.args.host_target)
240242 if not os.path.isdir(cmake_build_dir):
241243 os.makedirs(cmake_build_dir)
242244
243245 cwd = os.getcwd()
246+
247+ file_dir = os.path.dirname(os.path.abspath(__file__))
248+ cmake_patch_path = os.path.join(file_dir, "cmake-swift.patch")
249+ cmake_source_dir = os.path.join(source_root, "cmake")
250+ os.chdir(cmake_source_dir)
251+ shell.call_without_sleeping(['git', 'apply', cmake_patch_path],
252+ echo=True)
253+
244254 os.chdir(cmake_build_dir)
245- shell.call_without_sleeping([cmake_bootstrap], echo=True)
255+ shell.call_without_sleeping([cmake_bootstrap, '--prefix=%s' %
256+ cmake_install_dir], echo=True)
246257 shell.call_without_sleeping(['make', '-j%s' % self.args.build_jobs],
247258 echo=True)
259+ shell.call_without_sleeping(['make', 'install'], echo=True)
260+
261+ os.chdir(cmake_source_dir)
262+ # undo the patch so the next time we call this it applies again
263+ shell.call_without_sleeping(['git', 'checkout', '-f'],
264+ echo=True)
265+
248266 os.chdir(cwd)
249- return os.path.join(cmake_build_dir , 'bin', 'cmake')
267+ return os.path.join(cmake_install_dir , 'bin', 'cmake')
250268
251269 # For Linux only, determine the version of the installed CMake compared to
252270 # the source and build the source if necessary. Returns the path to the
0 commit comments