-
Notifications
You must be signed in to change notification settings - Fork 806
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
Add support for containerURLs through publisher cache folders #2384
Conversation
|
||
#include <COMIncludes.h> | ||
#import <windows.storage.h> | ||
#import <wrl\client.h> |
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.
standardize on /
ComPtr<IStorageItem> storageItem; | ||
RETURN_NULL_IF_FAILED(folder.As(&storageItem)); | ||
|
||
HSTRING folderPath; |
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.
You probably want a HStringReference
here; i think get_Path will return a +1 HSTRING, and you'll leak it.
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.
Ah, spent too much time with CF, got used to Get = 0
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.
You actually want a Wrappers::HString
https://msdn.microsoft.com/en-us/library/hh771141.aspx
HStringReference
is for a reference to an existing string resource to avoid copies.
In reply to: 109047974 [](ancestors = 109047974)
String m_productType; | ||
StringVec m_buildRuleIds; | ||
/* End of serialized values */ | ||
|
||
PBXFileReference* m_productReferencePtr; | ||
BuildRuleList m_buildRulePtrs; | ||
XCConfigurationList* m_nativeBuildConfigurationListPtr; |
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.
XCConfigurationList* [](start = 3, length = 21)
this is fine as a raw ptr? do we not own the config list here?
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.
We do not, it is just a pointer to an object owned by the pbxDoc. Ideally it would be a shared_ptr but that's a lot more fixing than I want to do for this change set.
tools/vsimporter/src/SBProject.cpp
Outdated
extension += | ||
" </PublisherCacheFolders>\n" | ||
" </Extension>\n"; | ||
ret.emplace_back(extension); |
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.
extension [](start = 25, length = 9)
should you std move extension here?
tools/vsimporter/src/SBProject.cpp
Outdated
pDict = boost::any_cast<Plist::dictionary_type>(&pAny); | ||
} catch (const std::exception& e) { | ||
SBLog::error() << e.what() << std::endl; | ||
pDict = nullptr; |
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.
pDict = nullptr; [](start = 12, length = 20)
move this up to the declaration?
|
|
||
static const wchar_t* TAG = L"NSFileManager"; | ||
|
||
using namespace Microsoft::WRL; | ||
using namespace ABI::Windows::Storage; | ||
|
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.
we can get rid of the #ifdef linux code here.
// Dispose of any resources that can be recreated. | ||
} | ||
|
||
- (void)readFile { |
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.
want to add a negative test here trying to read folder2?
tools/vsimporter/src/SBProject.cpp
Outdated
" </PublisherCacheFolders>\n" | ||
" </Extension>\n"; | ||
ret.emplace_back(extension); | ||
} |
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.
Use pugixml for this. See VSTemplateProject.cpp.
@@ -43,6 +43,8 @@ | |||
</Application> | |||
</Applications> | |||
|
|||
$extensions$ |
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.
$extensions$ [](start = 2, length = 12)
Use in combination with pugixml instead
String ret = ""; | ||
buildSettings.getValue("CODE_SIGN_ENTITLEMENTS", ret); | ||
return ret; | ||
} |
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.
SBResourcesBuildPhase.cpp does this simpler. See SBResourcesBuildPhase::writeVCProjectFiles:
String plistPath = bs.second->getValue("INFOPLIST_FILE");
🕐 |
extensionsOutput += " </Extensions>"; | ||
m_params["$extensions$"] = extensionsOutput; | ||
} | ||
} |
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.
You don't seem to be using this function anymore. Revert changes in VSTemplateParameters.cpp/h
Plist::dictionary_type* pDict = nullptr; | ||
boost::any pAny; | ||
try { | ||
Plist::readPlist(entitlementsPath.c_str(), pAny); |
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.
Plist::readPlist(entitlementsPath.c_str(), pAny); [](start = 8, length = 49)
Needs to be relative to xcodeproj or something, not relative to the current dir.
static void insertUrlSchemes(const String& file, const StringSet& schemes) { | ||
// | ||
// Inject registered URL schemes into the AppX manifest file, in this format: | ||
static std::vector<String> getCacheFolders(const String& entitlementsPath) { |
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.
getCacheFolders [](start = 27, length = 15)
return this by ref vs making a copy.
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.
The compiler should elide this copy #ByDesign
SBLog::error() << e.what() << std::endl; | ||
} | ||
|
||
if (pDict) { |
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.
nit: a comment here would be nice
tools/vsimporter/src/SBProject.cpp
Outdated
@@ -16,6 +16,7 @@ | |||
|
|||
#include <iostream> | |||
#include <iterator> | |||
#include <memory> |
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.
Remove unused include
@@ -21,6 +21,8 @@ | |||
#include "PBXBuildRule.h" | |||
#include "PBXObjectIdConvert.h" | |||
#include "VariableCollection.h" | |||
#include "XCBuildConfiguration.h" |
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.
Remove unused includes
tools/vsimporter/include/SBProject.h
Outdated
@@ -67,6 +67,7 @@ class SBProject { | |||
void queryBuildConfigurations(); | |||
void selectBuildConfigurations(const StringSet* configNames); | |||
void getMatchingFiles(fileMatchFunc matchFunc, ConstFileList& ret) const; | |||
std::vector<std::string> SBProject::getPublisherCacheFolderNames() const; |
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.
Remove. This is never defined/used.
The reference platform has a concept of an application-group entitlement which allows apps made by the same publisher to share folders and semaphores. The shared folders can be accessed through
-[NSFileManager containerURLForSecurityApplicationGroupIdentifier:]
which will return an NSURL pointing to the shared folder with the given name if one exists.These folders are declared in an entitlements file separate from the main .pbxproj and info.plist where other settings are stored, and is pointed at by the value with key CODE_SIGN_ENTITLEMENTS in the PBXNativeTarget's Build Configurations.
Here, the shared folders are implemented using Windows' Publisher Cache Folders, which also allow files to be shared in designated folders between apps of the same publisher, but with the caveat that users can clear the data at any time so it should not be used as the sole storage for key data.
VSImporter has been modified to check if CODE_SIGN_ENTITLEMENTS exists, and if it does, read the file and look for com.apple.security.application-groups, which will contain an array of folder names which are to be shared. The reference platform specifies the format which folders must be named, but Publisher Cache Folders does not have such a restriction for names so any valid folder names will be taken and used.
-[NSFileManager containerURLForSecurityApplicationGroupIdentifier:]
is implemented by checking if a Publisher Cache Folder of the given name, and if it does returning an NSURL to it.Fixes #2295
Fixes #2307