dfintha / barge

A simple tool to build small, Assembly/C/C++/FORTRAN projects without writing custom makefiles. Written in Rust, ironically.
MIT License
2 stars 0 forks source link
assembly build-tools c cpp fortran

barge

Overview

barge is a very simple tool written in Rust, which manages building projects, which contain Assembly, C, and C++ source files, with its main goal being simplicity.

Each project translates to a single library (static or shared) or executable. Projects have and src and an include directory at their root. which contain the source and header files respectively. Subdirectories within these directories are supported.

Source and header files shall have appropriate file extensions based on their type: .c for C source files, .cpp for C++ source files, .s for Assembly source files, .f90 for FORTRAN source files, .ld for linker scripts, .h for C header files, and .hpp for C++ header files.

barge supports the NO_COLOR environment variable: if it is set, no output will be colorized using ANSI terminal escape codes.

Please note that the development of this software is in a very early stage. As such, changes to the project file format and/or usage can happen frequently.

Dependencies

Internally, barge uses the following external software, which are required for proper functionality.

Required

Project-dependent

Subcommands

barge supports the following subcommands.

The build, rebuild, and run subcommands have an optional argument, which represents the configuration (target) of the build. The currently supported targets are debug and release. If none is specified, debug is selected by default.

In debug configuration, the resulting file contains its debug symbols, and is optimized for debugging, while in release configuration, the symbols are stripped, and the file is optimized for fast execution.

The project file

The user can specify the settings to their project by changing barge.json at the project root. This file contains a single configuration object with the following fields.

Specific project file, which contains all the optional fields

{
    "name": "example",
    "authors": ["Somebody <somebody@example.org>"],
    "description": "An awesome example project.",
    "project_type": "executable",
    "version": "0.1.0",
    "toolset": "gnu",
    "c_standard": "c99",
    "cpp_standard": "c++14",
    "fortran_standard": "f2003",
    "external_libraries": [
        {
            "type": "pkg_config",
            "name": "sdl"
        },
        {
            "type": "manual",
            "cflags": "",
            "ldflags": "-lpthread"
        }
    ],
    "custom_cflags": "-DNDEBUG",
    "custom_cxxflags": "-DNDEBUG",
    "custom_fortranflags": "",
    "custom_ldflags": "-ggdb",
    "custom_makeopts": "-j2",
    "format_style": "Google",
    "pre_build_steps": [
        "prebuild-1.py",
        "prebuild-2.cpp"
    ],
    "post_build_steps": [
        "postbuild.c"
    ]
}

Minimal project file, which contains no optional fields

{
    "name": "example",
    "authors": ["Somebody <somebody@example.org>"],
    "description": "An awesome example project.",
    "project_type": "executable",
    "version": "0.1.0"
}

Pre-build and post-build scripts

Executables for pre_build_step and post_build_step support the following file types, and the interpreter or compiler is chosen based on the file extension.

Obviously, the bash, python3, and perl interpreters must be present for their respective scripts to work. C/C++ build steps are compiled using the C11/C++17 standards.

During their execution, these scripts/binaries have the following environment variables set.

Timestamps in build step script environment variables are in RFC3339 or ISO 8601 format (for example, 2023-11-28T02:40:50.370090151+01:00).