Skip to content

Commit

Permalink
Merge pull request #2825 from develop
Browse files Browse the repository at this point in the history
1712.1 release
  • Loading branch information
MSFTFox committed Jan 5, 2018
2 parents db05d76 + 22fb297 commit 04bf9f3
Show file tree
Hide file tree
Showing 46 changed files with 1,403 additions and 113 deletions.
63 changes: 63 additions & 0 deletions Frameworks/CoreFoundation/PlugIn.subproj/CFBundle_Locale.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,10 @@ CF_PRIVATE CFArrayRef _CFBundleCopyUserLanguages() {
static CFArrayRef _CFBundleUserLanguages = NULL;
static dispatch_once_t once = 0;
dispatch_once(&once, ^{
// WINOBJC: __CFAppleLanguages does not exist on Windows
#if DEPLOYMENT_TARGET_WINDOWS
_CFBundleUserLanguages = CFLocaleCopyPreferredLanguages();
#else
CFArrayRef preferencesArray = NULL;
if (__CFAppleLanguages) {
CFDataRef data;
Expand All @@ -555,6 +559,7 @@ CF_PRIVATE CFArrayRef _CFBundleCopyUserLanguages() {
_CFBundleUserLanguages = NULL;
}
if (preferencesArray) CFRelease(preferencesArray);
#endif
});

if (_CFBundleUserLanguages) {
Expand Down Expand Up @@ -663,8 +668,66 @@ static CFStringRef _CFBundleCopyLanguageFoundInLocalizations(CFArrayRef localiza
return NULL;
}

// WINOBJC: Helper functions for workaround in _CFBundleCreateMutableArrayOfFallbackLanguages
static CFStringRef _copyStringTruncated(CFStringRef localization, CFRange cutoff) {
return CFStringCreateWithSubstring(NULL, localization, CFRangeMake(0, cutoff.location));
}

static CFStringRef _copyStringWithUnderscores(CFStringRef localization) {
CFMutableStringRef underscoredString = CFStringCreateMutableCopy(NULL, 0, localization);
CFStringFindAndReplace(underscoredString, CFSTR("-"), CFSTR("_"), CFRangeMake(0, CFStringGetLength(underscoredString)), 0);
return underscoredString;
}

// Given a list of localizations (e.g., provided as argument to API, or present as .lproj directories), return a mutable array of localizations in preferred order. Returns NULL if nothing is found.
static CFMutableArrayRef _CFBundleCreateMutableArrayOfFallbackLanguages(CFArrayRef availableLocalizations, CFArrayRef preferredLocalizations) {
// WINOBJC: The API that performs the work described below does not exist in our 3rd party libraries. ualoc_ is an Apple ICU addition.
#if DEPLOYMENT_TARGET_WINDOWS
// Here we need to intersect the preferred languages with the available localizations
// We know the user languages are in preferred order, add to this list in this order
// Prefer the full language locale, attempt to convert any hyphens to underscores as
// Windows language settings are retrieved with hyphens while underscores are commonly used for localization.
// Finally, attempt to truncate any underscores from the language to find a base localization.
// For example, an english locale will appear as "en-US" and a German locale will appear as "de-DE".
// A localization for "en-US" may be set up as "en-US", "en_US", or even just "en".

CFMutableArrayRef resultArray = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks);

for (CFIndex i = 0, preferredCount = CFArrayGetCount(preferredLocalizations); i < preferredCount; i++) {
CFStringRef preferredLocalization = (CFStringRef)CFArrayGetValueAtIndex(preferredLocalizations, i);
for (CFIndex j = 0, availableCount = CFArrayGetCount(availableLocalizations); j < availableCount; j++) {
CFStringRef availableLocalization = (CFStringRef)CFArrayGetValueAtIndex(availableLocalizations, j);
if(CFStringCompare(preferredLocalization, availableLocalization, 0) == kCFCompareEqualTo) {
CFArrayAppendValue(resultArray, preferredLocalization);
}
CFRange hyphenation;
if (CFStringFindWithOptions(preferredLocalization, CFSTR("-"), CFRangeMake(0, CFStringGetLength(preferredLocalization)), kCFCompareCaseInsensitive, &hyphenation) == true) {
CFStringRef underscoreNotationLocalization = _copyStringWithUnderscores(preferredLocalization);
if (CFStringCompare(underscoreNotationLocalization, availableLocalization, 0) == kCFCompareEqualTo) {
CFArrayAppendValue(resultArray, underscoreNotationLocalization);
}

CFStringRef truncatedLocalization = _copyStringTruncated(underscoreNotationLocalization, hyphenation);
if (CFStringCompare(truncatedLocalization, availableLocalization, 0) == kCFCompareEqualTo) {
CFArrayAppendValue(resultArray, truncatedLocalization);
}

CFRelease(underscoreNotationLocalization);
CFRelease(truncatedLocalization);
} else if (CFStringFindWithOptions(preferredLocalization, CFSTR("_"), CFRangeMake(0, CFStringGetLength(preferredLocalization)), kCFCompareCaseInsensitive, &hyphenation) == true) {
CFStringRef truncatedLocalization = _copyStringTruncated(preferredLocalization, hyphenation);
if (CFStringCompare(truncatedLocalization, availableLocalization, 0) == kCFCompareEqualTo) {
CFArrayAppendValue(resultArray, truncatedLocalization);
}
CFRelease(truncatedLocalization);
}
}
}
if (CFArrayGetCount(resultArray) > 0) {
return resultArray;
}
return NULL;
#endif
// stringPointers must be the length of list
char * (^makeBuffer)(CFArrayRef, char **) = ^(CFArrayRef list, char *stringPointers[]) {
#if !__HAS_APPLE_ICU__
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,11 @@
<ClangCompile Include="$(StarboardBasePath)\tests\unittests\Foundation\WindowsOnly\NSRecursiveLockInternalTests.mm" />
<ClangCompile Include="$(StarboardBasePath)\tests\unittests\Foundation\WindowsOnly\NSPointerArrayInternalTests.mm" />
<ClangCompile Include="$(StarboardBasePath)\tests\unittests\Foundation\WindowsOnly\ArchivalInternalTests.mm" />
<ClangCompile Include="$(StarboardBasePath)\tests\unittests\Foundation\WindowsOnly\BundleInternalTests.mm" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(StarboardBasePath)\tests\unittests\Foundation\RuntimeTestHelpers.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Import Project="$(StarboardBasePath)\common\winobjc.packagereference.override.targets" Condition="Exists('$(StarboardBasePath)\common\winobjc.packagereference.override.targets')" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
<ClangCompile Include="$(StarboardBasePath)\Frameworks\Foundation\NSString+HSTRING.mm" />
<ClangCompile Include="$(StarboardBasePath)\tests\unittests\Foundation\WindowsOnly\ArchivalInternalTests.mm" />
<ClangCompile Include="$(StarboardBasePath)\tests\unittests\Foundation\WindowsOnly\FoundationInternalTests.mm" />
<ClangCompile Include="$(StarboardBasePath)\tests\unittests\Foundation\WindowsOnly\BundleInternalTests.mm" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
<ClangCompile Include="$(StarboardBasePath)\tests\UnitTests\Foundation\NSObject_NSKeyValueSetAdaptersTests.mm" />
<ClangCompile Include="$(StarboardBasePath)\tests\unittests\Foundation\NSUUIDTests.mm" />
<ClangCompile Include="$(StarboardBasePath)\tests\unittests\Foundation\NSNotificationQueueTests.mm" />
<ClangCompile Include="$(StarboardBasePath)\tests\unittests\Foundation\DispatchTests.mm" />
</ItemGroup>
<ItemGroup>
<Text Include="..\..\..\tests\unittests\Foundation\NSFileManagerUT.txt">
Expand Down Expand Up @@ -349,4 +350,4 @@
<Copy SourceFiles="@(ReferenceFoundationTestResourceFile)" DestinationFolder="$(OutDir)" SkipUnchangedFiles="True" />
</Target>
<Import Project="$(StarboardBasePath)\common\winobjc.packagereference.override.targets" Condition="Exists('$(StarboardBasePath)\common\winobjc.packagereference.override.targets')" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
<ClangCompile Include="$(StarboardBasePath)\tests\unittests\Foundation\NSScannerTests.mm" />
<ClangCompile Include="$(StarboardBasePath)\tests\unittests\Foundation\FoundationTests.mm" />
<ClangCompile Include="$(StarboardBasePath)\tests\unittests\Foundation\NSNotificationQueueTests.mm" />
<ClangCompile Include="$(StarboardBasePath)\tests\unittests\Foundation\DispatchTests.mm" />
</ItemGroup>
<ItemGroup>
<Text Include="..\..\..\tests\unittests\Foundation\NSFileManagerUT.txt" />
Expand All @@ -162,4 +163,4 @@
<UniqueIdentifier>{1beaf0a2-ff8a-415b-ac31-aeb41c89f25d}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
</Project>
3 changes: 2 additions & 1 deletion build/Tests/UnitTests/WOCStdLib/WOCStdLib.UnitTests.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@
<ClangCompile Include="..\..\..\..\tests\unittests\WOCStdLib\mach\mach_task_info_test.mm" />
<ClangCompile Include="..\..\..\..\tests\unittests\WOCStdLib\mach\mach_test.mm" />
<ClangCompile Include="..\..\..\..\tests\unittests\WOCStdLib\inettests.mm" />
<ClangCompile Include="..\..\..\..\tests\UnitTests\WOCStdLib\OSSpinLockTest.mm" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Import Project="$(StarboardBasePath)\common\winobjc.packagereference.override.targets" Condition="Exists('$(StarboardBasePath)\common\winobjc.packagereference.override.targets')"/>
<Import Project="$(StarboardBasePath)\common\winobjc.packagereference.override.targets" Condition="Exists('$(StarboardBasePath)\common\winobjc.packagereference.override.targets')" />
</Project>
29 changes: 10 additions & 19 deletions deps/3rdparty/libdispatch/build/libdispatch.vcxproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
Expand Down Expand Up @@ -37,27 +37,27 @@
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
Expand All @@ -82,13 +82,11 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IntDir>$(SolutionDir)obj\$(Platform)\$(TargetOsAndVersion)\$(Configuration)\</IntDir>
<IncludePath>.;$(IncludePath)</IncludePath>

<TargetName>libdispatch</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<IntDir>$(SolutionDir)obj\$(Platform)\$(TargetOsAndVersion)\$(Configuration)\</IntDir>
<IncludePath>.;$(IncludePath)</IncludePath>

<TargetName>libdispatch</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
Expand All @@ -100,13 +98,11 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IntDir>$(SolutionDir)obj\$(Platform)\$(TargetOsAndVersion)\$(Configuration)\</IntDir>
<IncludePath>.;$(IncludePath)</IncludePath>

<TargetName>libdispatch</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<IntDir>$(SolutionDir)obj\$(Platform)\$(TargetOsAndVersion)\$(Configuration)\</IntDir>
<IncludePath>.;$(IncludePath)</IncludePath>

<TargetName>libdispatch</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
Expand Down Expand Up @@ -220,6 +216,7 @@
</ClangCompile>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="project.json" />
<ClangCompile Include="..\platform\windows\libkern\OSAtomic.c" />
<ClangCompile Include="..\platform\windows\platform.c" />
<ClangCompile Include="..\platform\windows\pthread.c" />
Expand Down Expand Up @@ -249,19 +246,13 @@
<ClangCompile Include="..\src\shims\mach.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

<PropertyGroup>
<PrebuiltPath Condition="'$(PrebuiltPath)' == ''">$(WINOBJC_SDK_ROOT)\deps\prebuilt\Universal Windows\$(PlatformTarget)\$(Configuration)\\</PrebuiltPath>
<PrebuiltRoot Condition="'$(PrebuiltRoot)' == ''">$(WINOBJC_SDK_ROOT)\tools\deps\prebuilt\\</PrebuiltRoot>
<PrebuiltPath Condition="'$(PrebuiltPath)' == ''">$(PrebuiltRoot)\Universal Windows\$(PlatformTarget)\$(Configuration)\\</PrebuiltPath>
</PropertyGroup>
<Target Name="CopyContent" AfterTargets="Build">
<Target Name="RemovePackageBinaries" BeforeTargets="Build;Deploy;_CopyFilesMarkedCopyLocal">
<ItemGroup>
<LibraryOutput Include="$(OutDir)\*.lib" />
<LibraryOutput Include="$(OutDir)\*.dll" />
<LibraryOutput Include="$(OutDir)\*.pdb" />
<Headers Include="..\dispatch\*.h" />
<Headers Include="..\src\*.h" />
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" />
</ItemGroup>
<Copy DestinationFolder="$(PrebuiltPath)" SkipUnchangedFiles="True" SourceFiles="@(LibraryOutput)" />
<Copy DestinationFolder="$(WINOBJC_SDK_ROOT)\deps\prebuilt\include\dispatch\\" SkipUnchangedFiles="True" SourceFiles="@(Headers)" />
</Target>
</Project>
16 changes: 16 additions & 0 deletions deps/3rdparty/libdispatch/build/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"dependencies": {
"WinObjC.Language": "*",
},
"frameworks": {
"uap10.0": {
"imports": "native"
}
},
"runtimes": {
"win10-arm": {},
"win10-x86": {},
"win10-arm-aot": {},
"win10-x86-aot": {}
}
}
Loading

0 comments on commit 04bf9f3

Please sign in to comment.