Skip to content

Add GYB support for Windows #6463

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
merged 1 commit into from
Jan 9, 2017
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
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