Skip to content

Commit a82945e

Browse files
committed
[benchmark][cmake] Refactor the swift benchmark helper libraries to use swift_benchmark_library.
rdar://34556274
1 parent 9175f62 commit a82945e

File tree

1 file changed

+12
-35
lines changed

1 file changed

+12
-35
lines changed

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 12 additions & 35 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"
@@ -142,41 +141,19 @@ function (swift_benchmark_compile_archopts)
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})
164-
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})
146+
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}")
154+
if (SWIFT_BENCHMARK_EMIT_SUB)
155+
precondition(sibfile_out)
156+
list(APPEND bench_library_subfiles "${sibfile_out}")
180157
endif()
181158
endforeach()
182159

0 commit comments

Comments
 (0)