Skip to content

Commit 343274f

Browse files
authored
Merge pull request swiftlang#12031 from gottesmm/more_benchmark_cmake
2 parents f691c5c + 30f4b1b commit 343274f

File tree

1 file changed

+15
-38
lines changed

1 file changed

+15
-38
lines changed

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

22
include(CMakeParseArguments)
33

4-
54
# Run a shell command and assign output to a variable or fail with an error.
65
# Example usage:
76
# runcmd(COMMAND "xcode-select" "-p"
@@ -20,7 +19,7 @@ function(runcmd)
2019
set(${RUNCMD_VARIABLE} ${${RUNCMD_VARIABLE}} PARENT_SCOPE)
2120
endfunction(runcmd)
2221

23-
function (swift_benchmark_library objfile_out sibfile_out)
22+
function (add_swift_benchmark_library objfile_out sibfile_out)
2423
cmake_parse_arguments(BENCHLIB "" "MODULE_PATH;SOURCE_DIR;OBJECT_DIR" "SOURCES;LIBRARY_FLAGS" ${ARGN})
2524

2625
precondition(BENCHLIB_MODULE_PATH)
@@ -127,56 +126,34 @@ function (swift_benchmark_compile_archopts)
127126

128127
set(objfile_out)
129128
set(sibfile_out)
130-
swift_benchmark_library(objfile_out sibfile_out
129+
add_swift_benchmark_library(objfile_out sibfile_out
131130
MODULE_PATH "${module_name_path}"
132131
SOURCE_DIR "${srcdir}"
133132
OBJECT_DIR "${objdir}"
134133
SOURCES ${sources}
135134
LIBRARY_FLAGS ${common_options_driver} ${BENCH_DRIVER_LIBRARY_FLAGS})
136135
precondition(objfile_out)
137136
list(APPEND bench_library_objects "${objfile_out}")
138-
if (SWIFT_BENCHMARK_EMIT_SUB)
137+
if (SWIFT_BENCHMARK_EMIT_SIB)
139138
precondition(sibfile_out)
140-
list(APPEND bench_library_subfiles "${sibfile_out}")
139+
list(APPEND bench_library_sibfiles "${sibfile_out}")
141140
endif()
142141
endforeach()
143142

144143
foreach(module_name_path ${BENCH_LIBRARY_MODULES})
145-
get_filename_component(module_name "${module_name_path}" NAME)
144+
set(sources "${srcdir}/${module_name_path}.swift")
146145

147-
set(objfile "${objdir}/${module_name}.o")
148-
set(swiftmodule "${objdir}/${module_name}.swiftmodule")
149-
set(source "${srcdir}/${module_name_path}.swift")
150-
list(APPEND bench_library_objects "${objfile}")
151-
add_custom_command(
152-
OUTPUT "${objfile}"
153-
DEPENDS
154-
${stdlib_dependencies} "${srcdir}/${module_name_path}.swift"
155-
${extra_sources}
156-
COMMAND "${SWIFT_EXEC}"
157-
${common_options}
158-
"-force-single-frontend-invocation"
159-
"-parse-as-library"
160-
"-module-name" "${module_name}"
161-
"-emit-module" "-emit-module-path" "${swiftmodule}"
162-
"-o" "${objfile}"
163-
"${source}" ${extra_sources})
146+
add_swift_benchmark_library(objfile_out sibfile_out
147+
MODULE_PATH "${module_name_path}"
148+
SOURCE_DIR "${srcdir}"
149+
OBJECT_DIR "${objdir}"
150+
SOURCES ${sources}
151+
LIBRARY_FLAGS ${common_options})
152+
precondition(objfile_out)
153+
list(APPEND bench_library_objects "${objfile_out}")
164154
if (SWIFT_BENCHMARK_EMIT_SIB)
165-
set(sibfile "${objdir}/${module_name}.sib")
166-
list(APPEND bench_library_sibfiles "${sibfile}")
167-
add_custom_command(
168-
OUTPUT "${sibfile}"
169-
DEPENDS
170-
${stdlib_dependencies} "${srcdir}/${module_name_path}.swift"
171-
${extra_sources}
172-
COMMAND "${SWIFT_EXEC}"
173-
${common_options}
174-
"-force-single-frontend-invocation"
175-
"-parse-as-library"
176-
"-module-name" "${module_name}"
177-
"-emit-sib"
178-
"-o" "${sibfile}"
179-
"${source}" ${extra_sources})
155+
precondition(sibfile_out)
156+
list(APPEND bench_library_sibfiles "${sibfile_out}")
180157
endif()
181158
endforeach()
182159

0 commit comments

Comments
 (0)