Verified Commit bdf62cf6 authored by nagayama15's avatar nagayama15

feat(cmd): read input wasm files

parent 9266d5db
cmake_minimum_required(VERSION 3.0.0)
set(CMAKE_CXX_FLAGS "-std=c++2a -Wall -Wextra -Werror -pedantic")
set(CMAKE_CXX_FLAGS "-std=c++17 -Wall -Wextra -Werror -pedantic")
set(CMAKE_CXX_FLAGS_DEBUG "-g3 -O0")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g3 -Og")
......
......@@ -4,6 +4,7 @@ add_executable(snpi
target_link_libraries(snpi
cmdline::cmdline
binaryen::binaryen
fmtlib::fmt
)
......@@ -13,5 +14,6 @@ add_executable(pisn
target_link_libraries(pisn
cmdline::cmdline
binaryen::binaryen
fmtlib::fmt
)
#include <fmt/printf.h>
#include "cmdline.h"
#include "wasm-io.h"
namespace {
const std::string program_name = "pisn";
......@@ -37,7 +38,16 @@ int main(int argc, char* argv[]) {
const auto input = options.rest()[0];
const auto method = options.get<std::string>("method");
const auto chunk_size = options.get<std::size_t>("chunk-size");
[[maybe_unused]] const auto chunk_size = options.get<std::size_t>("chunk-size");
(void)chunk_size;
try {
wasm::Module module{};
wasm::ModuleReader{}.read(input, module);
} catch (const std::exception& e) {
fmt::print(std::cerr, "error: {}\n", e.what());
std::exit(EXIT_FAILURE);
} catch (const wasm::ParseException& e) {
e.dump(std::cerr);
std::exit(EXIT_FAILURE);
}
}
#include <fmt/printf.h>
#include "cmdline.h"
#include "wasm-io.h"
namespace {
const std::string program_name = "snpi";
......@@ -39,7 +40,16 @@ int main(int argc, char* argv[]) {
const auto input = options.rest()[0];
const auto output = options.get<std::string>("output");
const auto method = options.get<std::string>("method");
const auto chunk_size = options.get<std::size_t>("chunk-size");
[[maybe_unused]] const auto chunk_size = options.get<std::size_t>("chunk-size");
(void)chunk_size;
try {
wasm::Module module{};
wasm::ModuleReader{}.read(input, module);
} catch (const std::exception& e) {
fmt::print(std::cerr, "error: {}\n", e.what());
std::exit(EXIT_FAILURE);
} catch (const wasm::ParseException& e) {
e.dump(std::cerr);
std::exit(EXIT_FAILURE);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment