From 0764fb724e482514181048d993b40644c3b52221 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sun, 2 Mar 2025 16:22:49 -0800 Subject: [PATCH] build: attempt to bundle files for the modules This adds a helper to bundle files into the resource directory for the module. --- Sources/CMakeLists.txt | 15 +++++++++++++++ Sources/SWBAndroidPlatform/CMakeLists.txt | 2 ++ Sources/SWBGenericUnixPlatform/CMakeLists.txt | 5 +++++ Sources/SWBQNXPlatform/CMakeLists.txt | 4 ++++ Sources/SWBWebAssemblyPlatform/CMakeLists.txt | 5 +++++ Sources/SWBWindowsPlatform/CMakeLists.txt | 5 +++++ 6 files changed, 36 insertions(+) diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 6c2fd9d4..f7c5d63d 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -8,6 +8,21 @@ See http://swift.org/LICENSE.txt for license information See http://swift.org/CONTRIBUTORS.txt for Swift project authors ]] +include(CMakeParseArguments) +function(SwiftBuild_Bundle) + set(Options) + set(OneValueArguments MODULE) + set(MultiValueArguments FILES) + cmake_parse_arguments(PARSE_ARGV 0 BundleXCSpecs + "${Options}" "${OneValueArguments}" "${MultiValueArguments}") + + add_custom_command(TARGET ${BundleXCSpecs_MODULE} POST_BUILD + COMMAND + ${CMAKE_COMMAND} -E make_directory "$/SwiftBuild_${BundleXCSpecs_MODULE}.resources" + COMMAND + ${CMAKE_COMMAND} -E copy_if_different ${BundleXCSpecs_FILES} "$/SwiftBuild_${BundleXCSpecs_MODULE}.resources/") +endfunction() + add_subdirectory(SWBCSupport) add_subdirectory(SWBCLibc) add_subdirectory(SWBLibc) diff --git a/Sources/SWBAndroidPlatform/CMakeLists.txt b/Sources/SWBAndroidPlatform/CMakeLists.txt index e2f2faae..e10823c4 100644 --- a/Sources/SWBAndroidPlatform/CMakeLists.txt +++ b/Sources/SWBAndroidPlatform/CMakeLists.txt @@ -37,3 +37,5 @@ target_link_libraries(SWBAndroidPlatform PUBLIC SWBUtil) target_sources(SWBAndroidPlatform PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/resource_bundle_accessor.swift") +SwiftBuild_Bundle(MODULE SWBAndroidPlatform FILES + Android.xcspec) diff --git a/Sources/SWBGenericUnixPlatform/CMakeLists.txt b/Sources/SWBGenericUnixPlatform/CMakeLists.txt index 8e5213b8..2281bef2 100644 --- a/Sources/SWBGenericUnixPlatform/CMakeLists.txt +++ b/Sources/SWBGenericUnixPlatform/CMakeLists.txt @@ -35,3 +35,8 @@ target_link_libraries(SWBGenericUnixPlatform PUBLIC SWBUtil) target_sources(SWBGenericUnixPlatform PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/resource_bundle_accessor.swift") +SwiftBuild_Bundle(MODULE SWBGenericUnixPlatform FILES + Unix.xcspec + UnixCompile.xcspec + UnixLd.xcspec + UnixLibtool.xcspec) diff --git a/Sources/SWBQNXPlatform/CMakeLists.txt b/Sources/SWBQNXPlatform/CMakeLists.txt index b458f8ce..2b4b41fd 100644 --- a/Sources/SWBQNXPlatform/CMakeLists.txt +++ b/Sources/SWBQNXPlatform/CMakeLists.txt @@ -37,3 +37,7 @@ target_link_libraries(SWBQNXPlatform PUBLIC SWBUtil) target_sources(SWBQNXPlatform PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/resource_bundle_accessor.swift") +SwiftBuild_Bundle(MODULE SWBQNXPlatform FILES + QNX.xcspec + QNXCompile.xcspec + QNXLibtool.xcspec) diff --git a/Sources/SWBWebAssemblyPlatform/CMakeLists.txt b/Sources/SWBWebAssemblyPlatform/CMakeLists.txt index 8953a5aa..27756644 100644 --- a/Sources/SWBWebAssemblyPlatform/CMakeLists.txt +++ b/Sources/SWBWebAssemblyPlatform/CMakeLists.txt @@ -36,3 +36,8 @@ target_link_libraries(SWBWebAssemblyPlatform PUBLIC SWBUtil) target_sources(SWBWebAssemblyPlatform PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/resource_bundle_accessor.swift") +SwiftBuild_Bundle(MODULE SWBWebAssemblyPlatform FILES + WasmCompile.xcspec + WasmLd.xcspec + WasmLibtool.xcspec + WebAssembly.xcspec) diff --git a/Sources/SWBWindowsPlatform/CMakeLists.txt b/Sources/SWBWindowsPlatform/CMakeLists.txt index 79e016d4..a6164029 100644 --- a/Sources/SWBWindowsPlatform/CMakeLists.txt +++ b/Sources/SWBWindowsPlatform/CMakeLists.txt @@ -38,3 +38,8 @@ target_link_libraries(SWBWindowsPlatform PUBLIC SWBUtil) target_sources(SWBWindowsPlatform PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/resource_bundle_accessor.swift") +SwiftBuild_Bundle(MODULE SWBWindowsPlatform FILES + Windows.xcspec + WindowsCompile.xcspec + WindowsLd.xcspec + WindowsLibtool.xcspec)