Skip to content

[CF] Preliminary support for standalone builds. #2646

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

Closed
wants to merge 2 commits into from

Conversation

3405691582
Copy link
Member

@3405691582 3405691582 commented Feb 4, 2020

This commit makes some preliminary fixes for standalone builds using
cmake. The standalone and Swift builds are similar, except for:

  • the CoreFoundation umbrella header,

  • ForSwiftFoundationOnly.h,

  • CFXMLParser.c and CFXMLNode.c, since these have CFTypeIDs that are
    present in CFRuntime_Internal.h behind DEPLOYMENT_RUNTIME_SWIFT, and

  • CFXMLInterface, since it refers to struct _NSCFXMLBridge, and this is
    defined in ForSwiftFoundationOnly.h.

Not present is a mechanism to refer to Block.h or dependent libraries.

Problems including TargetConditionals.h is dealt with in #2653.

(I'm not well-versed in cmake-speak, so if there's more idiomatic or stylistic ways of doing this, please let me know.)

@3405691582 3405691582 force-pushed the CMakeStandalone branch 2 times, most recently from bdd5169 to d097302 Compare February 5, 2020 00:49
3405691582 added a commit to 3405691582/swift-corelibs-foundation that referenced this pull request Feb 7, 2020
CoreFoundation gets built as a framework.  TargetConditionals.h is a
public header in this framework, so in order for the compiler to find
the header, it has to be referenced through the framework, that is,
<CoreFoundation/TargetConditionals.h>.

In CFBase.h, if we are building standalone (c.f. swiftlang#2646), we are not
DEPLOYMENT_RUNTIME_SWIFT and so we try and look for TargetConditionals.h
with <TargetConditionals.h>. Presumably this is fine on macOS, since
perhaps this is included elsewhere on that system, but on other
platforms this won't be found and we get an error.

But it's actually unnecessary to reference any other
TargetConditionals.h that may be defined elsewhere, because
TargetConditionals.h is part of the CoreFoundation framework. It is then
similarly unnecessary to test for the include, or to fall back on any
other TargetConditionals.h, so just refer to it in the framework
unconditionally. If there are any problems, we get a straightforward
compiler error.
@@ -373,7 +377,8 @@ add_framework(CoreFoundation
URL.subproj/CFURLAccess.c
URL.subproj/CFURL.c
URL.subproj/CFURLComponents.c
URL.subproj/CFURLComponents_URIParser.c)
URL.subproj/CFURLComponents_URIParser.c
${CF_SWIFT_SOURCES})
Copy link
Member

Choose a reason for hiding this comment

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

Please use target_sources for adding the additional source file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

install(TARGETS
CoreFoundation
CFURLSessionInterface
CFXMLInterface
${CF_SWIFT_TARGETS}
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 it may be nicer to just use a property that you append to, rather than doing the variable expansion here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I may be misunderstanding something. Do you mean use set_property() for something? If so, I'm not quite sure how you mean to apply it here.

For the moment, I've pulled out CFXMLInterface into a separate install(), which avoids the variable expansion. Maybe this is better too?

Copy link
Member

Choose a reason for hiding this comment

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

Im basically trying to avoid the whole variable soup that CMake <3.0 used to suffer from. Adding a second install(TARGETS) in an if is another approach.

This commit makes some preliminary fixes for standalone builds using
cmake. The standalone and Swift builds are similar, except for:
  * the CoreFoundation umbrella header,

  * ForSwiftFoundationOnly.h,

  * CFXMLParser.c and CFXMLNode.c, since these have CFTypeIDs that are
    present in CFRuntime_Internal.h behind DEPLOYMENT_RUNTIME_SWIFT, and

  * CFXMLInterface, since it refers to struct _NSCFXMLBridge, and this is
    defined in ForSwiftFoundationOnly.h.

Not present is a mechanism to refer to Block.h or dependent libraries.
@3405691582
Copy link
Member Author

I've also added some indents appropriately where there were missing before.

@spevans
Copy link
Contributor

spevans commented Feb 12, 2020

@swift-ci test linux

@millenomi
Copy link
Contributor

@swift-ci please test

@shahmishal shahmishal closed this Oct 6, 2020
@shahmishal
Copy link
Member

The Swift project moved the default branch to main and deleted master branch, so GitHub automatically closed the PR. Please re-create pull request with main branch.

More detail about the branch update - https://forums.swift.org/t/updating-branch-names/40412

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.

5 participants