diff --git a/Crafter.Build-Configuration.cpp b/Crafter.Build-Configuration.cpp index b9271da..781988e 100644 --- a/Crafter.Build-Configuration.cpp +++ b/Crafter.Build-Configuration.cpp @@ -1,6 +1,6 @@ /* Crafter.Build -Copyright (C) 2024 Catcrafts +Copyright (C) 2025 Catcrafts® Catcrafts.net This library is free software; you can redistribute it and/or diff --git a/Crafter.Build-Configuration.cppm b/Crafter.Build-Configuration.cppm index f9f0a18..346876d 100644 --- a/Crafter.Build-Configuration.cppm +++ b/Crafter.Build-Configuration.cppm @@ -1,6 +1,6 @@ /* Crafter.Build -Copyright (C) 2024 Catcrafts +Copyright (C) 2025 Catcrafts® Catcrafts.net This library is free software; you can redistribute it and/or @@ -8,7 +8,7 @@ modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. -This library is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. @@ -52,7 +52,7 @@ export namespace Crafter::Build { std::vector dependencies; std::unordered_map additionalProperties; std::vector flags; - bool verbose; + bool verbose = false; Configuration(std::string name, std::string standard, std::vector sourceFiles, std::vector moduleFiles, std::string optimizationLevel, std::string buildDir, std::string outputDir, std::string type, std::string target, std::string march, std::vector dependencies, std::vector additionalFiles, std::vector flags, bool debug, std::vector libs, std::vector lib_paths, std::vector c_files, std::vector shaderFiles, std::vector includeDirs, bool verbose); Configuration(const nlohmann::json& configs, const nlohmann::json& config, fs::path workingDir); }; diff --git a/Crafter.Build-Dependency.cpp b/Crafter.Build-Dependency.cpp index 539729f..6a1b9ae 100644 --- a/Crafter.Build-Dependency.cpp +++ b/Crafter.Build-Dependency.cpp @@ -1,6 +1,6 @@ /* Crafter.Build -Copyright (C) 2024 Catcrafts +Copyright (C) 2025 Catcrafts® Catcrafts.net This library is free software; you can redistribute it and/or @@ -8,7 +8,7 @@ modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. -This library is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. diff --git a/Crafter.Build-Dependency.cppm b/Crafter.Build-Dependency.cppm index 6c97366..506cdb8 100644 --- a/Crafter.Build-Dependency.cppm +++ b/Crafter.Build-Dependency.cppm @@ -1,13 +1,14 @@ /* Crafter.Build -Copyright (C) 2024 Catcrafts +Copyright (C) 2025 Catcrafts® +Catcrafts.net This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. -This library is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. diff --git a/Crafter.Build-ModuleFile.cpp b/Crafter.Build-ModuleFile.cpp index 5a20e47..2e19190 100644 --- a/Crafter.Build-ModuleFile.cpp +++ b/Crafter.Build-ModuleFile.cpp @@ -1,6 +1,6 @@ /* Crafter.Build -Copyright (C) 2024 Catcrafts +Copyright (C) 2025 Catcrafts® Catcrafts.net This library is free software; you can redistribute it and/or @@ -8,7 +8,7 @@ modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. -This library is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. diff --git a/Crafter.Build-ModuleFile.cppm b/Crafter.Build-ModuleFile.cppm index f76bc00..f182213 100644 --- a/Crafter.Build-ModuleFile.cppm +++ b/Crafter.Build-ModuleFile.cppm @@ -1,6 +1,6 @@ /* Crafter.Build -Copyright (C) 2024 Catcrafts +Copyright (C) 2025 Catcrafts® Catcrafts.net This library is free software; you can redistribute it and/or @@ -8,7 +8,7 @@ modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. -This library is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. diff --git a/Crafter.Build-Project.cpp b/Crafter.Build-Project.cpp index d6bb771..41587cf 100644 --- a/Crafter.Build-Project.cpp +++ b/Crafter.Build-Project.cpp @@ -1,6 +1,6 @@ /* Crafter.Build -Copyright (C) 2024 Catcrafts +Copyright (C) 2025 Catcrafts® Catcrafts.net This library is free software; you can redistribute it and/or @@ -8,7 +8,7 @@ modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. -This library is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. diff --git a/Crafter.Build-Project.cppm b/Crafter.Build-Project.cppm index 272ff53..16ed230 100644 --- a/Crafter.Build-Project.cppm +++ b/Crafter.Build-Project.cppm @@ -1,6 +1,6 @@ /* Crafter.Build -Copyright (C) 2024 Catcrafts +Copyright (C) 2025 Catcrafts® Catcrafts.net This library is free software; you can redistribute it and/or @@ -8,7 +8,7 @@ modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. -This library is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. diff --git a/Crafter.Build-Shader.cpp b/Crafter.Build-Shader.cpp index c116d39..35e5107 100644 --- a/Crafter.Build-Shader.cpp +++ b/Crafter.Build-Shader.cpp @@ -1,13 +1,14 @@ /* Crafter.Build -Copyright (C) 2025 Catcrafts +Copyright (C) 2025 Catcrafts® +Catcrafts.net This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. -This library is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. @@ -35,65 +36,65 @@ Shader::Shader(fs::path path, std::string entrypoint, EShLanguage type): path(pa } void Shader::Compile(fs::path outputDir) { - // glslang::InitializeProcess(); - // EShMessages messages = static_cast(EShMsgDefault | EShMsgVulkanRules | EShMsgSpvRules); - // std::ifstream fileStream(path, std::ios::in | std::ios::binary); - // if (!fileStream) { - // throw std::ios_base::failure("Failed to open file: " + path.string()); - // } - // std::ostringstream contents; - // contents << fileStream.rdbuf(); - // std::string src = contents.str(); + glslang::InitializeProcess(); + EShMessages messages = static_cast(EShMsgDefault | EShMsgVulkanRules | EShMsgSpvRules); + std::ifstream fileStream(path, std::ios::in | std::ios::binary); + if (!fileStream) { + throw std::ios_base::failure("Failed to open file: " + path.string()); + } + std::ostringstream contents; + contents << fileStream.rdbuf(); + std::string src = contents.str(); - // const char *file_name_list[1] = {""}; - // const char *shader_source = reinterpret_cast(src.data()); + const char *file_name_list[1] = {""}; + const char *shader_source = reinterpret_cast(src.data()); - // glslang::TShader shader(type); - // shader.setStringsWithLengthsAndNames(&shader_source, nullptr, file_name_list, 1); - // shader.setEntryPoint(entrypoint.c_str()); - // shader.setSourceEntryPoint(entrypoint.c_str()); - // shader.setEnvTarget(glslang::EShTargetSpv, glslang::EShTargetSpv_1_4); - // DirStackFileIncluder includeDir; - // includeDir.pushExternalLocalDirectory(path.parent_path().generic_string()); - // std::string info_log; - // if (!shader.parse(GetDefaultResources(), 100, false, messages, includeDir)) - // { - // info_log = std::string(shader.getInfoLog()) + std::string(shader.getInfoDebugLog()); - // } - // // Add shader to new program object. - // glslang::TProgram program; - // program.addShader(&shader); + glslang::TShader shader(type); + shader.setStringsWithLengthsAndNames(&shader_source, nullptr, file_name_list, 1); + shader.setEntryPoint(entrypoint.c_str()); + shader.setSourceEntryPoint(entrypoint.c_str()); + shader.setEnvTarget(glslang::EShTargetSpv, glslang::EShTargetSpv_1_4); + DirStackFileIncluder includeDir; + includeDir.pushExternalLocalDirectory(path.parent_path().generic_string()); + std::string info_log; + if (!shader.parse(GetDefaultResources(), 100, false, messages, includeDir)) + { + info_log = std::string(shader.getInfoLog()) + std::string(shader.getInfoDebugLog()); + } + // Add shader to new program object. + glslang::TProgram program; + program.addShader(&shader); - // // Link program. - // if (!program.link(messages)) - // { - // info_log = std::string(program.getInfoLog()) + std::string(program.getInfoDebugLog()); - // } + // Link program. + if (!program.link(messages)) + { + info_log = std::string(program.getInfoLog()) + std::string(program.getInfoDebugLog()); + } - // // Save any info log that was generated. - // if (shader.getInfoLog()) - // { - // info_log += std::string(shader.getInfoLog()) + std::string(shader.getInfoDebugLog()); - // } + // Save any info log that was generated. + if (shader.getInfoLog()) + { + info_log += std::string(shader.getInfoLog()) + std::string(shader.getInfoDebugLog()); + } - // if (program.getInfoLog()) - // { - // info_log += std::string(program.getInfoLog()) + std::string(program.getInfoDebugLog()); - // } + if (program.getInfoLog()) + { + info_log += std::string(program.getInfoLog()) + std::string(program.getInfoDebugLog()); + } - // glslang::TIntermediate* intermediate = program.getIntermediate(type); - // if (!intermediate) - // { - // info_log += "Failed to get shared intermediate code."; - // } + glslang::TIntermediate* intermediate = program.getIntermediate(type); + if (!intermediate) + { + info_log += "Failed to get shared intermediate code."; + } - // spv::SpvBuildLogger logger; - // std::vector spirv; - // std::cout << info_log; - // glslang::GlslangToSpv(*intermediate, spirv, &logger); - // std::cout << logger.getAllMessages(); - // glslang::FinalizeProcess(); - // path.replace_extension("spirv"); - // std::ofstream file(outputDir/path, std::ios::binary); - // file.write(reinterpret_cast(spirv.data()), spirv.size() * sizeof(std::uint32_t)); + spv::SpvBuildLogger logger; + std::vector spirv; + std::cout << info_log; + glslang::GlslangToSpv(*intermediate, spirv, &logger); + std::cout << logger.getAllMessages(); + glslang::FinalizeProcess(); + fs::path filename = path.filename().replace_extension("spirv"); + std::ofstream file(outputDir/filename, std::ios::binary); + file.write(reinterpret_cast(spirv.data()), spirv.size() * sizeof(std::uint32_t)); } diff --git a/Crafter.Build-Shader.cppm b/Crafter.Build-Shader.cppm index ca65d25..abb18a2 100644 --- a/Crafter.Build-Shader.cppm +++ b/Crafter.Build-Shader.cppm @@ -1,13 +1,14 @@ /* Crafter.Build -Copyright (C) 2025 Catcrafts +Copyright (C) 2025 Catcrafts® +Catcrafts.net This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. -This library is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. diff --git a/Crafter.Build.cppm b/Crafter.Build.cppm index cfd99c1..5d5cb87 100644 --- a/Crafter.Build.cppm +++ b/Crafter.Build.cppm @@ -1,6 +1,6 @@ /* Crafter.Build -Copyright (C) 2024 Catcrafts +Copyright (C) 2025 Catcrafts® Catcrafts.net This library is free software; you can redistribute it and/or @@ -8,7 +8,7 @@ modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. -This library is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. diff --git a/build.sh b/build.sh index fa1b4c4..bcdb682 100755 --- a/build.sh +++ b/build.sh @@ -21,6 +21,6 @@ clang++ -std=c++26 ./build/Crafter.Build-ModuleFile.pcm -fprebuilt-module-path=. clang++ -std=c++26 ./build/Crafter.Build-Shader.pcm -fprebuilt-module-path=./build -c -O3 -o ./build/Crafter.Build-Shader.o clang++ -std=c++26 ./build/Crafter.Build-Dependency.pcm -fprebuilt-module-path=./build -c -O3 -o ./build/Crafter.Build-Dependency.o clang++ -std=c++26 ./build/Crafter.Build.pcm -fprebuilt-module-path=./build -c -O3 -o ./build/Crafter.Build.o -clang++ -Llibvulkan -LlibMachineIndependent, -LlibOSDependent, -LlibGenericCodeGen -Llibglslang -Lglslang-default-resource-limits -LlibSPIRV -LlibSPVRemapper ./build/main.o ./build/Crafter.Build-ModuleFile_source.o ./build/Crafter.Build-ModuleFile.o ./build/Crafter.Build-Shader_source.o ./build/Crafter.Build-Shader.o ./build/Crafter.Build.o ./build/Crafter.Build-Configuration.o ./build/Crafter.Build-Configuration_source.o ./build/Crafter.Build-Project.o ./build/Crafter.Build-Project_source.o ./build/Crafter.Build-Dependency.o ./build/Crafter.Build-Dependency_source.o -O3 -o ./bin/crafter-build +clang++ ./build/main.o ./build/Crafter.Build-ModuleFile_source.o ./build/Crafter.Build-ModuleFile.o ./build/Crafter.Build-Shader_source.o ./build/Crafter.Build-Shader.o ./build/Crafter.Build.o ./build/Crafter.Build-Configuration.o ./build/Crafter.Build-Configuration_source.o ./build/Crafter.Build-Project.o ./build/Crafter.Build-Project_source.o ./build/Crafter.Build-Dependency.o ./build/Crafter.Build-Dependency_source.o -O3 -o ./bin/crafter-build -L/usr/local/lib -L/usr/lib/ -lvulkan -lMachineIndependent -lOSDependent -lGenericCodeGen -lglslang -lglslang-default-resource-limits -lSPIRV -lSPVRemapper -fuse-ld=lld rm -rf build diff --git a/main.cpp b/main.cpp index e9a1547..784ecaf 100644 --- a/main.cpp +++ b/main.cpp @@ -1,14 +1,14 @@ /* Crafter.Build -Copyright (C) 2024 Catcrafts +Copyright (C) 2025 Catcrafts® Catcrafts.net This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. +version 3.0 of the License, or (at your option) any later version. -This library is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. @@ -71,7 +71,7 @@ int main(int argc, char* argv[]) { if(config.target == "x86_64-w64-mingw64" || config.target == "x86_64-w64-mingw32") { project.name += ".exe"; } - system(std::format("{}", (projectPath/fs::path(config.outputDir)/project.name).generic_string()).c_str()); + system(std::format("cd {} && ./{}", (projectPath/fs::path(config.outputDir)).generic_string(), project.name).c_str()); return 0; } } diff --git a/project.json b/project.json index 392ead6..a983993 100644 --- a/project.json +++ b/project.json @@ -8,7 +8,8 @@ "module_files": ["Crafter.Build-Dependency", "Crafter.Build-Configuration", "Crafter.Build-Project", "Crafter.Build-Shader", "Crafter.Build", "Crafter.Build-ModuleFile"], "build_dir": "./build", "output_dir": "./bin", - "libs": ["vulkan", "MachineIndependent", "OSDependent", "GenericCodeGen", "glslang", "glslang-default-resource-limits", "SPIRV", "SPVRemapper"] + "libs": ["vulkan", "MachineIndependent", "OSDependent", "GenericCodeGen", "glslang", "glslang-default-resource-limits", "SPIRV", "SPVRemapper"], + "verbose": true }, { "name": "executable",