Skip to content

Include xcspec resources in the CMake build #488

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

owenv
Copy link
Collaborator

@owenv owenv commented May 5, 2025

Builds on a rebased #243 by @compnerd

  • Add SwiftBuild_Bundle to handle assembly of the resource bundles
  • Move resource bundle access generation inside so it can be shared among all the targets

This adds a helper to bundle files into the resource directory for the
module.
@owenv
Copy link
Collaborator Author

owenv commented May 5, 2025

@swift-ci test

${CMAKE_COMMAND} -E copy_if_different ${BundleXCSpecs_FILES} "${CMAKE_CURRENT_BINARY_DIR}/SwiftBuild_${BundleXCSpecs_MODULE}.resources/")

file(CONFIGURE
OUTPUT resource_bundle_accessor.swift
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the absolute path with the conversion is important. Otherwise, the output location is not very well defined.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you referring to the native path conversion for the path used in the generated code, or the use of a relative path when setting the output for file(CONFIGURE? I restored the former, the latter I thought was ok to remain relative since it's documented to be relative to CMAKE_CURRENT_BINARY_DIR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is documented to be relative to that, and I originally tried to use the relative path but ended up running into some issues. Furthermore, now that it is extracted into a helper, you no longer have a good idea of where CMAKE_CURRENT_BINARY_DIR is pointing to.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, that makes sense to me, thanks. Updated the patch to use an absolute path here and avoid use of CMAKE_CURRENT_BINARY_DIR in general

@owenv owenv force-pushed the owenv/bundling-continued branch from f4c62b0 to ea9d19b Compare May 5, 2025 18:27
- Handle all the remaining xcspecs
- centralize resource accessor generation alongside the bundling
@owenv owenv force-pushed the owenv/bundling-continued branch from ea9d19b to fce47fd Compare May 6, 2025 16:37
@owenv owenv requested a review from compnerd May 6, 2025 16:38
@owenv
Copy link
Collaborator Author

owenv commented May 6, 2025

@swift-ci test

COMMAND
${CMAKE_COMMAND} -E copy_if_different ${BundleXCSpecs_FILES} "${CMAKE_BINARY_DIR}/share/pm/SwiftBuild_${BundleXCSpecs_MODULE}.resources/")

file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/share/pm/SwiftBuild_${BundleXCSpecs_MODULE}.resources" _SWIFT_BUILD_RESOURCE_BUNDLE_BUILD_PATH)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can use $<TARGET_PROEPRTY:${BundleXCSpecs_MODULE},BINARY_DIR> to get the module's binary dir rather than placing this at the top-level.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gave this a try but I was unable to use a generator expression in the output path when creating the resource accessor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants