Adds EMSCRIPTEN preprocessor definition to libsolidity build & avoid accessing filesystem::current_path() if building for Emscripten.

This commit is contained in:
Christian Parpart 2022-03-14 16:52:33 +01:00
parent ec6f1758c1
commit 3572d52ace
2 changed files with 11 additions and 1 deletions

View File

@ -176,3 +176,7 @@ set(sources
add_library(solidity ${sources})
target_link_libraries(solidity PUBLIC yul evmasm langutil smtutil solutil Boost::boost fmt::fmt-header-only)
if(EMSCRIPTEN)
target_compile_definitions(solidity PRIVATE EMSCRIPTEN=1)
endif()

View File

@ -244,7 +244,13 @@ boost::filesystem::path FileReader::normalizeCLIPathForVFS(
// - Preserves case. Even if the filesystem is case-insensitive but case-preserving and the
// case differs, the actual case from disk is NOT detected.
boost::filesystem::path canonicalWorkDir = boost::filesystem::weakly_canonical(boost::filesystem::current_path());
boost::filesystem::path canonicalWorkDir =
#if defined(EMSCRIPTEN)
boost::filesystem::path("/")
#else
boost::filesystem::weakly_canonical(boost::filesystem::current_path())
#endif
;
// NOTE: On UNIX systems the path returned from current_path() has symlinks resolved while on
// Windows it does not. To get consistent results we resolve them on all platforms.