update
This commit is contained in:
parent
2daf890ed1
commit
be18fb8568
12 changed files with 427 additions and 19 deletions
|
|
@ -20,11 +20,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
module;
|
||||
#include "json.hpp"
|
||||
#include <glslang/Public/ShaderLang.h>
|
||||
module Crafter.Build;
|
||||
using namespace Crafter::Build;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
Configuration::Configuration(std::string name, std::string standard, std::vector<fs::path> sourceFiles, std::vector<fs::path> moduleFiles, std::string optimizationLevel, std::string buildDir, std::string outputDir, std::string type, std::string target, std::string march, std::vector<Dependency> dependencies, std::vector<fs::path> additionalFiles, std::vector<std::string> flags): name(name), standard(standard), sourceFiles(sourceFiles), moduleFiles(moduleFiles), optimizationLevel(optimizationLevel), buildDir(buildDir), outputDir(outputDir), type(type), target(target), march(march), dependencies(dependencies), additionalFiles(additionalFiles), flags(flags) {
|
||||
Configuration::Configuration(std::string name, std::string standard, std::vector<fs::path> sourceFiles, std::vector<fs::path> moduleFiles, std::string optimizationLevel, std::string buildDir, std::string outputDir, std::string type, std::string target, std::string march, std::vector<Dependency> dependencies, std::vector<fs::path> additionalFiles, std::vector<std::string> flags, bool debug, std::vector<std::string> libs, std::vector<std::string> lib_paths, std::vector<fs::path> c_files, std::vector<Shader> shaderFiles, std::vector<std::string> includeDirs, bool verbose): name(name), standard(standard), sourceFiles(sourceFiles), moduleFiles(moduleFiles), optimizationLevel(optimizationLevel), buildDir(buildDir), outputDir(outputDir), type(type), target(target), march(march), dependencies(dependencies), additionalFiles(additionalFiles), flags(flags), debug(debug), libs(libs), lib_paths(lib_paths), c_files(c_files), shaderFiles(shaderFiles), includeDirs(includeDirs), verbose(verbose) {
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -33,9 +34,13 @@ Configuration::Configuration(const nlohmann::json& configs, const nlohmann::json
|
|||
for (auto& [key, val] : config.items())
|
||||
{
|
||||
if(key == "standard"){
|
||||
standard = val.get<std::string>();
|
||||
standard = val.get<std::string>();
|
||||
} else if(key == "target") {
|
||||
target = val.get<std::string>();
|
||||
target = val.get<std::string>();
|
||||
} else if(key == "debug") {
|
||||
debug = val.get<bool>();
|
||||
} else if(key == "verbose") {
|
||||
verbose = val.get<bool>();
|
||||
} else if(key == "type") {
|
||||
type = val.get<std::string>();
|
||||
} else if(key == "march") {
|
||||
|
|
@ -48,8 +53,22 @@ Configuration::Configuration(const nlohmann::json& configs, const nlohmann::json
|
|||
const std::filesystem::path fullFilePath = workingDir / filePath;
|
||||
sourceFiles[i] = fullFilePath.generic_string();
|
||||
}
|
||||
} else if(key == "c_files") {
|
||||
const std::vector<std::string> tempSourceFiles = val.get<std::vector<std::string>>();
|
||||
c_files = std::vector<fs::path>(tempSourceFiles.size());
|
||||
for(std::int_fast32_t i = 0; i < c_files.size(); i++){
|
||||
const std::filesystem::path filePath (tempSourceFiles[i]);
|
||||
const std::filesystem::path fullFilePath = workingDir / filePath;
|
||||
c_files[i] = fullFilePath.generic_string();
|
||||
}
|
||||
} else if(key == "flags") {
|
||||
flags = val.get<std::vector<std::string>>();
|
||||
} else if(key == "lib_paths") {
|
||||
lib_paths = val.get<std::vector<std::string>>();
|
||||
} else if(key == "include_dirs") {
|
||||
includeDirs = val.get<std::vector<std::string>>();
|
||||
} else if(key == "libs") {
|
||||
libs = val.get<std::vector<std::string>>();
|
||||
} else if(key == "module_files") {
|
||||
const std::vector<std::string> tempModuleFiles = val.get<std::vector<std::string>>();
|
||||
moduleFiles = std::vector<fs::path>(tempModuleFiles.size());
|
||||
|
|
@ -58,6 +77,12 @@ Configuration::Configuration(const nlohmann::json& configs, const nlohmann::json
|
|||
const std::filesystem::path fullFilePath = workingDir / filePath;
|
||||
moduleFiles[i] = fullFilePath.generic_string();
|
||||
}
|
||||
} else if(key == "shaders") {
|
||||
for (auto it : val) {
|
||||
const std::filesystem::path filePath (it["path"].get<std::string>());
|
||||
const std::filesystem::path fullFilePath = workingDir / filePath;
|
||||
shaderFiles.emplace_back(fullFilePath, it["entrypoint"].get<std::string>(), static_cast<EShLanguage>(it["type"].get<std::uint32_t>()));
|
||||
}
|
||||
} else if(key == "additional_files") {
|
||||
const std::vector<std::string> tempAdditionalFiles = val.get<std::vector<std::string>>();
|
||||
additionalFiles = std::vector<fs::path>(tempAdditionalFiles.size());
|
||||
|
|
@ -133,9 +158,30 @@ Configuration::Configuration(const nlohmann::json& configs, const nlohmann::json
|
|||
if(!extendData.march.empty() && march.empty()) {
|
||||
march = extendData.march;
|
||||
}
|
||||
if(!extendData.lib_paths.empty()){
|
||||
lib_paths.insert(lib_paths.end(), extendData.lib_paths.begin(), extendData.lib_paths.end());
|
||||
}
|
||||
if(!extendData.c_files.empty()){
|
||||
c_files.insert(c_files.end(), extendData.c_files.begin(), extendData.c_files.end());
|
||||
}
|
||||
if(!extendData.flags.empty()){
|
||||
flags.insert(flags.end(), extendData.flags.begin(), extendData.flags.end());
|
||||
}
|
||||
if(extendData.debug){
|
||||
debug = true;
|
||||
}
|
||||
if(extendData.verbose){
|
||||
verbose = true;
|
||||
}
|
||||
if(!extendData.libs.empty()){
|
||||
libs.insert(libs.end(), extendData.libs.begin(), extendData.libs.end());
|
||||
}
|
||||
if(!extendData.shaderFiles.empty()){
|
||||
shaderFiles.insert(shaderFiles.end(), extendData.shaderFiles.begin(), extendData.shaderFiles.end());
|
||||
}
|
||||
if(!extendData.includeDirs.empty()){
|
||||
includeDirs.insert(includeDirs.end(), extendData.includeDirs.begin(), extendData.includeDirs.end());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue