Skip to content

Commit 91bc24d

Browse files
committed
Add (non-wprking) cpp-to-wasm test
1 parent f4aa662 commit 91bc24d

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

ffi/cpp/examples/fixeddecimal/Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,12 @@ a.out: ../../../../target/debug/libicu_capi.a $(ALL_HEADERS) test.cpp
2222
build: a.out
2323

2424
test: build
25-
./a.out
25+
./a.out
26+
27+
28+
../../../../target/wasm32-unknown-unknown/debug/libicu_capi.a: $(ALL_RUST)
29+
cargo +nightly build -p icu_capi --target wasm32-unknown-unknown -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort
30+
31+
# Currently this doesn't run successfully, however it's the status quo of compiling ICU4X in C++ to WASM
32+
main.html: ../../../../target/wasm32-unknown-unknown/debug/libicu_capi.a $(ALL_HEADERS) test.cpp
33+
emcc -std=c++17 test.cpp ../../../../target/wasm32-unknown-unknown/debug/libicu_capi.a -ldl -lpthread -lm -DWASM -g -o main.html --emrun -sWASM=1

ffi/cpp/examples/fixeddecimal/test.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@
66

77
#include <iostream>
88

9+
#ifndef WASM
910
const std::string_view path = "../../../../provider/testdata/data/json/";
11+
#endif
1012

1113
int main() {
1214
ICU4XLocale locale = ICU4XLocale::create("bn").value();
1315
std::cout << "Running test for locale " << locale.tostring().ok().value() << std::endl;
16+
#ifdef WASM
17+
ICU4XDataProvider dp = ICU4XDataProvider::create_static().provider.value();
18+
#else
1419
ICU4XDataProvider dp = ICU4XDataProvider::create_fs(path).provider.value();
15-
20+
#endif
1621
ICU4XFixedDecimalFormatOptions opts = {ICU4XFixedDecimalGroupingStrategy::Auto, ICU4XFixedDecimalSignDisplay::Auto};
1722
ICU4XFixedDecimalFormat fdf = ICU4XFixedDecimalFormat::try_new(locale, dp, opts).fdf.value();
1823

0 commit comments

Comments
 (0)