Skip to content

Commit 9189a4b

Browse files
committed
[MERGE chakra-core#4766 @jackhorton] Allow ChakraFull to build with Windows Kit ICU
Merge pull request chakra-core#4766 from jackhorton:icu/windows-kit
2 parents 99918dc + b30c7a5 commit 9189a4b

13 files changed

Lines changed: 70 additions & 41 deletions

Build/Chakra.Build.props

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,14 @@
2525
<!-- ARM does not support ICU until we figure out how to link icudtXXl.dat without genccode.exe -->
2626
<ChakraICU Condition="'$(Platform)'=='ARM'">false</ChakraICU>
2727

28+
<WindowsICU Condition="'$(WindowsICU)'==''">false</WindowsICU>
29+
2830
<UseICU Condition="'$(UseICU)'==''">false</UseICU>
2931
<UseICU Condition="'$(BuildLite)'=='true'">false</UseICU>
30-
<UseICU Condition="'$(ChakraICU)'!='false'">true</UseICU>
32+
<UseICU Condition="'$(ChakraICU)'!='false' OR '$(WindowsICU)'=='true'">true</UseICU>
33+
</PropertyGroup>
34+
<PropertyGroup Condition="'$(WindowsICU)'=='true'">
35+
<IcuLibraryDependencies>icuuc.lib;icuin.lib</IcuLibraryDependencies>
3136
</PropertyGroup>
3237
<Import Condition="'$(ChakraICU)'!='false' AND exists('$(ChakraCoreRootDirectory)deps\Chakra.ICU\Chakra.ICU.props')" Project="$(ChakraCoreRootDirectory)deps\Chakra.ICU\Chakra.ICU.props" />
3338
<ItemDefinitionGroup>
@@ -53,7 +58,8 @@
5358
</PreprocessorDefinitions>
5459
<PreprocessorDefinitions Condition="'$(UseICU)'=='true'">
5560
%(PreprocessorDefinitions);
56-
HAS_ICU
61+
HAS_ICU;
62+
U_DISABLE_RENAMING=1; <!-- Disable renaming to maintain compatibility with Windows Kit ICU's icuuc/icuin.lib -->
5763
</PreprocessorDefinitions>
5864
<PreprocessorDefinitions Condition="'$(EnableIntl)'=='true' AND '$(UseICU)'=='true'">
5965
%(PreprocessorDefinitions);
@@ -63,10 +69,13 @@
6369
%(PreprocessorDefinitions);
6470
U_STATIC_IMPLEMENTATION=1
6571
</PreprocessorDefinitions>
66-
<PreprocessorDefinitions Condition="'$(UseICU)'=='true'">
67-
U_DISABLE_RENAMING=1; <!-- Disable renaming to maintain compatibility with Windows Kit ICU's icuuc/icuin.lib -->
68-
ICU_VERSION=$(IcuVersionMajor);
69-
%(PreprocessorDefinitions)
72+
<PreprocessorDefinitions Condition="'$(WindowsICU)'=='true'">
73+
%(PreprocessorDefinitions);
74+
WINDOWS10_ICU
75+
</PreprocessorDefinitions>
76+
<PreprocessorDefinitions Condition="'$(WindowsICU)'=='false'">
77+
%(PreprocessorDefinitions);
78+
ICU_VERSION=$(IcuVersionMajor)
7079
</PreprocessorDefinitions>
7180
<PreprocessorDefinitions Condition="'$(ForceSWB)'=='true'">
7281
%(PreprocessorDefinitions);
@@ -78,7 +87,7 @@
7887
%(DisableSpecificWarnings);
7988
4458; <!-- declaration of '' hides class member -->
8089
4312; <!-- 'type cast': conversion from '' to '' of greater size -->
81-
4800; <!-- type' : forcing value to bool 'true' or 'false' (performance warning) [always off in 2017 by default, but warns in 2015 -->
90+
4800; <!-- 'type' : forcing value to bool 'true' or 'false' (performance warning) [always off in 2017 by default, but warns in 2015] -->
8291
</DisableSpecificWarnings>
8392
<!-- Use the debug CRT in debug build -->
8493
<RuntimeLibrary Condition="'$(Configuration)'=='Debug' AND '$(RuntimeLib)'!='static_library'">MultiThreadedDebugDLL</RuntimeLibrary>

bin/ChakraCore/ChakraCore.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
$(ChakraCommonLinkDependencies)
5454
</AdditionalDependencies>
5555
<AdditionalDependencies Condition="'$(UseICU)'=='true' AND '$(ChakraICU)'=='false'">
56-
$(IcuLibraryDependencies)
56+
$(IcuLibraryDependencies);
5757
%(AdditionalDependencies)
5858
</AdditionalDependencies>
5959
<DelayLoadDLLs>%(DelayLoadDLLs);oleaut32.dll</DelayLoadDLLs>

bin/ch/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ else() # // shared library below
9191
PRIVATE Chakra.Common.Codex.Singular
9292
PRIVATE Chakra.Runtime.PlatformAgnostic.Singular
9393
)
94+
95+
# Link explicitly to ICU to support u_getVersion
96+
set(lib_target ${lib_target} ${ICU_LIBRARIES})
9497
endif()
9598

