Skip to content

[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

Merged
merged 4 commits into from
Jan 19, 2018
Merged

[FHS bundles] Initial implementation. #1395

merged 4 commits into from
Jan 19, 2018

Conversation

millenomi
Copy link
Contributor

This is an implementation that tracks the proposal at #1392.

@millenomi
Copy link
Contributor Author

@swift-ci Please test.

@millenomi
Copy link
Contributor Author

Unable to reproduce on ToT locally. Let's try again.

@swift-ci Please test.

…tests are concerned. Remove the change to the module map.
@millenomi
Copy link
Contributor Author

@swift-ci Please test.

@millenomi
Copy link
Contributor Author

@swift-ci Please test.

#if CFBUNDLE_ALLOW_FHS_BUNDLES
#define _CFBundleFHSDirectory_share CFSTR("share")

CF_INLINE Boolean _CFBundleURLIsForFHSInstalledBundle(CFURLRef bundleURL) {
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

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);

Copy link
Contributor

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
Copy link
Contributor

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.

@millenomi millenomi changed the title Initial implementation of FHS installed and freestanding bundles proposal [FHS bundles] Initial implementation. Jan 18, 2018
 - 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
@millenomi
Copy link
Contributor Author

@swift-ci Please test.

@millenomi
Copy link
Contributor Author

@swift-ci Please test and merge.

@swift-ci swift-ci merged commit bc4a91c into swiftlang:master Jan 19, 2018
@millenomi millenomi deleted the pr/fhs-bundles-impl branch January 19, 2018 21:31
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.

3 participants