Skip to content

Commit 74462bc

Browse files
committed
[MERGE #4737 @jackhorton] Support shared builds of Chakra.ICU
Merge pull request #4737 from jackhorton:icu/shared This PR enables Chakra.ICU to be built into DLLs, both for ease of embedding and for internal testing scenarios. I have confirmed that the DLLs produced here work on Windows ~8, including with binaries that linked to Windows Kit ICU in Windows 10. The full workflow for using these binaries with Windows Kit ICU-linked exes: 1) Build host exe targeting RS2+, importing <icu.h>/<icucommon.h>/<icuin.h> from the Windows Kit and linking to icuuc.lib and icuin.lib from System32 1) Copy exe to Windows 8 1) Copy Chakra.ICU.Common.dll, Chakra.ICU.i18n.dll, and Chakra.ICU.Data.dll to the same folder on the Windows 8 machine as the exe 1) Make a copy of Chakra.ICU.Common.dll to icuuc.dll, or symlink it (if thats a thing on Windows 8? I couldn't get it to work on chakrafs, which was my scratchpad here). Do the same for Chakra.ICU.i18n.dll -> icuin.dll 1) With 6 resulting files (exe, 3x Chakra.ICU.dll, icuuc, icuin), the exe should be runnable.
2 parents 5720cdb + a3e07be commit 74462bc

File tree

8 files changed

+46
-5
lines changed

8 files changed

+46
-5
lines changed

Build/Chakra.Build.props

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@
5959
%(PreprocessorDefinitions);
6060
INTL_ICU=1
6161
</PreprocessorDefinitions>
62+
<PreprocessorDefinitions Condition="'$(ChakraICU)'=='static'">
63+
%(PreprocessorDefinitions);
64+
U_STATIC_IMPLEMENTATION=1
65+
</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)
70+
</PreprocessorDefinitions>
6271
<PreprocessorDefinitions Condition="'$(ForceSWB)'=='true'">
6372
%(PreprocessorDefinitions);
6473
GLOBAL_ENABLE_WRITE_BARRIER=1

deps/Chakra.ICU/Chakra.ICU.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
UCONFIG_NO_REGULAR_EXPRESSIONS=1;
1919
UCONFIG_NO_SERVICE=1;
2020
%(PreprocessorDefinitions)
21-
</PreprocessorDefinitions>
21+
</PreprocessorDefinitions>
2222

2323
<!-- Default ICU Configuration (see source\common\common.vcxproj) -->
2424
<!-- Note that we already configure most of what common.vcxproj handles elsewhere -->

deps/Chakra.ICU/Chakra.ICU.Common.vcxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
U_COMMON_IMPLEMENTATION=1
2828
</PreprocessorDefinitions>
2929
</ClCompile>
30+
<Link Condition="'$(ChakraICU)'=='shared'">
31+
<SubSystem>Console</SubSystem>
32+
</Link>
3033
</ItemDefinitionGroup>
3134
<ItemGroup Condition="'$(ChakraICU)'!='false'">
3235
<ClCompile Include="$(IcuCommonSources)" />

deps/Chakra.ICU/Chakra.ICU.Data.vcxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
2222
<GenCCodePath>$(OutBaseDir)\bin\$(PlatformPathName.ToLower())_$(Configuration.ToLower())\Chakra.ICU.GenCCode.exe</GenCCodePath>
2323
</PropertyGroup>
24+
<ItemDefinitionGroup>
25+
<Link Condition="'$(ChakraICU)'=='shared'">
26+
<SubSystem>Console</SubSystem>
27+
<NoEntryPoint>true</NoEntryPoint>
28+
</Link>
29+
</ItemDefinitionGroup>
2430
<ItemGroup Condition="'$(ChakraICU)'!='false'">
2531
<None Include="$(IntDir)icudt$(IcuVersionMajor)l_dat.obj" /> <!-- forces the automagic build system to create a lib from the obj -->
2632
<CustomBuild Include="$(MSBuildThisFileDirectory)source\data\in\icudt$(IcuVersionMajor)l.dat">