9699
if(CC_TARGET_OS_ANDROID OR CC_TARGET_OS_LINUX)

bin/ch/WScriptJsrt.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,11 @@ bool WScriptJsrt::Initialize()
909909
#else
910910
const char* LINK_TYPE = "shared";
911911
#endif
912+
#ifdef HAS_ICU
913+
int icuVersion = PlatformAgnostic::ICUHelpers::GetICUMajorVersion();
914+
#else
915+
int icuVersion = -1;
916+
#endif
912917

913918
JsValueRef wscript;
914919
IfJsrtErrorFail(ChakraRTInterface::JsCreateObject(&wscript), false);
@@ -1005,7 +1010,7 @@ bool WScriptJsrt::Initialize()
10051010
JsPropertyIdRef icuVersionProp;
10061011
IfJsrtErrorFail(CreatePropertyIdFromString("ICU_VERSION", &icuVersionProp), false);
10071012
JsValueRef icuVersionNum;
1008-
IfJsrtErrorFail(ChakraRTInterface::JsIntToNumber(ICU_VERSION, &icuVersionNum), false);
1013+
IfJsrtErrorFail(ChakraRTInterface::JsIntToNumber(icuVersion, &icuVersionNum), false);
10091014
IfJsrtErrorFail(ChakraRTInterface::JsSetProperty(platformObject, icuVersionProp, icuVersionNum, true), false);
10101015

