From 81469d25a4eafb21e482accbcf7a410324a92cdd Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 22 Aug 2019 21:11:59 +0200 Subject: [PATCH] Removed some dependencies and use abseil's flags --- .gitmodules | 9 --------- CMakeLists.txt | 7 ++----- external/cxxopts | 1 - external/gsl-lite | 1 - external/spdlog | 1 - sources/Main.cpp | 19 ++++++++----------- sources/ParserMain.cpp | 23 +++++++++-------------- 7 files changed, 19 insertions(+), 42 deletions(-) delete mode 160000 external/cxxopts delete mode 160000 external/gsl-lite delete mode 160000 external/spdlog diff --git a/.gitmodules b/.gitmodules index b52b5486..092997c3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,24 +1,15 @@ [submodule "external/abseil-cpp"] path = external/abseil-cpp url = https://github.com/abseil/abseil-cpp -[submodule "external/spdlog"] - path = external/spdlog - url = https://github.com/gabime/spdlog [submodule "external/Catch2"] path = external/Catch2 url = https://github.com/catchorg/Catch2 -[submodule "external/cxxopts"] - path = external/cxxopts - url = https://github.com/jarro2783/cxxopts [submodule "external/benchmark"] path = external/benchmark url = https://github.com/google/benchmark [submodule "external/readerwriterqueue"] path = external/readerwriterqueue url = https://github.com/cameron314/readerwriterqueue.git -[submodule "external/gsl-lite"] - path = external/gsl-lite - url = https://github.com/martinmoene/gsl-lite.git [submodule "external/cnpy"] path = external/cnpy url = https://github.com/rogersce/cnpy.git diff --git a/CMakeLists.txt b/CMakeLists.txt index ca59b2e4..1888a744 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,10 +42,7 @@ set(BUILD_TESTING OFF CACHE BOOL "Disable Abseil's tests") set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Disable Google Benchmark tests") set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "Disable Google Benchmark install") add_subdirectory(external/abseil-cpp) -add_subdirectory(external/spdlog) add_subdirectory(external/Catch2) -add_subdirectory(external/cxxopts) -add_subdirectory(external/gsl-lite) add_subdirectory(external/benchmark) add_subdirectory(external/cnpy) @@ -121,7 +118,7 @@ add_executable(sfzprint sources/ParserMain.cpp sources/Opcode.cpp sources/Parser if(UNIX) target_link_libraries(sfzprint stdc++fs) endif(UNIX) -target_link_libraries(sfzprint absl::strings cxxopts) +target_link_libraries(sfzprint absl::strings absl::flags_parse) ############################### @@ -132,7 +129,7 @@ if(UNIX) target_compile_options(sfizz PRIVATE -fno-rtti) target_link_libraries(sfizz stdc++fs) endif(UNIX) -target_link_libraries(sfizz absl::strings cxxopts sndfile absl::flat_hash_map readerwriterqueue) +target_link_libraries(sfizz absl::strings sndfile absl::flat_hash_map readerwriterqueue absl::flags_parse) ############################### # Test application diff --git a/external/cxxopts b/external/cxxopts deleted file mode 160000 index cb60381e..00000000 --- a/external/cxxopts +++ /dev/null @@ -1 +0,0 @@ -Subproject commit cb60381e84df99a4829e3d3c657c06380f916d0f diff --git a/external/gsl-lite b/external/gsl-lite deleted file mode 160000 index 89987ffc..00000000 --- a/external/gsl-lite +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 89987ffc3b6940ad7b7b9c61c5d5beea0bf2f2c0 diff --git a/external/spdlog b/external/spdlog deleted file mode 160000 index 139c0d13..00000000 --- a/external/spdlog +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 139c0d135f303946bd542a9bc2d6b18d6a7415bb diff --git a/sources/Main.cpp b/sources/Main.cpp index 6da852e9..b512dfe4 100644 --- a/sources/Main.cpp +++ b/sources/Main.cpp @@ -1,20 +1,17 @@ #include "Synth.h" #include -#include "cxxopts.hpp" +#include +#include int main(int argc, char** argv) { std::ios::sync_with_stdio(false); - std::vector filesToParse; - cxxopts::Options options("sfzparser", "Parses an sfz file and prints the output"); - options.add_options()("positional", "SFZ files to parse", cxxopts::value>(filesToParse)); - options.parse_positional({"positional"}); - auto result = options.parse(argc, argv); - if (filesToParse.size() == 0) - { - std::cout << options.help() << '\n'; - return -1; - } + auto arguments = absl::ParseCommandLine(argc, argv); + auto filesToParse = absl::MakeConstSpan(arguments).subspan(1); + std::cout << "Positional arguments:"; + for (auto& file: filesToParse) + std::cout << " " << file << ','; + std::cout << '\n'; sfz::Synth synth; std::filesystem::path filename { filesToParse[0] }; diff --git a/sources/ParserMain.cpp b/sources/ParserMain.cpp index d3868645..990487c5 100644 --- a/sources/ParserMain.cpp +++ b/sources/ParserMain.cpp @@ -1,10 +1,9 @@ #include "Parser.h" -#include "cxxopts.hpp" -// #include "spdlog/spdlog.h" #include #include #include - +#include +#include class PrintingParser: public sfz::Parser { @@ -44,17 +43,13 @@ private: int main(int argc, char** argv) { std::ios::sync_with_stdio(false); - std::vector filesToParse; - cxxopts::Options options("sfzparser", "Parses an sfz file and prints the output"); - options.add_options()("positional", "SFZ files to parse", cxxopts::value>(filesToParse)); - options.parse_positional({"positional"}); - auto result = options.parse(argc, argv); - if (filesToParse.size() == 0) - { - std::cout << options.help() << '\n'; - return -1; - } - + auto arguments = absl::ParseCommandLine(argc, argv); + auto filesToParse = absl::MakeConstSpan(arguments).subspan(1); + std::cout << "Positional arguments:"; + for (auto& file: filesToParse) + std::cout << " " << file << ','; + std::cout << '\n'; + PrintingParser parser; std::filesystem::path filename { filesToParse[0] }; parser.loadSfzFile(filename);