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 authored and ksh8281 committed Sep 15, 2023
1 parent 2a2586e commit 3d39641
Show file tree
Hide file tree
Showing 30 changed files with 2,074 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++14 /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++14)
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
23 changes: 23 additions & 0 deletions third_party/wabt/include/string-view-lite/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Loading

0 comments on commit 3d39641

Please sign in to comment.