| 2689 | } |
| 2690 | |
| 2691 | void WasmRuntime::buildWaAsync(String fullPath, const std::function<void(String)>& callback) { |
| 2692 | #ifdef DORA_NO_WA |
| 2693 | DORA_UNUSED_PARAM(fullPath); |
| 2694 | Error("Wa build not supported"); |
| 2695 | callback("Wa build not supported"s); |
| 2696 | #else // !DORA_NO_WA |
| 2697 | #if BX_PLATFORM_ANDROID |
| 2698 | if (!_thread) { |
| 2699 | _thread = SharedAsyncThread.newThread(); |
| 2700 | } |
| 2701 | _thread->run([fullPath = fullPath.toString()]() { |
| 2702 | auto result = WaBuild(c_cast<char*>(fullPath.c_str())); |
| 2703 | std::string data = result ? std::string(result) : "Wa build not available"; |
| 2704 | if (result) { |
| 2705 | WaFreeCString(result); |
| 2706 | } |
| 2707 | return Values::alloc(std::move(data)); |
| 2708 | }, |
| 2709 | [callback](Own<Values> values) { |
| 2710 | std::string data; |
| 2711 | values->get(data); |
| 2712 | callback(data); |
| 2713 | }); |
| 2714 | #else // BX_PLATFORM_ANDROID |
| 2715 | if (!_thread) { |
| 2716 | _thread = SharedAsyncThread.newThread(); |
| 2717 | } |
| 2718 | _thread->run([fullPath = fullPath.toString()]() { |
| 2719 | auto result = WaBuild(c_cast<char*>(fullPath.c_str())); |
| 2720 | std::string data = result ? std::string(result) : "Wa build not available"; |
| 2721 | if (result) { |
| 2722 | WaFreeCString(result); |
| 2723 | } |
| 2724 | return Values::alloc(std::move(data)); |
| 2725 | }, |
| 2726 | [callback](Own<Values> values) { |
| 2727 | std::string data; |
| 2728 | values->get(data); |
| 2729 | callback(data); |
| 2730 | }); |
| 2731 | #endif // BX_PLATFORM_ANDROID |
| 2732 | #endif // !DORA_NO_WA |
| 2733 | } |
| 2734 | |
| 2735 | void WasmRuntime::formatWaAsync(String fullPath, const std::function<void(String)>& callback) { |
| 2736 | #ifdef DORA_NO_WA |