From b21246fbf4b082e21f811d488bd85e8dafdee428 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 18 Nov 2025 08:45:58 +0100 Subject: feat: CMake file, new entries to gitignore, and code under BSD-3 now. Signed-off-by: Amlal El Mahrouss --- .gitignore | 3 +++ CMakeLists.txt | 37 +++++++++++++++++++++++++++++++++++++ GNUmakefile | 10 ++++++++-- ReadMe.md | 15 +++++++++++++++ dev/BuildKit/Defines.h | 2 +- dev/BuildKit/IManifestBuilder.h | 2 +- dev/BuildKit/Imports.h | 2 +- dev/BuildKit/JSONManifestBuilder.h | 2 +- dev/BuildKit/TOMLManifestBuilder.h | 2 +- dev/cli/App.cc | 6 +++--- dev/src/IManifestBuilder.cc | 2 +- dev/src/JSONManifestBuilder.cc | 4 ++-- dev/src/TOMLManifestBuilder.cc | 4 ++-- 13 files changed, 76 insertions(+), 15 deletions(-) create mode 100644 CMakeLists.txt diff --git a/.gitignore b/.gitignore index 16285f7..97210be 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,9 @@ latex/ nebuild +build/ +build*/ + .cmake/ .qtc_clangd/ CMakeCache.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..7311780 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 3.16) + +project(nebuild VERSION 0.1 LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +include_directories(${CMAKE_SOURCE_DIR}/dev ${CMAKE_SOURCE_DIR}/vendor) + +file(GLOB NEBUILD_CLI_SOURCES "${CMAKE_SOURCE_DIR}/dev/cli/*.cc") +file(GLOB NEBUILD_SRC_SOURCES "${CMAKE_SOURCE_DIR}/dev/src/*.cc") +set(NEBUILD_SOURCES ${NEBUILD_CLI_SOURCES} ${NEBUILD_SRC_SOURCES}) + +add_executable(nebuild ${NEBUILD_SOURCES}) + +target_include_directories(nebuild PRIVATE ${CMAKE_SOURCE_DIR}/dev ${CMAKE_SOURCE_DIR}/vendor) + +option(BUILD_WINDOWS "Produce a Windows executable name (nebuild.exe)" OFF) +if(BUILD_WINDOWS) + set_target_properties(nebuild PROPERTIES OUTPUT_NAME "nebuild.exe") +endif() + +add_custom_target(build-nebuild + COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target nebuild + COMMENT "=> NeBuild built successfully for POSIX." +) + +add_custom_target(build-nebuild-windows + COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target nebuild + COMMENT "=> NeBuild built successfully for Windows (configure with -DBUILD_WINDOWS=ON)." +) + +message(STATUS "Project: nebuild") +message(STATUS "Sources: ${NEBUILD_SOURCES}") +message(STATUS "Include dirs: ${CMAKE_SOURCE_DIR}/dev;${CMAKE_SOURCE_DIR}/vendor") +message(STATUS "To build for Windows-style executable: configure with -DBUILD_WINDOWS=ON") diff --git a/GNUmakefile b/GNUmakefile index b05411c..44dbfeb 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,3 +1,8 @@ +# // ============================================================= // +# // nebuild +# // Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under BSD-3 license. +# // ============================================================= // + SUDO=sudo GCC=g++ GCC_MINGW=x86_64-w64-mingw32-g++ @@ -10,15 +15,16 @@ CP=cp .PHONY: build-nebuild build-nebuild: $(SUDO) $(GCC) $(CXXFLAGS) $(SRC) $(CXXSTD) -o $(OUT) - $(SUDO) $(CP) $(OUT) /usr/local/bin + @echo "=> NeBuild built successfully for POSIX." .PHONY: build-nebuild-windows build-nebuild-windows: $(GCC_MINGW) $(CXXFLAGS) $(SRC) -o $(OUT).exe + @echo "=> NeBuild built successfully for Windows." .PHONY: help help: - @echo "NEBUILD => HELP" + @echo "=> NEBUILD HELP:" @echo "=> help: Show this help message." @echo "=> build-nebuild-windows: Build NeBuild for Windows." @echo "=> build-nebuild: Build NeBuild for POSIX." diff --git a/ReadMe.md b/ReadMe.md index 8516959..eb319b6 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -16,4 +16,19 @@ - Run `nebuild` and pass the path to the manifest file. +## Guide (CMake): + +```zsh +# out-of-source configure + build (POSIX) +cmake -S . -B build -DCMAKE_BUILD_TYPE=Release +cmake --build build --target nebuild + +# or build the provided custom target +cmake --build build --target build-nebuild + +# produce a Windows-style executable name on non-Windows hosts: +cmake -S . -B build -DBUILD_WINDOWS=ON -DCMAKE_BUILD_TYPE=Release +cmake --build build --target nebuild +``` + ###### Copyright (C) 2024-2025, Amlal El Mahrouss and NeKernel.org Authors, licensed under the BSD 3 Clause license. diff --git a/dev/BuildKit/Defines.h b/dev/BuildKit/Defines.h index d408058..4774c85 100644 --- a/dev/BuildKit/Defines.h +++ b/dev/BuildKit/Defines.h @@ -1,6 +1,6 @@ // ============================================================= // // nebuild -// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. +// Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under BSD-3 license. // ============================================================= // #pragma once diff --git a/dev/BuildKit/IManifestBuilder.h b/dev/BuildKit/IManifestBuilder.h index c1d45d0..8f9b2cf 100644 --- a/dev/BuildKit/IManifestBuilder.h +++ b/dev/BuildKit/IManifestBuilder.h @@ -1,6 +1,6 @@ // ============================================================= // // nebuild -// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. +// Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under BSD-3 license. // ============================================================= // #pragma once diff --git a/dev/BuildKit/Imports.h b/dev/BuildKit/Imports.h index c542737..e22c933 100644 --- a/dev/BuildKit/Imports.h +++ b/dev/BuildKit/Imports.h @@ -1,6 +1,6 @@ // ============================================================= // // nebuild -// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. +// Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under BSD-3 license. // ============================================================= // #ifndef NEBUILD_INCLUDES_H diff --git a/dev/BuildKit/JSONManifestBuilder.h b/dev/BuildKit/JSONManifestBuilder.h index 63a67b7..81643e3 100644 --- a/dev/BuildKit/JSONManifestBuilder.h +++ b/dev/BuildKit/JSONManifestBuilder.h @@ -1,6 +1,6 @@ // ============================================================= // // nebuild -// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. +// Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under BSD-3 license. // ============================================================= // #pragma once diff --git a/dev/BuildKit/TOMLManifestBuilder.h b/dev/BuildKit/TOMLManifestBuilder.h index 9c4a3a0..6baa9f5 100644 --- a/dev/BuildKit/TOMLManifestBuilder.h +++ b/dev/BuildKit/TOMLManifestBuilder.h @@ -1,6 +1,6 @@ // ============================================================= // // nebuild -// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. +// Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under BSD-3 license. // ============================================================= // #pragma once diff --git a/dev/cli/App.cc b/dev/cli/App.cc index ca81d4e..d78ad69 100644 --- a/dev/cli/App.cc +++ b/dev/cli/App.cc @@ -1,7 +1,7 @@ // ============================================================= // // nebuild -// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. +// Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under BSD-3 license. // ============================================================= // #include @@ -19,10 +19,10 @@ int main(int argc, char** argv) { if (index_path == "-v" || index_path == "--version") { NeBuild::Logger::info() << "NeKernel Build Tool.\n"; NeBuild::Logger::info() - << "Bugs, or issues? Check out: https://github.com/nekernel-org/nebuild/issues\n"; + << "Bugs or issues? Check out: https://github.com/nekernel-org/nebuild/issues\n"; return EXIT_SUCCESS; - } else if (index_path == "--dry-run") { + } else if (index_path == "--dry-run" || index_path == "-n") { kDryRun = true; continue; } else if (index_path == "-h" || index_path == "--help") { diff --git a/dev/src/IManifestBuilder.cc b/dev/src/IManifestBuilder.cc index 1397dd4..745e81d 100644 --- a/dev/src/IManifestBuilder.cc +++ b/dev/src/IManifestBuilder.cc @@ -1,6 +1,6 @@ // ============================================================= // // nebuild -// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. +// Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under BSD-3 license. // ============================================================= // #include diff --git a/dev/src/JSONManifestBuilder.cc b/dev/src/JSONManifestBuilder.cc index daf47af..dba5b37 100644 --- a/dev/src/JSONManifestBuilder.cc +++ b/dev/src/JSONManifestBuilder.cc @@ -1,6 +1,6 @@ // ============================================================= // // nebuild -// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. +// Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under BSD-3 license. // ============================================================= // #include @@ -52,7 +52,7 @@ bool JSONManifestBuilder::BuildTarget(const std::string& argv_val, const bool dr command += "-I" + headers.get() + " "; } - JSON headers_path = json_obj["headers_path"]; + JSON headers_path = json_obj["headers_path"]; for (auto& headers : headers_path) { command += "-I" + headers.get() + " "; diff --git a/dev/src/TOMLManifestBuilder.cc b/dev/src/TOMLManifestBuilder.cc index e35416a..53034e8 100644 --- a/dev/src/TOMLManifestBuilder.cc +++ b/dev/src/TOMLManifestBuilder.cc @@ -1,6 +1,6 @@ // ============================================================= // // nebuild -// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. +// Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under BSD-3 license. // ============================================================= // #include @@ -75,7 +75,7 @@ bool TOMLManifestBuilder::BuildTarget(const std::string& argv_val, const bool dr for (auto& flag : *compiler_flags) { command += flag.as_string()->get() + " "; } - } + } if (toml_file["compiler_std"].is_string()) command += "-std=" + toml_file["compiler_std"].as_string()->get() + " "; -- cgit v1.2.3