10111016
IfJsrtErrorFail(ChakraRTInterface::JsSetProperty(wscript, platformProperty,

bin/ch/ch.vcxproj

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
$(IntDir);
2828
%(AdditionalIncludeDirectories);
2929
</AdditionalIncludeDirectories>
30+
<!-- For ChakraICU.h -->
31+
<AdditionalIncludeDirectories Condition="'$(UseICU)'=='true'">
32+
$(ChakraCoreRootDirectory)lib\Runtime;
33+
%(AdditionalIncludeDirectories)
34+
</AdditionalIncludeDirectories>
3035
</ClCompile>
3136
<Link>
3237
<ModuleDefinitionFile>ch.def</ModuleDefinitionFile>
@@ -39,6 +44,10 @@
3944
Rpcrt4.lib;
4045
version.lib;
4146
</AdditionalDependencies>
47+
<AdditionalDependencies Condition="'$(UseICU)'=='true' AND '$(ChakraICU)'=='false'">
48+
$(IcuLibraryDependencies);
49+
%(AdditionalDependencies)
50+
</AdditionalDependencies>
4251
</Link>
4352
</ItemDefinitionGroup>
4453
<ItemGroup>
@@ -88,6 +97,10 @@
8897
<ProjectReference Include="..\ChakraCore\ChakraCore.vcxproj">
8998
<Project>{EA882C8D-81FC-42FE-ABD5-2666DB933FDB}</Project>
9099
</ProjectReference>
100+
<!-- for u_getVersion() referenced in PlatformAgnostic::ICUHelpers::GetICUMajorVersion -->
101+
<ProjectReference Condition="'$(ChakraICU)'!='false'" Include="..\..\deps\Chakra.ICU\Chakra.ICU.Common.vcxproj">
102+
<Project>{EE2A3111-4D85-427C-B0AB-E6B0EA7FFB44}</Project>
103+
</ProjectReference>
91104
</ItemGroup>
92105
<ItemGroup>
93106
<None Include="262.js" />
@@ -106,4 +119,4 @@
106119
</ItemGroup>
107120
<Import Project="$(BuildConfigPropsPath)Chakra.Build.targets" Condition="exists('$(BuildConfigPropsPath)Chakra.Build.targets')" />
108121
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
109-
</Project>
122+
</Project>

bin/ch/stdafx.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ using utf8::WideStringToNarrowDynamic;
8888
#include "Helpers.h"
8989

9090
#include "PlatformAgnostic/SystemInfo.h"
91+
#ifdef HAS_ICU
92+
#include "PlatformAgnostic/ChakraICU.h"
93+
#endif
9194

9295
#define IfJsErrorFailLog(expr) \
9396
do { \

lib/Common/CommonDefines.h

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -110,21 +110,14 @@
110110
#define ENABLE_UNICODE_API 1 // Enable use of Unicode-related APIs
111111
#endif
112112

113-
// Normalize ICU_VERSION which is set by the build system on Windows
114-
// because U_ICU_VERSION_MAJOR_NUM is not available in Windows Kit ICU
115-
#if defined(HAS_ICU) && !defined(ICU_VERSION)
116-
#ifndef WINDOWS10_ICU
113+
// Normalize ICU_VERSION for non-Kit ICU
114+
#if defined(HAS_ICU) && !defined(ICU_VERSION) && !defined(WINDOWS10_ICU)
117115
#include "unicode/uvernum.h"
118116
#define ICU_VERSION U_ICU_VERSION_MAJOR_NUM
119-
#else
120-
#error "No ICU version information"
121-
#endif
122-
#else
123-
#define ICU_VERSION -1
124117
#endif
125118

126-
// ICU Configuration
127-
#if defined(HAS_ICU) || defined(HAS_REAL_ICU)
119+
// Make non-Windows Kit ICU look and act like Windows Kit ICU for better compat
120+
#if defined(HAS_ICU) && !defined(WINDOWS10_ICU)
128121
#define U_SHOW_CPLUSPLUS_API 0
129122
// ICU 55 (Ubuntu 16.04 system default) has uloc_toUnicodeLocale* marked as draft, which is required for Intl
130123
#if ICU_VERSION > 56
@@ -137,19 +130,12 @@
137130
#endif
138131

139132
// Language features
140-
141133
#if !defined(CHAKRACORE_LITE) && (defined(_WIN32) || defined(INTL_ICU))
142134
#define ENABLE_INTL_OBJECT // Intl support
143135
#define ENABLE_JS_BUILTINS // Built In functions support
144136
#endif
145-
//#define INTL_ICU 1 // NOTE: uncomment this to allow the IDE to see INTL_ICU blocks
146-
#ifdef INTL_ICU
147-
#ifdef DBG
148-
//#define INTL_ICU_DEBUG 1 // NOTE: uncomment this to display INTL_ICU-specific debug output
149-
#endif
150-
//#define INTL_ICU_ALLOW_HYBRID 1 // NOTE: uncomment this line to test INTL_ICU SxS with INTL_WINGLOB while INTL_ICU is in-development
151-
#endif
152-
#if defined(_WIN32) && (!defined(INTL_ICU) || (defined(INTL_ICU) && defined(INTL_ICU_ALLOW_HYBRID)))
137+
138+
#if defined(_WIN32) && !defined(HAS_ICU)
153139
#define INTL_WINGLOB 1
154140
#endif
155141

lib/Runtime/Library/IntlEngineInterfaceExtensionObject.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ using namespace Windows::Globalization;
2020

2121
#ifdef INTL_ICU
2222
#include <CommonPal.h>
23-
#include "PlatformAgnostic/ICU.h"
23+
#include "PlatformAgnostic/ChakraICU.h"
2424
using namespace PlatformAgnostic::ICUHelpers;
2525

2626
template<typename ICUFunc>
@@ -2212,7 +2212,7 @@ namespace Js
22122212

22132213
// status can be U_UNSUPPORTED_ERROR if the calendar isn't gregorian, which
22142214
// there does not seem to be a way to check for ahead of time in the C API
2215-
AssertOrFailFastMsg(U_SUCCESS(status) || status == U_UNSUPPORTED_ERROR, u_errorName(status));
2215+
AssertOrFailFastMsg(U_SUCCESS(status) || status == U_UNSUPPORTED_ERROR, ICU_ERRORMESSAGE(status));
22162216

22172217
// cache dtf for later use (so that the condition that brought us here returns true for future calls)
22182218
state->SetInternalProperty(

lib/Runtime/PlatformAgnostic/Chakra.Runtime.PlatformAgnostic.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<ClInclude Include="PerfTrace.h" />
5858
<ClInclude Include="RuntimePlatformAgnosticPch.h" />
5959
<ClInclude Include="UnicodeText.h" />
60-
<ClInclude Include="ICU.h" Condition="'$(UseICU)'=='true'" />
60+
<ClInclude Include="ChakraICU.h" Condition="'$(UseICU)'=='true'" />
6161
</ItemGroup>
6262
<ItemGroup>
6363
<ProjectReference Include="..\..\JITIDL\Chakra.JITIDL.vcxproj">

lib/Runtime/PlatformAgnostic/Chakra.Runtime.PlatformAgnostic.vcxproj.filters

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@
3434
<ClInclude Include="IPlatformAgnosticResource.h">
3535
<Filter>Interfaces</Filter>
3636
</ClInclude>
37-
<ClInclude Include="ICU.h">
38-
<Filter>Interfaces</Filter>
39-
</ClInclude>
40-
<ClInclude Include="Intl.h">
37+
<ClInclude Include="ChakraICU.h">
4138
<Filter>Interfaces</Filter>
4239
</ClInclude>
4340
</ItemGroup>

0 commit comments

Comments
 (0)