@@ -103,6 +103,14 @@ def add_build_args(parser):
103
103
'--ninja-path' ,
104
104
metavar = 'PATH' ,
105
105
help = 'path to the ninja binary to use for building with CMake' )
106
+ parser .add_argument (
107
+ '--ar-path' ,
108
+ metavar = 'PATH' ,
109
+ help = 'path to the ar binary to use for building with CMake' )
110
+ parser .add_argument (
111
+ '--ranlib-path' ,
112
+ metavar = 'PATH' ,
113
+ help = 'path to the ranlib binary to use for building with CMake' )
106
114
parser .add_argument (
107
115
"--dispatch-build-dir" ,
108
116
help = "path to Dispatch build directory" )
@@ -211,9 +219,11 @@ def parse_build_args(args):
211
219
args .build_dirs ["llbuild" ] = os .path .abspath (args .llbuild_build_dir )
212
220
213
221
args .swiftc_path = get_swiftc_path (args )
214
- args .clang_path = get_clang_path (args )
215
- args .cmake_path = get_cmake_path (args )
216
- args .ninja_path = get_ninja_path (args )
222
+ args .clang_path = get_tool_path (args , "clang" )
223
+ args .cmake_path = get_tool_path (args , "cmake" )
224
+ args .ninja_path = get_tool_path (args , "ninja" )
225
+ args .ar_path = get_tool_path (args , "ar" )
226
+ args .ranlib_path = get_tool_path (args , "ranlib" )
217
227
if args .cross_compile_hosts :
218
228
if re .match ("macosx-" , args .cross_compile_hosts ):
219
229
# Use XCBuild target directory when building for multiple arches.
@@ -256,44 +266,19 @@ def get_swiftc_path(args):
256
266
return swiftc_path
257
267
error ("unable to find swiftc at %s" % swiftc_path )
258
268
259
- def get_clang_path (args ):
260
- """Returns the path to the Clang compiler."""
261
- if args .clang_path :
262
- return os .path .abspath (args .clang_path )
263
- elif platform .system () == 'Darwin' :
264
- return call_output (
265
- ["xcrun" , "--find" , "clang" ],
266
- stderr = subprocess .PIPE ,
267
- verbose = args .verbose
268
- )
269
- else :
270
- return call_output (["which" , "clang" ], verbose = args .verbose )
271
-
272
- def get_cmake_path (args ):
273
- """Returns the path to CMake."""
274
- if args .cmake_path :
275
- return os .path .abspath (args .cmake_path )
276
- elif platform .system () == 'Darwin' :
277
- return call_output (
278
- ["xcrun" , "--find" , "cmake" ],
279
- stderr = subprocess .PIPE ,
280
- verbose = args .verbose
281
- )
282
- else :
283
- return call_output (["which" , "cmake" ], verbose = args .verbose )
284
-
285
- def get_ninja_path (args ):
286
- """Returns the path to Ninja."""
287
- if args .ninja_path :
288
- return os .path .abspath (args .ninja_path )
269
+ def get_tool_path (args , tool ):
270
+ """Returns the path to the specified tool."""
271
+ path = getattr (args , tool + "_path" , None )
272
+ if path is not None :
273
+ return os .path .abspath (path )
289
274
elif platform .system () == 'Darwin' :
290
275
return call_output (
291
- ["xcrun" , "--find" , "ninja" ],
276
+ ["xcrun" , "--find" , tool ],
292
277
stderr = subprocess .PIPE ,
293
278
verbose = args .verbose
294
279
)
295
280
else :
296
- return call_output (["which" , "ninja" ], verbose = args .verbose )
281
+ return call_output (["which" , tool ], verbose = args .verbose )
297
282
298
283
def get_build_target (args , cross_compile = False ):
299
284
"""Returns the target-triple of the current machine or for cross-compilation."""
@@ -517,6 +502,8 @@ def build_with_cmake(args, cmake_args, ninja_args, source_path, build_dir, cmake
517
502
"-DCMAKE_Swift_FLAGS='%s'" % swift_flags ,
518
503
"-DCMAKE_Swift_COMPILER:=%s" % (args .swiftc_path ),
519
504
"-DCMAKE_C_COMPILER:=%s" % (args .clang_path ),
505
+ "-DCMAKE_AR:PATH=%s" % (args .ar_path ),
506
+ "-DCMAKE_RANLIB:PATH=%s" % (args .ranlib_path ),
520
507
] + cmake_args + [source_path ]
521
508
522
509
if args .verbose :
@@ -550,6 +537,8 @@ def build_llbuild(args):
550
537
flags = [
551
538
"-DCMAKE_C_COMPILER:=%s" % (args .clang_path ),
552
539
"-DCMAKE_CXX_COMPILER:=%s" % (args .clang_path ),
540
+ "-DCMAKE_AR:PATH=%s" % (args .ar_path ),
541
+ "-DCMAKE_RANLIB:PATH=%s" % (args .ranlib_path ),
553
542
"-DLLBUILD_SUPPORT_BINDINGS:=Swift" ,
554
543
]
555
544
cmake_env = []
0 commit comments