@@ -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" )
@@ -208,9 +216,11 @@ def parse_build_args(args):
208
216
args .build_dirs ["llbuild" ] = os .path .abspath (args .llbuild_build_dir )
209
217
210
218
args .swiftc_path = get_swiftc_path (args )
211
- args .clang_path = get_clang_path (args )
212
- args .cmake_path = get_cmake_path (args )
213
- args .ninja_path = get_ninja_path (args )
219
+ args .clang_path = get_tool_path (args , "clang" )
220
+ args .cmake_path = get_tool_path (args , "cmake" )
221
+ args .ninja_path = get_tool_path (args , "ninja" )
222
+ args .ar_path = get_tool_path (args , "ar" )
223
+ args .ranlib_path = get_tool_path (args , "ranlib" )
214
224
if args .cross_compile_hosts :
215
225
if re .match ("macosx-" , args .cross_compile_hosts ):
216
226
# Use XCBuild target directory when building for multiple arches.
@@ -253,44 +263,19 @@ def get_swiftc_path(args):
253
263
return swiftc_path
254
264
error ("unable to find swiftc at %s" % swiftc_path )
255
265
256
- def get_clang_path (args ):
257
- """Returns the path to the Clang compiler."""
258
- if args .clang_path :
259
- return os .path .abspath (args .clang_path )
260
- elif platform .system () == 'Darwin' :
261
- return call_output (
262
- ["xcrun" , "--find" , "clang" ],
263
- stderr = subprocess .PIPE ,
264
- verbose = args .verbose
265
- )
266
- else :
267
- return call_output (["which" , "clang" ], verbose = args .verbose )
268
-
269
- def get_cmake_path (args ):
270
- """Returns the path to CMake."""
271
- if args .cmake_path :
272
- return os .path .abspath (args .cmake_path )
273
- elif platform .system () == 'Darwin' :
274
- return call_output (
275
- ["xcrun" , "--find" , "cmake" ],
276
- stderr = subprocess .PIPE ,
277
- verbose = args .verbose
278
- )
279
- else :
280
- return call_output (["which" , "cmake" ], verbose = args .verbose )
281
-
282
- def get_ninja_path (args ):
283
- """Returns the path to Ninja."""
284
- if args .ninja_path :
285
- return os .path .abspath (args .ninja_path )
266
+ def get_tool_path (args , tool ):
267
+ """Returns the path to the specified tool."""
268
+ path = getattr (args , tool + "_path" , None )
269
+ if path is not None :
270
+ return os .path .abspath (path )
286
271
elif platform .system () == 'Darwin' :
287
272
return call_output (
288
- ["xcrun" , "--find" , "ninja" ],
273
+ ["xcrun" , "--find" , tool ],
289
274
stderr = subprocess .PIPE ,
290
275
verbose = args .verbose
291
276
)
292
277
else :
293
- return call_output (["which" , "ninja" ], verbose = args .verbose )
278
+ return call_output (["which" , tool ], verbose = args .verbose )
294
279
295
280
def get_build_target (args , cross_compile = False ):
296
281
"""Returns the target-triple of the current machine or for cross-compilation."""
@@ -504,6 +489,8 @@ def build_with_cmake(args, cmake_args, ninja_args, source_path, build_dir, cmake
504
489
"-DCMAKE_Swift_FLAGS='%s'" % swift_flags ,
505
490
"-DCMAKE_Swift_COMPILER:=%s" % (args .swiftc_path ),
506
491
"-DCMAKE_C_COMPILER:=%s" % (args .clang_path ),
492
+ "-DCMAKE_AR:PATH=%s" % (args .ar_path ),
493
+ "-DCMAKE_RANLIB:PATH=%s" % (args .ranlib_path ),
507
494
] + cmake_args + [source_path ]
508
495
509
496
if args .verbose :
@@ -537,6 +524,8 @@ def build_llbuild(args):
537
524
flags = [
538
525
"-DCMAKE_C_COMPILER:=%s" % (args .clang_path ),
539
526
"-DCMAKE_CXX_COMPILER:=%s" % (args .clang_path ),
527
+ "-DCMAKE_AR:PATH=%s" % (args .ar_path ),
528
+ "-DCMAKE_RANLIB:PATH=%s" % (args .ranlib_path ),
540
529
"-DLLBUILD_SUPPORT_BINDINGS:=Swift" ,
541
530
]
542
531
cmake_env = []
0 commit comments