V2 progress

This commit is contained in:
Jorijn van der Graaf 2026-04-23 01:57:25 +02:00
commit 5e1fcd8590
9837 changed files with 790 additions and 1708518 deletions

View file

@ -0,0 +1,65 @@
/*
Crafter® Build
Copyright (C) 2026 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:Clang;
import std;
import :Shader;
namespace fs = std::filesystem;
export namespace Crafter {
struct BuildResult {
std::string result;
bool repack;
std::unordered_set<std::string> libs;
}
struct Dependency {
fs::path path;
std::vector<std::pair<std::string, std::string>> arguments;
}
export struct Define {
std::string name;
std::string value;
};
enum class ConfigurationType {
Executable,
LibraryStatic,
LibraryDynamic,
};
struct Configuration {
std::string march = "native";
std::string mtune = "native";
bool debug = false;
ConfigurationType type = ConfigurationType::Executable;
std::vector<std::path> interfaces;
std::vector<std::path> implementations;
std::vector<std::path> cFiles;
std::vector<std::path> dependencies;
std::vector<std::path> files;
std::vector<Define> defines;
std::vector<Shader> shaders;
std::vector<Dependency> deps;
}
BuildResult Build(fs::path config, std::unordered_set<std::string> depSet);
BuildResult Build(const Configuration& config, std::unordered_set<std::string> depSet);
}

View file

@ -1,46 +0,0 @@
/*
Crafter® Build
Copyright (C) 2026 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 class Project;
export class Configuration;
export std::string RunCommand(const std::string_view cmd);
export void RunCommandIgnore(const std::string_view cmd);
export std::string RunClang(const std::string_view cmd);
export std::filesystem::path GetPath();
export void BuildStdPcm(const Project& project, const Configuration& configuration);
}

View file

@ -1,73 +0,0 @@
/*
Crafter® Build
Copyright (C) 2026 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 enum ConfigurationType {
CRAFTER_CONFIGURATION_TYPE_EXECUTABLE,
CRAFTER_CONFIGURATION_TYPE_LIBRARY,
CRAFTER_CONFIGURATION_TYPE_SHARED_LIBRARY,
};
export struct CmakeDep {
fs::path path;
std::string options;
};
export class Project;
export class Configuration {
public:
std::string name;
std::string standard;
std::vector<std::unique_ptr<Module>> interfaces;
std::vector<Implementation> implementations;
std::vector<std::string> includeDirs;
std::vector<std::string> libDirs;
std::vector<fs::path> c_files;
std::vector<fs::path> cuda;
std::vector<std::tuple<std::shared_ptr<Project>, Configuration&>> dependencies;
std::vector<CmakeDep> cmakeDeps;
std::vector<Shader> shaders;
std::vector<fs::path> additionalFiles;
std::vector<Define> defines;
ConfigurationType type;
std::string target;
std::string march;
std::string mtune;
bool debug;
std::vector<std::string> libs;
Configuration(std::string&& name);
Configuration(const nlohmann::json& configs, const nlohmann::json& config, fs::path workingDir, const Project& project);
void SetDataFromJson(const nlohmann::json& configs, const nlohmann::json& config, fs::path workingDir, const Project& project);
};
}

View file

@ -17,8 +17,7 @@ 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 :CompileStatus;
export module Crafter.Build:Interface;
import std;
namespace fs = std::filesystem;
@ -28,30 +27,26 @@ namespace Crafter {
public:
std::vector<Module*> moduleDependencies;
std::vector<ModulePartition*> partitionDependencies;
std::atomic<CompileStatus> compiled;
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, std::string& result);
void CompileSource(const std::string_view clang, const fs::path& pcmDir, const fs::path& buildDir, std::string& result);
void Compile(const std::string_view clang, const fs::path& pcmDir, const fs::path& buildDir, std::atomic<bool>& buildCancelled, std::string& buildError);
};
export class Module {
public:
std::atomic<CompileStatus> compiled;
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, std::string& result);
void CompileSource(const std::string_view clang, const fs::path& pcmDir, const fs::path& buildDir, std::string& result);
void Compile(const std::string_view clang, const fs::path& pcmDir, const fs::path& buildDir, std::atomic<bool>& buildCancelled, std::string& buildError);
};
}

View file

@ -17,13 +17,14 @@ 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:CompileStatus;
export module Crafter.Build:Platform;
import std;
namespace fs = std::filesystem;
namespace Crafter {
export enum CompileStatus {
CRAFTER_COMPILE_STATUS_WAITING,
CRAFTER_COMPILE_STATUS_COMPLETED,
CRAFTER_COMPILE_STATUS_ERROR
};
struct Configuration;
std::string BuildStdPcm(Configuration& config);
fs::path GetCacheDir();
std::string RunCommand();
std::string GetBaseCommand(Configuration& config);
}

View file

@ -1,52 +0,0 @@
/*
Crafter® Build
Copyright (C) 2026 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 struct BuildResult {
std::string errors;
bool repack;
};
export class Project {
public:
std::string name;
fs::path buildDir;
fs::path binDir;
fs::path path;
std::vector<Configuration> configurations;
std::vector<Test> tests;
Project(fs::path&& path);
Project(fs::path&& path, const std::string_view config);
Project(std::string&& name, fs::path&& path, std::vector<Configuration>&& configurations);
Project(std::string&& name, fs::path&& path, std::vector<Configuration>&& configurations, fs::path&& buildDir, fs::path&& binDir);
std::tuple<Configuration&, BuildResult> Build(std::string_view configuration);
std::tuple<Configuration&, BuildResult> Build(std::string_view configuration, const fs::path& binDir, const fs::path& outputDir, const fs::path& buildDir, std::string outputName);
BuildResult Build(Configuration& configuration) const;
BuildResult Build(Configuration& configuration, const fs::path& binDir, const fs::path& outputDir, const fs::path& buildDir, std::string outputName) const;
TestResult RunTest(const std::string_view test);
TestResult RunTest(Test& test) const;
std::vector<TestResult> RunTests();
};
}

View file

@ -31,6 +31,6 @@ namespace Crafter {
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;
std::string Compile(const fs::path& outputDir) const;
};
}

View file

@ -1,40 +0,0 @@
/*
Crafter® Build
Copyright (C) 2026 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 Project;
export class Test {
public:
Configuration config;
Test(Configuration&& name);
Test(const nlohmann::json& configs, const nlohmann::json& config, const fs::path& workingDir, const Project& project);
};
}

View file

@ -18,11 +18,7 @@ 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 :Clang;
export import :Platform;
export import :Implementation;
export import :Test;
export import :CompileStatus;
export import :Shader;