diff --git a/.gitignore b/.gitignore index be6d93f..cefd271 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ target/ sandbox/** .idea/ .vscode/ -.env \ No newline at end of file +.env + +personal/ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index b0a0072..8eebbea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Changelog +## [0.6.7] - 2026-05-21 + +Added: + +- `build.filename` and `build.extension` in `dcr.toml` — complete control over the final artifact name without relying on `package.name`. + Example: + ```toml + [build] + filename = "KERNEL" + extension = "EFI" + ``` + Produces `KERNEL.EFI` (works for `bin`, `staticlib`, and `sharedlib`). +- Automatic injection of `--target=` into compiler flags when `build.target` is set in `dcr.toml`. This greatly simplifies clang-based cross-compilation (especially for bare-metal targets like `aarch64-none-elf`). +- Bare-metal targets (containing `none`, `-elf`, `eabi`, `baremetal`) no longer receive DCR's internal default flags (`-g`, `-Wall`, `-Wextra`, `-fno-omit-frame-pointer`, `-DDCR_DEBUG`, etc.). Prevents unwanted sections (`.comment`, debug info, etc.) that break custom linker scripts when `inherit = true`. + +Fixed: + +- `build.target` declared in `dcr.toml` is now correctly used as the default target even when `--target` is not passed on the command line (previously the host target was always forced for config resolution). + ## [0.6.6] - 2026-05-18 Fixed: @@ -29,8 +48,9 @@ between `cli/build.rs`, `cli/run.rs`, `cli/clean.rs`, `cli/gen.rs` `package_root_from_registry_info`, `registry_include_dir`, `registry_lib_dir`, `path_from_string_dep` - Unit tests for `register.rs` (`is_registry_dep`, `package_root_from_registry_info`), -`deps/mod.rs` (`path_dep_path`, `push_default_lib_dirs`), -`utils/build.rs` (`normalize_target_os`, `parse_version_info`) + `deps/mod.rs` (`path_dep_path`, `push_default_lib_dirs`), + `utils/build.rs` (`normalize_target_os`, `parse_version_info`) +- `dcr tree` command — visual dependency tree viewer (similar to `cargo tree`) Removed: diff --git a/Cargo.lock b/Cargo.lock index 0366d4f..dceb3b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -112,7 +112,7 @@ dependencies = [ [[package]] name = "dcr" -version = "0.6.6" +version = "0.6.7" dependencies = [ "ctrlc", "git2", diff --git a/Cargo.toml b/Cargo.toml index 2e113bf..4f705cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dcr" -version = "0.6.6" +version = "0.6.7" edition = "2024" build = "build.rs" diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index b5fdc8e..91abe29 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -27,6 +27,7 @@ * [dcr clean](commands/dcr-clean.md) * [dcr gen](commands/dcr-gen.md) * [dcr test](commands/dcr-test.md) +* [dcr tree](commands/dcr-tree.md) ## Dependencies & Build diff --git a/docs/commands/dcr-build.md b/docs/commands/dcr-build.md index 01e64a9..dd08931 100644 --- a/docs/commands/dcr-build.md +++ b/docs/commands/dcr-build.md @@ -25,6 +25,8 @@ dcr build --debug --clean ## Config values used - `package.name` +- `build.filename` +- `build.extension` - `build.compiler` - `build.language` - `build.standard` @@ -60,7 +62,9 @@ dcr build --debug --clean - Incremental rebuild checks source/object mtime and tracked header dependencies. - `--force` skips build cache checks and recompiles. - `--clean` removes `target/` and `build.clean` paths before building. +- `build.filename` + `build.extension` allow full control over the final artifact name (e.g. `KERNEL.BIN` instead of using `package.name`). - Default GCC/Clang profile flags: `debug` -> `-O0 -g -Wall -Wextra -fno-omit-frame-pointer -DDCR_DEBUG`, `release` -> `-O3 -DNDEBUG`. + These defaults are **not applied** for bare-metal targets (e.g. `aarch64-none-elf`, targets containing `none` / `-elf` / `eabi`). - For `language = "asm"` with `compiler = "as"`/`"gas"`, use `.s` files (no preprocessing). For `.S`, use `gcc` or `clang`. - In workspace root, `dcr build` builds all members in dependency order. - `build.exclude` removes paths from source/header collection; `build.include` re-allows matching paths and has priority over `exclude`. diff --git a/docs/commands/dcr-tree.md b/docs/commands/dcr-tree.md new file mode 100644 index 0000000..066e3b6 --- /dev/null +++ b/docs/commands/dcr-tree.md @@ -0,0 +1,22 @@ +# dcr tree + +Displays a visual dependency tree for the current project (similar to `cargo tree`). + +## Usage + +```sh +dcr tree +dcr tree --invert +dcr tree -p some-package +``` + +## What it shows + +- All direct and transitive dependencies +- Version of each dependency +- Whether a dependency is a registry, git, or path dependency + +## Notes + +- Useful for debugging dependency issues and understanding the build graph. +- Output format is inspired by `cargo tree`. diff --git a/docs/configuration/build-section.md b/docs/configuration/build-section.md index bcedd6d..ac59089 100644 --- a/docs/configuration/build-section.md +++ b/docs/configuration/build-section.md @@ -8,6 +8,8 @@ language = "c" standard = "c11" compiler = "clang" kind = "bin" +# filename = "KERNEL" +# extension = "BIN" # optional: # inherit = true # Inherit from base (default true) # targets = ["linux", "macos"] # Multiple targets to build @@ -32,9 +34,12 @@ kind = "bin" - `standard` (string, required): language standard passed to compiler. - `compiler` (string, required): compiler command (for example `clang`, `gcc`, `cl`). - `kind` (string, required): `bin`, `staticlib`, or `sharedlib`. +- `filename` (string, optional): custom output filename (without extension). Overrides `package.name` for the final artifact. +- `extension` (string, optional): custom file extension without the leading dot (e.g. `BIN`, `efi`, `EFI`). Combined with `filename`. - `inherit` (bool, optional): inherit settings from base `[build]` (default `true`). If `false`, only use target/profile specific settings. - `targets` (string array, optional): list of targets to build simultaneously. Supports short names (`linux`, `macos`, `windows`). - `target` (string, optional): custom output directory for final artifact. + When set, DCR automatically injects `--target=` into `cflags` (useful for clang cross-compilation). - `platform` (string, optional): architecture hint for compiler (used for `-march` or `/arch`). - `cflags` (string array, optional): extra compile flags. - `ldflags` (string array, optional): extra link flags. diff --git a/docs/dependencies-and-build/cross-compilation.md b/docs/dependencies-and-build/cross-compilation.md index c4c4898..a3cf9f0 100644 --- a/docs/dependencies-and-build/cross-compilation.md +++ b/docs/dependencies-and-build/cross-compilation.md @@ -178,6 +178,8 @@ compiler = "aarch64-linux-gnu-gcc"' >> dcr.toml dcr build --target aarch64-linux-gnu --release ``` +**Note:** If you set `target = "aarch64-linux-gnu"` (or any value) directly under `[build]`, DCR will automatically add `--target=...` to cflags when using clang. You usually don't need to repeat it manually. + ### Windows Build on Linux ```bash diff --git a/docs/reference-and-help/cli-reference.md b/docs/reference-and-help/cli-reference.md index 231e420..5aab80e 100644 --- a/docs/reference-and-help/cli-reference.md +++ b/docs/reference-and-help/cli-reference.md @@ -7,9 +7,11 @@ dcr new dcr init dcr setup dcr add (optional) -dcr build [--debug|--release] +dcr build [--debug|--release] [--target ] dcr run [--debug|--release] dcr clean [--debug|--release] [--all] +dcr tree +dcr test dcr gen dcr --help dcr --version @@ -23,6 +25,8 @@ dcr --update - `init` and `--update` do not accept extra arguments. - `clean` accepts `--debug|--release` and optional `--all`. - `gen` supports `project-info`, `compile-commands`, `vscode`, `clion`. +- `tree` shows a dependency tree (similar to `cargo tree`). +- `test` / `tests` runs the project's tests. ## Exit behavior overview diff --git a/docs/reference-and-help/config-reference.md b/docs/reference-and-help/config-reference.md index 9b03619..b62110e 100644 --- a/docs/reference-and-help/config-reference.md +++ b/docs/reference-and-help/config-reference.md @@ -12,6 +12,8 @@ language = "c|c++|cpp|cxx|asm" # required (string or array) standard = "string" # required compiler = "string" # required kind = "bin|staticlib|sharedlib" # required +filename = "string" # optional (custom output name without extension) +extension = "string" # optional (custom extension without dot, e.g. "BIN") target = "string" # optional platform = "string" # optional cflags = ["string", "..."] # optional diff --git a/src/core/builder/unix_cc.rs b/src/core/builder/unix_cc.rs index a3cdb6f..ddd022c 100644 --- a/src/core/builder/unix_cc.rs +++ b/src/core/builder/unix_cc.rs @@ -129,6 +129,19 @@ fn default_flags(profile: &str) -> &'static [&'static str] { } } +fn is_bare_metal_target(target: Option<&str>) -> bool { + if let Some(t) = target { + let lower = t.to_lowercase(); + lower.contains("none") + || lower.contains("-elf") + || lower.contains("eabi") + || lower.contains("baremetal") + || lower.contains("bare-metal") + } else { + false + } +} + fn build_objects( compiler: &str, sources: &[String], @@ -183,7 +196,8 @@ fn build_object( cmd.arg(format!("-std={}", ctx.standard)); } - if ctx.cflags.is_empty() { + let use_dcr_defaults = ctx.cflags.is_empty() && !is_bare_metal_target(ctx.target); + if use_dcr_defaults { for flag in default_flags(ctx.profile) { cmd.arg(flag); }