11
11
VERSION = '68_2'
12
12
HASH = '12c3db5966c234c94e7918fb8acc8bd0838edc36a620f3faa788e7ff27b06f1aa431eb117401026e3963622b9323212f444b735d5c9dd3d0b82d772a4834b993'
13
13
14
+ libname_libicu_common = 'libicu_common.a'
15
+ libname_libicu_stubdata = 'libicu_stubdata.a'
16
+ libname_libicu_i18n = 'libicu_i18n.a'
17
+
14
18
15
19
def needed (settings ):
16
20
return settings .USE_ICU
@@ -19,25 +23,64 @@ def needed(settings):
19
23
def get (ports , settings , shared ):
20
24
url = 'https://github.com/unicode-org/icu/releases/download/%s/icu4c-%s-src.zip' % (TAG , VERSION )
21
25
ports .fetch_project ('icu' , url , 'icu' , sha512hash = HASH )
26
+ icu_source_path = os .path .join (ports .get_build_dir (), 'icu' , 'source' )
22
27
23
- def create (final ):
24
- logging .info ('building port: icu' )
25
-
26
- source_path = os .path .join (ports .get_dir (), 'icu' , 'icu' )
27
- dest_path = os .path .join (ports .get_build_dir (), 'icu' )
28
-
28
+ def prepare_build ():
29
+ source_path = os .path .join (ports .get_dir (), 'icu' , 'icu' ) # downloaded icu4c path
30
+ dest_path = os .path .join (ports .get_build_dir (), 'icu' ) # icu build path
31
+ logging .debug (f'preparing for icu build: { source_path } -> { dest_path } ' )
29
32
shutil .rmtree (dest_path , ignore_errors = True )
30
33
shutil .copytree (source_path , dest_path )
31
34
32
- ports .build_port (os .path .join (dest_path , 'source' , 'common' ), final , [os .path .join (dest_path , 'source' , 'common' )], ['-DU_COMMON_IMPLEMENTATION=1' ])
33
-
34
- ports .install_header_dir (os .path .join (dest_path , 'source' , 'common' , 'unicode' ))
35
-
36
- return [shared .Cache .get_lib ('libicuuc.a' , create )]
35
+ def build_lib (lib_output , lib_src , other_includes , build_flags ):
36
+ logging .debug ('building port: icu- ' + lib_output )
37
+
38
+ additional_build_flags = [
39
+ # usage of 'using namespace icu' is deprecated: icu v61
40
+ '-DU_USING_ICU_NAMESPACE=0' ,
41
+ # make explicit inclusion of utf header: ref utf.h
42
+ '-DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1' ,
43
+ # mark UnicodeString constructors explicit : ref unistr.h
44
+ '-DUNISTR_FROM_CHAR_EXPLICIT=explicit' ,
45
+ '-DUNISTR_FROM_STRING_EXPLICIT=explicit' ,
46
+ # generate static
47
+ '-DU_STATIC_IMPLEMENTATION' ,
48
+ # CXXFLAGS
49
+ '-std=c++11'
50
+ ]
51
+ ports .build_port (lib_src , lib_output , other_includes , build_flags + additional_build_flags )
52
+
53
+ # creator for libicu_common
54
+ def create_libicu_common (lib_output ):
55
+ prepare_build ()
56
+ lib_src = os .path .join (icu_source_path , 'common' )
57
+ ports .install_headers (os .path .join (lib_src , 'unicode' ), target = 'unicode' )
58
+ build_lib (lib_output , lib_src , [], ['-DU_COMMON_IMPLEMENTATION=1' ])
59
+
60
+ # creator for libicu_stubdata
61
+ def create_libicu_stubdata (lib_output ):
62
+ lib_src = os .path .join (icu_source_path , 'stubdata' )
63
+ other_includes = [os .path .join (icu_source_path , 'common' )]
64
+ build_lib (lib_output , lib_src , other_includes , [])
65
+
66
+ # creator for libicu_i18n
67
+ def create_libicu_i18n (lib_output ):
68
+ lib_src = os .path .join (icu_source_path , 'i18n' )
69
+ ports .install_headers (os .path .join (lib_src , 'unicode' ), target = 'unicode' )
70
+ other_includes = [os .path .join (icu_source_path , 'common' )]
71
+ build_lib (lib_output , lib_src , other_includes , ['-DU_I18N_IMPLEMENTATION=1' ])
72
+
73
+ return [
74
+ shared .Cache .get_lib (libname_libicu_common , create_libicu_common ), # this also prepares the build
75
+ shared .Cache .get_lib (libname_libicu_stubdata , create_libicu_stubdata ),
76
+ shared .Cache .get_lib (libname_libicu_i18n , create_libicu_i18n )
77
+ ]
37
78
38
79
39
80
def clear (ports , settings , shared ):
40
- shared .Cache .erase_file ('libicuuc.a' )
81
+ shared .Cache .erase_file (libname_libicu_common )
82
+ shared .Cache .erase_file (libname_libicu_stubdata )
83
+ shared .Cache .erase_file (libname_libicu_i18n )
41
84
42
85
43
86
def process_args (ports ):
0 commit comments