mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Patch funcfiftlib and emulator-emscripten builds (#905)
Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
parent
eb4831d7d6
commit
a4d618b0fc
5 changed files with 43 additions and 30 deletions
|
@ -48,7 +48,7 @@ if (USE_EMSCRIPTEN)
|
|||
add_executable(emulator-emscripten ${EMULATOR_EMSCRIPTEN_SOURCE})
|
||||
target_link_libraries(emulator-emscripten PUBLIC emulator)
|
||||
target_link_options(emulator-emscripten PRIVATE -sEXPORTED_RUNTIME_METHODS=_malloc,free,UTF8ToString,stringToUTF8,allocate,ALLOC_NORMAL,lengthBytesUTF8)
|
||||
target_link_options(emulator-emscripten PRIVATE -sEXPORTED_FUNCTIONS=_emulate,_free,_run_get_method)
|
||||
target_link_options(emulator-emscripten PRIVATE -sEXPORTED_FUNCTIONS=_emulate,_free,_run_get_method,_create_emulator,_destroy_emulator,_emulate_with_emulator)
|
||||
target_link_options(emulator-emscripten PRIVATE -sEXPORT_NAME=EmulatorModule)
|
||||
target_link_options(emulator-emscripten PRIVATE -sERROR_ON_UNDEFINED_SYMBOLS=0)
|
||||
target_link_options(emulator-emscripten PRIVATE -Oz)
|
||||
|
@ -57,6 +57,7 @@ if (USE_EMSCRIPTEN)
|
|||
target_link_options(emulator-emscripten PRIVATE -sMODULARIZE=1)
|
||||
target_link_options(emulator-emscripten PRIVATE -sENVIRONMENT=web)
|
||||
target_link_options(emulator-emscripten PRIVATE -sFILESYSTEM=0)
|
||||
target_link_options(emulator-emscripten PRIVATE -sALLOW_MEMORY_GROWTH=1)
|
||||
target_link_options(emulator-emscripten PRIVATE -fexceptions)
|
||||
if (USE_EMSCRIPTEN_NO_WASM)
|
||||
target_link_options(emulator-emscripten PRIVATE -sWASM=0)
|
||||
|
|
|
@ -124,9 +124,39 @@ td::Result<GetMethodParams> decode_get_method_params(const char* json) {
|
|||
return params;
|
||||
}
|
||||
|
||||
class NoopLog : public td::LogInterface {
|
||||
public:
|
||||
NoopLog() {
|
||||
}
|
||||
|
||||
void append(td::CSlice new_slice, int log_level) override {
|
||||
}
|
||||
|
||||
void rotate() override {
|
||||
}
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
|
||||
const char *emulate(const char *config, const char* libs, int verbosity, const char* account, const char* message, const char* params) {
|
||||
void* create_emulator(const char *config, int verbosity) {
|
||||
NoopLog logger;
|
||||
|
||||
td::log_interface = &logger;
|
||||
|
||||
SET_VERBOSITY_LEVEL(verbosity_NEVER);
|
||||
return transaction_emulator_create(config, verbosity);
|
||||
}
|
||||
|
||||
void destroy_emulator(void* em) {
|
||||
NoopLog logger;
|
||||
|
||||
td::log_interface = &logger;
|
||||
|
||||
SET_VERBOSITY_LEVEL(verbosity_NEVER);
|
||||
transaction_emulator_destroy(em);
|
||||
}
|
||||
|
||||
const char *emulate_with_emulator(void* em, const char* libs, const char* account, const char* message, const char* params) {
|
||||
StringLog logger;
|
||||
|
||||
td::log_interface = &logger;
|
||||
|
@ -138,8 +168,6 @@ const char *emulate(const char *config, const char* libs, int verbosity, const c
|
|||
}
|
||||
auto decoded_params = decoded_params_res.move_as_ok();
|
||||
|
||||
auto em = transaction_emulator_create(config, verbosity);
|
||||
|
||||
bool rand_seed_set = true;
|
||||
if (decoded_params.rand_seed_hex) {
|
||||
rand_seed_set = transaction_emulator_set_rand_seed(em, decoded_params.rand_seed_hex.unwrap().c_str());
|
||||
|
@ -162,8 +190,6 @@ const char *emulate(const char *config, const char* libs, int verbosity, const c
|
|||
result = transaction_emulator_emulate_transaction(em, account, message);
|
||||
}
|
||||
|
||||
transaction_emulator_destroy(em);
|
||||
|
||||
const char* output = nullptr;
|
||||
{
|
||||
td::JsonBuilder jb;
|
||||
|
@ -178,6 +204,13 @@ const char *emulate(const char *config, const char* libs, int verbosity, const c
|
|||
return output;
|
||||
}
|
||||
|
||||
const char *emulate(const char *config, const char* libs, int verbosity, const char* account, const char* message, const char* params) {
|
||||
auto em = transaction_emulator_create(config, verbosity);
|
||||
auto result = emulate_with_emulator(em, libs, account, message, params);
|
||||
transaction_emulator_destroy(em);
|
||||
return result;
|
||||
}
|
||||
|
||||
const char *run_get_method(const char *params, const char* stack, const char* config) {
|
||||
StringLog logger;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue