move headerize to submodule
This commit is contained in:
parent
cc2c18f1c8
commit
3ff2b1f056
5 changed files with 8 additions and 78 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -10,3 +10,6 @@
|
||||||
[submodule "vendor/benchmark"]
|
[submodule "vendor/benchmark"]
|
||||||
path = vendor/benchmark
|
path = vendor/benchmark
|
||||||
url = https://github.com/google/benchmark.git
|
url = https://github.com/google/benchmark.git
|
||||||
|
[submodule "vendor/headerize"]
|
||||||
|
path = vendor/headerize
|
||||||
|
url = https://github.com/no1msd/headerize.git
|
||||||
|
|
|
@ -18,6 +18,7 @@ add_subdirectory(src)
|
||||||
|
|
||||||
if(WITH_UNIT_TESTS)
|
if(WITH_UNIT_TESTS)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
add_subdirectory(vendor/headerize)
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,7 @@
|
||||||
find_package(Boost 1.54 COMPONENTS program_options REQUIRED)
|
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
${CMAKE_SOURCE_DIR}/include
|
${CMAKE_SOURCE_DIR}/include
|
||||||
${CMAKE_SOURCE_DIR}/vendor/Catch/single_include
|
${CMAKE_SOURCE_DIR}/vendor/Catch/single_include
|
||||||
${CMAKE_SOURCE_DIR}/vendor/json.hpp/include
|
${CMAKE_SOURCE_DIR}/vendor/json.hpp/include)
|
||||||
${Boost_INCLUDE_DIR})
|
|
||||||
|
|
||||||
add_executable(headerize headerize.cpp)
|
|
||||||
target_link_libraries(headerize ${Boost_PROGRAM_OPTIONS_LIBRARY})
|
|
||||||
|
|
||||||
file(GLOB data_files RELATIVE
|
file(GLOB data_files RELATIVE
|
||||||
"${CMAKE_SOURCE_DIR}/test/data"
|
"${CMAKE_SOURCE_DIR}/test/data"
|
||||||
|
@ -25,7 +19,7 @@ file(GLOB string_files RELATIVE
|
||||||
"${CMAKE_SOURCE_DIR}/test/data/*.partial")
|
"${CMAKE_SOURCE_DIR}/test/data/*.partial")
|
||||||
|
|
||||||
foreach(string_file ${string_files})
|
foreach(string_file ${string_files})
|
||||||
list(APPEND genargs "-S${string_file}")
|
list(APPEND genargs "-i${string_file}")
|
||||||
endforeach(string_file)
|
endforeach(string_file)
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
|
@ -40,7 +34,7 @@ file(GLOB specs_files RELATIVE
|
||||||
"${CMAKE_SOURCE_DIR}/vendor/spec/specs/*.json")
|
"${CMAKE_SOURCE_DIR}/vendor/spec/specs/*.json")
|
||||||
|
|
||||||
foreach(specs_file ${specs_files})
|
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 "\\.json" "" test_name "${specs_file}")
|
||||||
string(REGEX REPLACE "~" "" test_name "${test_name}")
|
string(REGEX REPLACE "~" "" test_name "${test_name}")
|
||||||
list(APPEND tests "specs_${test_name}")
|
list(APPEND tests "specs_${test_name}")
|
||||||
|
|
|
@ -1,69 +0,0 @@
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
#include <boost/algorithm/string/replace.hpp>
|
|
||||||
#include <boost/program_options/options_description.hpp>
|
|
||||||
#include <boost/program_options/variables_map.hpp>
|
|
||||||
#include <boost/program_options/parsers.hpp>
|
|
||||||
|
|
||||||
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<std::string>(), "output file")
|
|
||||||
("namespace", po::value<std::string>(), "namespace to use")
|
|
||||||
("input-string,S", po::value<std::vector<std::string>>(),
|
|
||||||
"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::string>(), std::ios::out);
|
|
||||||
|
|
||||||
if (vm.count("namespace"))
|
|
||||||
output << "namespace " << vm["namespace"].as<std::string>() << " {\n";
|
|
||||||
|
|
||||||
if (vm.count("input-string"))
|
|
||||||
for (auto& filename: vm["input-string"].as<std::vector<std::string>>()) {
|
|
||||||
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;
|
|
||||||
}
|
|
1
vendor/headerize
vendored
Submodule
1
vendor/headerize
vendored
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit fba2f0124e46257e1a3aabde2d95d672680a6c15
|
Loading…
Reference in a new issue