1
1
2
2
include (CMakeParseArguments )
3
3
4
+
4
5
# Run a shell command and assign output to a variable or fail with an error.
5
6
# Example usage:
6
7
# runcmd(COMMAND "xcode-select" "-p"
@@ -19,57 +20,6 @@ function(runcmd)
19
20
set (${RUNCMD_VARIABLE} ${${RUNCMD_VARIABLE}} PARENT_SCOPE )
20
21
endfunction (runcmd )
21
22
22
- function (add_swift_benchmark_library objfile_out sibfile_out )
23
- cmake_parse_arguments (BENCHLIB "" "MODULE_PATH;SOURCE_DIR;OBJECT_DIR" "SOURCES;LIBRARY_FLAGS" ${ARGN} )
24
-
25
- precondition (BENCHLIB_MODULE_PATH )
26
- precondition (BENCHLIB_SOURCE_DIR )
27
- precondition (BENCHLIB_OBJECT_DIR )
28
- precondition (BENCHLIB_SOURCES )
29
-
30
- set (module_name_path "${BENCHLIB_MODULE_PATH} " )
31
- get_filename_component (module_name "${module_name_path} " NAME )
32
- set (srcdir "${BENCHLIB_SOURCE_DIR} " )
33
- set (objdir "${BENCHLIB_OBJECT_DIR} " )
34
- set (sources "${BENCHLIB_SOURCES} " )
35
-
36
- set (objfile "${objdir} /${module_name} .o" )
37
- set (swiftmodule "${objdir} /${module_name} .swiftmodule" )
38
-
39
- precondition (objfile_out )
40
- add_custom_command (
41
- OUTPUT "${objfile} "
42
- DEPENDS ${stdlib_dependencies} ${sources}
43
- COMMAND "${SWIFT_EXEC} "
44
- ${BENCHLIB_LIBRARY_FLAGS}
45
- "-force-single-frontend-invocation"
46
- "-parse-as-library"
47
- "-module-name" "${module_name} "
48
- "-emit-module" "-emit-module-path" "${swiftmodule} "
49
- "-o" "${objfile} "
50
- ${sources} )
51
- set (${objfile_out} "${objfile} " PARENT_SCOPE )
52
-
53
- if (SWIFT_BENCHMARK_EMIT_SIB )
54
- precondition (sibfile_out )
55
- set (sibfile "${objdir} /${module_name} .sib" )
56
-
57
- add_custom_command (
58
- OUTPUT "${sibfile} "
59
- DEPENDS
60
- ${stdlib_dependencies} ${sources}
61
- COMMAND "${SWIFT_EXEC} "
62
- ${BENCHLIB_LIBRARY_FLAGS}
63
- "-force-single-frontend-invocation"
64
- "-parse-as-library"
65
- "-module-name" "${module_name} "
66
- "-emit-sib"
67
- "-o" "${sibfile} "
68
- ${sources} )
69
- set (sibfile_out "${sibfile} " PARENT_SCOPE )
70
- endif ()
71
- endfunction ()
72
-
73
23
function (swift_benchmark_compile_archopts )
74
24
cmake_parse_arguments (BENCH_COMPILE_ARCHOPTS "" "PLATFORM;ARCH;OPT" "" ${ARGN} )
75
25
set (sdk ${${BENCH_COMPILE_ARCHOPTS_PLATFORM}_sdk} )
@@ -117,43 +67,84 @@ function (swift_benchmark_compile_archopts)
117
67
set (bench_library_objects )
118
68
set (bench_library_sibfiles )
119
69
foreach (module_name_path ${BENCH_DRIVER_LIBRARY_MODULES} )
120
- set (sources "${srcdir} /${module_name_path} .swift" )
121
-
122
70
get_filename_component (module_name "${module_name_path} " NAME )
71
+
123
72
if ("${module_name} " STREQUAL "DriverUtils" )
124
- list ( APPEND sources "${srcdir} /utils/ArgParse.swift" )
73
+ set ( extra_sources "${srcdir} /utils/ArgParse.swift" )
125
74
endif ()
126
75
127
- set (objfile_out )
128
- set (sibfile_out )
129
- add_swift_benchmark_library (objfile_out sibfile_out
130
- MODULE_PATH "${module_name_path} "
131
- SOURCE_DIR "${srcdir} "
132
- OBJECT_DIR "${objdir} "
133
- SOURCES ${sources}
134
- LIBRARY_FLAGS ${common_options_driver} ${BENCH_DRIVER_LIBRARY_FLAGS} )
135
- precondition (objfile_out )
136
- list (APPEND bench_library_objects "${objfile_out} " )
137
- if (SWIFT_BENCHMARK_EMIT_SIB )
138
- precondition (sibfile_out )
139
- list (APPEND bench_library_sibfiles "${sibfile_out} " )
76
+ set (objfile "${objdir} /${module_name} .o" )
77
+ set (swiftmodule "${objdir} /${module_name} .swiftmodule" )
78
+ list (APPEND bench_library_objects "${objfile} " )
79
+ set (source "${srcdir} /${module_name_path} .swift" )
80
+ add_custom_command (
81
+ OUTPUT "${objfile} "
82
+ DEPENDS ${stdlib_dependencies} "${source} " ${extra_sources}
83
+ COMMAND "${SWIFT_EXEC} "
84
+ ${common_options_driver}
85
+ ${BENCH_DRIVER_LIBRARY_FLAGS}
86
+ "-force-single-frontend-invocation"
87
+ "-parse-as-library"
88
+ "-module-name" "${module_name} "
89
+ "-emit-module" "-emit-module-path" "${swiftmodule} "
90
+ "-o" "${objfile} "
91
+ "${source} " ${extra_sources} )
92
+ if (SWIFT_BENCHMARK_EMIT_SIB )
93
+ set (sibfile "${objdir} /${module_name} .sib" )
94
+ list (APPEND bench_library_sibfiles "${sibfile} " )
95
+ add_custom_command (
96
+ OUTPUT "${sibfile} "
97
+ DEPENDS
98
+ ${stdlib_dependencies} "${srcdir} /${module_name_path} .swift"
99
+ ${extra_sources}
100
+ COMMAND "${SWIFT_EXEC} "
101
+ ${common_options_driver}
102
+ ${BENCH_DRIVER_LIBRARY_FLAGS}
103
+ "-force-single-frontend-invocation"
104
+ "-parse-as-library"
105
+ "-module-name" "${module_name} "
106
+ "-emit-sib"
107
+ "-o" "${sibfile} "
108
+ "${source} " ${extra_sources} )
140
109
endif ()
141
110
endforeach ()
142
111
143
112
foreach (module_name_path ${BENCH_LIBRARY_MODULES} )
144
- set (sources "${srcdir} /${module_name_path} .swift" )
145
-
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} " )
113
+ get_filename_component (module_name "${module_name_path} " NAME )
114
+
115
+ set (objfile "${objdir} /${module_name} .o" )
116
+ set (swiftmodule "${objdir} /${module_name} .swiftmodule" )
117
+ set (source "${srcdir} /${module_name_path} .swift" )
118
+ list (APPEND bench_library_objects "${objfile} " )
119
+ add_custom_command (
120
+ OUTPUT "${objfile} "
121
+ DEPENDS
122
+ ${stdlib_dependencies} "${srcdir} /${module_name_path} .swift"
123
+ ${extra_sources}
124
+ COMMAND "${SWIFT_EXEC} "
125
+ ${common_options}
126
+ "-force-single-frontend-invocation"
127
+ "-parse-as-library"
128
+ "-module-name" "${module_name} "
129
+ "-emit-module" "-emit-module-path" "${swiftmodule} "
130
+ "-o" "${objfile} "
131
+ "${source} " ${extra_sources} )
154
132
if (SWIFT_BENCHMARK_EMIT_SIB )
155
- precondition (sibfile_out )
156
- list (APPEND bench_library_sibfiles "${sibfile_out} " )
133
+ set (sibfile "${objdir} /${module_name} .sib" )
134
+ list (APPEND bench_library_sibfiles "${sibfile} " )
135
+ add_custom_command (
136
+ OUTPUT "${sibfile} "
137
+ DEPENDS
138
+ ${stdlib_dependencies} "${srcdir} /${module_name_path} .swift"
139
+ ${extra_sources}
140
+ COMMAND "${SWIFT_EXEC} "
141
+ ${common_options}
142
+ "-force-single-frontend-invocation"
143
+ "-parse-as-library"
144
+ "-module-name" "${module_name} "
145
+ "-emit-sib"
146
+ "-o" "${sibfile} "
147
+ "${source} " ${extra_sources} )
157
148
endif ()
158
149
endforeach ()
159
150
0 commit comments