diff options
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/BuildKit/Defines.h | 8 | ||||
| -rw-r--r-- | dev/BuildKit/IManifestBuilder.h | 24 | ||||
| -rw-r--r-- | dev/BuildKit/Imports.h | 4 | ||||
| -rw-r--r-- | dev/BuildKit/JSONManifestBuilder.h | 18 | ||||
| -rw-r--r-- | dev/BuildKit/TOMLManifestBuilder.h | 18 | ||||
| -rw-r--r-- | dev/cli/AppMain.cc (renamed from dev/cli/App.cc) | 4 | ||||
| -rw-r--r-- | dev/src/JSONManifestBuilder.cc | 8 | ||||
| -rw-r--r-- | dev/src/TOMLManifestBuilder.cc | 17 |
8 files changed, 70 insertions, 31 deletions
diff --git a/dev/BuildKit/Defines.h b/dev/BuildKit/Defines.h index 4774c85..1c88ceb 100644 --- a/dev/BuildKit/Defines.h +++ b/dev/BuildKit/Defines.h @@ -7,12 +7,16 @@ #include <BuildKit/Imports.h> +/// =========================================================== /// +/// @brief Defines file +/// =========================================================== /// + #define LIKELY(ARG) ((ARG) ? assert(false) : ((void) 0)) #define UNLIKELY(ARG) LIKELY(!(ARG)) -#define LIBNEBUILD_VERSION "v0.0.1-libNeBuild" +#define LIBNEBUILD_VERSION "v0.0.7-buildkit" -#define LIBNEBUILD_VERSION_BCD 0x0001 +#define LIBNEBUILD_VERSION_BCD 0x0007 #define LIBNEBUILD_VERSION_MAJOR 1 #define LIBNEBUILD_VERSION_MINOR 1 diff --git a/dev/BuildKit/IManifestBuilder.h b/dev/BuildKit/IManifestBuilder.h index 8f9b2cf..abb389f 100644 --- a/dev/BuildKit/IManifestBuilder.h +++ b/dev/BuildKit/IManifestBuilder.h @@ -7,11 +7,13 @@ #include <BuildKit/Defines.h> -#define NEBUILD_MANIFEST_BUILDER : public NeBuild::IManifestBuilder +#define NEBUILD_MANIFEST_BUILDER : public ::NeBuild::IManifestBuilder namespace NeBuild { +/// =========================================================== /// /// @brief Builder interface class. /// @note This class is meant to be used as an interface. +/// =========================================================== /// class IManifestBuilder { public: IManifestBuilder() = default; @@ -20,12 +22,18 @@ class IManifestBuilder { IManifestBuilder& operator=(const IManifestBuilder&) = default; IManifestBuilder(const IManifestBuilder&) = default; - /// @brief Builds a target using the implemented laguage. - /// @param arg_sz filename size - /// @param arg_val filename path. - /// @retval true succeeded. - /// @retval false failed. - virtual bool BuildTarget(const std::string& arg, const bool dry_run = false) = 0; - virtual const char* BuildSystem() = 0; + /// =========================================================== /// + /// @brief Builds a TOML target from a file. + /// @param arg_sz filename size (must be 1 or greater). + /// @param arg_val filename path (must be a valid language file). + /// @retval true building has succeeded. + /// @retval false fail to build, see error message. + /// =========================================================== /// + virtual bool BuildTarget(const std::string& arg, const bool dry_run = false) = 0; + + /// =========================================================== /// + /// @brief Returns the build system name. + /// =========================================================== /// + virtual const char* BuildSystem() = 0; }; } // namespace NeBuild
\ No newline at end of file diff --git a/dev/BuildKit/Imports.h b/dev/BuildKit/Imports.h index e22c933..33e1e31 100644 --- a/dev/BuildKit/Imports.h +++ b/dev/BuildKit/Imports.h @@ -6,6 +6,10 @@ #ifndef NEBUILD_INCLUDES_H #define NEBUILD_INCLUDES_H +/// =========================================================== /// +/// @brief Imports file +/// =========================================================== /// + #include <rang/rang.h> #include <cassert> #include <cstddef> diff --git a/dev/BuildKit/JSONManifestBuilder.h b/dev/BuildKit/JSONManifestBuilder.h index 81643e3..438bdab 100644 --- a/dev/BuildKit/JSONManifestBuilder.h +++ b/dev/BuildKit/JSONManifestBuilder.h @@ -22,12 +22,18 @@ class JSONManifestBuilder final NEBUILD_MANIFEST_BUILDER { JSONManifestBuilder(const JSONManifestBuilder&) = default; public: - /// @brief Builds a JSON target. - /// @param arg_sz filename size - /// @param arg_val filename path. - /// @retval true build succeeded. - /// @retval false failed to build. - bool BuildTarget(const std::string& arg_val, const bool dry_run = false) override; + /// =========================================================== /// + /// @brief Builds a JSON target from a JSON file. + /// @param arg_sz filename size (must be 1 or greater). + /// @param arg_val filename path (must be a valid JSON file). + /// @retval true building has succeeded. + /// @retval false fail to build, see error message. + /// =========================================================== /// + bool BuildTarget(const std::string& arg_val, const bool dry_run = false) override; + + /// =========================================================== /// + /// @brief Returns the build system name. + /// =========================================================== /// const char* BuildSystem() override; }; } // namespace NeBuild
\ No newline at end of file diff --git a/dev/BuildKit/TOMLManifestBuilder.h b/dev/BuildKit/TOMLManifestBuilder.h index 6baa9f5..7c508fc 100644 --- a/dev/BuildKit/TOMLManifestBuilder.h +++ b/dev/BuildKit/TOMLManifestBuilder.h @@ -22,12 +22,18 @@ class TOMLManifestBuilder final NEBUILD_MANIFEST_BUILDER { TOMLManifestBuilder(const TOMLManifestBuilder&) = default; public: - /// @brief Builds a TOML target. - /// @param arg_sz filename size - /// @param arg_val filename path. - /// @retval true build succeeded. - /// @retval false failed to build. - bool BuildTarget(const std::string& arg_val, const bool dry_run = false) override; + /// =========================================================== /// + /// @brief Builds a TOML target from a TOML file. + /// @param arg_sz filename size (must be 1 or greater). + /// @param arg_val filename path (must be a valid TOML file). + /// @retval true building has succeeded. + /// @retval false fail to build, see error message. + /// =========================================================== /// + bool BuildTarget(const std::string& arg_val, const bool dry_run = false) override; + + /// =========================================================== /// + /// @brief Returns the build system name. + /// =========================================================== /// const char* BuildSystem() override; }; } // namespace NeBuild
\ No newline at end of file diff --git a/dev/cli/App.cc b/dev/cli/AppMain.cc index d78ad69..53cbdf3 100644 --- a/dev/cli/App.cc +++ b/dev/cli/AppMain.cc @@ -17,7 +17,7 @@ int main(int argc, char** argv) { std::string index_path = argv[index]; if (index_path == "-v" || index_path == "--version") { - NeBuild::Logger::info() << "NeKernel Build Tool.\n"; + NeBuild::Logger::info() << "NeKernel Build.\n"; NeBuild::Logger::info() << "Bugs or issues? Check out: https://github.com/nekernel-org/nebuild/issues\n"; @@ -58,7 +58,7 @@ int main(int argc, char** argv) { goto end; } else { NeBuild::Logger::info() - << "error: file '" << index_path << "' is not a JSON file!" << std::endl; + << "error: file '" << index_path << "' is not a manifest file!" << std::endl; kFailed = true; return; } diff --git a/dev/src/JSONManifestBuilder.cc b/dev/src/JSONManifestBuilder.cc index dba5b37..8eaf20a 100644 --- a/dev/src/JSONManifestBuilder.cc +++ b/dev/src/JSONManifestBuilder.cc @@ -10,11 +10,13 @@ namespace FS = std::filesystem; using namespace NeBuild; +/// =========================================================== /// /// @brief Builds a JSON target from a JSON file. /// @param arg_sz filename size (must be 1 or greater). /// @param arg_val filename path (must be a valid JSON file). /// @retval true building has succeeded. /// @retval false fail to build, see error message. +/// =========================================================== /// bool JSONManifestBuilder::BuildTarget(const std::string& argv_val, const bool dry_run) { std::string path; @@ -84,7 +86,6 @@ bool JSONManifestBuilder::BuildTarget(const std::string& argv_val, const bool dr auto target = json_obj["output_name"].get<std::string>(); NeBuild::Logger::info() << "output path: " << target << "\n"; - NeBuild::Logger::info() << "command: " << command << "\n"; auto ret_exec = std::system(command.c_str()); @@ -94,13 +95,16 @@ bool JSONManifestBuilder::BuildTarget(const std::string& argv_val, const bool dr return false; } } catch (std::runtime_error& err) { - NeBuild::Logger::info() << "error: " << err.what() << std::endl; + NeBuild::Logger::info() << "error: exit with message: " << err.what() << "" << std::endl; return false; } return true; } +/// =========================================================== /// +/// @brief Returns the build system name. +/// =========================================================== /// const char* JSONManifestBuilder::BuildSystem() { return "NeBuild (JSON)"; } diff --git a/dev/src/TOMLManifestBuilder.cc b/dev/src/TOMLManifestBuilder.cc index 53034e8..f264ade 100644 --- a/dev/src/TOMLManifestBuilder.cc +++ b/dev/src/TOMLManifestBuilder.cc @@ -9,11 +9,13 @@ namespace FS = std::filesystem; using namespace NeBuild; +/// =========================================================== /// /// @brief Builds a TOML target from a TOML file. /// @param arg_sz filename size (must be 1 or greater). /// @param arg_val filename path (must be a valid TOML file). /// @retval true building has succeeded. /// @retval false fail to build, see error message. +/// =========================================================== /// bool TOMLManifestBuilder::BuildTarget(const std::string& argv_val, const bool dry_run) { std::string path; @@ -77,15 +79,17 @@ bool TOMLManifestBuilder::BuildTarget(const std::string& argv_val, const bool dr } } - if (toml_file["compiler_std"].is_string()) - command += "-std=" + toml_file["compiler_std"].as_string()->get() + " "; + if (!toml_file["compiler_std"].is_string()) return false; + + command += "-std=" + toml_file["compiler_std"].as_string()->get() + " "; + + if (toml_file["output_name"].as_string() == nullptr) return false; command += "-o " + toml_file["output_name"].as_string()->get(); auto target = toml_file["output_name"].as_string()->get(); - NeBuild::Logger::info() << "output path: " << target << "\n"; - NeBuild::Logger::info() << "command: " << command << "\n"; + NeBuild::Logger::info() << "output: " << target << "\n"; auto ret_exec = std::system(command.c_str()); @@ -95,13 +99,16 @@ bool TOMLManifestBuilder::BuildTarget(const std::string& argv_val, const bool dr return false; } } catch (std::runtime_error& err) { - NeBuild::Logger::info() << "error: " << err.what() << std::endl; + NeBuild::Logger::info() << "error: exit with message: " << err.what() << "" << std::endl; return false; } return true; } +/// =========================================================== /// +/// @brief Returns the build system name. +/// =========================================================== /// const char* TOMLManifestBuilder::BuildSystem() { return "NeBuild (TOML)"; } |
