Skip to content

Commit 6740a61

Browse files
authored
Merge pull request #30704 from drexin/wip-patch-cmake
Patch CMake Swift module to correctly load flags
2 parents e43c12f + 1709bce commit 6740a61

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
From dbc2c645465a7045efe4d4d0a791ebbdd514343a Mon Sep 17 00:00:00 2001
2+
From: Dario Rexin <[email protected]>
3+
Date: Sat, 28 Mar 2020 15:30:26 -0700
4+
Subject: [PATCH] Load swift flags in swift module
5+
6+
---
7+
Modules/CMakeSwiftInformation.cmake | 2 ++
8+
1 file changed, 2 insertions(+)
9+
10+
diff --git a/Modules/CMakeSwiftInformation.cmake b/Modules/CMakeSwiftInformation.cmake
11+
index f6510b922f..6d3fe187a7 100644
12+
--- a/Modules/CMakeSwiftInformation.cmake
13+
+++ b/Modules/CMakeSwiftInformation.cmake
14+
@@ -47,6 +47,8 @@ set(CMAKE_Swift_FLAGS_RELEASE_INIT "-O")
15+
set(CMAKE_Swift_FLAGS_RELWITHDEBINFO_INIT "-O -g")
16+
set(CMAKE_Swift_FLAGS_MINSIZEREL_INIT "-Osize")
17+
18+
+cmake_initialize_per_config_variable(CMAKE_Swift_FLAGS "Swift Compiler Flags")
19+
+
20+
# NOTE(compnerd) we do not have an object compile rule since we build the objects as part of the link step
21+
if(NOT CMAKE_Swift_COMPILE_OBJECT)
22+
set(CMAKE_Swift_COMPILE_OBJECT ":")
23+
--
24+
2.15.0
25+

utils/swift_build_support/swift_build_support/cmake.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)