Skip to content

Commit

Permalink
Replace std::string_view of c++17 with c++11 compatible string-view-lite
Browse files Browse the repository at this point in the history
Signed-off-by: HyukWoo Park <[email protected]>
  • Loading branch information
clover2123 committed Sep 13, 2023
1 parent 2a2586e commit 106bd4c
Show file tree
Hide file tree
Showing 29 changed files with 2,051 additions and 364 deletions.
8 changes: 4 additions & 4 deletions build/target.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ENDIF()

# Default options per compiler
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR ${COMPILER_CLANG_CL})
SET (WALRUS_CXXFLAGS /std:c++17 /fp:strict /Zc:__cplusplus /EHs /source-charset:utf-8 /D_CRT_SECURE_NO_WARNINGS /D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING /wd4244 /wd4267 /wd4805 /wd4018 /wd4172)
SET (WALRUS_CXXFLAGS /std:c++11 /fp:strict /Zc:__cplusplus /EHs /source-charset:utf-8 /D_CRT_SECURE_NO_WARNINGS /D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING /wd4244 /wd4267 /wd4805 /wd4018 /wd4172)
SET (WALRUS_CXXFLAGS_RELEASE /O2 /Oy-)
SET (WALRUS_THIRDPARTY_CFLAGS /D_CRT_SECURE_NO_WARNINGS /Oy- /wd4146 /EHs)
IF (${COMPILER_CLANG_CL})
Expand All @@ -41,7 +41,7 @@ IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR ${COMPILER_CLANG_CL})
SET (WALRUS_CXXFLAGS_SHAREDLIB)
SET (WALRUS_LDFLAGS_SHAREDLIB)
SET (WALRUS_CXXFLAGS_STATICLIB /DWASM_API_EXTERN)
SET (WALRUS_CXXFLAGS_SHELL /DWASM_API_EXTERN /std:c++17)
SET (WALRUS_CXXFLAGS_SHELL /DWASM_API_EXTERN /std:c++11)
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET (WALRUS_CXXFLAGS
${WALRUS_CXXFLAGS}
Expand Down Expand Up @@ -73,7 +73,7 @@ ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET (WALRUS_CXXFLAGS_SHAREDLIB -fPIC)
SET (WALRUS_LDFLAGS_SHAREDLIB -ldl)
SET (WALRUS_CXXFLAGS_STATICLIB -fPIC -DWASM_API_EXTERN=)
SET (WALRUS_CXXFLAGS_SHELL -DWASM_API_EXTERN= -frtti -std=c++17)
SET (WALRUS_CXXFLAGS_SHELL -DWASM_API_EXTERN= -frtti -std=c++11)

ELSEIF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # Clang and AppleClang
SET (WALRUS_CXXFLAGS
Expand Down Expand Up @@ -103,7 +103,7 @@ ELSEIF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # Clang and AppleClang
SET (WALRUS_CXXFLAGS_SHAREDLIB -fPIC)
SET (WALRUS_LDFLAGS_SHAREDLIB -ldl)
SET (WALRUS_CXXFLAGS_STATICLIB -fPIC -DWASM_API_EXTERN=)
SET (WALRUS_CXXFLAGS_SHELL -DWASM_API_EXTERN= -frtti -std=c++17)
SET (WALRUS_CXXFLAGS_SHELL -DWASM_API_EXTERN= -frtti -std=c++11)
ELSE()
MESSAGE (FATAL_ERROR ${CMAKE_CXX_COMPILER_ID} " is Unsupported Compiler")
ENDIF()
Expand Down
15 changes: 9 additions & 6 deletions src/shell/Shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ static void runExports(Store* store, const std::string& filename, const std::vec

static void parseArguments(int argc, char* argv[], ArgParser& argParser)
{
const std::vector<std::string_view> args(argv + 1, argv + argc);
const std::vector<nonstd::string_view> args(argv + 1, argv + argc);

for (auto it = args.begin(); it != args.end(); ++it) {
if (*it == "--run-export") {
Expand All @@ -842,12 +842,15 @@ static void parseArguments(int argc, char* argv[], ArgParser& argParser)
}

std::advance(it, 1);
argParser.exportToRun = *it;
} else if (auto arg = std::string(*it); endsWith(arg, "wat") || endsWith(arg, "wast") || endsWith(arg, "wasm")) {
argParser.fileNames.emplace_back(*it);
argParser.exportToRun = nonstd::to_string(*it);
} else {
fprintf(stderr, "error: unknown argument: %s\n", it->data());
exit(1);
auto arg = nonstd::to_string(*it);
if (endsWith(arg, "wat") || endsWith(arg, "wast") || endsWith(arg, "wasm")) {
argParser.fileNames.emplace_back(*it);
} else {
fprintf(stderr, "error: unknown argument: %s\n", it->data());
exit(1);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion third_party/wabt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ cmake_minimum_required(VERSION 3.1.0)
project(WABT LANGUAGES C CXX VERSION 1.0.30)
include(GNUInstallDirs)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Expand Down
Loading

0 comments on commit 106bd4c

Please sign in to comment.