Skip to content

Commit

Permalink
refactor: split quadrados-gen from quadrados
Browse files Browse the repository at this point in the history
  • Loading branch information
RiscadoA committed Sep 25, 2023
1 parent 3948aad commit 9666b2b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions cmake/QuadradosGenerate.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ function(quadrados_generate target source_dir)

add_custom_command(
OUTPUT ${binary_dir}/${target}-components.cpp
COMMAND $<TARGET_FILE:quadrados> generate ${source_dir} ${binary_dir}/${target}-components.cpp
DEPENDS $<TARGET_FILE:quadrados> ${source_dir}
COMMAND $<TARGET_FILE:quadrados-gen> ${source_dir} ${binary_dir}/${target}-components.cpp
DEPENDS $<TARGET_FILE:quadrados-gen> ${source_dir}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)

Expand Down
1 change: 1 addition & 0 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
# Cubos tools build configuration

add_subdirectory(quadrados)
add_subdirectory(quadrados-gen)
add_subdirectory(tesseratos)
6 changes: 6 additions & 0 deletions tools/quadrados-gen/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# tools/quadrados-gen/CMakeLists.txt
# Quadrados generate build configuration

add_executable(quadrados-gen "src/main.cpp")
target_link_libraries(quadrados-gen PUBLIC cubos-core)
cubos_common_target_options(quadrados-gen)
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include <utility>
#include <vector>

#include "tools.hpp"

namespace fs = std::filesystem;

/// The input options of the program.
Expand All @@ -31,7 +29,7 @@ struct Component
/// Prints the help message of the program.
static void printHelp()
{
std::cerr << "Usage: quadrados generate <INPUT> <OUTPUT>" << std::endl;
std::cerr << "Usage: quadrados <INPUT> <OUTPUT>" << std::endl;

Check warning on line 32 in tools/quadrados-gen/src/main.cpp

View check run for this annotation

Codecov / codecov/patch

tools/quadrados-gen/src/main.cpp#L32

Added line #L32 was not covered by tests
std::cerr << "Options:" << std::endl;
std::cerr << " -h Prints this help message." << std::endl;
}
Expand Down Expand Up @@ -790,7 +788,7 @@ static bool generate(const GenerateOptions& options)
return false;
}

file << "/// This file was generated by quadrados generate." << std::endl;
file << "/// This file was generated by quadrados-gen." << std::endl;

Check warning on line 791 in tools/quadrados-gen/src/main.cpp

View check run for this annotation

Codecov / codecov/patch

tools/quadrados-gen/src/main.cpp#L791

Added line #L791 was not covered by tests
file << "/// Do not edit this file." << std::endl;
file << std::endl;
file << "#include <cubos/core/ecs/registry.hpp>" << std::endl;
Expand Down Expand Up @@ -892,11 +890,11 @@ static bool generate(const GenerateOptions& options)
return true;
}

int runGenerate(int argc, char** argv)
int main(int argc, char** argv)

Check warning on line 893 in tools/quadrados-gen/src/main.cpp

View check run for this annotation

Codecov / codecov/patch

tools/quadrados-gen/src/main.cpp#L893

Added line #L893 was not covered by tests
{
// Parse command line arguments.
GenerateOptions options = {};
if (!parseArguments(argc, argv, options))
if (!parseArguments(argc - 1, argv + 1, options))

Check warning on line 897 in tools/quadrados-gen/src/main.cpp

View check run for this annotation

Codecov / codecov/patch

tools/quadrados-gen/src/main.cpp#L897

Added line #L897 was not covered by tests
{
printHelp();
return 1;
Expand Down
5 changes: 1 addition & 4 deletions tools/quadrados/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ set(QUADRADOS_SOURCE
"src/entry.cpp"
"src/embed.cpp"
"src/convert.cpp"
"src/generate.cpp"
)

add_executable(quadrados ${QUADRADOS_SOURCE})
set_property(TARGET quadrados PROPERTY CXX_STANDARD 20)
target_compile_features(quadrados PUBLIC cxx_std_20)
target_link_libraries(quadrados PUBLIC cubos-core)
target_link_libraries(quadrados PUBLIC cubos-engine)
cubos_common_target_options(quadrados)
2 changes: 0 additions & 2 deletions tools/quadrados/src/tools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ struct Tool
int runHelp(int argc, char** argv);
int runEmbed(int argc, char** argv);
int runConvert(int argc, char** argv);
int runGenerate(int argc, char** argv);

static const Tool Tools[] = {
{"help", runHelp},
{"embed", runEmbed},
{"convert", runConvert},
{"generate", runGenerate},
};

0 comments on commit 9666b2b

Please sign in to comment.