From 3ff2b1f056fec09557410fbe5298c3366659628a Mon Sep 17 00:00:00 2001 From: Daniel Sipka Date: Mon, 12 Oct 2015 00:24:25 +0200 Subject: [PATCH] move headerize to submodule --- .gitmodules | 3 ++ CMakeLists.txt | 1 + test/CMakeLists.txt | 12 ++------ test/headerize.cpp | 69 --------------------------------------------- vendor/headerize | 1 + 5 files changed, 8 insertions(+), 78 deletions(-) delete mode 100644 test/headerize.cpp create mode 160000 vendor/headerize diff --git a/.gitmodules b/.gitmodules index 28ae018..0387dda 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ [submodule "vendor/benchmark"] path = vendor/benchmark url = https://github.com/google/benchmark.git +[submodule "vendor/headerize"] + path = vendor/headerize + url = https://github.com/no1msd/headerize.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 6bc4d75..ab7682c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,7 @@ add_subdirectory(src) if(WITH_UNIT_TESTS) enable_testing() + add_subdirectory(vendor/headerize) add_subdirectory(test) endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1ed3fea..c27c32e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,13 +1,7 @@ -find_package(Boost 1.54 COMPONENTS program_options REQUIRED) - include_directories( ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/vendor/Catch/single_include - ${CMAKE_SOURCE_DIR}/vendor/json.hpp/include - ${Boost_INCLUDE_DIR}) - -add_executable(headerize headerize.cpp) -target_link_libraries(headerize ${Boost_PROGRAM_OPTIONS_LIBRARY}) + ${CMAKE_SOURCE_DIR}/vendor/json.hpp/include) file(GLOB data_files RELATIVE "${CMAKE_SOURCE_DIR}/test/data" @@ -25,7 +19,7 @@ file(GLOB string_files RELATIVE "${CMAKE_SOURCE_DIR}/test/data/*.partial") foreach(string_file ${string_files}) - list(APPEND genargs "-S${string_file}") + list(APPEND genargs "-i${string_file}") endforeach(string_file) add_custom_command( @@ -40,7 +34,7 @@ file(GLOB specs_files RELATIVE "${CMAKE_SOURCE_DIR}/vendor/spec/specs/*.json") foreach(specs_file ${specs_files}) - list(APPEND specsargs "-S${specs_file}") + list(APPEND specsargs "-i${specs_file}") string(REGEX REPLACE "\\.json" "" test_name "${specs_file}") string(REGEX REPLACE "~" "" test_name "${test_name}") list(APPEND tests "specs_${test_name}") diff --git a/test/headerize.cpp b/test/headerize.cpp deleted file mode 100644 index 4a08e77..0000000 --- a/test/headerize.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include -#include - -#include -#include -#include -#include - -void wrap_string(std::istream& input, std::ostream& output, - const std::string& variable_name) -{ - output << "const std::string " << variable_name << "{\n"; - std::string line; - while (std::getline(input, line)) { - boost::replace_all(line, "\\", "\\\\"); - boost::replace_all(line, "\"", "\\\""); - output << " \"" << line; - if (!input.eof()) - output << "\\n"; - output << "\"\n"; - } - output << "};\n"; -} - -int main(int argc, char* argv[]) { - namespace po = boost::program_options; - - po::options_description desc("Allowed options"); - desc.add_options() - ("help", "show help") - ("output", po::value(), "output file") - ("namespace", po::value(), "namespace to use") - ("input-string,S", po::value>(), - "files to parse as strings"); - po::variables_map vm; - po::store(po::parse_command_line(argc, argv, desc), vm); - po::notify(vm); - - if (vm.count("help")) { - std::cout << desc << std::endl; - return 1; - } - - if (!vm.count("output")) { - std::cerr << "Output file not set" << std::endl; - return 1; - } - - std::ofstream output(vm["output"].as(), std::ios::out); - - if (vm.count("namespace")) - output << "namespace " << vm["namespace"].as() << " {\n"; - - if (vm.count("input-string")) - for (auto& filename: vm["input-string"].as>()) { - std::ifstream input(filename, std::ios::in); - std::string variable_name = boost::replace_all_copy(filename, ".", "_"); - boost::replace_all(variable_name, "~", ""); - wrap_string(input, output, variable_name); - input.close(); - } - - if (vm.count("namespace")) - output << "}\n"; - - output.close(); - - return 0; -} diff --git a/vendor/headerize b/vendor/headerize new file mode 160000 index 0000000..fba2f01 --- /dev/null +++ b/vendor/headerize @@ -0,0 +1 @@ +Subproject commit fba2f0124e46257e1a3aabde2d95d672680a6c15