Skip to content

[Platform] Unify Linux/FreeBSD modulemaps with gyb #2081

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
Apr 7, 2016
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
22 changes: 15 additions & 7 deletions stdlib/public/Platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ foreach(sdk ${SWIFT_SDKS})
set(arch_subdir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}")
set(module_dir "${SWIFTLIB_DIR}/${arch_subdir}")

set(glibc_modulemap_source "glibc.${SWIFT_SDK_${sdk}_TRIPLE_NAME}.modulemap.in")
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${glibc_modulemap_source}")
set(glibc_modulemap_source "glibc.modulemap.in")
endif()

# Determine the location of glibc headers based on the target.
set(GLIBC_INCLUDE_PATH "/usr/include")
set(GLIBC_ARCH_INCLUDE_PATH ${GLIBC_INCLUDE_PATH})
Expand All @@ -55,11 +50,24 @@ foreach(sdk ${SWIFT_SDKS})

# Configure the module map based on the target. Each platform needs to
# reference different headers, based on what's available in their glibc.
set(glibc_modulemap_gyb_source "glibc.modulemap.in.gyb")
set(glibc_modulemap_gyb_configured
"${CMAKE_CURRENT_BINARY_DIR}/${arch_subdir}/glibc.modulemap.gyb")
configure_file(
${glibc_modulemap_gyb_source}
${glibc_modulemap_gyb_configured}
@ONLY)

set(gyb_tool "${SWIFT_SOURCE_DIR}/utils/gyb")
set(glibc_modulemap_configured
"${CMAKE_CURRENT_BINARY_DIR}/${arch_subdir}/glibc.modulemap")
configure_file(${glibc_modulemap_source} ${glibc_modulemap_configured} @ONLY)

add_custom_command_target(glibc_modulemap_target
# We can't use handle_gyb_sources() here because we need to ensure
# gyb is invoked before we copy glibc.modulemap into the module dir.
# FIXME: Instead of using a combination of configure_file() and gyb,
# we should use just gyb--it'd be simpler.
COMMAND
${gyb_tool} "-DCMAKE_SDK=${sdk}" -o ${glibc_modulemap_configured} ${glibc_modulemap_gyb_configured}
COMMAND
${CMAKE_COMMAND} -E make_directory ${module_dir}
COMMAND
Expand Down
Loading