1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

Func and Fift lib for WASM (#455)

* Add social badges

Add telegram, Twitter and Stack Overflow badges in Readme

* update README.md badges

* patch for wasm build

* fix narrowing conversion error for clang compiler

* refactor func code

* funcfift lib implementation

* fix funcfift lib
fix CMakeFile

* fix rvalue missing

* remove unused field from result json

* name fix
remove unused target

* rename

* added script for building funcfiftlib to wasm

* fix json fild names

* fix commit hash for script

* added version function to funcfiftlib

* update commit hash for script

* add realpath fail processing
fix DISABLE_EXCEPTION_CATCHING option

* update hash in script

Co-authored-by: Anthony Tsivarev <tsivarev.a@gmail.com>
Co-authored-by: EmelyanenkoK <emelyanenko.kirill@gmail.com>
Co-authored-by: tolya-yanot <1449561+tolya-yanot@users.noreply.github.com>
This commit is contained in:
AlexeyFSL 2022-09-14 16:36:01 +07:00 committed by GitHub
parent 45e99a5c63
commit e2cca03a78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 491 additions and 163 deletions

View file

@ -179,6 +179,7 @@ set(FUNC_LIB_SOURCE
func/stack-transform.cpp
func/optimize.cpp
func/codegen.cpp
func/func.cpp
)
set(TLB_BLOCK_AUTO
@ -266,6 +267,8 @@ set(BIGINT_TEST_SOURCE
PARENT_SCOPE
)
set(USE_EMSCRIPTEN ${USE_EMSCRIPTEN} PARENT_SCOPE)
add_library(ton_crypto STATIC ${TON_CRYPTO_SOURCE})
target_include_directories(ton_crypto PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
@ -305,13 +308,30 @@ target_include_directories(ton_block PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SO
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/block> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
target_link_libraries(ton_block PUBLIC ton_crypto tdutils tdactor tl_api)
add_executable(func func/func.cpp ${FUNC_LIB_SOURCE})
add_executable(func func/func-main.cpp ${FUNC_LIB_SOURCE})
target_include_directories(func PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
target_link_libraries(func PUBLIC ton_crypto src_parser git ton_block)
if (WINGETOPT_FOUND)
target_link_libraries_system(func wingetopt)
endif()
if (USE_EMSCRIPTEN)
add_executable(funcfiftlib funcfiftlib/funcfiftlib.cpp ${FUNC_LIB_SOURCE})
target_include_directories(funcfiftlib PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
target_link_libraries(funcfiftlib PUBLIC fift-lib src_parser git)
target_link_options(funcfiftlib PRIVATE -sEXPORTED_RUNTIME_METHODS=FS,ccall,cwrap,_malloc,free,UTF8ToString,stringToUTF8)
target_link_options(funcfiftlib PRIVATE -sEXPORTED_FUNCTIONS=_func_compile,_version)
target_link_options(funcfiftlib PRIVATE -sEXPORT_NAME=CompilerModule)
target_link_options(funcfiftlib PRIVATE -sERROR_ON_UNDEFINED_SYMBOLS=0)
target_link_options(funcfiftlib PRIVATE -sFILESYSTEM=1)
target_link_options(funcfiftlib PRIVATE -Oz)
target_link_options(funcfiftlib PRIVATE -sIGNORE_MISSING_MAIN=1)
target_link_options(funcfiftlib PRIVATE -sAUTO_NATIVE_LIBRARIES=0)
target_link_options(funcfiftlib PRIVATE -sMODULARIZE=1)
target_link_options(funcfiftlib PRIVATE --embed-file ${CMAKE_CURRENT_SOURCE_DIR}/fift/lib@/fiftlib)
target_compile_options(funcfiftlib PRIVATE -sDISABLE_EXCEPTION_CATCHING=0)
endif()
add_executable(tlbc tl/tlbc.cpp)
target_include_directories(tlbc PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
target_link_libraries(tlbc PUBLIC ton_crypto src_parser)
@ -337,16 +357,26 @@ if (TON_USE_ASAN AND NOT WIN32)
endif()
file(MAKE_DIRECTORY smartcont/auto)
if (NOT CMAKE_CROSSCOMPILING)
if (NOT CMAKE_CROSSCOMPILING OR USE_EMSCRIPTEN)
set(GENERATE_TLB_CMD tlbc)
add_custom_command(
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/block
COMMAND ${TURN_OFF_LSAN}
COMMAND ${GENERATE_TLB_CMD} -o block-auto -n block::gen -z block.tlb
COMMENT "Generate block tlb source files"
OUTPUT ${TLB_BLOCK_AUTO}
DEPENDS tlbc block/block.tlb
)
if (NOT USE_EMSCRIPTEN)
add_custom_command(
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/block
COMMAND ${TURN_OFF_LSAN}
COMMAND ${GENERATE_TLB_CMD} -o block-auto -n block::gen -z block.tlb
COMMENT "Generate block tlb source files"
OUTPUT ${TLB_BLOCK_AUTO}
DEPENDS tlbc block/block.tlb
)
else()
add_custom_command(
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/block
COMMAND ${TURN_OFF_LSAN}
COMMENT "Generate block tlb source files"
OUTPUT ${TLB_BLOCK_AUTO}
DEPENDS tlbc block/block.tlb
)
endif()
add_custom_target(tlb_generate_block DEPENDS ${TLB_BLOCK_AUTO})
add_dependencies(ton_block tlb_generate_block)