-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[FHS bundles] Initial implementation. #1395
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
Conversation
@swift-ci Please test. |
Unable to reproduce on ToT locally. Let's try again. @swift-ci Please test. |
…tests are concerned. Remove the change to the module map.
@swift-ci Please test. |
@swift-ci Please test. |
#if CFBUNDLE_ALLOW_FHS_BUNDLES | ||
#define _CFBundleFHSDirectory_share CFSTR("share") | ||
|
||
CF_INLINE Boolean _CFBundleURLIsForFHSInstalledBundle(CFURLRef bundleURL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be static but probably not inlined.
extension && | ||
containingDirectoryName && | ||
CFEqual(extension, _CFBundleSiblingResourceDirectoryExtension) && | ||
CFEqual(containingDirectoryName, _CFBundleFHSDirectory_share); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some style points: in CF we typically don't split conditionals across several lines, but if we do then they should be indented to indicate clearly they are part of previous line.
// <anywhere>/share/<name>.resources | ||
|
||
CFStringRef extension = CFURLCopyPathExtension(bundleURL); | ||
CFURLRef parentURL = CFURLCreateCopyDeletingLastPathComponent(NULL, bundleURL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the implementation of CF itself, we use kCFAllocatorSystemDefault
instead of NULL.
@@ -302,6 +302,9 @@ CFBundleRefNum _CFBundleOpenBundleResourceFork(CFBundleRef bundle); // deprecate | |||
CF_EXPORT | |||
void _CFBundleCloseBundleResourceFork(CFBundleRef bundle); // deprecated in favor of CFBundleCloseBundleResourceMap | |||
|
|||
CF_EXPORT | |||
Boolean _CFBundleSupportsFHSBundles(void); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this will only apply on Linux for Swift, I think this may be better as CF_SWIFT_EXPORT
and located in the ForSwiftFoundationOnly.h
file.
@@ -38,7 +62,22 @@ static CFURLRef _CFBundleCopyExecutableURLRaw(CFURLRef urlPath, CFStringRef exeN | |||
CFURLRef executableURL = NULL; | |||
if (!urlPath || !exeName) return NULL; | |||
|
|||
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI | |||
#if CFBUNDLE_ALLOW_FHS_BUNDLES |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should probably turn this macro into a deployment-style macro, to keep things consistent there. We haven't generally had a lot of success with feature flag style.
- CFBUNDLE_* feature flag is unrolled into its component parts - Enable this feature for all distributions of CF compiled for the Swift runtime (except Windows, because Windows does not heed the FHS and has its own structure). - Fix indentation and typos - _CFBundleSupportsFHSBundles() is only useful for tests and has been moved to ForSwiftFoundationOnly.h - Symbols are now consistently prefixed with _kCF… - Use kCFAllocatorSystemDefault rather than NULL where needed
@swift-ci Please test. |
@swift-ci Please test and merge. |
This is an implementation that tracks the proposal at #1392.