Skip to content

[benchmark][cmake] Move runcmd from AddSwiftBench* => SwiftBenchmarkU… #16833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,6 @@
include(CMakeParseArguments)
include(SwiftBenchmarkUtils)

# Run a shell command and assign output to a variable or fail with an error.
# Example usage:
# runcmd(COMMAND "xcode-select" "-p"
# VARIABLE xcodepath
# ERROR "Unable to find current Xcode path")
function(runcmd)
cmake_parse_arguments(RUNCMD "" "VARIABLE;ERROR" "COMMAND" ${ARGN})
execute_process(
COMMAND ${RUNCMD_COMMAND}
OUTPUT_VARIABLE ${RUNCMD_VARIABLE}
RESULT_VARIABLE result
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT "${result}" MATCHES "0")
message(FATAL_ERROR "${RUNCMD_ERROR}")
endif()
set(${RUNCMD_VARIABLE} ${${RUNCMD_VARIABLE}} PARENT_SCOPE)
endfunction(runcmd)

function (add_swift_benchmark_library objfile_out sibfile_out)
cmake_parse_arguments(BENCHLIB "" "MODULE_PATH;SOURCE_DIR;OBJECT_DIR" "SOURCES;LIBRARY_FLAGS;DEPENDS" ${ARGN})

Expand Down
19 changes: 19 additions & 0 deletions benchmark/cmake/modules/SwiftBenchmarkUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,22 @@ function(translate_flag is_set flag_name var_name)
set("${var_name}" "" PARENT_SCOPE)
endif()
endfunction()


# Run a shell command and assign output to a variable or fail with an error.
# Example usage:
# runcmd(COMMAND "xcode-select" "-p"
# VARIABLE xcodepath
# ERROR "Unable to find current Xcode path")
function(runcmd)
cmake_parse_arguments(RUNCMD "" "VARIABLE;ERROR" "COMMAND" ${ARGN})
execute_process(
COMMAND ${RUNCMD_COMMAND}
OUTPUT_VARIABLE ${RUNCMD_VARIABLE}
RESULT_VARIABLE result
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT "${result}" MATCHES "0")
message(FATAL_ERROR "${RUNCMD_ERROR}")
endif()
set(${RUNCMD_VARIABLE} ${${RUNCMD_VARIABLE}} PARENT_SCOPE)
endfunction(runcmd)