Skip to content

Commit

Permalink
dispatch: attempt to use a VFS overlay
Browse files Browse the repository at this point in the history
Use a VFS overlay to avoid polluting the source tree.
  • Loading branch information
compnerd committed Apr 1, 2023
1 parent 1848afe commit ed909bb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 26 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@ config
configure
libtool
.dirstamp
/dispatch/module.modulemap
22 changes: 10 additions & 12 deletions dispatch/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@

if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(DISPATCH_MODULE_MAP ${PROJECT_SOURCE_DIR}/dispatch/darwin/module.modulemap)
else()
set(DISPATCH_MODULE_MAP ${PROJECT_SOURCE_DIR}/dispatch/generic/module.modulemap)
endif()
configure_file(dispatch-vfs.yaml.in
${CMAKE_BINARY_DIR}/dispatch-vfs-overlay.yaml
@ONLY)

install(FILES
base.h
block.h
Expand All @@ -16,19 +25,8 @@ install(FILES
DESTINATION
"${INSTALL_DISPATCH_HEADERS_DIR}")
if(ENABLE_SWIFT)
set(base_dir "${CMAKE_CURRENT_SOURCE_DIR}")
if(NOT BUILD_SHARED_LIBS)
set(base_dir "${CMAKE_CURRENT_SOURCE_DIR}/generic_static")
endif()

get_filename_component(
MODULE_MAP
module.modulemap
REALPATH
BASE_DIR "${base_dir}")

install(FILES
${MODULE_MAP}
${DISPATCH_MODULE_MAP}
DESTINATION
"${INSTALL_DISPATCH_HEADERS_DIR}")
endif()
Expand Down
11 changes: 11 additions & 0 deletions dispatch/dispatch-vfs.yaml.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: 0
case-sensitive: false
use-external-names: false
roots:
- name: "@CMAKE_CURRENT_SOURCE_DIR@"
type: directory
contents:
- name: module.modulemap
type: file
external-contents: "@DISPATCH_MODULE_MAP@"
15 changes: 2 additions & 13 deletions src/swift/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,6 @@ target_include_directories(DispatchStubs PRIVATE
set_target_properties(DispatchStubs PROPERTIES
POSITION_INDEPENDENT_CODE YES)


if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/dispatch/module.modulemap
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_SOURCE_DIR}/dispatch/darwin/module.modulemap ${PROJECT_SOURCE_DIR}/dispatch/module.modulemap)
else()
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/dispatch/module.modulemap
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_SOURCE_DIR}/dispatch/generic/module.modulemap ${PROJECT_SOURCE_DIR}/dispatch/module.modulemap)
endif()
add_custom_target(module-map ALL
DEPENDS ${PROJECT_SOURCE_DIR}/dispatch/module.modulemap)


add_library(swiftDispatch
Block.swift
Data.swift
Expand All @@ -45,6 +33,8 @@ target_compile_options(swiftDispatch PRIVATE
"SHELL:-Xcc -fmodule-map-file=${PROJECT_SOURCE_DIR}/dispatch/module.modulemap"
"SHELL:-Xcc -I${PROJECT_SOURCE_DIR}"
"SHELL:-Xcc -I${PROJECT_SOURCE_DIR}/src/swift/shims")
target_compile_options(swiftDispatch PUBLIC
"SHELL:-vfsoverlay ${CMAKE_BINARY_DIR}/dispatch-vfs-overlay.yaml")
set_target_properties(swiftDispatch PROPERTIES
Swift_MODULE_NAME Dispatch
Swift_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/swift
Expand All @@ -54,7 +44,6 @@ target_link_libraries(swiftDispatch PRIVATE
BlocksRuntime::BlocksRuntime)
target_link_libraries(swiftDispatch PUBLIC
dispatch)
add_dependencies(swiftDispatch module-map)

get_swift_host_arch(swift_arch)
install(FILES
Expand Down

0 comments on commit ed909bb

Please sign in to comment.