build.sh fix

This commit is contained in:
Jorijn van der Graaf 2025-04-29 00:15:14 +02:00
commit cf08a52f42
14 changed files with 86 additions and 82 deletions

View file

@ -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

View file

@ -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<Dependency> dependencies;
std::unordered_map<std::string, nlohmann::json> additionalProperties;
std::vector<std::string> flags;
bool verbose;
bool verbose = false;
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);
Configuration(const nlohmann::json& configs, const nlohmann::json& config, fs::path workingDir);
};

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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<EShMessages>(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<EShMessages>(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<const char *>(src.data());
const char *file_name_list[1] = {""};
const char *shader_source = reinterpret_cast<const char *>(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<std::uint32_t> 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<const char*>(spirv.data()), spirv.size() * sizeof(std::uint32_t));
spv::SpvBuildLogger logger;
std::vector<std::uint32_t> 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<const char*>(spirv.data()), spirv.size() * sizeof(std::uint32_t));
}

View file

@ -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.

View file

@ -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.

View file

@ -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

View file

@ -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;
}
}

View file

@ -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",