Skip to content

Commit c99d60e

Browse files
[wasm] Build and install Foundation for Wasm SDK
1 parent 020dde5 commit c99d60e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

utils/swift_build_support/swift_build_support/products/wasmswiftsdk.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,36 @@ def _build_libxml2(self, swift_host_triple, has_pthread, wasi_sysroot):
135135
shell.call([self.toolchain.cmake, '--install', '.', '--prefix', '/', '--component', 'development'],
136136
env={'DESTDIR': wasi_sysroot})
137137

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+
138168
def _build_swift_testing(self, swift_host_triple, has_pthread, wasi_sysroot):
139169
swift_testing = CMakeProduct(
140170
args=self.args,
@@ -182,6 +212,7 @@ def _build_target_package(self, swift_host_triple, has_pthread,
182212
env={'DESTDIR': clang_dir})
183213

184214
self._build_libxml2(swift_host_triple, has_pthread, wasi_sysroot)
215+
self._build_foundation(swift_host_triple, has_pthread, wasi_sysroot)
185216
# Build swift-testing
186217
self._build_swift_testing(swift_host_triple, has_pthread, wasi_sysroot)
187218

0 commit comments

Comments
 (0)