rewrite
This commit is contained in:
parent
23fa8b98b0
commit
0eed272765
35 changed files with 1634 additions and 1507 deletions
42
interfaces/Crafter.Build-Command.cppm
Normal file
42
interfaces/Crafter.Build-Command.cppm
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
Crafter® Build
|
||||
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 version 3.0 as published by the Free Software Foundation;
|
||||
|
||||
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.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
export module Crafter.Build:Command;
|
||||
import std;
|
||||
|
||||
namespace Crafter {
|
||||
export struct CompileError {
|
||||
std::string filename;
|
||||
std::uint_fast32_t line;
|
||||
std::string message;
|
||||
std::string code;
|
||||
};
|
||||
|
||||
export class CompileException : public std::exception {
|
||||
public:
|
||||
std::string message;
|
||||
std::vector<CompileError> errors;
|
||||
CompileException(std::vector<CompileError>&& errors);
|
||||
const char* what() const noexcept override;
|
||||
};
|
||||
|
||||
export std::string RunCommand(const std::string_view cmd);
|
||||
export void RunCommandIgnore(const std::string_view cmd);
|
||||
export void RunClang(const std::string_view cmd);
|
||||
}
|
||||
72
interfaces/Crafter.Build-Configuration.cppm
Normal file
72
interfaces/Crafter.Build-Configuration.cppm
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
Crafter® Build
|
||||
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 version 3.0 as published by the Free Software Foundation;
|
||||
|
||||
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.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
module;
|
||||
#include "../lib/json.hpp"
|
||||
export module Crafter.Build:Configuration;
|
||||
import std;
|
||||
import :Implementation;
|
||||
import :Shader;
|
||||
import :Module;
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace Crafter {
|
||||
export struct Define {
|
||||
std::string name;
|
||||
std::string value;
|
||||
Define(std::string&& name, std::string&& value): name(std::move(name)), value(std::move(value)) { }
|
||||
};
|
||||
|
||||
export class Dependency {
|
||||
public:
|
||||
std::string path;
|
||||
std::string configuration;
|
||||
std::string commit;
|
||||
std::string branch;
|
||||
Dependency(std::string&& path, std::string&& configuration, std::string&& commit, std::string&& branch): path(std::move(path)), configuration(std::move(configuration)), commit(std::move(commit)), branch(std::move(branch)) { }
|
||||
};;
|
||||
|
||||
export enum ConfigurationType {
|
||||
CRAFTER_CONFIGURATION_TYPE_EXECUTABLE,
|
||||
CRAFTER_CONFIGURATION_TYPE_LIBRARY,
|
||||
CRAFTER_CONFIGURATION_TYPE_SHARED_LIBRARY,
|
||||
};
|
||||
|
||||
export class Configuration {
|
||||
public:
|
||||
std::string name;
|
||||
std::string standard;
|
||||
std::vector<std::unique_ptr<Module>> interfaces;
|
||||
std::vector<Implementation> implementations;
|
||||
std::vector<Dependency> dependencies;
|
||||
std::vector<Shader> shaders;
|
||||
std::vector<fs::path> additionalFiles;
|
||||
std::vector<Define> defines;
|
||||
fs::path buildDir;
|
||||
fs::path outputDir;
|
||||
ConfigurationType type;
|
||||
std::string target;
|
||||
std::string march;
|
||||
bool debug;
|
||||
std::vector<std::string> libs;
|
||||
Configuration(std::string&& name);
|
||||
Configuration(const nlohmann::json& configs, const nlohmann::json& config, fs::path workingDir);
|
||||
void SetDataFromJson(const nlohmann::json& configs, const nlohmann::json& config, fs::path workingDir);
|
||||
};
|
||||
}
|
||||
82
interfaces/Crafter.Build-FixedVector.cppm
Normal file
82
interfaces/Crafter.Build-FixedVector.cppm
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
Crafter® Build
|
||||
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 version 3.0 as published by the Free Software Foundation;
|
||||
|
||||
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.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
export module Crafter.Build:FixedVector;
|
||||
import std;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace Crafter {
|
||||
export template <typename T>
|
||||
class FixedVector {
|
||||
public:
|
||||
using value_type = T;
|
||||
using iterator = T*;
|
||||
using const_iterator = const T*;
|
||||
T* values;
|
||||
std::uint_fast32_t size_;
|
||||
FixedVector() {}
|
||||
FixedVector(std::uint_fast32_t size): values(reinterpet_cast<T*>(operator new[](size * sizeof(T)))), size_(size) {}
|
||||
|
||||
void Set(std::uint_fast32_t size) {
|
||||
#ifdef CRAFTER_BUILD_CONFIGURATION_DEBUG
|
||||
if(this->size_ != 0) {
|
||||
throw std::runtime_error("FixedVector already set!");
|
||||
}
|
||||
#endif
|
||||
values = reinterpet_cast<T*>(operator new[](size * sizeof(T)));
|
||||
this->size_ = size;
|
||||
}
|
||||
|
||||
~FixedVector() {
|
||||
delete[] values;
|
||||
}
|
||||
|
||||
FixedVector(const FixedVector&) = delete;
|
||||
FixedVector& operator=(const FixedVector&) = delete;
|
||||
|
||||
FixedVector(FixedVector&& other) noexcept : values(other.values), size_(other.size_) {
|
||||
other.values = nullptr;
|
||||
other.size_ = 0;
|
||||
}
|
||||
|
||||
FixedVector& operator=(FixedVector&& other) noexcept {
|
||||
if (this != &other) {
|
||||
delete[] values;
|
||||
values = other.values;
|
||||
size_ = other.size_;
|
||||
other.values = nullptr;
|
||||
other.size_ = 0;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
T& operator[](std::uint_fast32_t index) { return values[index]; }
|
||||
const T& operator[](std::uint_fast32_t index) const { return values[index]; }
|
||||
|
||||
std::uint_fast32_t size() const { return size_; }
|
||||
|
||||
iterator begin() { return values; }
|
||||
const_iterator begin() const { return values; }
|
||||
const_iterator cbegin() const { return values; }
|
||||
|
||||
iterator end() { return values + size_; }
|
||||
const_iterator end() const { return values + size_; }
|
||||
const_iterator cend() const { return values + size_; }
|
||||
};
|
||||
}
|
||||
36
interfaces/Crafter.Build-Implementation.cppm
Normal file
36
interfaces/Crafter.Build-Implementation.cppm
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
Crafter® Build
|
||||
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 version 3.0 as published by the Free Software Foundation;
|
||||
|
||||
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.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
export module Crafter.Build:Implementation;
|
||||
import std;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace Crafter {
|
||||
export class Module;
|
||||
export class ModulePartition;
|
||||
export class Implementation {
|
||||
public:
|
||||
std::vector<Module*> moduleDependencies;
|
||||
std::vector<ModulePartition*> partitionDependencies;
|
||||
fs::path path;
|
||||
Implementation(fs::path&& path);
|
||||
bool Check(const fs::path& buildDir, const fs::path& pcmDir) const;
|
||||
void Compile(const std::string_view clang, const fs::path& pcmDir, const fs::path& buildDir) const;
|
||||
};
|
||||
}
|
||||
54
interfaces/Crafter.Build-Module.cppm
Normal file
54
interfaces/Crafter.Build-Module.cppm
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
Crafter® Build
|
||||
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 version 3.0 as published by the Free Software Foundation;
|
||||
|
||||
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.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
export module Crafter.Build:Module;
|
||||
import std;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace Crafter {
|
||||
export class Module;
|
||||
export class ModulePartition {
|
||||
public:
|
||||
std::vector<Module*> moduleDependencies;
|
||||
std::vector<ModulePartition*> partitionDependencies;
|
||||
std::atomic<bool> compiled;
|
||||
bool needsRecompiling;
|
||||
bool checked = false;
|
||||
std::string name;
|
||||
fs::path path;
|
||||
ModulePartition(std::string&& name, fs::path&& path);
|
||||
bool Check(const fs::path& pcmDir);
|
||||
void Compile(const std::string_view clang, const fs::path& pcmDir, const fs::path& buildDir);
|
||||
};
|
||||
|
||||
export class Module {
|
||||
public:
|
||||
std::atomic<bool> compiled;
|
||||
bool needsRecompiling;
|
||||
bool checked = false;
|
||||
std::vector<std::unique_ptr<ModulePartition>> partitions;
|
||||
std::string name;
|
||||
fs::path path;
|
||||
Module(fs::path&& path);
|
||||
Module(std::string&& name, fs::path&& path);
|
||||
Module(std::string&& name, fs::path&& path, std::vector<std::unique_ptr<ModulePartition>>&& partitions);
|
||||
bool Check(const fs::path& pcmDir);
|
||||
void Compile(const std::string_view clang, const fs::path& pcmDir, const fs::path& buildDir);
|
||||
};
|
||||
}
|
||||
47
interfaces/Crafter.Build-Project.cppm
Normal file
47
interfaces/Crafter.Build-Project.cppm
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
Crafter® Build
|
||||
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 version 3.0 as published by the Free Software Foundation;
|
||||
|
||||
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.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
export module Crafter.Build:Project;
|
||||
import std;
|
||||
import :Configuration;
|
||||
import :Test;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace Crafter {
|
||||
export class Project {
|
||||
public:
|
||||
std::string name;
|
||||
fs::path path;
|
||||
std::vector<Configuration> configurations;
|
||||
std::vector<Test> tests;
|
||||
Project(std::string&& name, fs::path&& path, std::vector<Configuration>&& configurations);
|
||||
static Project LoadFromJSON(const fs::path& path);
|
||||
Configuration& Build(std::string_view configuration);
|
||||
Configuration& Build(std::string_view configuration, const fs::path& outputDir);
|
||||
Configuration& Build(std::string_view configuration, const fs::path& outputDir, const fs::path& binDir);
|
||||
Configuration& Build(std::string_view configuration, const fs::path& outputDir, const fs::path& binDir, const fs::path& builDir);
|
||||
void Build(Configuration& configuration) const;
|
||||
void Build(Configuration& configuration, const fs::path& outputDir) const;
|
||||
void Build(Configuration& configuration, const fs::path& outputDir, const fs::path& binDir) const;
|
||||
void Build(Configuration& configuration, const fs::path& outputDir, const fs::path& binDir, const fs::path& builDir) const;
|
||||
TestResult RunTest(const std::string_view test);
|
||||
TestResult RunTest(Test& test);
|
||||
std::vector<TestResult> RunTests();
|
||||
};
|
||||
}
|
||||
39
interfaces/Crafter.Build-Shader.cppm
Normal file
39
interfaces/Crafter.Build-Shader.cppm
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
Crafter® Build
|
||||
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 version 3.0 as published by the Free Software Foundation;
|
||||
|
||||
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.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
module;
|
||||
#include <glslang/SPIRV/GlslangToSpv.h>
|
||||
#include <glslang/Public/ShaderLang.h>
|
||||
#include <glslang/Public/ResourceLimits.h>
|
||||
#include "../lib/DirStackFileIncluder.h"
|
||||
export module Crafter.Build:Shader;
|
||||
import std;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace Crafter {
|
||||
export class Shader {
|
||||
public:
|
||||
fs::path path;
|
||||
std::string entrypoint;
|
||||
EShLanguage type;
|
||||
Shader(fs::path&& path, std::string&& entrypoint, EShLanguage type);
|
||||
bool Check(const fs::path& outputDir) const;
|
||||
void Compile(const fs::path& outputDir) const;
|
||||
};
|
||||
}
|
||||
39
interfaces/Crafter.Build-Test.cppm
Normal file
39
interfaces/Crafter.Build-Test.cppm
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
Crafter® Build
|
||||
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 version 3.0 as published by the Free Software Foundation;
|
||||
|
||||
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.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
module;
|
||||
#include "../lib/json.hpp"
|
||||
export module Crafter.Build:Test;
|
||||
import std;
|
||||
import :Configuration;
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace Crafter {
|
||||
export struct TestResult {
|
||||
std::string name;
|
||||
std::string message;
|
||||
};
|
||||
|
||||
export class Test {
|
||||
public:
|
||||
Configuration config;
|
||||
Test(Configuration&& name);
|
||||
Test(const nlohmann::json& configs, const nlohmann::json& config, const fs::path& workingDir);
|
||||
};
|
||||
}
|
||||
28
interfaces/Crafter.Build.cppm
Normal file
28
interfaces/Crafter.Build.cppm
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
Crafter® Build
|
||||
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 version 3.0 as published by the Free Software Foundation;
|
||||
|
||||
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.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
export module Crafter.Build;
|
||||
export import :Command;
|
||||
export import :Project;
|
||||
export import :Module;
|
||||
export import :Configuration;
|
||||
export import :Shader;
|
||||
export import :Implementation;
|
||||
export import :FixedVector;
|
||||
export import :Test;
|
||||
Loading…
Add table
Add a link
Reference in a new issue