deps/Chakra.ICU/Chakra.ICU.Stubdata.vcxproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
<ProjectName>Chakra.ICU.Stubdata</ProjectName>
1010
</PropertyGroup>
1111
<PropertyGroup Label="Configuration">
12-
<ConfigurationType>StaticLibrary</ConfigurationType>
12+
<ConfigurationType Condition="'$(ChakraICU)'!='shared'">StaticLibrary</ConfigurationType>
13+
<ConfigurationType Condition="'$(ChakraICU)'=='shared'">DynamicLibrary</ConfigurationType>
1314
</PropertyGroup>
1415
<Import Project="$(BuildConfigPropsPath)Chakra.Build.Default.props" />
1516
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
@@ -31,6 +32,12 @@
3132
$(IcuSourceDirectory)\common
3233
</AdditionalIncludeDirectories>
3334
</ClCompile>
35+
<Link Condition="'$(ChakraICU)'=='shared'">
36+
<SubSystem>Console</SubSystem>
37+
<!-- Make Chakra.ICU.Stubdata pretend like its Chakra.ICU.Data for linking purposes -->
38+
<OutputFile>$(OutDir)\Chakra.ICU.Data.dll</OutputFile>
39+
<ImportLibrary>$(OutDir)\Chakra.ICU.Data.lib</ImportLibrary>
40+
</Link>
3441
</ItemDefinitionGroup>
3542
<ItemGroup Condition="'$(ChakraICU)'!='false'">
3643
<ClCompile Include="$(IcuStubdataSources)" />

deps/Chakra.ICU/Chakra.ICU.i18n.vcxproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,18 @@
3535
<!-- Some ICU files use embedded UTF-8 -->
3636
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
3737
</ClCompile>
38+
<Link Condition="'$(ChakraICU)'=='shared'">
39+
<SubSystem>Console</SubSystem>
40+
</Link>
3841
</ItemDefinitionGroup>
3942
<ItemGroup Condition="'$(ChakraICU)'!='false'">
4043
<ClCompile Include="$(IcuI18nSources)" />
4144
<ClInclude Include="$(IcuI18nHeaders)" />
4245
<ProjectReference Include="$(MSBuildThisFileDirectory)Chakra.ICU.Stubdata.vcxproj">
4346
<Project>{E14F373D-05A0-4259-A5E9-AFE8405FB847}</Project>
44-
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
47+
</ProjectReference>
48+
<ProjectReference Include="$(MSBuildThisFileDirectory)Chakra.ICU.Common.vcxproj">
49+
<Project>{EE2A3111-4D85-427C-B0AB-E6B0EA7FFB44}</Project>
4550
</ProjectReference>
4651
</ItemGroup>
4752
<Import Project="$(BuildConfigPropsPath)Chakra.Build.targets" Condition="exists('$(BuildConfigPropsPath)Chakra.Build.targets')" />

lib/Common/CommonDefines.h

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

113+
// ICU Configuration
114+
#if defined(HAS_ICU) || defined(HAS_REAL_ICU)
115+
#define U_SHOW_CPLUSPLUS_API 0
116+
// ICU 55 (Ubuntu 16.04 system default) has uloc_toUnicodeLocale* marked as draft, which is required for Intl
117+
#if ICU_VERSION > 56
118+
#define U_DEFAULT_SHOW_DRAFT 0
119+
#define U_HIDE_DRAFT_API 1
120+
#endif
121+
#define U_HIDE_DEPRECATED_API 1
122+
#define U_HIDE_OBSOLETE_API 1
123+
#define U_HIDE_INTERNAL_API 1
124+
#endif
125+
113126
// Language features
114127

115128
#if !defined(CHAKRACORE_LITE) && (defined(_WIN32) || defined(INTL_ICU))

lib/Runtime/PlatformAgnostic/ICU.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
#ifdef WINDOWS10_ICU
99
#include <icu.h>
1010
#else
11-
#define U_STATIC_IMPLEMENTATION 1
12-
#define U_SHOW_CPLUSPLUS_API 0
1311
#include "unicode/ucal.h"
1412
#include "unicode/ucol.h"
1513
#include "unicode/udat.h"

0 commit comments

Comments
 (0)