Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ jobs:
- uses: actions/checkout@v4
- name: Install Packages
run: sudo apt update && sudo apt install build-essential
- name: Build BTB
run: make build-btb
- name: Build NeBuild
run: make build-nebuild
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ syntax: glob
html/
latex/

btb
nebuild

.cmake/
.qtc_clangd/
Expand Down
34 changes: 0 additions & 34 deletions BTBKit/Macros.h

This file was deleted.

3 changes: 2 additions & 1 deletion CREDITS
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
rang: https://github.com/agauniyal/rang
json: https://github.com/nlohmann/json
json: https://github.com/nlohmann/json
toml++: https://marzer.github.io/tomlplusplus/
18 changes: 9 additions & 9 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
SUDO=sudo
GCC=g++
GCC_MINGW=x86_64-w64-mingw32-g++
CXXFLAGS=-I./ -I./vendor
CXXFLAGS=-I./dev -I./vendor
CXXSTD= -std=c++20
SRC=$(wildcard cli/*.cc) $(wildcard src/*.cc)
OUT=btb
SRC=$(wildcard dev/cli/*.cc) $(wildcard dev/src/*.cc)
OUT=nebuild
CP=cp

.PHONY: build-btb
build-btb:
.PHONY: build-nebuild
build-nebuild:
$(SUDO) $(GCC) $(CXXFLAGS) $(SRC) $(CXXSTD) -o $(OUT)
$(SUDO) $(CP) $(OUT) /usr/local/bin

.PHONY: build-btb-windows
build-btb-windows:
.PHONY: build-nebuild-windows
build-nebuild-windows:
$(GCC_MINGW) $(CXXFLAGS) $(SRC) -o $(OUT).exe

.PHONY: help
help:
@echo "=> help: Show this help message."
@echo "=> build-btb-windows: Build BTB for Windows."
@echo "=> build-btb: Build BTB for POSIX."
@echo "=> build-nebuild-windows: Build NeBuild for Windows."
@echo "=> build-nebuild: Build NeBuild for POSIX."
17 changes: 8 additions & 9 deletions ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# BTB.
# NeBuild

![CI](https://github.com/amlel-el-mahrouss/btb/actions/workflows/c-cpp.yml/badge.svg)
![CI](https://github.com/nekernel-ort/nebuild/actions/workflows/c-cpp.yml/badge.svg)
[![License: GPL-3.0](https://img.shields.io/badge/license-BSD--3.0-blue.svg)](LICENSE)
[![QEMU Tested](https://img.shields.io/badge/QEMU-Tested-success)](#)

## Installation requirements:
## Requirements:

- GNU C++
- GNU Make

## Steps (GNU Make):
## Guide (GNU Make):

- Run make `build-btb-core` and `build-btb`.
- Run make `build-nebuild-core` and `build-nebuild`.

## Steps (BTB):
## Guide (NeBuild):

- Run `btb` and pass the path to the manifest file.
- Run `nebuild` and pass the path to the manifest file.

###### Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. All rights reserved.
###### Copyright (C) 2024-2025, Amlal El Mahrouss and NeKernel.org Authors, all rights reserved.
5 changes: 3 additions & 2 deletions compile_flags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-std=c++20
-I./
-Ivendor
-Idev/
-Ivendor
-xc++
30 changes: 30 additions & 0 deletions dev/BuildKit/Defines.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// ============================================================= //
// nebuild
// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
// ============================================================= //

#pragma once

#include <BuildKit/Imports.h>

#define LIKELY(ARG) ((ARG) ? assert(false) : ((void) 0))
#define UNLIKELY(ARG) LIKELY(!(ARG))

#define LIBNEBUILD_VERSION "v0.0.1-libNeBuild"

#define LIBNEBUILD_VERSION_BCD 0x0001

#define LIBNEBUILD_VERSION_MAJOR 1
#define LIBNEBUILD_VERSION_MINOR 1
#define LIBNEBUILD_VERSION_PATCH 0

#define LIBNEBUILD_UNUSED(X) ((void) X)

namespace NeBuild::Logger {
/// @brief replacement for std::cout for NeBuild logging.
inline std::ostream& info() noexcept {
auto& out = std::cout;
out << rang::fg::red << "nebuild: " << rang::style::reset;
return out;
}
} // namespace NeBuild::Logger
17 changes: 8 additions & 9 deletions BTBKit/IManifestBuilder.h → dev/BuildKit/IManifestBuilder.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
// ============================================================= //
// btb
// nebuild
// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
// ============================================================= //

#pragma once

#include <BTBKit/Includes.h>
#include <BTBKit/Macros.h>
#include <BuildKit/Defines.h>

#define BTB_MANIFEST_BUILDER : public BTB::IManifestBuilder
#define NEBUILD_MANIFEST_BUILDER : public NeBuild::IManifestBuilder

namespace BTB {
namespace NeBuild {
/// @brief Builder interface class.
/// @note This class is meant to be used as an interface.
class IManifestBuilder {
public:
IManifestBuilder() = default;
IManifestBuilder() = default;
virtual ~IManifestBuilder() = default;

IManifestBuilder& operator=(const IManifestBuilder&) = default;
Expand All @@ -26,7 +25,7 @@ class IManifestBuilder {
/// @param arg_val filename path.
/// @retval true succeeded.
/// @retval false failed.
virtual bool buildTarget(int arg_sz, const char* arg_val, const bool dry_run = false) = 0;
virtual const char* buildSystem() = 0;
virtual bool BuildTarget(const std::string& arg, const bool dry_run = false) = 0;
virtual const char* BuildSystem() = 0;
};
} // namespace BTB
} // namespace NeBuild
10 changes: 6 additions & 4 deletions BTBKit/Includes.h → dev/BuildKit/Imports.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// ============================================================= //
// btb
// nebuild
// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
// ============================================================= //

#ifndef BTB_INCLUDES_H
#define BTB_INCLUDES_H
#ifndef NEBUILD_INCLUDES_H
#define NEBUILD_INCLUDES_H

#include <rang/rang.h>
#include <cassert>
#include <cstddef>
#include <cstdio>
#include <fstream>
Expand All @@ -14,4 +16,4 @@
#include <string>
#include <thread>

#endif // BTB_INCLUDES_H
#endif // NEBUILD_INCLUDES_H
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
// ============================================================= //
// btb
// nebuild
// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
// ============================================================= //

#pragma once

#include <BTBKit/IManifestBuilder.h>
#include <json.h>
#include <BuildKit/IManifestBuilder.h>
#include <json/json.h>

namespace BTB {
/// @file JSONManifestBuilder.h
/// @brief JSON manifest builder header file.

namespace NeBuild {
/// @brief JSON builder
class JSONManifestBuilder final BTB_MANIFEST_BUILDER {
class JSONManifestBuilder final NEBUILD_MANIFEST_BUILDER {
public:
JSONManifestBuilder() = default;
JSONManifestBuilder() = default;
~JSONManifestBuilder() override = default;

JSONManifestBuilder& operator=(const JSONManifestBuilder&) = default;
Expand All @@ -24,7 +27,7 @@ class JSONManifestBuilder final BTB_MANIFEST_BUILDER {
/// @param arg_val filename path.
/// @retval true build succeeded.
/// @retval false failed to build.
bool buildTarget(int arg_sz, const char* arg_val, const bool dry_run = false) override;
const char* buildSystem() override;
bool BuildTarget(const std::string& arg_val, const bool dry_run = false) override;
const char* BuildSystem() override;
};
} // namespace BTB
} // namespace NeBuild
33 changes: 33 additions & 0 deletions dev/BuildKit/TOMLManifestBuilder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// ============================================================= //
// nebuild
// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
// ============================================================= //

#pragma once

#include <BuildKit/IManifestBuilder.h>
#include <toml++/toml.hpp>

/// @file TOMLManifestBuilder.h
/// @brief TOML manifest builder header file.

namespace NeBuild {
/// @brief TOML builder
class TOMLManifestBuilder final NEBUILD_MANIFEST_BUILDER {
public:
TOMLManifestBuilder() = default;
~TOMLManifestBuilder() override = default;

TOMLManifestBuilder& operator=(const TOMLManifestBuilder&) = default;
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(int arg_sz, const char* arg_val, const bool dry_run = false) override;
const char* BuildSystem() override;
};
} // namespace NeBuild
29 changes: 14 additions & 15 deletions cli/CommandLine.cc → dev/cli/Tool.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

// ============================================================= //
// btb
// nebuild
// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
// ============================================================= //

#include <BTBKit/Includes.h>
#include <BTBKit/JSONManifestBuilder.h>
#include <BuildKit/JSONManifestBuilder.h>

static bool kFailed = false;
static bool kDryRun = false;
Expand All @@ -17,51 +16,51 @@ int main(int argc, char** argv) {
std::string index_path = argv[index];

if (index_path == "-v" || index_path == "--version") {
BTB::Logger::info() << "Brought to you by Amlal El Mahrouss for the NeKernel project.\n";
BTB::Logger::info() << "© 2024-2025 Amlal El Mahrouss, all rights reserved.\n";
NeBuild::Logger::info() << "Brought to you by Amlal El Mahrouss for NeKernel.org.\n";
NeBuild::Logger::info() << "© 2024-2025 Amlal El Mahrouss, all rights reserved.\n";

BTB::Logger::info()
<< "Bugs, issues? Check out: https://github.com/nekernel-org/btb/issues\n";
NeBuild::Logger::info()
<< "Bugs, issues? Check out: https://github.com/nekernel-org/nebuild/issues\n";

return EXIT_SUCCESS;
} else if (index_path == "--dry-run") {
kDryRun = true;
continue;
} else if (index_path == "-h" || index_path == "--help") {
BTB::Logger::info() << "Usage: btb <file>\n";
NeBuild::Logger::info() << "Usage: nebuild <file>\n";

return EXIT_SUCCESS;
}

if (index_path.starts_with("-")) {
BTB::Logger::info() << "error: unknown option '" << index_path << "'\n";
NeBuild::Logger::info() << "error: unknown option '" << index_path << "'\n";

return EXIT_FAILURE;
}

std::thread job_build_thread(
[](std::string index_path) -> void {
BTB::IManifestBuilder* builder = nullptr;
NeBuild::IManifestBuilder* builder = nullptr;

const auto kJsonExtension = ".json";

if (index_path.ends_with(kJsonExtension)) {
builder = new BTB::JSONManifestBuilder();
builder = new NeBuild::JSONManifestBuilder();

if (!builder) {
kFailed = true;
return;
}
} else {
BTB::Logger::info() << "error: file '" << index_path << "' is not a JSON file!"
<< std::endl;
NeBuild::Logger::info()
<< "error: file '" << index_path << "' is not a JSON file!" << std::endl;
kFailed = true;
return;
}

BTB::Logger::info() << "building manifest: " << index_path << std::endl;
NeBuild::Logger::info() << "building manifest: " << index_path << std::endl;

if (builder && !builder->buildTarget(index_path.size(), index_path.c_str(), kDryRun)) {
if (builder && !builder->BuildTarget(index_path, kDryRun)) {
kFailed = true;
}

Expand Down
4 changes: 2 additions & 2 deletions src/IManifestBuilder.cc → dev/src/IManifestBuilder.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ============================================================= //
// btb
// nebuild
// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
// ============================================================= //

#include <BTBKit/IManifestBuilder.h>
#include <BuildKit/IManifestBuilder.h>
Loading