mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #12749 from ethereum/cmake-refactor-libsolc
[CMake] Refactor libsolc linker flag for EXPORTED_FUNCTIONS and make it more readable.
This commit is contained in:
commit
c6fcb6c395
@ -48,3 +48,11 @@ function(detect_stray_source_files FILELIST DIRECTORY)
|
||||
message(SEND_ERROR "The following source files are present but are not compiled: ${sources}")
|
||||
endif()
|
||||
endfunction(detect_stray_source_files)
|
||||
|
||||
# CreateExportedFunctionsForEMSDK(OUTPUT_VARIABLE Symbol1 Symbol2 ... SymbolN)
|
||||
function(CreateExportedFunctionsForEMSDK OUTPUT_VARIABLE)
|
||||
list(TRANSFORM ARGN PREPEND "\"_")
|
||||
list(TRANSFORM ARGN APPEND "\"")
|
||||
list(JOIN ARGN "," ARGN)
|
||||
set(${OUTPUT_VARIABLE} "[${ARGN}]" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
@ -1,8 +1,17 @@
|
||||
if (EMSCRIPTEN)
|
||||
CreateExportedFunctionsForEMSDK(
|
||||
ExportedFunctions
|
||||
solidity_license
|
||||
solidity_version
|
||||
solidity_compile
|
||||
solidity_alloc
|
||||
solidity_free
|
||||
solidity_reset
|
||||
)
|
||||
# Specify which functions to export in soljson.js.
|
||||
# Note that additional Emscripten-generated methods needed by solc-js are
|
||||
# defined to be exported in cmake/EthCompilerSettings.cmake.
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s EXPORTED_FUNCTIONS='[\"_solidity_license\",\"_solidity_version\",\"_solidity_compile\",\"_solidity_alloc\",\"_solidity_free\",\"_solidity_reset\"]'")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s EXPORTED_FUNCTIONS='${ExportedFunctions}'")
|
||||
add_executable(soljson libsolc.cpp libsolc.h)
|
||||
target_link_libraries(soljson PRIVATE solidity)
|
||||
else()
|
||||
|
Loading…
Reference in New Issue
Block a user