Crates.io | iceforge |
lib.rs | iceforge |
version | 0.1.0 |
source | src |
created_at | 2024-10-04 02:54:27.024751 |
updated_at | 2024-10-04 02:54:27.024751 |
description | A simple build tool for building C and C++ applications |
homepage | https://github.com/Dr-42/iceforge |
repository | https://github.com/Dr-42/iceforge |
max_upload_size | |
id | 1395998 |
size | 82,700 |
A build tool for C projects.
iceforge build [OPTIONS]
--release
: Build in release mode.--debug
: Build in debug mode (default).--subproject <name>
: Build only a specific subproject.--parallel <N>
: Specify the number of parallel jobs for the build.--generate-compile-commands
: Generate a compile_commands.json
file.--generate-vscode-config
: Generate .vscode/c_cpp_properties.json
.iceforge run [OPTIONS]
--binary <name>
: Specify which binary to run if multiple exist.iceforge clean [OPTIONS]
--subproject <name>
: Clean only a specific subproject.iceforge refresh
cargo update
).iceforge build --release
iceforge build --debug
iceforge build --subproject <name>
iceforge run
iceforge run --binary <name>
iceforge clean
iceforge clean --subproject <name>
iceforge install
iceforge publish [OPTIONS]
--remote <name>
: Adds the git tag to the specified remote repository.iceforge init [OPTIONS]
--name <name>
: Specify the project name.--dir <path>
: Create a new directory for the project and initialize it there.The following table summarizes the fields available in the iceforge build tool's TOML configuration file, specifying the possible values, whether the field is optional or required, and a brief description.
Section | Field | Required | Type | Possible Values | Description |
---|---|---|---|---|---|
[build] | c_standard |
No | String | "c99" , "c11" , "gnu11" , etc. |
Specifies the C standard to use in the build. |
compiler |
Yes | String | Any valid compiler name (e.g., "gcc" , "clang" ) |
Specifies the compiler to use for building the project. | |
global_cflags |
No | String | Any valid compiler flags | Specifies global compilation flags (e.g., "-Wall -Wextra" ). |
|
debug_flags |
No | String | Any valid debug flags | Specifies flags to use in debug mode builds (e.g., "-g" ). |
|
release_flags |
No | String | Any valid release flags | Specifies flags to use in release mode builds (e.g., "-O3" ). |
|
parallel_jobs |
No | Integer | Any positive integer | Specifies the number of parallel jobs for building (e.g., 4 ). |
|
[dependencies] | Section for external dependencies. | ||||
[dependencies.remote] | name |
Yes | String | Any valid string | Specifies the name of the remote dependency. |
version |
No | String | Any valid version tag (e.g., "v1.0.1" ) |
Specifies the version of the dependency (optional). | |
source |
Yes | URL String | A valid Git URL | The URL of the remote Git repository for the dependency. | |
include_name |
Yes | String | Any valid string | Specifies the folder prefix for source includes from the dependency. | |
include_dirs |
Yes | Array of Strings | A list of valid directory paths | Specifies the directories that need to be included in the build from the dependency. | |
build_method |
No | String | "cmake" , "header-only" , "custom" |
Specifies the build method for the remote dependency. | |
build_command |
No | String | Any valid shell command | Custom command to build the dependency if build_method is "custom" . |
|
build_output |
No | String | Any valid output path | Specifies the output binary or library if build_method is "custom" . |
|
[dependencies.pkg_config] | name |
Yes | String | Any valid package name | Specifies the name of the dependency to be queried via pkg-config . |
pkg_config_query |
Yes | String | Any valid pkg-config query |
Specifies the query to pkg-config (e.g., "freetype2" ). |
|
[dependencies.manual] | name |
Yes | String | Any valid string | Specifies the name of the manually handled dependency. |
ldflags |
Yes (manual) | String | Any valid linker flags | Specifies manual linker flags for the dependency (e.g., "-lglfw" ). |
|
[subprojects] | name |
Yes | String | Any valid string | Specifies the name of the subproject. |
type |
Yes | String | "binary" , "library" , "header-only" |
Specifies the type of subproject (binary, library, or header-only). | |
src_dir |
Yes (except header-only) | String | A valid directory path | Specifies the directory where the subproject source files are located. | |
include_dirs |
Yes | Array of Strings | A list of valid directory paths | Specifies the directories that need to be included in the build for this subproject. | |
dependencies |
No | Array of Strings | List of subproject and remote dependency names | Specifies the dependencies of the subproject (e.g., ["core", "mylib_v2"] ). |
|
output_name |
Yes | String | Any valid file name | Specifies the output binary or library name for the subproject (e.g., "game_executable" ). |
|
[custom_build_rules] | name |
Yes | String | Any valid string | Specifies the name of the custom build rule. |
description |
No | String | Any valid string | A brief description of the custom build rule. | |
src_dir |
Yes | String | A valid directory path | Specifies the directory where the source files for the custom build are located. | |
output_dir |
Yes | String | A valid directory path | Specifies the directory where the output files will be placed. | |
trigger_extensions |
Yes | Array of Strings | List of valid file extensions | Specifies the file extensions that will trigger the custom build rule (e.g., [".vert", ".frag"] ). |
|
output_extension |
Yes | String | A valid file extension | Specifies the extension for the output files (e.g., ".spv" ). |
|
command |
Yes | String | Any valid shell command | Specifies the shell command to run for the custom build (e.g., glslc -o $out -fshader-stage=vert $in ). |
|
rebuild_rule |
Yes | String | "if-changed" , "always" , "on-trigger" |
Specifies the condition for rebuilding (only rebuild if changed, always rebuild, or trigger-based). | |
[overrides] | name |
Yes | String | Any valid subproject name | Specifies the subproject name to which the override applies. |
c_standard |
No | String | "c99" , "c11" , "gnu11" , etc. |
Specifies the C standard to use in the overrie. | |
compiler |
Yes | String | Any valid compiler name (e.g., "gcc" , "clang" ) |
Specifies the compiler to use for building the overriden subproject. | |
cflags |
No | String | Any valid compiler flags | Specifies overriden compilation flags (e.g., "-Wall -Wextra" ). Global flags will be discarded |
|
debug_flags |
No | String | Any valid debug flags | Specifies flags to use in debug mode overriden subproject (e.g., "-g" ). |
|
release_flags |
No | String | Any valid release flags | Specifies flags to use in release mode overriden subproject (e.g., "-O3" ). |
|
parallel_jobs |
No | Integer | Any positive integer | Specifies the number of parallel jobs for building (e.g., 4 ). |
Required fields must be provided for the build to work, while optional fields provide flexibility for advanced customization.
Fields like build_method
, dependencies
, and cflags
allow the configuration to be as simple or complex as needed for a given project.
Multiple subprojects and remote dependencies can be defined, each with their own settings.
This section defines the general build configuration, including compiler settings, optimization flags, and parallel job configurations.
[build]
c_standard = "c11" # Specify the C standard (e.g., c99, c11, gnu11, etc.)
compiler = "gcc" # Compiler
global_cflags = "-Wall -Wextra" # Global optimization flags
debug_flags = "-g" # Debug flags for debug builds
release_flags = "-O3" # Release flags for release builds
parallel_jobs = 4 # Number of parallel jobs for building
This section allows specifying external dependencies, both remote and local, fetched from Git or using pkg-config
.
[dependencies]
[[dependencies.remote]]
name = "mylib_v1"
version = "v1.0.1"
source = "https://github.com/example/mylib.git"
include_name = "mylib" # The folder prefix for the source includes
include_dirs = ["src/include"] # Directories to include in the build
[[dependencies.remote]]
name = "glm"
source = "https://github.com/example/glm.git"
include_name = "glm"
include_dirs = ["src/include"]
build_method = "cmake" # Specifies custom build method
[[dependencies.pkg_config]]
name = "freetype"
pkg_config_query = "freetype2" # Queries pkg-config for `freetype2` library
[[dependencies.manual]]
name = "glfw"
ldflags = "-lglfw" # Manually specifies linking flags for GLFW
Defines subprojects within the build configuration, allowing each subproject to have its own configuration, dependencies, and output.
[[subprojects]]
name = "core"
type = "library" # Can be "binary", "library", or "header-only"
src_dir = "src/core" # Source directory
include_dirs = ["src/core/include"] # Include directories
dependencies = ["mylib_v2.mylibA", "freetype"] # Dependencies specific to this subproject
output_name = "libcore.a" # Output file (static library)
[[subprojects]]
name = "game"
type = "binary"
src_dir = "src/game"
include_dirs = ["src/game/include", "src/core/include"]
dependencies = ["core", "mylib_v2"] # This binary depends on core and mylib_v2
output_name = "game_executable" # Final binary name
Custom build rules allow the definition of additional build processes, such as asset compilation or custom source transformation, outside of regular compilation.
[[custom_build_rules]]
name = "vulkan_vertex_shaders"
description = "Compile vertex shaders to SPIR-V"
src_dir = "assets/shaders"
output_dir = "assets/compiled_shaders"
trigger_extensions = [".vert"] # Only files with this extension will trigger the rule
output_extension = ".spv" # Output file extension
command = "glslc -o $out -fshader-stage=vert $in" # Command to run for compilation
rebuild_rule = "if-changed" # Only rebuild if the source files change
[[custom_build_rules]]
name = "vulkan_fragment_shaders"
description = "Compile fragment shaders to SPIR-V"
src_dir = "assets/shaders"
output_dir = "assets/compiled_shaders"
trigger_extensions = [".frag"]
output_extension = ".spv"
command = "glslc -o ${out} -fshader-stage=frag ${in}"
rebuild_rule = "if-changed"
The overrides
section allows overriding specific build configurations for subprojects or specific builds (e.g., debugging, more strict compilation flags).
[[overrides]]
name = "core"
cflags = "-Werror" # Treat warnings as errors for this subproject
parallel_jobs = 8 # Override parallel job count for this subproject
This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.