Tool refactoring

This commit is contained in:
2023-03-22 18:54:22 -07:00
parent f267131d6b
commit 9e2f093527
41 changed files with 1871 additions and 1664 deletions

View File

@ -0,0 +1,47 @@
# Copyright (c) 2023 Dominic Msters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Texture Build Tool
project(prefabtool VERSION 1.0)
add_executable(prefabtool)
# Sources
target_sources(prefabtool
PRIVATE
${DAWN_SHARED_SOURCES}
${DAWN_TOOL_SOURCES}
PrefabTool.cpp
)
# Includes
target_include_directories(prefabtool
PUBLIC
${DAWN_SHARED_INCLUDES}
${DAWN_TOOL_INCLUDES}
${CMAKE_CURRENT_LIST_DIR}
)
# Definitions
target_compile_definitions(prefabtool
PUBLIC
DAWN_TOOL_INSTANCE=PrefabTool
DAWN_TOOL_HEADER="PrefabTool.hpp"
)
# Libraries
target_link_libraries(prefabtool
PUBLIC
${DAWN_BUILD_HOST_LIBS}
)
# Tool Function
function(tool_prefab target in)
add_custom_target(${target}
COMMAND prefabtool --input="${DAWN_ASSETS_SOURCE_DIR}/${in}"
COMMENT "Generating prefab ${target} from ${in}"
DEPENDS prefabtool
)
add_dependencies(${DAWN_TARGET_NAME} ${target})
endfunction()

View File

@ -0,0 +1,28 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "PrefabTool.hpp"
using namespace Dawn;
std::vector<std::string> PrefabTool::getRequiredFlags() {
return { "input" };
}
std::map<std::string, std::string> PrefabTool::getOptionalFlags() {
return std::map<std::string, std::string>();
}
int32_t PrefabTool::start() {
File input = File(flags["input"]);
if(!input.exists()) {
std::cout << "Input file does not exist!" << std::endl;
return 1;
}
std::cout << "Input: " << input.filename << std::endl;
return 0;
}

View File

@ -0,0 +1,19 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "util/DawnTool.hpp"
#include "util/File.hpp"
namespace Dawn {
class PrefabTool : public DawnTool {
protected:
std::vector<std::string> getRequiredFlags() override;
std::map<std::string, std::string> getOptionalFlags() override;
public:
int32_t start();
};
}