@@ -80,6 +80,91 @@ def _append_platform_cmake_options(self, cmake_options, swift_host_triple, has_p
80
80
cmake_options .define ('CMAKE_RANLIB' , os .path .join (
81
81
native_toolchain_path , 'bin' , 'llvm-ranlib' ))
82
82
83
+ def _build_libxml2 (self , swift_host_triple , has_pthread , wasi_sysroot ):
84
+ libxml2 = CMakeProduct (
85
+ args = self .args ,
86
+ toolchain = self .toolchain ,
87
+ source_dir = os .path .join (
88
+ os .path .dirname (self .source_dir ), 'libxml2' ),
89
+ build_dir = os .path .join (self .build_dir , 'libxml2' , swift_host_triple ))
90
+ self ._append_platform_cmake_options (
91
+ libxml2 .cmake_options , swift_host_triple , has_pthread , wasi_sysroot , [])
92
+ libxml2 .cmake_options .define ('LIBXML2_WITH_C14N' , 'FALSE' )
93
+ libxml2 .cmake_options .define ('LIBXML2_WITH_CATALOG' , 'FALSE' )
94
+ libxml2 .cmake_options .define ('LIBXML2_WITH_DEBUG' , 'FALSE' )
95
+ libxml2 .cmake_options .define ('LIBXML2_WITH_DOCB' , 'FALSE' )
96
+ libxml2 .cmake_options .define ('LIBXML2_WITH_FTP' , 'FALSE' )
97
+ libxml2 .cmake_options .define ('LIBXML2_WITH_HTML' , 'FALSE' )
98
+ libxml2 .cmake_options .define ('LIBXML2_WITH_HTTP' , 'FALSE' )
99
+ libxml2 .cmake_options .define ('LIBXML2_WITH_ICONV' , 'FALSE' )
100
+ libxml2 .cmake_options .define ('LIBXML2_WITH_ICU' , 'FALSE' )
101
+ libxml2 .cmake_options .define ('LIBXML2_WITH_ISO8859X' , 'FALSE' )
102
+ libxml2 .cmake_options .define ('LIBXML2_WITH_LEGACY' , 'FALSE' )
103
+ libxml2 .cmake_options .define ('LIBXML2_WITH_LZMA' , 'FALSE' )
104
+ libxml2 .cmake_options .define ('LIBXML2_WITH_MEM_DEBUG' , 'FALSE' )
105
+ libxml2 .cmake_options .define ('LIBXML2_WITH_MODULES' , 'FALSE' )
106
+ libxml2 .cmake_options .define ('LIBXML2_WITH_OUTPUT' , 'TRUE' )
107
+ libxml2 .cmake_options .define ('LIBXML2_WITH_PATTERN' , 'FALSE' )
108
+ libxml2 .cmake_options .define ('LIBXML2_WITH_PROGRAMS' , 'FALSE' )
109
+ libxml2 .cmake_options .define ('LIBXML2_WITH_PUSH' , 'TRUE' )
110
+ libxml2 .cmake_options .define ('LIBXML2_WITH_PYTHON' , 'FALSE' )
111
+ libxml2 .cmake_options .define ('LIBXML2_WITH_READER' , 'FALSE' )
112
+ libxml2 .cmake_options .define ('LIBXML2_WITH_REGEXPS' , 'TRUE' )
113
+ libxml2 .cmake_options .define ('LIBXML2_WITH_RUN_DEBUG' , 'FALSE' )
114
+ libxml2 .cmake_options .define ('LIBXML2_WITH_SAX1' , 'FALSE' )
115
+ libxml2 .cmake_options .define ('LIBXML2_WITH_SCHEMAS' , 'FALSE' )
116
+ libxml2 .cmake_options .define ('LIBXML2_WITH_SCHEMATRON' , 'FALSE' )
117
+ libxml2 .cmake_options .define ('LIBXML2_WITH_TESTS' , 'FALSE' )
118
+ libxml2 .cmake_options .define ('LIBXML2_WITH_TREE' , 'TRUE' )
119
+ libxml2 .cmake_options .define ('LIBXML2_WITH_VALID' , 'TRUE' )
120
+ libxml2 .cmake_options .define ('LIBXML2_WITH_WRITER' , 'FALSE' )
121
+ libxml2 .cmake_options .define ('LIBXML2_WITH_XINCLUDE' , 'FALSE' )
122
+ libxml2 .cmake_options .define ('LIBXML2_WITH_XPATH' , 'TRUE' )
123
+ libxml2 .cmake_options .define ('LIBXML2_WITH_XPTR' , 'FALSE' )
124
+ libxml2 .cmake_options .define ('LIBXML2_WITH_ZLIB' , 'FALSE' )
125
+ libxml2 .cmake_options .define ('BUILD_SHARED_LIBS' , 'FALSE' )
126
+
127
+ cmake_thread_enabled = 'TRUE' if has_pthread else 'FALSE'
128
+ libxml2 .cmake_options .define ('LIBXML2_WITH_THREAD_ALLOC' , cmake_thread_enabled )
129
+ libxml2 .cmake_options .define ('LIBXML2_WITH_THREADS' , cmake_thread_enabled )
130
+ libxml2 .cmake_options .define ('HAVE_PTHREAD_H' , cmake_thread_enabled )
131
+
132
+ libxml2 .build_with_cmake ([], self .args .build_variant , [],
133
+ prefer_native_toolchain = True )
134
+ with shell .pushd (libxml2 .build_dir ):
135
+ shell .call ([self .toolchain .cmake , '--install' , '.' , '--prefix' , '/' , '--component' , 'development' ],
136
+ env = {'DESTDIR' : wasi_sysroot })
137
+
138
+ def _build_foundation (self , swift_host_triple , has_pthread , wasi_sysroot ):
139
+ source_root = os .path .dirname (self .source_dir )
140
+ host_toolchain = self .native_toolchain_path (self .args .host_target )
141
+
142
+ foundation = CMakeProduct (
143
+ args = self .args ,
144
+ toolchain = self .toolchain ,
145
+ source_dir = os .path .join (
146
+ os .path .dirname (self .source_dir ), 'swift-corelibs-foundation' ),
147
+ build_dir = os .path .join (self .build_dir , 'foundation' , swift_host_triple ))
148
+ self ._append_platform_cmake_options (
149
+ foundation .cmake_options , swift_host_triple , has_pthread , wasi_sysroot , [])
150
+ foundation .cmake_options .define ('BUILD_SHARED_LIBS' , 'FALSE' )
151
+ foundation .cmake_options .define ('FOUNDATION_BUILD_TOOLS' , 'FALSE' )
152
+ foundation .cmake_options .define ('_SwiftCollections_SourceDIR' , os .path .join (source_root , 'swift-collections' ))
153
+ foundation .cmake_options .define ('_SwiftFoundation_SourceDIR' , os .path .join (source_root , 'swift-foundation' ))
154
+ foundation .cmake_options .define ('_SwiftFoundationICU_SourceDIR' , os .path .join (source_root , 'swift-foundation-icu' ))
155
+ foundation .cmake_options .define ('SwiftFoundation_MACRO' , os .path .join (host_toolchain , 'lib' , 'swift' , 'host' , 'plugins' ))
156
+
157
+ foundation .cmake_options .define ('LIBXML2_INCLUDE_DIR' , os .path .join (wasi_sysroot , 'include' , 'libxml2' ))
158
+ foundation .cmake_options .define ('LIBXML2_LIBRARY' , os .path .join (wasi_sysroot , 'lib' ))
159
+
160
+ foundation .build_with_cmake ([], self .args .build_variant , [],
161
+ prefer_native_toolchain = True )
162
+
163
+ dest_dir = self ._target_package_path (swift_host_triple )
164
+ with shell .pushd (foundation .build_dir ):
165
+ shell .call ([self .toolchain .cmake , '--install' , '.' , '--prefix' , '/usr' ],
166
+ env = {'DESTDIR' : dest_dir })
167
+
83
168
def _build_swift_testing (self , swift_host_triple , has_pthread , wasi_sysroot ):
84
169
swift_testing = CMakeProduct (
85
170
args = self .args ,
@@ -125,6 +210,9 @@ def _build_target_package(self, swift_host_triple, has_pthread,
125
210
shell .call ([self .toolchain .cmake , '--install' , '.' ,
126
211
'--component' , 'clang_rt.builtins-wasm32' ],
127
212
env = {'DESTDIR' : clang_dir })
213
+
214
+ self ._build_libxml2 (swift_host_triple , has_pthread , wasi_sysroot )
215
+ self ._build_foundation (swift_host_triple , has_pthread , wasi_sysroot )
128
216
# Build swift-testing
129
217
self ._build_swift_testing (swift_host_triple , has_pthread , wasi_sysroot )
130
218
0 commit comments