Skip to content

Commit

Permalink
Rework how decision to use 'cygpath -w' is made
Browse files Browse the repository at this point in the history
Provide OMR_TOOLCONFIG to GenerateStub.cmake so the decision whether
to use cygpath or not can be made within GenerateStub.cmake.

Signed-off-by: Keith W. Campbell <keithc@ca.ibm.com>
  • Loading branch information
keithc-ca committed Mar 21, 2024
1 parent ecae9e5 commit 0bd1949
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
5 changes: 0 additions & 5 deletions cmake/modules/OmrDDRSupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ function(make_ddr_set set_name)
set(DDR_MACRO_INPUTS_FILE "${DDR_BIN_DIR}/macros.list")
set(DDR_TOOLS_EXPORT "${omr_BINARY_DIR}/ddr/tools/DDRTools.cmake")
set(DDR_CONFIG_STAMP "${DDR_BIN_DIR}/config.stamp")
if((CMAKE_HOST_SYSTEM_NAME STREQUAL "CYGWIN") AND (OMR_TOOLCONFIG STREQUAL "msvc"))
set(PATH_TOOL cygpath -w)
else()
set(PATH_TOOL "")
endif()

# if DDR is not enabled, just skip
# Also skip if we are on a multi config generator since it is unsupported at the moment
Expand Down
9 changes: 1 addition & 8 deletions cmake/modules/ddr/DDRSetStub.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ set(DDR_BLOB "$<TARGET_PROPERTY:@DDR_TARGET_NAME@,BLOB>")
set(DDR_SUPERSET "$<TARGET_PROPERTY:@DDR_TARGET_NAME@,SUPERSET>")
set(DDR_MACRO_LIST "${DDR_INFO_DIR}/sets/@DDR_TARGET_NAME@.macros")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${OMR_MODULES_DIR})
set(PATH_TOOL "@PATH_TOOL@")
set(OBJECT_SEARCH_ROOT "$<TARGET_PROPERTY:@DDR_TARGET_NAME@,DDR_OBJECT_SEARCH_ROOT>")

set(DDR_TARGETS
Expand Down Expand Up @@ -104,12 +103,6 @@ function(process_source_files src_files)
list(APPEND BASE_ARGS "-D${def}")
endforeach()

if(PATH_TOOL)
set(path_tool_opt "-DPATH_TOOL=${PATH_TOOL}")
else()
set(path_tool_opt "")
endif()

foreach(source_file IN LISTS OPT_UNPARSED_ARGUMENTS)
get_filename_component(extension "${source_file}" EXT)
# If source_file isn't a C/C++ file, ignore it.
Expand Down Expand Up @@ -137,9 +130,9 @@ function(process_source_files src_files)
${DDR_SUPPORT_DIR}/GenerateStub.cmake
COMMAND ${CMAKE_COMMAND}
-DAWK_SCRIPT=${DDR_SUPPORT_DIR}/cmake_ddr.awk
-DOMR_TOOLCONFIG=@OMR_TOOLCONFIG@
-Dinput_file=${abs_file}
-Doutput_file=${stub_file}
${path_tool_opt}
-P ${DDR_SUPPORT_DIR}/GenerateStub.cmake
COMMENT ""
VERBATIM
Expand Down
22 changes: 14 additions & 8 deletions cmake/modules/ddr/GenerateStub.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,30 @@ elseif(NOT EXISTS "${input_file}")
message(FATAL_ERROR "Input file '${input_file}' does not exist")
endif()

macro(convert_path output filename)
if(PATH_TOOL)
if(NOT OMR_TOOLCONFIG)
message(FATAL_ERROR "OMR_TOOLCONFIG must be defined")
endif()

if((CMAKE_HOST_SYSTEM_NAME STREQUAL "CYGWIN") AND (OMR_TOOLCONFIG STREQUAL "msvc"))
macro(convert_path output filename)
execute_process(
COMMAND ${PATH_TOOL} "${filename}"
COMMAND cygpath -w "${filename}"
OUTPUT_VARIABLE _converted_path
RESULT_VARIABLE _convert_rc
)
if(NOT _convert_rc EQUAL 0)
message(FATAL_ERROR "Error converting path ${filename}")
endif()

# remove excess whitespace and save into result variable
# Remove excess whitespace and save into result variable.
string(STRIP "${_converted_path}" ${output})
else()
# no defined tool to convert path names, so do nothing
endmacro()
else()
macro(convert_path output filename)
# No need to convert path names, so do nothing.
set(${output} "${filename}")
endif()
endmacro()
endmacro()
endif()

file(WRITE "${output_file}" "/* generated file, DO NOT EDIT */\nconst char ddr_source[] = \"${input_file}\";\n")

Expand Down

0 comments on commit 0bd1949

Please sign in to comment.