Skip to content

Commit c4038de

Browse files
committed
[cmake] Always add local swift compilation jobs to the local job pool.
Compiling swift modules are always compiled local... so put them in the local job pool.
1 parent 08cfea2 commit c4038de

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

CMakeLists.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,15 @@ endif()
1111
list(APPEND CMAKE_MODULE_PATH
1212
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
1313

14-
# Make a job pool for things that can't yet be distributed
15-
cmake_host_system_information(
16-
RESULT localhost_logical_cores QUERY NUMBER_OF_LOGICAL_CORES)
17-
set_property(GLOBAL PROPERTY JOB_POOLS local_jobs=${localhost_logical_cores})
18-
# Put linking in that category
19-
set_property(GLOBAL PROPERTY JOB_POOL_LINK local_jobs)
20-
2114
ENABLE_LANGUAGE(C)
2215

2316
# First include general CMake utilities.
17+
include(SwiftLocalJobPool)
2418
include(SwiftUtils)
2519
include(CheckSymbolExists)
2620

21+
initialize_local_jobpool()
22+
2723
#
2824
# User-configurable options that control the inclusion and default build
2925
# behavior for components which may not strictly be necessary (tools, examples,

cmake/modules/SwiftLocalJobPool.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
function(initialize_local_jobpool)
3+
# Make a job pool for things that can't yet be distributed
4+
cmake_host_system_information(
5+
RESULT localhost_logical_cores QUERY NUMBER_OF_LOGICAL_CORES)
6+
set_property(GLOBAL PROPERTY JOB_POOLS local_jobs=${localhost_logical_cores})
7+
# Put linking in that category.
8+
set_property(GLOBAL PROPERTY JOB_POOL_LINK local_jobs)
9+
endfunction()
10+
11+
function(add_target_to_local_jobpool target)
12+
set_property(TARGET ${target} PROPERTY JOB_POOL_COMPILE local_jobs)
13+
# We do not need to set link jobs to be in local_jobs since above, we make
14+
# linking always local.
15+
endfunction()

cmake/modules/SwiftSource.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
include(SwiftUtils)
2+
include(SwiftLocalJobPool)
23

34
# Process the sources within the given variable, pulling out any Swift
45
# sources to be compiled with 'swift' directly. This updates
@@ -433,6 +434,7 @@ function(_compile_swift_files
433434
COMMAND ""
434435
OUTPUT ${obj_dirs}
435436
COMMENT "Generating obj dirs for ${first_output}")
437+
add_target_to_local_jobpool(${obj_dirs_dependency_target})
436438

437439
# Generate the api notes if we need them.
438440
if (apinotes_outputs)
@@ -449,6 +451,7 @@ function(_compile_swift_files
449451
${depends_create_apinotes}
450452
${obj_dirs_dependency_target}
451453
COMMENT "Generating API notes ${first_output}")
454+
add_target_to_local_jobpool(${api_notes_dependency_target})
452455
endif()
453456

454457
# Then we can compile both the object files and the swiftmodule files
@@ -476,6 +479,7 @@ function(_compile_swift_files
476479
${swift_ide_test_dependency} ${api_notes_dependency_target}
477480
${obj_dirs_dependency_target}
478481
COMMENT "Compiling ${first_output}")
482+
add_target_to_local_jobpool(${dependency_target})
479483
set("${dependency_target_out_var_name}" "${dependency_target}" PARENT_SCOPE)
480484

481485
# This is the target to generate:
@@ -511,6 +515,7 @@ function(_compile_swift_files
511515
${swift_ide_test_dependency} ${api_notes_dependency_target}
512516
${obj_dirs_dependency_target}
513517
COMMENT "Generating ${module_file}")
518+
add_target_to_local_jobpool(${module_dependency_target})
514519
set("${dependency_module_target_out_var_name}" "${module_dependency_target}" PARENT_SCOPE)
515520

516521
# This is the target to generate the .sib files. It is not built by default.
@@ -528,6 +533,7 @@ function(_compile_swift_files
528533
${obj_dirs_dependency_target}
529534
COMMENT "Generating ${sib_file}"
530535
EXCLUDE_FROM_ALL)
536+
add_target_to_local_jobpool(${sib_dependency_target})
531537
set("${dependency_sib_target_out_var_name}" "${sib_dependency_target}" PARENT_SCOPE)
532538

533539
add_custom_command_target(
@@ -544,6 +550,7 @@ function(_compile_swift_files
544550
${obj_dirs_dependency_target}
545551
COMMENT "Generating ${sibopt_file}"
546552
EXCLUDE_FROM_ALL)
553+
add_target_to_local_jobpool(${sibopt_dependency_target})
547554
set("${dependency_sibopt_target_out_var_name}" "${sibopt_dependency_target}" PARENT_SCOPE)
548555

549556
# This is the target to generate the .sibgen files. It is not built by default.
@@ -561,6 +568,7 @@ function(_compile_swift_files
561568
${obj_dirs_dependency_target}
562569
COMMENT "Generating ${sibgen_file}"
563570
EXCLUDE_FROM_ALL)
571+
add_target_to_local_jobpool(${sibgen_dependency_target})
564572
set("${dependency_sibgen_target_out_var_name}" "${sibgen_dependency_target}" PARENT_SCOPE)
565573
endif()
566574

0 commit comments

Comments
 (0)