Skip to content

Commit

Permalink
Add GYB support for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
hughbe committed Dec 22, 2016
1 parent 6805ecc commit 3ad0889
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,9 @@ CMakeFiles
# Ignore compile database
#==============================================================================#
compile_commands.json

# Ignore generated GYB files until we fix the workaround on Windows
#==============================================================================#
8
4
SortedCFDatabase.def
1 change: 1 addition & 0 deletions cmake/modules/SwiftAddCustomCommandTarget.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ function(add_custom_command_target dependency_out_var_name)
# CMake doesn't allow '/' characters in filenames, so replace them with '-'
list(GET ACCT_OUTPUT 0 output_filename)
string(REPLACE "${CMAKE_BINARY_DIR}/" "" target_name "${output_filename}")
string(REPLACE "${CMAKE_SOURCE_DIR}/" "" target_name "${target_name}")
string(REPLACE "${CMAKE_CFG_INTDIR}/" "" target_name "${target_name}")
string(REPLACE "/" "-" target_name "${target_name}")
else()
Expand Down
16 changes: 13 additions & 3 deletions cmake/modules/SwiftHandleGybSources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function(handle_gyb_source_single dependency_out_var_name)
COMMAND
"${CMAKE_COMMAND}" -E make_directory "${dir}"
COMMAND
"${gyb_tool}" "${gyb_flags}"
"${PYTHON_EXECUTABLE}" "${gyb_tool}" "${gyb_flags}"
-o "${GYB_SINGLE_OUTPUT}.tmp" "${GYB_SINGLE_SOURCE}"
COMMAND
"${CMAKE_COMMAND}" -E copy_if_different
Expand Down Expand Up @@ -113,10 +113,20 @@ function(handle_gyb_sources dependency_out_var_name sources_var_name arch)
if(src STREQUAL src_sans_gyb)
list(APPEND de_gybbed_sources "${src}")
else()

# On Windows (using Visual Studio), the generated project files assume that the
# generated GYB files will be in the source, not binary directory.
# We can work around this by modifying the root directory when generating VS projects.
if ("${CMAKE_GENERATOR_PLATFORM}" MATCHES "Visual Studio")
set(dir_root ${CMAKE_CURRENT_SOURCE_DIR})
else()
set(dir_root ${CMAKE_CURRENT_BINARY_DIR})
endif()

if (arch)
set(dir "${CMAKE_CURRENT_BINARY_DIR}/${ptr_size}")
set(dir "${dir_root}/${ptr_size}")
else()
set(dir "${CMAKE_CURRENT_BINARY_DIR}")
set(dir "${dir_root}")
endif()
set(output_file_name "${dir}/${src_sans_gyb}")
list(APPEND de_gybbed_sources "${output_file_name}")
Expand Down

0 comments on commit 3ad0889

Please sign in to comment.